From defd9f76e3fd3fab2fbedadd0d948ea26fb7704c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 10 Apr 2007 22:24:31 -0400 Subject: [PATCH] Convert icon data to python string before exposing it --- shell/view/BuddyMenu.py | 11 ++++------- sugar/presence/buddy.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/shell/view/BuddyMenu.py b/shell/view/BuddyMenu.py index 10b198d1..1a76168a 100644 --- a/shell/view/BuddyMenu.py +++ b/shell/view/BuddyMenu.py @@ -58,15 +58,12 @@ class BuddyMenu(Menu): if not buddy_object: return None - pixbuf = None icon_data = buddy_object.props.icon - icon_data_string = "" - for item in icon_data: - if item < 0: - item = item + 128 - icon_data_string += chr(item) + if not icon_data: + return None pbl = gtk.gdk.PixbufLoader() - pbl.write(icon_data_string) + pbl.write(icon_data) + pixbuf = None try: pbl.close() pixbuf = pbl.get_pixbuf() diff --git a/sugar/presence/buddy.py b/sugar/presence/buddy.py index f1b1c29c..c6f51d57 100644 --- a/sugar/presence/buddy.py +++ b/sugar/presence/buddy.py @@ -19,6 +19,12 @@ import gobject import gtk import dbus +def _bytes_to_string(bytes): + if len(bytes): + return ''.join([chr(item) for item in bytes]) + return None + + class Buddy(gobject.GObject): __gsignals__ = { @@ -87,14 +93,14 @@ class Buddy(gobject.GObject): return self._properties["owner"] elif pspec.name == "icon": if not self._icon: - self._icon = self._buddy.GetIcon() + self._icon = _bytes_to_string(self._buddy.GetIcon()) return self._icon def object_path(self): return self._object_path - def _emit_icon_changed_signal(self, icon_data): - self._icon = icon_data + def _emit_icon_changed_signal(self, bytes): + self._icon = _bytes_to_string(bytes) self.emit('icon-changed') return False