2006-08-28 14:04:51 +02:00
|
|
|
import goocanvas
|
|
|
|
|
2006-09-08 00:51:45 +02:00
|
|
|
from sugar.canvas.GridLayout import GridGroup
|
|
|
|
from sugar.canvas.GridLayout import GridConstraints
|
2006-08-28 14:04:51 +02:00
|
|
|
from sugar.canvas.IconItem import IconItem
|
2006-08-28 14:36:48 +02:00
|
|
|
import sugar
|
2006-08-28 14:04:51 +02:00
|
|
|
|
2006-09-08 00:51:45 +02:00
|
|
|
class TopPanel(GridGroup):
|
|
|
|
def __init__(self, shell):
|
2006-09-08 10:38:45 +02:00
|
|
|
GridGroup.__init__(self, 16, 1)
|
2006-08-28 14:36:48 +02:00
|
|
|
self._shell = shell
|
2006-08-28 14:04:51 +02:00
|
|
|
|
2006-09-08 00:51:45 +02:00
|
|
|
self.add_zoom_level(sugar.ZOOM_ACTIVITY, 'stock-zoom-activity', 1)
|
|
|
|
self.add_zoom_level(sugar.ZOOM_HOME, 'stock-zoom-home', 2)
|
|
|
|
self.add_zoom_level(sugar.ZOOM_FRIENDS, 'stock-zoom-friends', 3)
|
|
|
|
self.add_zoom_level(sugar.ZOOM_MESH, 'stock-zoom-mesh', 4)
|
|
|
|
|
|
|
|
icon = IconItem(icon_name='stock-share', size=self._width)
|
|
|
|
icon.connect('clicked', self.__share_clicked_cb)
|
|
|
|
self.add_icon(icon, 12)
|
|
|
|
|
|
|
|
icon = IconItem(icon_name='stock-invite', size=self._width)
|
|
|
|
icon.connect('clicked', self.__invite_clicked_cb)
|
|
|
|
self.add_icon(icon, 13)
|
|
|
|
|
|
|
|
icon = IconItem(icon_name='stock-chat', size=self._width)
|
|
|
|
icon.connect('clicked', self.__chat_clicked_cb)
|
|
|
|
self.add_icon(icon, 14)
|
2006-08-28 14:04:51 +02:00
|
|
|
|
2006-09-08 00:51:45 +02:00
|
|
|
def add_zoom_level(self, level, icon_name, pos):
|
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
|
|
|
|
2006-09-08 02:20:11 +02:00
|
|
|
constraints = GridConstraints(pos, 0, 1, 1, 6)
|
2006-09-08 00:51:45 +02:00
|
|
|
self._layout.set_constraints(icon, constraints)
|
|
|
|
self.add_child(icon)
|
2006-08-28 14:04:51 +02:00
|
|
|
|
2006-09-08 00:51:45 +02:00
|
|
|
def add_icon(self, icon, pos):
|
2006-09-08 02:20:11 +02:00
|
|
|
constraints = GridConstraints(pos, 0, 1, 1, 6)
|
2006-09-08 00:51:45 +02:00
|
|
|
self._layout.set_constraints(icon, constraints)
|
2006-08-28 14:04:51 +02:00
|
|
|
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-09-08 00:51:45 +02:00
|
|
|
def __share_clicked_cb(self, item):
|
|
|
|
activity = self._shell.get_current_activity()
|
|
|
|
if activity != None:
|
|
|
|
activity.share()
|
2006-08-28 14:04:51 +02:00
|
|
|
|
2006-09-08 00:51:45 +02:00
|
|
|
def __invite_clicked_cb(self, item):
|
|
|
|
pass
|
2006-08-28 14:04:51 +02:00
|
|
|
|
2006-09-08 00:51:45 +02:00
|
|
|
def __chat_clicked_cb(self, item):
|
|
|
|
pass
|