changeset 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 663e44f30092
children 9909ed7a7a20
files src/cagou/plugins/plugin_wid_chat.kv src/cagou/plugins/plugin_wid_chat.py
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.kv	Mon Jan 09 00:47:03 2017 +0100
+++ b/src/cagou/plugins/plugin_wid_chat.kv	Sun Jan 15 18:02:53 2017 +0100
@@ -56,7 +56,6 @@
         height: avatar.height
         MessAvatar:
             id: avatar
-            source: root.mess_data.avatar
         Label:
             id: time_label
             text_size: None, None
--- 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):