[Sugar-devel] [PATCH] Change toolbar to enable the use in Sugar < 0.86

godiard at sugarlabs.org godiard at sugarlabs.org
Tue Nov 2 09:07:21 EDT 2010


From: Gonzalo Odiard <godiard at sugarlabs.org>

---
 pippy_app.py |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/pippy_app.py b/pippy_app.py
index fc8aaaa..5fcdd31 100644
--- a/pippy_app.py
+++ b/pippy_app.py
@@ -45,6 +45,12 @@ PYTHON_PREFIX="""#!/usr/bin/python
 # -*- coding: utf-8 -*-
 """
 
+OLD_TOOLBAR = False
+try:
+    from sugar.graphics.toolbarbox import ToolbarBox
+except ImportError:
+    OLD_TOOLBAR = True
+
 # get screen sizes
 SIZE_X = gtk.gdk.screen_width()
 SIZE_Y = gtk.gdk.screen_height()
@@ -80,6 +86,11 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
         palette.menu.append(menu_item)
         menu_item.show()
 
+	if OLD_TOOLBAR:
+	    activity_toolbar = gtk.Toolbar()
+	    toolbox.add_toolbar('Pippy',activity_toolbar)
+	    toolbox.set_current_toolbar(1)
+
         # The "go" button
         goicon_bw = gtk.Image()
         goicon_bw.set_from_file("%s/icons/run_bw.svg" % os.getcwd())
@@ -92,7 +103,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
         gobutton.connect('clicked', self.flash_cb, dict({'bw':goicon_bw,
             'color':goicon_color}))
         gobutton.connect('clicked', self.gobutton_cb)
-        activity_toolbar.insert(gobutton, 2)
+        activity_toolbar.insert(gobutton, -1 if OLD_TOOLBAR else 2)
 
         # The "stop" button
         stopicon_bw = gtk.Image()
@@ -106,7 +117,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
             'color':stopicon_color}))
         stopbutton.connect('clicked', self.stopbutton_cb)
         stopbutton.set_tooltip("Stop Running")
-        activity_toolbar.insert(stopbutton, 3)
+        activity_toolbar.insert(stopbutton, -1 if OLD_TOOLBAR else 3)
 
         # The "clear" button
         clearicon_bw = gtk.Image()
@@ -120,12 +131,12 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
         clearbutton.connect('clicked', self.flash_cb, dict({'bw':clearicon_bw,
             'color':clearicon_color}))
         clearbutton.set_tooltip("Clear")
-        activity_toolbar.insert(clearbutton, 4)
+        activity_toolbar.insert(clearbutton, -1 if OLD_TOOLBAR else 4)
 
         # A vertical toolbar separator
         separator = gtk.SeparatorToolItem()
         separator.set_draw(True)
-        activity_toolbar.insert(separator, 5)
+        activity_toolbar.insert(separator, -1 if OLD_TOOLBAR else 5)
         activity_toolbar.show_all()
 
         self.set_toolbox(toolbox)
-- 
1.7.2.3



More information about the Sugar-devel mailing list