diff src/cagou/plugins/plugin_wid_chat.py @ 105:ce6ef88f2cff

chat: avatar improvments: - avatar source is not set anymore in kv but on MessageWidget init, so None value can be handled correclty - Message widget add itself to mess_data before parsing kv, so call to properties in kv can update the widget correctly (specially important for embedded bridge)
author Goffi <goffi@goffi.org>
date Sun, 15 Jan 2017 18:02:53 +0100
parents c601e3d40342
children 9909ed7a7a20
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.py	Mon Jan 09 00:47:03 2017 +0100
+++ b/src/cagou/plugins/plugin_wid_chat.py	Sun Jan 15 18:02:53 2017 +0100
@@ -529,8 +529,12 @@
     delivery = properties.ObjectProperty()
 
     def __init__(self, **kwargs):
+        # self must be registered in widgets before kv is parsed
+        kwargs['mess_data'].widgets.add(self)
         super(MessageWidget, self).__init__(**kwargs)
-        self.mess_data.widgets.add(self)
+        avatar_path = self.mess_data.avatar
+        if avatar_path is not None:
+            self.avatar.source = avatar_path
 
     @property
     def chat(self):