diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-10-05 11:26:02 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-10-05 11:26:02 (GMT) |
commit | b3abf30decf9804b492f938daaedd04cc2a9aed0 (patch) | |
tree | 0e2a7a1785dc698b1afd063bb36748e031d4e5cb | |
parent | 3972ff86511a09ff4e86e8f293d8bee0122667ea (diff) |
Improve stylesheet loading
-rw-r--r-- | shell/view/Makefile.am | 5 | ||||
-rw-r--r-- | shell/view/Shell.py | 4 | ||||
-rw-r--r-- | shell/view/frame/ActivitiesBox.py | 2 | ||||
-rw-r--r-- | shell/view/frame/ZoomBox.py | 14 | ||||
-rw-r--r-- | shell/view/stylesheet.py | 21 | ||||
-rw-r--r-- | sugar/graphics/__init__.py | 25 | ||||
-rw-r--r-- | sugar/graphics/style.py | 7 |
7 files changed, 43 insertions, 35 deletions
diff --git a/shell/view/Makefile.am b/shell/view/Makefile.am index e1db869..dc8570a 100644 --- a/shell/view/Makefile.am +++ b/shell/view/Makefile.am @@ -4,10 +4,11 @@ sugardir = $(pkgdatadir)/shell/view sugar_PYTHON = \ __init__.py \ ActivityHost.py \ - BuddyActivityView.py \ + BuddyActivityView.py \ ConsoleWindow.py \ FirstTimeDialog.py \ BuddyIcon.py \ BuddyMenu.py \ OverlayWindow.py \ - Shell.py + Shell.py \ + stylesheet.py diff --git a/shell/view/Shell.py b/shell/view/Shell.py index b4f6974..38ba9ac 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -2,6 +2,8 @@ import gtk import gobject import wnck +import view.stylesheet +from sugar.graphics import style from view.home.HomeWindow import HomeWindow from sugar.presence import PresenceService from view.ActivityHost import ActivityHost @@ -28,6 +30,8 @@ class Shell(gobject.GObject): self._hosts = {} self._screen = wnck.screen_get_default() + style.load_stylesheet(view.stylesheet) + self._key_grabber = KeyGrabber() self._key_grabber.connect('key-pressed', self.__global_key_pressed_cb) diff --git a/shell/view/frame/ActivitiesBox.py b/shell/view/frame/ActivitiesBox.py index d46f3be..5013a89 100644 --- a/shell/view/frame/ActivitiesBox.py +++ b/shell/view/frame/ActivitiesBox.py @@ -10,7 +10,7 @@ class ActivityItem(CanvasIcon): def __init__(self, activity): icon_name = activity.get_icon() CanvasIcon.__init__(self, icon_name=icon_name) - style.apply_stylesheet(self, 'frame-activity-icon') + style.apply_stylesheet(self, 'frame.ActivityIcon') self._activity = activity def get_bundle_id(self): diff --git a/shell/view/frame/ZoomBox.py b/shell/view/frame/ZoomBox.py index 7282da7..5b3ad3c 100644 --- a/shell/view/frame/ZoomBox.py +++ b/shell/view/frame/ZoomBox.py @@ -15,11 +15,11 @@ class ActivityMenu(Menu): Menu.__init__(self, activity_host.get_title()) icon = CanvasIcon(icon_name='stock-share-mesh') - style.apply_stylesheet(icon, 'menu-action-icon') + style.apply_stylesheet(icon, 'menu.ActionIcon') self.add_action(icon, ActivityMenu.ACTION_SHARE) icon = CanvasIcon(icon_name='stock-close') - style.apply_stylesheet(icon, 'menu-action-icon') + style.apply_stylesheet(icon, 'menu.ActionIcon') self.add_action(icon, ActivityMenu.ACTION_CLOSE) class ActivityIcon(MenuIcon): @@ -61,22 +61,22 @@ class ZoomBox(hippo.CanvasBox): self._activity_icon = None icon = CanvasIcon(icon_name='stock-zoom-mesh') - style.apply_stylesheet(icon, 'frame-zoom-icon') + style.apply_stylesheet(icon, 'frame.ZoomIcon') icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_MESH) self.append(icon) icon = CanvasIcon(icon_name='stock-zoom-friends') - style.apply_stylesheet(icon, 'frame-zoom-icon') + style.apply_stylesheet(icon, 'frame.ZoomIcon') icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_FRIENDS) self.append(icon) icon = CanvasIcon(icon_name='stock-zoom-home') - style.apply_stylesheet(icon, 'frame-zoom-icon') + style.apply_stylesheet(icon, 'frame.ZoomIcon') icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_HOME) self.append(icon) icon = CanvasIcon(icon_name='stock-zoom-activity') - style.apply_stylesheet(icon, 'frame-zoom-icon') + style.apply_stylesheet(icon, 'frame.ZoomIcon') icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_ACTIVITY) self.append(icon) @@ -89,7 +89,7 @@ class ZoomBox(hippo.CanvasBox): if activity: icon = ActivityIcon(self._shell, self._menu_shell, activity) - style.apply_stylesheet(icon, 'frame-zoom-icon') + style.apply_stylesheet(icon, 'frame.ZoomIcon') self.append(icon, 0) self._activity_icon = icon else: diff --git a/shell/view/stylesheet.py b/shell/view/stylesheet.py new file mode 100644 index 0000000..02f19f3 --- /dev/null +++ b/shell/view/stylesheet.py @@ -0,0 +1,21 @@ +import gtk + +from sugar.graphics.iconcolor import IconColor + +if gtk.gdk.screen_width() == 1200: + _medium_icon_size = 75 +else: + _medium_icon_size = 50 + +frame_ActivityIcon = { + 'color' : IconColor('white'), + 'size' : _medium_icon_size +} + +frame_ZoomIcon = { + 'size' : _medium_icon_size +} + +menu_ActionIcon = { + 'size' : _medium_icon_size +} diff --git a/sugar/graphics/__init__.py b/sugar/graphics/__init__.py index b3c54e1..e69de29 100644 --- a/sugar/graphics/__init__.py +++ b/sugar/graphics/__init__.py @@ -1,25 +0,0 @@ -import gtk - -from sugar.graphics import style -from sugar.graphics.iconcolor import IconColor - -if gtk.gdk.screen_width() == 1200: - _medium_icon_size = 75 -else: - _medium_icon_size = 50 - -_stylesheet = { - 'color' : IconColor('white'), - 'size' : _medium_icon_size -} -style.register_stylesheet('frame-activity-icon', _stylesheet) - -_stylesheet = { - 'size' : _medium_icon_size -} -style.register_stylesheet('frame-zoom-icon', _stylesheet) - -_stylesheet = { - 'size' : _medium_icon_size -} -style.register_stylesheet('menu-action-icon', _stylesheet) diff --git a/sugar/graphics/style.py b/sugar/graphics/style.py index 4b1bc53..ae1e424 100644 --- a/sugar/graphics/style.py +++ b/sugar/graphics/style.py @@ -1,5 +1,12 @@ _styles = {} +def load_stylesheet(module): + for objname in dir(module): + if not objname.startswith('_'): + obj = getattr(module, objname) + if isinstance(obj, dict): + register_stylesheet(objname.replace('_', '.'), obj) + def register_stylesheet(name, style): _styles[name] = style |