Implent color theming for Friends view

This commit is contained in:
Dan Williams 2006-08-23 08:06:45 -04:00
parent f3435bb914
commit 3b9d3daa3b
2 changed files with 34 additions and 9 deletions

View File

@ -5,21 +5,46 @@ import goocanvas
from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconItem import IconColor
from Theme import Theme
class Model(goocanvas.CanvasModelSimple):
def __init__(self, data_model):
goocanvas.CanvasModelSimple.__init__(self)
self._theme = Theme()
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_colors()[2]
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]
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]
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)
root.add_child(self._home_rect)
for friend in data_model:
self.add_friend(friend)
data_model.connect('friend-added', self.__friend_added_cb)
def __theme_changed_cb(self, theme, colors):
color = self._theme.get_home_colors()[0]
self._home_rect.set_property("fill-color", color)
color = self._theme.get_home_colors()[1]
self._friends_rect.set_property("fill-color", color)
color = self._theme.get_home_colors()[2]
self._mesh_rect.set_property("fill-color", color)
def add_friend(self, friend):
root = self.get_root_item()

View File

@ -47,15 +47,15 @@ class Background(goocanvas.Group):
self._theme.connect("theme-changed", self.__theme_changed_cb)
color = self._theme.get_home_colors()[1]
self._outer_rect = goocanvas.Rect(width=1200, height=900,
self._friends_rect = goocanvas.Rect(width=1200, height=900,
fill_color=color)
self.add_child(self._outer_rect)
self.add_child(self._friends_rect)
color = self._theme.get_home_colors()[0]
self._inner_rect = goocanvas.Rect(x=100, y=100, width=1000, height=700,
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)
self.add_child(self._inner_rect)
self.add_child(self._home_rect)
item = goocanvas.Text(text="My Activities",
x=12, y=12, fill_color="black",
@ -64,9 +64,9 @@ class Background(goocanvas.Group):
def __theme_changed_cb(self, theme, colors):
color = self._theme.get_home_colors()[0]
self._inner_rect.set_property("fill-color", color)
self._home_rect.set_property("fill-color", color)
color = self._theme.get_home_colors()[1]
self._outer_rect.set_property("fill-color", color)
self._friends_rect.set_property("fill-color", color)
class Model(goocanvas.CanvasModelSimple):
def __init__(self, shell):