Hook up activity colors

This commit is contained in:
Marco Pesenti Gritti 2006-08-26 14:17:55 +02:00
parent e34d437fb9
commit 83bbe54bc8
4 changed files with 20 additions and 3 deletions

View File

@ -3,6 +3,8 @@ import dbus
from sugar import conf from sugar import conf
from sugar.activity import Activity from sugar.activity import Activity
from sugar.presence import PresenceService
from sugar.canvas.IconColor import IconColor
from PeopleWindow import PeopleWindow from PeopleWindow import PeopleWindow
class ActivityHost: class ActivityHost:
@ -31,6 +33,14 @@ class ActivityHost:
def get_icon_name(self): def get_icon_name(self):
return self._icon_name 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): def share(self):
self._people_window.share() self._people_window.share()
self._activity.share() self._activity.share()

View File

@ -33,7 +33,8 @@ class TasksItem(DonutItem):
def _add(self, activity): def _add(self, activity):
icon_name = activity.get_icon_name() 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. # FIXME This really sucks. Fix goocanvas event handling.
item.set_data('activity', activity) item.set_data('activity', activity)

View File

@ -1,6 +1,7 @@
import gobject import gobject
from sugar.presence import PresenceService from sugar.presence import PresenceService
from sugar.canvas.IconColor import IconColor
from sugar import conf from sugar import conf
class ActivityInfo: class ActivityInfo:
@ -15,6 +16,11 @@ class ActivityInfo:
def get_title(self): def get_title(self):
return self._service.get_published_value('title') 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): def get_service(self):
return self._service return self._service

View File

@ -14,7 +14,7 @@ class ActivityItem(IconItem):
info = registry.get_activity(activity.get_type()) info = registry.get_activity(activity.get_type())
icon_name = info.get_icon() icon_name = info.get_icon()
IconItem.__init__(self, icon_name, IconColor(), 48) IconItem.__init__(self, icon_name, activity.get_color(), 48)
self._activity = activity self._activity = activity
@ -57,7 +57,7 @@ class Model(goocanvas.CanvasModelSimple):
def add_activity(self, activity): def add_activity(self, activity):
root = self.get_root_item() root = self.get_root_item()
item = ActivityItem(activity, self._registry) item = ActivityItem(activity)
item.set_property('x', random.random() * 1100) item.set_property('x', random.random() * 1100)
item.set_property('y', random.random() * 800) item.set_property('y', random.random() * 800)
root.add_child(item) root.add_child(item)