# HG changeset patch # User Goffi # Date 1424792947 -3600 # Node ID 75715f5c95e34580189cf61de66af14321b90cbe # Parent 8da4735a3c811794b67793f955202c8b025dc87d browser side(contact list): added nick listener diff -r 8da4735a3c81 -r 75715f5c95e3 src/browser/sat_browser/contact_list.py --- 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