[Sugar-devel] [PATCH] Frame: show application-set icon for non-Sugar windows
Sascha Silbe
sascha-pgp at silbe.org
Wed Aug 4 09:55:29 EDT 2010
Display the _NET_WM_ICON content instead of a generic icon for non-Sugar
applications.
Because the sugar.graphics.Icon API is based on file names, we need to create
a temporary file to store the icon.
A future patch could either enhance sugar.graphics.Icon to accept
pixbufs or rework ActivityButton to use something different to show the icon.
Tested on XO-1.5 running Debian Squeeze. Updating the icon took << 0.1s
(0.018s, 0.005s and 0.026s) with /tmp on tmpfs.
Signed-off-by: Sascha Silbe <sascha-pgp at silbe.org>
---
src/jarabe/frame/activitiestray.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/jarabe/frame/activitiestray.py b/src/jarabe/frame/activitiestray.py
index 16c417d..495eff0 100644
--- a/src/jarabe/frame/activitiestray.py
+++ b/src/jarabe/frame/activitiestray.py
@@ -38,6 +38,7 @@ from sugar.activity import activityfactory
from sugar.datastore import datastore
from sugar import mime
from sugar import env
+from sugar import util
from jarabe.model import shell
from jarabe.model import neighborhood
@@ -71,6 +72,10 @@ class ActivityButton(RadioToolButton):
self._icon.props.file = home_activity.get_icon_path()
else:
self._icon.props.icon_name = 'image-missing'
+ window = home_activity.get_window()
+ if window is not None:
+ window.connect('icon-changed', self._icon_changed_cb)
+
self.set_icon_widget(self._icon)
self._icon.show()
@@ -101,6 +106,22 @@ class ActivityButton(RadioToolButton):
else:
self._icon.props.pulsing = False
+ def _icon_changed_cb(self, window):
+ gobject.idle_add(self._update_icon, window)
+
+ def _update_icon(self, window):
+ logging.debug('_update_icon: start')
+ pixbuf = window.get_icon()
+ if pixbuf is None:
+ return
+
+ fd, path = tempfile.mkstemp(suffix='.png')
+ os.close(fd)
+ pixbuf.save(path, 'png')
+ self._icon.props.icon_name = None
+ self._icon.props.file = util.TempFilePath(path)
+ logging.debug('_update_icon: updated icon')
+
class BaseInviteButton(ToolButton):
def __init__(self, invite):
--
tg: (97c3302..) t/frame-show-legacy-icons (depends on: upstream/master)
More information about the Sugar-devel
mailing list