changeset 47:7cabe3c1a5f2

browser side: connected contacts now appear differently
author Goffi <goffi@goffi.org>
date Thu, 26 May 2011 17:17:48 +0200
parents c3ee630914ba
children 153de5d461a4
files browser_side/contact.py public/libervia.css
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
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"""
--- a/public/libervia.css	Thu May 26 16:43:30 2011 +0200
+++ b/public/libervia.css	Thu May 26 17:17:48 2011 +0200
@@ -170,6 +170,10 @@
     font-size: small;
 }
 
+.contactConnected {
+    color: blue;
+}
+
 .selected {
     background-color: yellow;
 }