diff options
Diffstat (limited to 'src/sugar/activity/activity.py')
-rw-r--r-- | src/sugar/activity/activity.py | 47 |
1 files changed, 38 insertions, 9 deletions
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 |