diff src/browser/sat_browser/blog.py @ 607:537649f6a2d0 frontends_multi_profiles

browser side (blog, contact list): use of new listener mechanism to update avatar
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:56:30 +0100
parents 7af8f4ab3675
children 1c0d5a87c554
line wrap: on
line diff
--- 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"""