[Sugar-devel] [PATCH] Fix toolbar items layout

Daniel Francis francis at sugarlabs.org
Tue Oct 15 10:23:00 EDT 2013


Most of the new code is copied from chat activity.

Signed-off-by: Daniel Francis <francis at sugarlabs.org>
Signed-off-by: Franco Correa <franco at francocorrea.com.uy>
Signed-off-by: Ezequiel Pereira <eze2307 at gmail.com>
---
 LevelActivity.py | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/LevelActivity.py b/LevelActivity.py
index ca5a19d..e8733cc 100644
--- a/LevelActivity.py
+++ b/LevelActivity.py
@@ -17,13 +17,20 @@
 
 from gi.repository import Gtk
 from gi.repository import GObject
-from sugar3.activity import widgets
 from sugar3.activity.widgets import StopButton
 from sugar3.activity import activity
 from math import pi, sqrt
 from gettext import gettext as _
 from collections import deque
 
+import logging
+logger = logging.getLogger('level-tool')
+
+from sugar3.graphics.toolbarbox import ToolbarBox
+from sugar3.activity.widgets import ActivityButton
+from sugar3.activity.widgets import TitleEntry
+from sugar3.activity.widgets import StopButton
+
 ACCELEROMETER_DEVICE = '/sys/devices/platform/lis3lv02d/position'
 #ACCELEROMETER_DEVICE = 'a.txt'
 
@@ -165,20 +172,35 @@ class MyCanvas(Gtk.DrawingArea):
 
         self.queue_draw()
 
+
+
 class LevelActivity(activity.Activity):
     def __init__(self, handle):
         "The entry point to the Activity"
         activity.Activity.__init__(self, handle)
 
-        toolbox = widgets.ActivityToolbar(self)
-        toolbox.share.props.visible = False
-
-        stop_button = StopButton(self)
-        stop_button.show()
-        toolbox.insert(stop_button, -1)
+        toolbar_box = ToolbarBox()
 
-        self.set_toolbar_box(toolbox)
-        toolbox.show()
+        toolbar_box.toolbar.insert(ActivityButton(self), -1)
+        toolbar_box.toolbar.insert(TitleEntry(self), -1)
+        try:
+            from sugar3.activity.widgets import DescriptionItem
+        except ImportError:
+            logger.debug('DescriptionItem button is not available, ' \
+                    'toolkit version < 0.96')
+        else:
+            description_item = DescriptionItem(self)
+            toolbar_box.toolbar.insert(description_item, -1)
+            description_item.show()
+        separator = Gtk.SeparatorToolItem()
+        separator.props.draw = False
+        separator.set_expand(True)
+        toolbar_box.toolbar.insert(separator, -1)
+
+        toolbar_box.toolbar.insert(StopButton(self), -1)
+        toolbar_box.show_all()
+        self.set_toolbar_box(toolbar_box)
+        toolbar_box.show()
 
         # Draw the canvas
         self._canvas = MyCanvas()
-- 
1.8.1.4



More information about the Sugar-devel mailing list