Get the zoom level buttons to work
This commit is contained in:
parent
a0127aa4df
commit
b6cf5ef31e
@ -19,6 +19,7 @@ from sugar.activity import Activity
|
||||
from FirstTimeDialog import FirstTimeDialog
|
||||
from panel.PanelManager import PanelManager
|
||||
from globalkeys import KeyGrabber
|
||||
import sugar
|
||||
from sugar import conf
|
||||
import sugar.logger
|
||||
|
||||
@ -42,11 +43,6 @@ class ShellDbusService(dbus.service.Object):
|
||||
gobject.idle_add(self.__show_console_idle)
|
||||
|
||||
class Shell(gobject.GObject):
|
||||
ZOOM_MESH = 0
|
||||
ZOOM_FRIENDS = 1
|
||||
ZOOM_HOME = 2
|
||||
ZOOM_ACTIVITY = 3
|
||||
|
||||
__gsignals__ = {
|
||||
'activity-opened': (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])),
|
||||
@ -86,13 +82,13 @@ class Shell(gobject.GObject):
|
||||
|
||||
def __global_key_pressed_cb(self, grabber, key):
|
||||
if key == 'F1':
|
||||
self.set_zoom_level(Shell.ZOOM_ACTIVITY)
|
||||
self.set_zoom_level(sugar.ZOOM_ACTIVITY)
|
||||
elif key == 'F2':
|
||||
self.set_zoom_level(Shell.ZOOM_HOME)
|
||||
self.set_zoom_level(sugar.ZOOM_HOME)
|
||||
elif key == 'F3':
|
||||
self.set_zoom_level(Shell.ZOOM_FRIENDS)
|
||||
self.set_zoom_level(sugar.ZOOM_FRIENDS)
|
||||
elif key == 'F4':
|
||||
self.set_zoom_level(Shell.ZOOM_MESH)
|
||||
self.set_zoom_level(sugar.ZOOM_MESH)
|
||||
|
||||
def __first_time_dialog_destroy_cb(self, dialog):
|
||||
conf.get_profile().save()
|
||||
@ -113,7 +109,7 @@ class Shell(gobject.GObject):
|
||||
|
||||
home_model = HomeModel()
|
||||
self._home_window.set_model(home_model)
|
||||
self.set_zoom_level(Shell.ZOOM_HOME)
|
||||
self.set_zoom_level(sugar.ZOOM_HOME)
|
||||
|
||||
self._panel_manager = PanelManager(self)
|
||||
|
||||
@ -122,7 +118,7 @@ class Shell(gobject.GObject):
|
||||
|
||||
def __showing_desktop_changed_cb(self, screen):
|
||||
if not screen.get_showing_desktop():
|
||||
self._zoom_level = Shell.ZOOM_ACTIVITY
|
||||
self._zoom_level = sugar.ZOOM_ACTIVITY
|
||||
|
||||
def __window_opened_cb(self, screen, window):
|
||||
if window.get_window_type() == wnck.WINDOW_NORMAL:
|
||||
@ -215,14 +211,14 @@ class Shell(gobject.GObject):
|
||||
def set_zoom_level(self, level):
|
||||
self._zoom_level = level
|
||||
|
||||
if level == Shell.ZOOM_ACTIVITY:
|
||||
if level == sugar.ZOOM_ACTIVITY:
|
||||
self._screen.toggle_showing_desktop(False)
|
||||
else:
|
||||
self._screen.toggle_showing_desktop(True)
|
||||
|
||||
if level == Shell.ZOOM_HOME:
|
||||
if level == sugar.ZOOM_HOME:
|
||||
self._home_window.set_view(HomeWindow.HOME_VIEW)
|
||||
elif level == Shell.ZOOM_FRIENDS:
|
||||
elif level == sugar.ZOOM_FRIENDS:
|
||||
self._home_window.set_view(HomeWindow.FRIENDS_VIEW)
|
||||
elif level == Shell.ZOOM_MESH:
|
||||
elif level == sugar.ZOOM_MESH:
|
||||
self._home_window.set_view(HomeWindow.MESH_VIEW)
|
||||
|
@ -2,19 +2,22 @@ import goocanvas
|
||||
|
||||
from panel.Panel import Panel
|
||||
from sugar.canvas.IconItem import IconItem
|
||||
import sugar
|
||||
|
||||
class ZoomBar(goocanvas.Group):
|
||||
def __init__(self, height):
|
||||
def __init__(self, shell, height):
|
||||
goocanvas.Group.__init__(self)
|
||||
self._height = height
|
||||
self._shell = shell
|
||||
|
||||
self.add_zoom_level('stock-zoom-activity')
|
||||
self.add_zoom_level('stock-zoom-home')
|
||||
self.add_zoom_level('stock-zoom-friends')
|
||||
self.add_zoom_level('stock-zoom-mesh')
|
||||
self.add_zoom_level(sugar.ZOOM_ACTIVITY, 'stock-zoom-activity')
|
||||
self.add_zoom_level(sugar.ZOOM_HOME, 'stock-zoom-home')
|
||||
self.add_zoom_level(sugar.ZOOM_FRIENDS, 'stock-zoom-friends')
|
||||
self.add_zoom_level(sugar.ZOOM_MESH, 'stock-zoom-mesh')
|
||||
|
||||
def add_zoom_level(self, icon_name):
|
||||
def add_zoom_level(self, level, icon_name):
|
||||
icon = IconItem(icon_name=icon_name, size=self._height)
|
||||
icon.connect('clicked', self.__level_clicked_cb, level)
|
||||
|
||||
icon_size = self._height
|
||||
x = (icon_size + 6) * self.get_n_children()
|
||||
@ -22,6 +25,9 @@ class ZoomBar(goocanvas.Group):
|
||||
|
||||
self.add_child(icon)
|
||||
|
||||
def __level_clicked_cb(self, item, level):
|
||||
self._shell.set_zoom_level(level)
|
||||
|
||||
class TopPanel(Panel):
|
||||
def __init__(self, shell):
|
||||
Panel.__init__(self)
|
||||
@ -30,6 +36,6 @@ class TopPanel(Panel):
|
||||
def construct(self):
|
||||
Panel.construct(self)
|
||||
|
||||
zoom_bar = ZoomBar(self.get_height())
|
||||
zoom_bar = ZoomBar(self._shell, self.get_height())
|
||||
zoom_bar.translate(self.get_border(), self.get_border())
|
||||
self.get_root().add_child(zoom_bar)
|
||||
|
@ -0,0 +1,4 @@
|
||||
ZOOM_MESH = 0
|
||||
ZOOM_FRIENDS = 1
|
||||
ZOOM_HOME = 2
|
||||
ZOOM_ACTIVITY = 3
|
@ -50,7 +50,12 @@ class IconCache(gobject.GObject):
|
||||
self._icons[key] = icon
|
||||
return icon
|
||||
|
||||
class IconItem(goocanvas.Image):
|
||||
class IconItem(goocanvas.Image, goocanvas.Item):
|
||||
__gsignals__ = {
|
||||
'clicked': (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, ([])),
|
||||
}
|
||||
|
||||
__gproperties__ = {
|
||||
'icon-name': (str, None, None, None,
|
||||
gobject.PARAM_CONSTRUCT_ONLY |
|
||||
@ -64,14 +69,6 @@ class IconItem(goocanvas.Image):
|
||||
gobject.PARAM_READWRITE)
|
||||
}
|
||||
|
||||
def do_set_property(self, pspec, value):
|
||||
if pspec.name == 'icon-name':
|
||||
self._icon_name = value
|
||||
elif pspec.name == 'color':
|
||||
self._color = value
|
||||
elif pspec.name == 'size':
|
||||
self._size = value
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
goocanvas.Image.__init__(self, **kwargs)
|
||||
|
||||
@ -83,3 +80,19 @@ class IconItem(goocanvas.Image):
|
||||
theme = gtk.icon_theme_get_default()
|
||||
pixbuf = theme.load_icon(self._icon_name, self._size, 0)
|
||||
self.props.pixbuf = pixbuf
|
||||
|
||||
def do_set_property(self, pspec, value):
|
||||
if pspec.name == 'icon-name':
|
||||
self._icon_name = value
|
||||
elif pspec.name == 'color':
|
||||
self._color = value
|
||||
elif pspec.name == 'size':
|
||||
self._size = value
|
||||
|
||||
def do_create_view(self, canvas, parent_view):
|
||||
view = goocanvas.Image.do_create_view(self, canvas, parent_view)
|
||||
view.connect('button-press-event', self.__button_press_cb)
|
||||
return view
|
||||
|
||||
def __button_press_cb(self, view, target, event):
|
||||
self.emit('clicked')
|
||||
|
Loading…
Reference in New Issue
Block a user