# HG changeset patch # User Goffi # Date 1423515390 -3600 # Node ID 537649f6a2d09260489eb8dfd90d8262de0da000 # Parent 7af8f4ab36759369637edef9c80321eb4fc755ce browser side (blog, contact list): use of new listener mechanism to update avatar diff -r 7af8f4ab3675 -r 537649f6a2d0 src/browser/sat_browser/blog.py --- a/src/browser/sat_browser/blog.py Mon Feb 09 21:55:16 2015 +0100 +++ b/src/browser/sat_browser/blog.py Mon Feb 09 21:56:30 2015 +0100 @@ -374,6 +374,7 @@ self.vpanel = VerticalPanel() self.vpanel.setStyleName('microblogPanel') self.setWidget(self.vpanel) + host.addListerner('avatar', self.onAvatarUpdate) def __str__(self): return u"Blog Widget [target: {}, profile: {}]".format(self.target, self.profile) @@ -382,6 +383,21 @@ def target(self): return tuple(self.accepted_groups) + def onDelete(self): + quick_widgets.QuickWidget.onDelete(self) + self.host.removeListener('avatar', self.onAvatarUpdate) + + def onAvatarUpdate(self, jid_, hash_, profile): + """Called on avatar update events + + @param jid_: jid of the entity with updated avatar + @param hash_: hash of the avatar + @param profile: should be C.PROF_KEY_NONE + """ + whoami = self.host.profiles[self.profile].whoami.bare + if self.isJidAccepted(jid_) or jid_.bare == whoami.bare: + self.updateValue('avatar', jid_, hash_) + def refresh(self): """Refresh the display of this widget. If the unibox is disabled, display the 'New message' button or an empty bubble on top of the panel""" diff -r 7af8f4ab3675 -r 537649f6a2d0 src/browser/sat_browser/contact_list.py --- a/src/browser/sat_browser/contact_list.py Mon Feb 09 21:55:16 2015 +0100 +++ b/src/browser/sat_browser/contact_list.py Mon Feb 09 21:56:30 2015 +0100 @@ -335,11 +335,16 @@ self.add(self.scroll_panel) self.setStyleName('contactList') Window.addWindowResizeListener(self) + host.addListerner('avatar', self.onAvatarUpdate) @property def profile(self): return C.PROF_KEY_NONE + def onDelete(self): + QuickContactList.onDelete(self) + self.host.removeListener('avatar', self.onAvatarUpdate) + def update(self): ### GROUPS ### _keys = self._groups.keys() @@ -535,6 +540,15 @@ """ self._contacts_panel.updateAvatar(jid_s, url) + def onAvatarUpdate(self, jid_, hash_, profile): + """Called on avatar update events + + @param jid_: jid of the entity with updated avatar + @param hash_: hash of the avatar + @param profile: should be C.PROF_KEY_NONE + """ + self._contacts_panel.updateAvatar(jid_, self.host.getAvatarURL(jid_)) + def hasVisibleMembers(self, group): """Tell if the given group actually has visible members