Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2010-10-15 07:48:19 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2010-10-15 07:48:19 (GMT)
commit44d974c44079678483e11f41289c7a38e81c3268 (patch)
tree995dc15df7dd9904313a78bd5cd42a4b26688df5
parentdb46363e9d35f04060eae11ab9198e42d679d284 (diff)
parent2f827135497b3840a0483e7c6ac84876aa7a8744 (diff)
Merge remote branch 'refs/remotes/origin/t/set-window-icon' into HEADt/set-window-icon
-rw-r--r--.topdeps1
-rw-r--r--.topmsg13
-rw-r--r--src/sugar/activity/activity.py47
3 files changed, 52 insertions, 9 deletions
diff --git a/.topdeps b/.topdeps
new file mode 100644
index 0000000..9c9ac90
--- /dev/null
+++ b/.topdeps
@@ -0,0 +1 @@
+upstream/master
diff --git a/.topmsg b/.topmsg
new file mode 100644
index 0000000..3f359fc
--- /dev/null
+++ b/.topmsg
@@ -0,0 +1,13 @@
+From: Sascha Silbe <sascha-pgp@silbe.org>
+Subject: [sugar-toolkit PATCH] set window icon
+Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
+
+Set the window icon to the activity icon for improved look-and-feel when
+using non-Sugar ways of switching windows (e.g. by enabling the metacity key
+bindings).
+
+Tested on XO-1.5 running Debian Squeeze. Setting the icon takes << 0.1s
+(0.058s, 0.026s, 0.021s).
+
+Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org>
+Reviewed-by: James Cameron <quozl@laptop.org>
diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py
index 0bda2ea..238716f 100644
--- a/src/sugar/activity/activity.py
+++ b/src/sugar/activity/activity.py
@@ -70,13 +70,15 @@ from telepathy.interfaces import CHANNEL, \
from telepathy.constants import CONNECTION_HANDLE_TYPE_CONTACT
from sugar import util
+from sugar.bundle.activitybundle import ActivityBundle
from sugar.presence import presenceservice
from sugar.activity.activityservice import ActivityService
from sugar.activity.namingalert import NamingAlert
from sugar.graphics import style
from sugar.graphics.window import Window
from sugar.graphics.alert import Alert
-from sugar.graphics.icon import Icon
+from sugar.graphics.icon import Icon, get_surface
+from sugar.graphics.xocolor import XoColor
from sugar.datastore import datastore
from sugar.session import XSMPClient
from sugar import wm
@@ -327,20 +329,24 @@ class Activity(Window, gtk.Container):
warn_if_none=False)
self._set_up_sharing(mesh_instance, share_scope)
- if handle.object_id is None and create_jobject:
- logging.debug('Creating a jobject.')
- self._jobject = self._initialize_journal_object()
- self.set_title(self._jobject.metadata['title'])
-
- def _initialize_journal_object(self):
- title = _('%s Activity') % get_bundle_name()
-
if self.shared_activity is not None:
icon_color = self.shared_activity.props.color
else:
client = gconf.client_get_default()
icon_color = client.get_string('/desktop/sugar/user/color')
+ icon_pixbuf = self._get_icon_pixbuf(icon_color)
+ gtk.window_set_default_icon(icon_pixbuf)
+ self.set_icon(icon_pixbuf)
+
+ if handle.object_id is None and create_jobject:
+ logging.debug('Creating a jobject.')
+ self._jobject = self._initialize_journal_object(icon_color)
+ self.set_title(self._jobject.metadata['title'])
+
+ def _initialize_journal_object(self, icon_color):
+ title = _('%s Activity') % get_bundle_name()
+
jobject = datastore.create()
jobject.metadata['title'] = title
jobject.metadata['title_set_by_user'] = '0'
@@ -402,6 +408,29 @@ class Activity(Window, gtk.Container):
self._set_up_sharing(mesh_instance, SCOPE_PRIVATE)
wait_loop.quit()
+ def _get_icon_pixbuf(self, icon_color):
+ """Return colored activity icon as a Pixbuf."""
+ bundle = ActivityBundle(get_bundle_path())
+ xo_color = XoColor(icon_color)
+ # FIXME: without background_color there's garbage in the output
+ surface = get_surface(file_name=bundle.get_icon(),
+ fill_color=xo_color.get_fill_color(),
+ stroke_color=xo_color.get_stroke_color(),
+ background_color=style.COLOR_WHITE.get_gdk_color())
+ width, height = surface.get_width(), surface.get_height()
+ colormap = gtk.gdk.colormap_get_system()
+ pixmap = gtk.gdk.Pixmap(self.window, width, height,
+ colormap.get_visual().depth)
+ pixmap.set_colormap(colormap)
+ cr = pixmap.cairo_create()
+ cr.set_source_surface(surface, 0, 0)
+ cr.paint()
+ pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True,
+ colormap.get_visual().bits_per_rgb, width, height)
+ pixbuf = pixbuf.get_from_drawable(pixmap, colormap, 0, 0, 0, 0,
+ width, height)
+ return pixbuf
+
def get_active(self):
return self._active