From e366753ab0b3c2f21109859745fd60b927b9504c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 23 Aug 2006 10:41:12 -0400 Subject: [PATCH] Make theme color accessors more descriptive; add mesh view zoom rects --- shell/home/FriendsView.py | 14 +++++++------- shell/home/HomeView.py | 10 +++++----- shell/home/MeshView.py | 26 +++++++++++++++++++++++--- shell/home/Theme.py | 11 +++++++++-- 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/shell/home/FriendsView.py b/shell/home/FriendsView.py index 29418b75..2d6fb474 100644 --- a/shell/home/FriendsView.py +++ b/shell/home/FriendsView.py @@ -15,18 +15,18 @@ class Model(goocanvas.CanvasModelSimple): root = self.get_root_item() - color = self._theme.get_home_colors()[2] + color = self._theme.get_home_mesh_color() self._mesh_rect = goocanvas.Rect(width=1200, height=900, fill_color=color) root.add_child(self._mesh_rect) - color = self._theme.get_home_colors()[1] + color = self._theme.get_home_friends_color() self._friends_rect = goocanvas.Rect(x=100, y=100, width=1000, height=700, line_width=0, fill_color=color, radius_x=30, radius_y=30) root.add_child(self._friends_rect) - color = self._theme.get_home_colors()[0] + color = self._theme.get_home_activities_color() self._home_rect = goocanvas.Rect(x=400, y=300, width=400, height=300, line_width=0, fill_color=color, radius_x=30, radius_y=30) @@ -37,12 +37,12 @@ class Model(goocanvas.CanvasModelSimple): data_model.connect('friend-added', self.__friend_added_cb) - def __theme_changed_cb(self, theme, colors): - color = self._theme.get_home_colors()[0] + def __theme_changed_cb(self, theme): + color = self._theme.get_home_activities_color() self._home_rect.set_property("fill-color", color) - color = self._theme.get_home_colors()[1] + color = self._theme.get_home_friends_color() self._friends_rect.set_property("fill-color", color) - color = self._theme.get_home_colors()[2] + color = self._theme.get_home_mesh_color() self._mesh_rect.set_property("fill-color", color) def add_friend(self, friend): diff --git a/shell/home/HomeView.py b/shell/home/HomeView.py index a84b4f62..7894368c 100644 --- a/shell/home/HomeView.py +++ b/shell/home/HomeView.py @@ -46,12 +46,12 @@ class Background(goocanvas.Group): self._theme = Theme.get_instance() self._theme.connect("theme-changed", self.__theme_changed_cb) - color = self._theme.get_home_colors()[1] + color = self._theme.get_home_friends_color() self._friends_rect = goocanvas.Rect(width=1200, height=900, fill_color=color) self.add_child(self._friends_rect) - color = self._theme.get_home_colors()[0] + color = self._theme.get_home_activities_color() self._home_rect = goocanvas.Rect(x=100, y=100, width=1000, height=700, line_width=0, fill_color=color, radius_x=30, radius_y=30) @@ -62,10 +62,10 @@ class Background(goocanvas.Group): font="Sans 21") self.add_child(item) - def __theme_changed_cb(self, theme, colors): - color = self._theme.get_home_colors()[0] + def __theme_changed_cb(self, theme): + color = self._theme.get_home_activities_color() self._home_rect.set_property("fill-color", color) - color = self._theme.get_home_colors()[1] + color = self._theme.get_friends_colors() self._friends_rect.set_property("fill-color", color) class Model(goocanvas.CanvasModelSimple): diff --git a/shell/home/MeshView.py b/shell/home/MeshView.py index a2694be5..533fb7e8 100644 --- a/shell/home/MeshView.py +++ b/shell/home/MeshView.py @@ -6,6 +6,8 @@ from sugar.canvas.IconItem import IconItem from sugar.canvas.IconItem import IconColor from sugar import conf +import Theme + class ActivityItem(IconItem): def __init__(self, activity): registry = conf.get_activity_registry() @@ -22,18 +24,36 @@ class ActivityItem(IconItem): class Model(goocanvas.CanvasModelSimple): def __init__(self, data_model): goocanvas.CanvasModelSimple.__init__(self) + self._theme = Theme.get_instance() + self._theme.connect("theme-changed", self.__theme_changed_cb) root = self.get_root_item() - item = goocanvas.Rect(width=1200, height=900, - fill_color="#d8d8d8") - root.add_child(item) + color = self._theme.get_home_mesh_color() + self._mesh_rect = goocanvas.Rect(width=1200, height=900, + fill_color=color) + root.add_child(self._mesh_rect) + + color = self._theme.get_home_friends_color() + self._friends_rect = goocanvas.Rect(x=350, y=280, width=500, height=340, + line_width=0, fill_color=color, + radius_x=30, radius_y=30) + root.add_child(self._friends_rect) + + color = self._theme.get_home_activities_color() + self._home_rect = goocanvas.Rect(x=480, y=360, width=240, height=180, + line_width=0, fill_color=color, + radius_x=30, radius_y=30) + root.add_child(self._home_rect) for activity in data_model: self.add_activity(activity) data_model.connect('activity-added', self.__activity_added_cb) + def __theme_changed_cb(self, theme): + pass + def add_activity(self, activity): root = self.get_root_item() diff --git a/shell/home/Theme.py b/shell/home/Theme.py index 259d7724..f0a4cbc2 100644 --- a/shell/home/Theme.py +++ b/shell/home/Theme.py @@ -1,5 +1,7 @@ import gobject + + class Theme(gobject.GObject): __gsignals__ = { 'theme-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, @@ -37,9 +39,14 @@ class Theme(gobject.GObject): if updated: self.emit('theme-changed') - def get_home_colors(self): - return self.__colors[self._cur_theme] + def get_home_activities_color(self): + return self.__colors[self._cur_theme][0] + def get_home_friends_color(self): + return self.__colors[self._cur_theme][1] + + def get_home_mesh_color(self): + return self.__colors[self._cur_theme][2] # Use this accessor, don't create more than one theme object _theme = None