comparison cagou/core/common.py @ 256:ba7b8cb7ddcd

common: don't use anymore positional argument in JidItem
author Goffi <goffi@goffi.org>
date Sat, 26 Jan 2019 20:24:48 +0100
parents cf61a011f731
children 0ef216091f2b
comparison
equal deleted inserted replaced
255:03d74435c01c 256:ba7b8cb7ddcd
41 41
42 42
43 class JidItem(BoxLayout): 43 class JidItem(BoxLayout):
44 bg_color = properties.ListProperty([0.2, 0.2, 0.2, 1]) 44 bg_color = properties.ListProperty([0.2, 0.2, 0.2, 1])
45 color = properties.ListProperty([1, 1, 1, 1]) 45 color = properties.ListProperty([1, 1, 1, 1])
46 jid = properties.StringProperty()
47 profile = properties.StringProperty()
48 nick = properties.StringProperty()
49 avatar = properties.ObjectProperty()
46 50
47 def __init__(self, jid, profile, **kwargs): 51 def on_avatar(self, wid, jid_):
48 self.jid = jid 52 if self.jid and self.profile:
49 self.profile = profile 53 self.getImage()
50 self.nick = kwargs.get('nick')
51 super(JidItem, self).__init__(**kwargs)
52 54
53 def getImage(self, wid): 55 def on_jid(self, wid, jid_):
56 if self.profile and self.avatar:
57 self.getImage()
58
59 def on_profile(self, wid, profile):
60 if self.jid and self.avatar:
61 self.getImage()
62
63 def getImage(self):
54 host = G.host 64 host = G.host
55 if host.contact_lists[self.profile].isRoom(self.jid.bare): 65 if host.contact_lists[self.profile].isRoom(self.jid.bare):
56 wid.opacity = 0 66 self.avatar.opacity = 0
57 return "" 67 self.avatar.source = ""
58 else: 68 else:
59 return (host.getAvatar(self.jid, profile=self.profile) 69 try:
60 or host.getDefaultAvatar(self.jid)) 70 self.avatar.source = (
71 host.getAvatar(self.jid, profile=self.profile)
72 or host.getDefaultAvatar(self.jid)
73 )
74 except Exception as e:
75 __import__('pudb').set_trace()
76 print(e)
61 77
62 78
63 class JidButton(ButtonBehavior, JidItem): 79 class JidButton(ButtonBehavior, JidItem):
64 pass 80 pass
65 81