Improve stylesheet loading
This commit is contained in:
parent
3972ff8651
commit
b3abf30dec
@ -4,10 +4,11 @@ sugardir = $(pkgdatadir)/shell/view
|
|||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
ActivityHost.py \
|
ActivityHost.py \
|
||||||
BuddyActivityView.py \
|
BuddyActivityView.py \
|
||||||
ConsoleWindow.py \
|
ConsoleWindow.py \
|
||||||
FirstTimeDialog.py \
|
FirstTimeDialog.py \
|
||||||
BuddyIcon.py \
|
BuddyIcon.py \
|
||||||
BuddyMenu.py \
|
BuddyMenu.py \
|
||||||
OverlayWindow.py \
|
OverlayWindow.py \
|
||||||
Shell.py
|
Shell.py \
|
||||||
|
stylesheet.py
|
||||||
|
@ -2,6 +2,8 @@ import gtk
|
|||||||
import gobject
|
import gobject
|
||||||
import wnck
|
import wnck
|
||||||
|
|
||||||
|
import view.stylesheet
|
||||||
|
from sugar.graphics import style
|
||||||
from view.home.HomeWindow import HomeWindow
|
from view.home.HomeWindow import HomeWindow
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from view.ActivityHost import ActivityHost
|
from view.ActivityHost import ActivityHost
|
||||||
@ -28,6 +30,8 @@ class Shell(gobject.GObject):
|
|||||||
self._hosts = {}
|
self._hosts = {}
|
||||||
self._screen = wnck.screen_get_default()
|
self._screen = wnck.screen_get_default()
|
||||||
|
|
||||||
|
style.load_stylesheet(view.stylesheet)
|
||||||
|
|
||||||
self._key_grabber = KeyGrabber()
|
self._key_grabber = KeyGrabber()
|
||||||
self._key_grabber.connect('key-pressed',
|
self._key_grabber.connect('key-pressed',
|
||||||
self.__global_key_pressed_cb)
|
self.__global_key_pressed_cb)
|
||||||
|
@ -10,7 +10,7 @@ class ActivityItem(CanvasIcon):
|
|||||||
def __init__(self, activity):
|
def __init__(self, activity):
|
||||||
icon_name = activity.get_icon()
|
icon_name = activity.get_icon()
|
||||||
CanvasIcon.__init__(self, icon_name=icon_name)
|
CanvasIcon.__init__(self, icon_name=icon_name)
|
||||||
style.apply_stylesheet(self, 'frame-activity-icon')
|
style.apply_stylesheet(self, 'frame.ActivityIcon')
|
||||||
self._activity = activity
|
self._activity = activity
|
||||||
|
|
||||||
def get_bundle_id(self):
|
def get_bundle_id(self):
|
||||||
|
@ -15,11 +15,11 @@ class ActivityMenu(Menu):
|
|||||||
Menu.__init__(self, activity_host.get_title())
|
Menu.__init__(self, activity_host.get_title())
|
||||||
|
|
||||||
icon = CanvasIcon(icon_name='stock-share-mesh')
|
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)
|
self.add_action(icon, ActivityMenu.ACTION_SHARE)
|
||||||
|
|
||||||
icon = CanvasIcon(icon_name='stock-close')
|
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)
|
self.add_action(icon, ActivityMenu.ACTION_CLOSE)
|
||||||
|
|
||||||
class ActivityIcon(MenuIcon):
|
class ActivityIcon(MenuIcon):
|
||||||
@ -61,22 +61,22 @@ class ZoomBox(hippo.CanvasBox):
|
|||||||
self._activity_icon = None
|
self._activity_icon = None
|
||||||
|
|
||||||
icon = CanvasIcon(icon_name='stock-zoom-mesh')
|
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)
|
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_MESH)
|
||||||
self.append(icon)
|
self.append(icon)
|
||||||
|
|
||||||
icon = CanvasIcon(icon_name='stock-zoom-friends')
|
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)
|
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_FRIENDS)
|
||||||
self.append(icon)
|
self.append(icon)
|
||||||
|
|
||||||
icon = CanvasIcon(icon_name='stock-zoom-home')
|
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)
|
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_HOME)
|
||||||
self.append(icon)
|
self.append(icon)
|
||||||
|
|
||||||
icon = CanvasIcon(icon_name='stock-zoom-activity')
|
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)
|
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_ACTIVITY)
|
||||||
self.append(icon)
|
self.append(icon)
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class ZoomBox(hippo.CanvasBox):
|
|||||||
|
|
||||||
if activity:
|
if activity:
|
||||||
icon = ActivityIcon(self._shell, self._menu_shell, 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.append(icon, 0)
|
||||||
self._activity_icon = icon
|
self._activity_icon = icon
|
||||||
else:
|
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 = {}
|
_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):
|
def register_stylesheet(name, style):
|
||||||
_styles[name] = style
|
_styles[name] = style
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user