changeset 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 028a98983e46
files src/cagou/plugins/plugin_wid_chat.kv src/cagou/plugins/plugin_wid_chat.py
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.kv	Sat Sep 10 00:04:18 2016 +0200
+++ b/src/cagou/plugins/plugin_wid_chat.kv	Sat Sep 10 00:05:46 2016 +0200
@@ -34,6 +34,7 @@
     size_hint: 1, None
     height: self.minimum_height
     on_width: self.widthAdjust()
+    avatar: avatar
     BoxLayout:
         id: header_box
         size_hint: 1, None
--- a/src/cagou/plugins/plugin_wid_chat.py	Sat Sep 10 00:04:18 2016 +0200
+++ b/src/cagou/plugins/plugin_wid_chat.py	Sat Sep 10 00:05:46 2016 +0200
@@ -52,6 +52,11 @@
     mess_data = properties.ObjectProperty()
     mess_label = properties.ObjectProperty()
     mess_padding = (dp(5), dp(5))
+    avatar = properties.ObjectProperty()
+
+    def __init__(self, **kwargs):
+        super(MessageWidget, self).__init__(**kwargs)
+        self.mess_data.widgets.add(self)
 
     @property
     def chat(self):
@@ -77,6 +82,10 @@
             else:
                 self.mess_label.text_size = (parent.width  - padding_x, None)
 
+    def update(self, key, value=None):
+        if key == 'avatar':
+            self.avatar.source = value
+
 
 class MessageInputWidget(TextInput):
 
@@ -184,10 +193,10 @@
 
     def onDelete(self, force=False):
         if force==True:
-            return True
+            return super(Chat, self).onDelete()
         if len(list(G.host.widgets.getWidgets(self.__class__, self.target, profiles=self.profiles))) > 1:
             # we don't keep duplicate widgets
-            return True
+            return super(Chat, self).onDelete()
         return False