diff browser_side/contact.py @ 47:7cabe3c1a5f2

browser side: connected contacts now appear differently
author Goffi <goffi@goffi.org>
date Thu, 26 May 2011 17:17:48 +0200
parents e70521e6d803
children 9f19e16187ff
line wrap: on
line diff
--- a/browser_side/contact.py	Thu May 26 16:43:30 2011 +0200
+++ b/browser_side/contact.py	Thu May 26 17:17:48 2011 +0200
@@ -106,6 +106,21 @@
         VerticalPanel.add(self, _item)
         self.contacts.append(_item)
 
+    def setState(self, jid, state):
+        """Change the appearance of the contact, according to the state
+        @param jid: jid which need to change state
+        @param state: 'unavailable' if not connected, else presence like RFC6121 #4.7.2.1"""
+        _item = None
+        for contact in self.contacts:
+            if contact.jid == jid:
+                _item = contact
+                break
+        if _item:
+            if state == 'unavailable':
+                _item.removeStyleName('contactConnected')
+            else:
+                _item.addStyleName('contactConnected')
+
 class ContactTitleLabel(DragLabel, Label):
     def __init__(self, text):
         Label.__init__(self, text) #, Element=DOM.createElement('div')
@@ -161,6 +176,7 @@
             if not self.connected.has_key(jid):
                 self.connected[jid] = {}
             self.connected[jid][resource] = (availability, priority, statuses)
+        self._contactList.setState(jid, availability)
 
     def getConnected(self):
         """return a list of all jid (bare jid) connected"""