From 83bbe54bc8f7f8be451f52ffd919569e47783930 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sat, 26 Aug 2006 14:17:55 +0200 Subject: [PATCH] Hook up activity colors --- shell/ActivityHost.py | 10 ++++++++++ shell/home/HomeView.py | 3 ++- shell/home/MeshModel.py | 6 ++++++ shell/home/MeshView.py | 4 ++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/shell/ActivityHost.py b/shell/ActivityHost.py index d8b6569a..37628c76 100644 --- a/shell/ActivityHost.py +++ b/shell/ActivityHost.py @@ -3,6 +3,8 @@ import dbus from sugar import conf from sugar.activity import Activity +from sugar.presence import PresenceService +from sugar.canvas.IconColor import IconColor from PeopleWindow import PeopleWindow class ActivityHost: @@ -31,6 +33,14 @@ class ActivityHost: def get_icon_name(self): return self._icon_name + def get_icon_color(self): + pservice = PresenceService.get_instance() + activity = pservice.get_activity(self._id) + if activity != None: + return IconColor(activity.get_color()) + else: + return conf.get_profile().get_color() + def share(self): self._people_window.share() self._activity.share() diff --git a/shell/home/HomeView.py b/shell/home/HomeView.py index 8d91b0bb..e1c6904e 100644 --- a/shell/home/HomeView.py +++ b/shell/home/HomeView.py @@ -33,7 +33,8 @@ class TasksItem(DonutItem): def _add(self, activity): icon_name = activity.get_icon_name() - item = self.add_piece(100 / 8, icon_name, IconColor()) + icon_color = activity.get_icon_color() + item = self.add_piece(100 / 8, icon_name, icon_color) # FIXME This really sucks. Fix goocanvas event handling. item.set_data('activity', activity) diff --git a/shell/home/MeshModel.py b/shell/home/MeshModel.py index 68ed4a9d..b659dff1 100644 --- a/shell/home/MeshModel.py +++ b/shell/home/MeshModel.py @@ -1,6 +1,7 @@ import gobject from sugar.presence import PresenceService +from sugar.canvas.IconColor import IconColor from sugar import conf class ActivityInfo: @@ -15,6 +16,11 @@ class ActivityInfo: def get_title(self): return self._service.get_published_value('title') + + def get_color(self): + pservice = PresenceService.get_instance() + activity = pservice.get_activity(self.get_id()) + return IconColor(activity.get_color()) def get_service(self): return self._service diff --git a/shell/home/MeshView.py b/shell/home/MeshView.py index 533fb7e8..d5c43277 100644 --- a/shell/home/MeshView.py +++ b/shell/home/MeshView.py @@ -14,7 +14,7 @@ class ActivityItem(IconItem): info = registry.get_activity(activity.get_type()) icon_name = info.get_icon() - IconItem.__init__(self, icon_name, IconColor(), 48) + IconItem.__init__(self, icon_name, activity.get_color(), 48) self._activity = activity @@ -57,7 +57,7 @@ class Model(goocanvas.CanvasModelSimple): def add_activity(self, activity): root = self.get_root_item() - item = ActivityItem(activity, self._registry) + item = ActivityItem(activity) item.set_property('x', random.random() * 1100) item.set_property('y', random.random() * 800) root.add_child(item)