sugar-toolkit-gtk3/shell/panel/TopPanel.py
2006-08-28 14:36:48 +02:00

42 lines
1.1 KiB
Python

import goocanvas
from panel.Panel import Panel
from sugar.canvas.IconItem import IconItem
import sugar
class ZoomBar(goocanvas.Group):
def __init__(self, shell, height):
goocanvas.Group.__init__(self)
self._height = height
self._shell = shell
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, 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()
icon.set_property('x', x)
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)
self._shell = shell
def construct(self):
Panel.construct(self)
zoom_bar = ZoomBar(self._shell, self.get_height())
zoom_bar.translate(self.get_border(), self.get_border())
self.get_root().add_child(zoom_bar)