Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-07-31 01:27:04 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2011-07-31 22:34:07 (GMT)
commit7f3ad4e1c292b60035fd7f018fe67a737194a5af (patch)
tree6e103bed1b8d403079a9fb9819a494751a2a7a34
parentab8ab494c9e30abc7cafab485545dfb128157238 (diff)
add support for new toolbars
Added support for 0.86 toolbars.
-rw-r--r--Jam/JamMain.py69
-rw-r--r--TamTamJam.py42
2 files changed, 96 insertions, 15 deletions
diff --git a/Jam/JamMain.py b/Jam/JamMain.py
index 2798d4c..599d483 100644
--- a/Jam/JamMain.py
+++ b/Jam/JamMain.py
@@ -200,15 +200,60 @@ class JamMain(gtk.EventBox):
self.prepareKeyImage( key )
#-- Toolbars ------------------------------------------
- self.jamToolbar = JamToolbar( self )
- self.activity.toolbox.add_toolbar( _("Jam"), self.jamToolbar )
- self.playbackToolbar = PlaybackToolbar( self )
- self.activity.toolbox.add_toolbar( _("Playback"), self.playbackToolbar )
- self.desktopToolbar = DesktopToolbar( self )
- self.activity.toolbox.add_toolbar( _("Desktop"), self.desktopToolbar )
- if Config.FEATURES_MIC or Config.FEATURES_NEWSOUNDS:
- self.recordToolbar = RecordToolbar( self )
- self.activity.toolbox.add_toolbar( _("Record"), self.recordToolbar )
+ if self.activity.have_toolbox:
+ from sugar.graphics.toolbarbox import ToolbarButton
+
+ self.jamToolbar = JamToolbar(self)
+ jam_toolbar_button = ToolbarButton(label=_('Jam'),
+ page=self.jamToolbar,
+ icon_name='voltemp')
+ self.jamToolbar.show()
+ jam_toolbar_button.show()
+ self.activity.toolbox.toolbar.insert(jam_toolbar_button, -1)
+
+ self.playbackToolbar = PlaybackToolbar(self)
+ playback_toolbar_button = ToolbarButton(label=_('Playback'),
+ page=self.playbackToolbar,
+ # Fixme: need an icon
+ icon_name='activity-start')
+ self.playbackToolbar.show()
+ playback_toolbar_button.show()
+ self.activity.toolbox.toolbar.insert(playback_toolbar_button, -1)
+
+ self.desktopToolbar = DesktopToolbar(self)
+ desktop_toolbar_button = ToolbarButton(label=_('Desktop'),
+ page=self.desktopToolbar,
+ icon_name='text-x-generic')
+ self.desktopToolbar.show()
+ desktop_toolbar_button.show()
+ self.activity.toolbox.toolbar.insert(desktop_toolbar_button, -1)
+
+ if Config.FEATURES_MIC or Config.FEATURES_NEWSOUNDS:
+ self.recordToolbar = RecordToolbar(self)
+ record_toolbar_button = ToolbarButton(label=_('Record'),
+ page=self.recordToolbar,
+ icon_name='microphone')
+ self.recordToolbar.show()
+ record_toolbar_button.show()
+ self.activity.toolbox.toolbar.insert(record_toolbar_button, -1)
+
+ self.activity.add_stop_button()
+ else:
+ self.jamToolbar = JamToolbar(self)
+ self.activity.toolbox.add_toolbar(_("Jam"), self.jamToolbar)
+
+ self.playbackToolbar = PlaybackToolbar(self)
+ self.activity.toolbox.add_toolbar(_("Playback"),
+ self.playbackToolbar)
+
+ self.desktopToolbar = DesktopToolbar(self)
+ self.activity.toolbox.add_toolbar(_("Desktop"),
+ self.desktopToolbar)
+
+ if Config.FEATURES_MIC or Config.FEATURES_NEWSOUNDS:
+ self.recordToolbar = RecordToolbar(self)
+ self.activity.toolbox.add_toolbar(_("Record"),
+ self.recordToolbar)
#-- GUI -----------------------------------------------
if True: # GUI
@@ -336,7 +381,11 @@ class JamMain(gtk.EventBox):
#-- Final Set Up --------------------------------------
self.setVolume( self.volume )
self.setTempo( self.tempo )
- self.activity.toolbox.set_current_toolbar(1) # JamToolbar
+ if self.activity.have_toolbox:
+ # jam_toolbar_button.set_expanded(True)
+ pass
+ else:
+ self.activity.toolbox.set_current_toolbar(1) # JamToolbar
self.setDesktop( 0, True )
diff --git a/TamTamJam.py b/TamTamJam.py
index e8766db..be2443e 100644
--- a/TamTamJam.py
+++ b/TamTamJam.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 TamTamJam(activity.Activity):
@@ -72,12 +81,22 @@ class TamTamJam(activity.Activity):
self.connect('destroy', self.onDestroy)
#load the sugar toolbar
- toolbox = activity.ActivityToolbox(self)
- self.set_toolbox(toolbox)
-
- self.activity_toolbar = toolbox.get_activity_toolbar()
+ self.have_toolbox = HAVE_TOOLBOX
+ if HAVE_TOOLBOX:
+ self.toolbox = ToolbarBox()
+ activity_button = ActivityToolbarButton(self)
+ self.toolbox.toolbar.insert(activity_button, 0)
+ activity_button.show()
+ separator = gtk.SeparatorToolItem()
+ separator.props.draw = True
+ separator.set_expand(False)
+ self.toolbox.toolbar.insert(separator, -1)
+ separator.show()
+ else:
+ self.toolbox = activity.ActivityToolbox(self)
+ self.set_toolbox(self.toolbox)
- toolbox.show()
+ self.toolbox.show()
self.trackpad.setContext('jam')
self.jam = JamMain(self)
@@ -150,3 +169,16 @@ class TamTamJam(activity.Activity):
def write_file(self, file_path):
self.jam.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()