Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Williams <dcbw@localhost.localdomain>2006-08-23 11:09:10 (GMT)
committer Dan Williams <dcbw@localhost.localdomain>2006-08-23 11:09:10 (GMT)
commitf3435bb9148bf5d7fe91c6fef591b5e9156e9a41 (patch)
tree2cc1390d16cbe9886da08812940d36a39c50717c /shell
parent1b688469c1861f0f47729393d7649d38b100fc61 (diff)
Add simple theme support to pick up color themes in the Home Window
Diffstat (limited to 'shell')
-rw-r--r--shell/home/HomeView.py23
-rw-r--r--shell/home/Theme.py41
2 files changed, 61 insertions, 3 deletions
diff --git a/shell/home/HomeView.py b/shell/home/HomeView.py
index 9cc01ac..d7a7be9 100644
--- a/shell/home/HomeView.py
+++ b/shell/home/HomeView.py
@@ -8,6 +8,8 @@ from sugar.canvas.DonutItem import DonutItem
from sugar.canvas.DonutItem import PieceItem
from sugar.canvas.DonutItem import PieceIcon
+from Theme import Theme
+
class TasksItem(DonutItem):
def __init__(self, shell):
DonutItem.__init__(self, 250)
@@ -41,16 +43,31 @@ class TasksItem(DonutItem):
class Background(goocanvas.Group):
def __init__(self):
goocanvas.Group.__init__(self)
+ self._theme = Theme()
+ self._theme.connect("theme-changed", self.__theme_changed_cb)
- item = goocanvas.Rect(width=1200, height=900,
- fill_color="#d8d8d8")
- self.add_child(item)
+ color = self._theme.get_home_colors()[1]
+ self._outer_rect = goocanvas.Rect(width=1200, height=900,
+ fill_color=color)
+ self.add_child(self._outer_rect)
+
+ color = self._theme.get_home_colors()[0]
+ self._inner_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)
item = goocanvas.Text(text="My Activities",
x=12, y=12, fill_color="black",
font="Sans 21")
self.add_child(item)
+ def __theme_changed_cb(self, theme, colors):
+ color = self._theme.get_home_colors()[0]
+ self._inner_rect.set_property("fill-color", color)
+ color = self._theme.get_home_colors()[1]
+ self._outer_rect.set_property("fill-color", color)
+
class Model(goocanvas.CanvasModelSimple):
def __init__(self, shell):
goocanvas.CanvasModelSimple.__init__(self)
diff --git a/shell/home/Theme.py b/shell/home/Theme.py
new file mode 100644
index 0000000..747c1eb
--- /dev/null
+++ b/shell/home/Theme.py
@@ -0,0 +1,41 @@
+import gobject
+
+class Theme(gobject.GObject):
+ __gsignals__ = {
+ 'theme-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([]))
+ }
+
+ # from OLPC_PLAN_14.swf
+ __colors = {
+ 'blue': ("#c7d2fb", "#bbc8fa", "#afbffa"),
+ 'turquoise': ("#c8dce8", "#bdd4e3", "#b1cdde"),
+ 'green': ("#ccebac", "#c1e79a", "#b6e388"),
+ 'tan': ("#e8ead1", "#e4e5c8", "#dfe1be"),
+ 'gray': ("#dbe1dd", "#d3dbd5", "#ccd5ce"),
+ 'dark-gray': ("#dad1d4", "#d2c7cb", "#cabdc2")
+ }
+
+ def __init__(self):
+ gobject.GObject.__init__(self)
+ self._cur_theme = 'blue'
+
+ def set(self, theme):
+ updated = False
+ if type(theme) == type(""):
+ theme = theme.lower()
+ if self.__colors.has_key(theme):
+ self._cur_theme = theme
+ updated = True
+ elif type(theme) == type(1):
+ try:
+ theme = self.__colors.keys()[theme]
+ self._cur_theme = theme
+ updated = True
+ except IndexError:
+ pass
+ if updated:
+ self.emit('theme-changed')
+
+ def get_home_colors(self):
+ return self.__colors[self._cur_theme]