comparison src/cagou/plugins/plugin_wid_chat.py @ 47:abb81efef3bb

chat: update avatar following quick frontend improvments
author Goffi <goffi@goffi.org>
date Sat, 10 Sep 2016 00:05:46 +0200
parents d6a63942d5ad
children 514c187afebc
comparison
equal deleted inserted replaced
46:d6a63942d5ad 47:abb81efef3bb
50 50
51 class MessageWidget(GridLayout): 51 class MessageWidget(GridLayout):
52 mess_data = properties.ObjectProperty() 52 mess_data = properties.ObjectProperty()
53 mess_label = properties.ObjectProperty() 53 mess_label = properties.ObjectProperty()
54 mess_padding = (dp(5), dp(5)) 54 mess_padding = (dp(5), dp(5))
55 avatar = properties.ObjectProperty()
56
57 def __init__(self, **kwargs):
58 super(MessageWidget, self).__init__(**kwargs)
59 self.mess_data.widgets.add(self)
55 60
56 @property 61 @property
57 def chat(self): 62 def chat(self):
58 """return parent Chat instance""" 63 """return parent Chat instance"""
59 return self.mess_data.parent 64 return self.mess_data.parent
75 if text_width < self.text_max: 80 if text_width < self.text_max:
76 self.mess_label.text_size = (None, None) 81 self.mess_label.text_size = (None, None)
77 else: 82 else:
78 self.mess_label.text_size = (parent.width - padding_x, None) 83 self.mess_label.text_size = (parent.width - padding_x, None)
79 84
85 def update(self, key, value=None):
86 if key == 'avatar':
87 self.avatar.source = value
88
80 89
81 class MessageInputWidget(TextInput): 90 class MessageInputWidget(TextInput):
82 91
83 def _key_down(self, key, repeat=False): 92 def _key_down(self, key, repeat=False):
84 displayed_str, internal_str, internal_action, scale = key 93 displayed_str, internal_str, internal_action, scale = key
182 191
183 G.host.bridge.discoInfos(jid_.domain, self.profile, callback=discoCb, errback=discoEb) 192 G.host.bridge.discoInfos(jid_.domain, self.profile, callback=discoCb, errback=discoEb)
184 193
185 def onDelete(self, force=False): 194 def onDelete(self, force=False):
186 if force==True: 195 if force==True:
187 return True 196 return super(Chat, self).onDelete()
188 if len(list(G.host.widgets.getWidgets(self.__class__, self.target, profiles=self.profiles))) > 1: 197 if len(list(G.host.widgets.getWidgets(self.__class__, self.target, profiles=self.profiles))) > 1:
189 # we don't keep duplicate widgets 198 # we don't keep duplicate widgets
190 return True 199 return super(Chat, self).onDelete()
191 return False 200 return False
192 201
193 202
194 PLUGIN_INFO["factory"] = Chat.factory 203 PLUGIN_INFO["factory"] = Chat.factory
195 quick_widgets.register(quick_chat.QuickChat, Chat) 204 quick_widgets.register(quick_chat.QuickChat, Chat)