[Sugar-devel] [PATCH Maze] Maze icon in the toolbar SL #3380

Manuel Kaufmann humitos at gmail.com
Tue May 8 11:04:06 EDT 2012


 - Show the Maze icon in the toolbar.

 - Don't use olpcgames.PygameActivity.build_toolbar anymore because it
   doesn't do what we need. Used our own build_toolbar method instead.

Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
---
 activity.py |   42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/activity.py b/activity.py
index 46a942c..4afbf56 100755
--- a/activity.py
+++ b/activity.py
@@ -4,6 +4,9 @@ import olpcgames
 import pygame
 import gtk
 
+from sugar.activity.widgets import ActivityToolbarButton
+from sugar.activity.widgets import StopButton
+from sugar.graphics.toolbarbox import ToolbarBox
 from sugar.graphics.toolbutton import ToolButton
 from gettext import gettext as _
 
@@ -15,26 +18,41 @@ class MazeActivity(olpcgames.PyGameActivity):
 
     def build_toolbar(self):
         """Build our Activity toolbar for the Sugar system."""
-        toolbar = super(MazeActivity, self).build_toolbar()
+
+        toolbar_box = ToolbarBox()
+        activity_button = ActivityToolbarButton(self)
+        toolbar_box.toolbar.insert(activity_button, 0)
+        activity_button.show()
 
         separator = gtk.SeparatorToolItem()
-        separator.set_expand(True)
-        separator.set_draw(False)
-        toolbar.insert(separator, 0)
+        toolbar_box.toolbar.insert(separator, -1)
+        separator.show()
+
+        easier_button = ToolButton('create-easier')
+        easier_button.set_tooltip(_('Easier level'))
+        easier_button.connect('clicked', self._easier_button_cb)
+        toolbar_box.toolbar.insert(easier_button, -1)
 
         harder_button = ToolButton('create-harder')
         harder_button.set_tooltip(_('Harder level'))
         harder_button.connect('clicked', self._harder_button_cb)
-        toolbar.insert(harder_button, 2)
-        harder_button.show()
+        toolbar_box.toolbar.insert(harder_button, -1)
 
-        easier_button = ToolButton('create-easier')
-        easier_button.set_tooltip(_('Easier level'))
-        easier_button.connect('clicked', self._easier_button_cb)
-        toolbar.insert(easier_button, 2)
-        easier_button.show()
+        separator = gtk.SeparatorToolItem()
+        separator.props.draw = False
+        separator.set_size_request(0, -1)
+        separator.set_expand(True)
+        toolbar_box.toolbar.insert(separator, -1)
+        separator.show()
+
+        stop_button = StopButton(self)
+        toolbar_box.toolbar.insert(stop_button, -1)
+        stop_button.show()
+
+        self.set_toolbar_box(toolbar_box)
+        toolbar_box.show_all()
 
-        return toolbar
+        return toolbar_box
 
     def _easier_button_cb(self, button):
         pygame.event.post(olpcgames.eventwrap.Event(
-- 
1.7.10



More information about the Sugar-devel mailing list