# HG changeset patch # User Goffi # Date 1553759043 -3600 # Node ID 717c6c368f707b908ccd979c56d3051ef855da38 # Parent 44752e8031f84f8fd5ba2d9af745ee5ad6640428 chat: merge user moved info messages: - MessageWidget now inheriates from the new quick_chat.MessageWidget - MessageWidget.message is now an AliasProperty - new message_widgets_rev property implemented - new handleUserMoved method is used diff -r 44752e8031f8 -r 717c6c368f70 cagou/plugins/plugin_wid_chat.py --- a/cagou/plugins/plugin_wid_chat.py Thu Mar 28 08:42:11 2019 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Thu Mar 28 08:44:03 2019 +0100 @@ -73,7 +73,7 @@ pass -class MessageWidget(BoxLayout): +class MessageWidget(BoxLayout, quick_chat.MessageWidget): mess_data = properties.ObjectProperty() mess_xhtml = properties.ObjectProperty() mess_padding = (dp(5), dp(5)) @@ -94,16 +94,27 @@ """return parent Chat instance""" return self.mess_data.parent - @property - def message(self): + def _get_message(self): """Return currently displayed message""" return self.mess_data.main_message + def _set_message(self, message): + if message == self.mess_data.message.get(u""): + return False + self.mess_data.message = {u"": message} + return True + + message = properties.AliasProperty(_get_message, _set_message) + @property def message_xhtml(self): """Return currently displayed message""" return self.mess_data.main_message_xhtml + @property + def info_type(self): + return self.mess_data.info_type + def widthAdjust(self): """this widget grows up with its children""" pass @@ -437,6 +448,10 @@ on_existing_widget=G.host.getOrClone, profiles=profiles) + @property + def message_widgets_rev(self): + return self.messages_widget.children + ## header ## def changeWidget(self, jid_): @@ -547,6 +562,12 @@ self.appendMessage(message) def appendMessage(self, mess_data): + """Append a message Widget to the history + + @param mess_data(quick_chat.Message): message data + """ + if self.handleUserMoved(mess_data): + return self.messages_widget.add_widget(MessageWidget(mess_data=mess_data)) self.notify(mess_data)