Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Williams <dcbw@localhost.localdomain>2006-09-25 19:20:28 (GMT)
committer Dan Williams <dcbw@localhost.localdomain>2006-09-25 19:20:28 (GMT)
commit6e28f4467d051ed981bcb6ec91d833c5eff34613 (patch)
tree67a374e2572a7385dfc92deab402326e14baf436 /shell
parentd585a251bdf11f5cd5af8a694f5790adf7f3cc48 (diff)
Add buddy icon to the buddy menu
Diffstat (limited to 'shell')
-rw-r--r--shell/view/BuddyMenu.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/shell/view/BuddyMenu.py b/shell/view/BuddyMenu.py
index 3658f87..33e10eb 100644
--- a/shell/view/BuddyMenu.py
+++ b/shell/view/BuddyMenu.py
@@ -1,6 +1,10 @@
from sugar.canvas.Menu import Menu
from sugar.canvas.IconItem import IconItem
from sugar.presence import PresenceService
+import gtk
+import goocanvas
+
+_ICON_SIZE = 72
class BuddyMenu(Menu):
ACTION_MAKE_FRIEND = 0
@@ -11,16 +15,43 @@ class BuddyMenu(Menu):
Menu.__init__(self, shell.get_grid(), buddy.get_name())
self._buddy = buddy
+ self._buddy.connect('icon-changed', self.__buddy_icon_changed_cb)
self._shell = shell
owner = shell.get_model().get_owner()
if buddy.get_name() != owner.get_name():
self._add_actions()
+ def _get_buddy_icon_pixbuf(self):
+ buddy_object = self._buddy.get_buddy()
+ if not buddy_object:
+ return None
+ icon_data = buddy_object.get_icon()
+ icon_data_string = ""
+ for item in icon_data:
+ if item < 0:
+ item = item + 128
+ icon_data_string = icon_data_string + chr(item)
+ pbl = gtk.gdk.PixbufLoader()
+ pbl.write(icon_data_string)
+ pbl.close()
+ pixbuf = pbl.get_pixbuf()
+ del pbl
+ return pixbuf
+
def _add_actions(self):
shell_model = self._shell.get_model()
pservice = PresenceService.get_instance()
+ pixbuf = self._get_buddy_icon_pixbuf()
+ if pixbuf:
+ pixbuf.scale_simple(_ICON_SIZE, _ICON_SIZE, gtk.gdk.INTERP_BILINEAR)
+ self._buddy_icon_item = goocanvas.Image()
+ self._buddy_icon_item.set_property('pixbuf', pixbuf)
+ self._buddy_icon_item.set_property('width', _ICON_SIZE)
+ self._buddy_icon_item.set_property('height', _ICON_SIZE)
+ self.add_image(self._buddy_icon_item, 3, 3)
+
friends = shell_model.get_friends()
if friends.has_buddy(self._buddy):
icon = IconItem(icon_name='stock-remove-friend')
@@ -40,3 +71,7 @@ class BuddyMenu(Menu):
icon = IconItem(icon_name='stock-invite')
self.add_action(icon, BuddyMenu.ACTION_INVITE)
+
+ def __buddy_icon_changed_cb(self, buddy):
+ pass
+