Improve stylesheet loading
This commit is contained in:
parent
3972ff8651
commit
b3abf30dec
@ -10,4 +10,5 @@ sugar_PYTHON = \
|
||||
BuddyIcon.py \
|
||||
BuddyMenu.py \
|
||||
OverlayWindow.py \
|
||||
Shell.py
|
||||
Shell.py \
|
||||
stylesheet.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)
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
21
shell/view/stylesheet.py
Normal file
21
shell/view/stylesheet.py
Normal file
@ -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
|
||||
}
|
@ -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)
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user