changeset 640:75715f5c95e3 frontends_multi_profiles

browser side(contact list): added nick listener
author Goffi <goffi@goffi.org>
date Tue, 24 Feb 2015 16:49:07 +0100
parents 8da4735a3c81
children f5145881723a
files src/browser/sat_browser/contact_list.py
diffstat 1 files changed, 29 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/sat_browser/contact_list.py	Tue Feb 24 16:48:41 2015 +0100
+++ b/src/browser/sat_browser/contact_list.py	Tue Feb 24 16:49:07 2015 +0100
@@ -112,6 +112,14 @@
                                          'contact': contact_html}
         self.setHTML(html)
 
+    def updateNick(self, new_nick):
+        """Change the current nick
+
+        @param new_nick(unicode): new nick to use
+        """
+        self.nick = new_nick
+        self.refresh()
+
     def setAlert(self, alert):
         """Show a visual indicator
 
@@ -171,6 +179,13 @@
         """
         self.avatar.setUrl(url)
 
+    def updateNick(self, new_nick):
+        """Update the nickname.
+
+        @param new_nick (unicode): new nickname to use
+        """
+        self.label.updateNick(new_nick)
+
     def onClick(self, sender):
         try:
             self.parent.onClick(self.jid)
@@ -296,6 +311,17 @@
         except TypeError:
             pass
 
+    def updateNick(self, jid_, new_nick):
+        """Update the avatar of the given contact
+
+        @param jid_ (jid.JID): contact jid
+        @param new_nick (unicode): new nick of the contact
+        """
+        try:
+            self.getContactBox(jid_).updateNick(new_nick)
+        except TypeError:
+            pass
+
 
 class ContactsPanel(BaseContactsPanel):
     """The contact list that is displayed on the left side."""
@@ -554,14 +580,6 @@
                 if contact.jid in jids:
                     contact.label.removeStyleName("selected")
 
-    def updateAvatar(self, jid_s, url):
-        """Update the avatar of the given contact
-
-        @param jid_s (unicode): contact jid
-        @param url (unicode): image url
-        """
-        self._contacts_panel.updateAvatar(jid_s, url)
-
     def onAvatarUpdate(self, jid_, hash_, profile):
         """Called on avatar update events
 
@@ -571,6 +589,9 @@
         """
         self._contacts_panel.updateAvatar(jid_, self.host.getAvatarURL(jid_))
 
+    def onNickUpdate(self, jid_, new_nick, profile):
+        self._contacts_panel.updateNick(jid_, new_nick)
+
     def hasVisibleMembers(self, group):
         """Tell if the given group actually has visible members