Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TamTamEdit.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-07-31 21:20:08 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2011-08-01 00:14:04 (GMT)
commit61ad74a016423a977f82648d9ff5e5fa72bd4dac (patch)
tree4590b95f35930045de6d8a17f1b00ed3e271e0ff /TamTamEdit.py
parenta01ad4582bb9afa30865190f3b5567419f09f022 (diff)
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.
Diffstat (limited to 'TamTamEdit.py')
-rw-r--r--TamTamEdit.py44
1 files changed, 39 insertions, 5 deletions
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 = '<Ctrl>q'
+ self.toolbox.toolbar.insert(stop_button, -1)
+ stop_button.show()