diff browser_side/panels.py @ 273:11718798ab8a

browser_side: can identify muc members with symbols
author souliane <souliane@mailoo.org>
date Thu, 21 Nov 2013 16:03:33 +0100
parents 9eb9c7d41bdc
children a763b2ac5d41
line wrap: on
line diff
--- a/browser_side/panels.py	Thu Nov 21 13:44:26 2013 +0100
+++ b/browser_side/panels.py	Thu Nov 21 16:03:33 2013 +0100
@@ -626,13 +626,24 @@
 class Occupant(HTML):
     """Occupant of a MUC room"""
 
-    def __init__(self, nick):
+    def __init__(self, nick, special=""):
+        HTML.__init__(self)
         self.nick = nick
-        HTML.__init__(self, "<div class='occupant'>%s</div>" % html_sanitize(nick))
+        self.special = special
+        self._refresh()
 
     def __str__(self):
         return self.nick
 
+    def addSpecial(self, special=""):
+        if special not in self.special:
+            self.special += special
+            self._refresh()
+
+    def _refresh(self):
+        special = "" if len(self.special) == 0 else " %s" % self.special
+        self.setHTML("<div class='occupant'>%s%s</div>" % (html_sanitize(self.nick), special))
+
 
 class OccupantsList(AbsolutePanel):
     """Panel user to show occupants of a room"""
@@ -657,6 +668,16 @@
         self.occupants_list.clear()
         AbsolutePanel.clear(self)
 
+    def addSpecials(self, occupants=[], html=""):
+        index = 0
+        special = html
+        for occupant in occupants:
+            if occupant in self.occupants_list.keys():
+                if isinstance(html, list):
+                    special = html[index]
+                    index = (index + 1) % len(html)
+                self.occupants_list[occupant].addSpecial(special)
+
 
 class ChatPanel(base_widget.LiberviaWidget):