From 61ad74a016423a977f82648d9ff5e5fa72bd4dac Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sun, 31 Jul 2011 21:20:08 +0000 Subject: add support for new toolbars to Edit Support for new toolbars. Straightforrward replication of the old-style toolbars. But in a separate patch, I will move the playback buttons to the main toolbar. --- (limited to 'TamTamEdit.py') diff --git a/TamTamEdit.py b/TamTamEdit.py index 13e7dc0..0a5c913 100644 --- a/TamTamEdit.py +++ b/TamTamEdit.py @@ -42,6 +42,15 @@ from common.Util.Trackpad import Trackpad from gettext import gettext as _ import commands from sugar.activity import activity +try: + from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton + HAVE_TOOLBOX = True +except ImportError: + HAVE_TOOLBOX = False + +if HAVE_TOOLBOX: + from sugar.activity.widgets import ActivityToolbarButton + from sugar.activity.widgets import StopButton class TamTamEdit(activity.Activity): @@ -66,12 +75,23 @@ class TamTamEdit(activity.Activity): self.connect('destroy', self.onDestroy) #load the sugar toolbar - toolbox = activity.ActivityToolbox(self) - self.set_toolbox(toolbox) + #load the sugar toolbar + self.have_toolbox = HAVE_TOOLBOX + if self.have_toolbox: + # no sharing + self.max_participants = 1 + + self.toolbox = ToolbarBox() + activity_button = ActivityToolbarButton(self) + self.toolbox.toolbar.insert(activity_button, 0) + activity_button.show() + else: + self.toolbox = activity.ActivityToolbox(self) + self.set_toolbox(self.toolbox) - self.activity_toolbar = toolbox.get_activity_toolbar() + self.activity_toolbar = self.toolbox.get_activity_toolbar() - toolbox.show() + self.toolbox.show() self.trackpad.setContext('edit') self.edit = MainWindow(self) @@ -84,7 +104,8 @@ class TamTamEdit(activity.Activity): self.edit.onActivate(arg=None) self.show() - self.activity_toolbar.share.hide() + if not self.have_toolbox: + self.activity_toolbar.share.hide() def onPreloadTimeout(self): if Config.DEBUG > 4: @@ -145,3 +166,16 @@ class TamTamEdit(activity.Activity): def write_file(self, file_path): self.edit.handleJournalSave(file_path) + + def add_stop_button(self): + ''' Add a stop button if using the new toolbars ''' + if self.have_toolbox: + separator = gtk.SeparatorToolItem() + separator.props.draw = False + separator.set_expand(True) + self.toolbox.toolbar.insert(separator, -1) + separator.show() + stop_button = StopButton(self) + stop_button.props.accelerator = 'q' + self.toolbox.toolbar.insert(stop_button, -1) + stop_button.show() -- cgit v0.9.1