diff frontends/src/primitivus/chat.py @ 637:3b02554d4c8b

primitivus: chat state implementation for now chat states are displayed in primitivus surrended text (after the contact's name)
author souliane <souliane@mailoo.org>
date Sun, 08 Sep 2013 19:13:02 +0200
parents c8c07c920e30
children 6821fc06a324
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py	Thu Sep 05 20:48:47 2013 +0200
+++ b/frontends/src/primitivus/chat.py	Sun Sep 08 19:13:02 2013 +0200
@@ -145,7 +145,22 @@
                 self.__appendPresentPanel()
 
     def __getDecoration(self, widget):
-        return sat_widgets.LabelLine(widget, sat_widgets.SurroundedText(unicode(unescapePrivate(self.target))))
+        return sat_widgets.LabelLine(widget, self.__getSurrendedText())
+
+    def __getSurrendedText(self):
+        """Get the text to be displayed as the dialog title."""
+        if not hasattr(self, "surrended_text"):
+            self.__setSurrendedText()
+        return self.surrended_text
+
+    def __setSurrendedText(self, state=None):
+        """Set the text to be displayed as the dialog title
+        @param stat: chat state of the contact
+        """
+        text = unicode(unescapePrivate(self.target))
+        if state:
+            text += " (" + state + ")"
+        self.surrended_text = sat_widgets.SurroundedText(text)
 
     def showDecoration(self, show=True):
         """Show/Hide the decoration around the chat window"""
@@ -155,6 +170,18 @@
             main_widget = self.pile
         self._w = main_widget
 
+    def updateChatState(self, state):
+        """Update the chat state of the contact.
+        @param state: new state to set
+        """
+        if (self.type == 'one2one'):
+            self.__setSurrendedText(state)
+            self.showDecoration()
+            self.host.redraw()
+        elif (self.type == 'group'):
+            # TODO: chat state for groupchat
+            pass
+
     def _presentClicked(self, list_wid, clicked_wid):
         assert(self.type == 'group')
         nick = clicked_wid.getValue()