From a0127aa4df05dfac0c99019f1fdfa89f587b4932 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 28 Aug 2006 14:04:51 +0200 Subject: [PATCH] Add the top panel, unfinished. --- shell/panel/Panel.py | 3 +++ shell/panel/PanelManager.py | 9 +++++---- shell/panel/TopPanel.py | 35 +++++++++++++++++++++++++++++++++++ shell/panel/VerbsPanel.py | 2 +- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 shell/panel/TopPanel.py diff --git a/shell/panel/Panel.py b/shell/panel/Panel.py index 7c3798b2..c7347f12 100644 --- a/shell/panel/Panel.py +++ b/shell/panel/Panel.py @@ -35,6 +35,9 @@ class Panel(gtk.Window): def get_model(self): return self._view.get_model() + def get_root(self): + return self.get_model().get_root_item() + def get_border(self): return PanelModel.BORDER diff --git a/shell/panel/PanelManager.py b/shell/panel/PanelManager.py index 998ba72a..04ffadcf 100644 --- a/shell/panel/PanelManager.py +++ b/shell/panel/PanelManager.py @@ -2,6 +2,7 @@ import gtk from panel.VerbsPanel import VerbsPanel from panel.FriendsPanel import FriendsPanel +from panel.TopPanel import TopPanel from panel.Panel import Panel class PanelManager: @@ -18,10 +19,10 @@ class PanelManager: self._friends_panel.resize(size, gtk.gdk.screen_height()) self._friends_panel.show() - panel = Panel() - panel.move(0, 0) - panel.resize(gtk.gdk.screen_width(), size) - panel.show() + self._top_panel = TopPanel(shell) + self._top_panel.move(0, 0) + self._top_panel.resize(gtk.gdk.screen_width(), size) + self._top_panel.show() panel = Panel() panel.move(0, 0) diff --git a/shell/panel/TopPanel.py b/shell/panel/TopPanel.py new file mode 100644 index 00000000..58e12f6a --- /dev/null +++ b/shell/panel/TopPanel.py @@ -0,0 +1,35 @@ +import goocanvas + +from panel.Panel import Panel +from sugar.canvas.IconItem import IconItem + +class ZoomBar(goocanvas.Group): + def __init__(self, height): + goocanvas.Group.__init__(self) + self._height = height + + 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') + + def add_zoom_level(self, icon_name): + icon = IconItem(icon_name=icon_name, size=self._height) + + icon_size = self._height + x = (icon_size + 6) * self.get_n_children() + icon.set_property('x', x) + + self.add_child(icon) + +class TopPanel(Panel): + def __init__(self, shell): + Panel.__init__(self) + self._shell = shell + + def construct(self): + Panel.construct(self) + + zoom_bar = ZoomBar(self.get_height()) + zoom_bar.translate(self.get_border(), self.get_border()) + self.get_root().add_child(zoom_bar) diff --git a/shell/panel/VerbsPanel.py b/shell/panel/VerbsPanel.py index ed4beb12..43c07553 100644 --- a/shell/panel/VerbsPanel.py +++ b/shell/panel/VerbsPanel.py @@ -12,7 +12,7 @@ class ActivityItem(IconItem): icon_name = activity.get_icon() if not icon_name: act_type = activity.get_default_type() - raise RuntimeError("Actvity %s did not have an icon!" % act_type) + raise RuntimeError("Activity %s did not have an icon!" % act_type) IconItem.__init__(self, icon_name=icon_name, color=IconColor('white'), size=size) self._activity = activity