sugar-toolkit-gtk3/shell/panel/TopPanel.py

42 lines
1.1 KiB
Python
Raw Normal View History

2006-08-28 14:04:51 +02:00
import goocanvas
from panel.Panel import Panel
from sugar.canvas.IconItem import IconItem
2006-08-28 14:36:48 +02:00
import sugar
2006-08-28 14:04:51 +02:00
class ZoomBar(goocanvas.Group):
2006-08-28 14:36:48 +02:00
def __init__(self, shell, height):
2006-08-28 14:04:51 +02:00
goocanvas.Group.__init__(self)
self._height = height
2006-08-28 14:36:48 +02:00
self._shell = shell
2006-08-28 14:04:51 +02:00
2006-08-28 14:36:48 +02:00
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')
2006-08-28 14:04:51 +02:00
2006-08-28 14:36:48 +02:00
def add_zoom_level(self, level, icon_name):
2006-08-28 14:04:51 +02:00
icon = IconItem(icon_name=icon_name, size=self._height)
2006-08-28 14:36:48 +02:00
icon.connect('clicked', self.__level_clicked_cb, level)
2006-08-28 14:04:51 +02:00
icon_size = self._height
x = (icon_size + 6) * self.get_n_children()
icon.set_property('x', x)
self.add_child(icon)
2006-08-28 14:36:48 +02:00
def __level_clicked_cb(self, item, level):
self._shell.set_zoom_level(level)
2006-08-28 14:04:51 +02:00
class TopPanel(Panel):
def __init__(self, shell):
Panel.__init__(self)
self._shell = shell
def construct(self):
Panel.construct(self)
2006-08-28 14:36:48 +02:00
zoom_bar = ZoomBar(self._shell, self.get_height())
2006-08-28 14:04:51 +02:00
zoom_bar.translate(self.get_border(), self.get_border())
self.get_root().add_child(zoom_bar)