Convert icon data to python string before exposing it

This commit is contained in:
Dan Williams 2007-04-10 22:24:31 -04:00
parent 117934f709
commit defd9f76e3
2 changed files with 13 additions and 10 deletions

View File

@ -58,15 +58,12 @@ class BuddyMenu(Menu):
if not buddy_object: if not buddy_object:
return None return None
pixbuf = None
icon_data = buddy_object.props.icon icon_data = buddy_object.props.icon
icon_data_string = "" if not icon_data:
for item in icon_data: return None
if item < 0:
item = item + 128
icon_data_string += chr(item)
pbl = gtk.gdk.PixbufLoader() pbl = gtk.gdk.PixbufLoader()
pbl.write(icon_data_string) pbl.write(icon_data)
pixbuf = None
try: try:
pbl.close() pbl.close()
pixbuf = pbl.get_pixbuf() pixbuf = pbl.get_pixbuf()

View File

@ -19,6 +19,12 @@ import gobject
import gtk import gtk
import dbus import dbus
def _bytes_to_string(bytes):
if len(bytes):
return ''.join([chr(item) for item in bytes])
return None
class Buddy(gobject.GObject): class Buddy(gobject.GObject):
__gsignals__ = { __gsignals__ = {
@ -87,14 +93,14 @@ class Buddy(gobject.GObject):
return self._properties["owner"] return self._properties["owner"]
elif pspec.name == "icon": elif pspec.name == "icon":
if not self._icon: if not self._icon:
self._icon = self._buddy.GetIcon() self._icon = _bytes_to_string(self._buddy.GetIcon())
return self._icon return self._icon
def object_path(self): def object_path(self):
return self._object_path return self._object_path
def _emit_icon_changed_signal(self, icon_data): def _emit_icon_changed_signal(self, bytes):
self._icon = icon_data self._icon = _bytes_to_string(bytes)
self.emit('icon-changed') self.emit('icon-changed')
return False return False