Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian <icarito@sugarlabs.org>2011-03-17 02:16:50 (GMT)
committer Sebastian <icarito@sugarlabs.org>2011-03-17 02:16:50 (GMT)
commite073c407cd93132f387ca1e86a401d90b2dc6ad7 (patch)
tree012a47f8b6126f657a2e0aa660b018a1351908f4
parentdc78e36c678e8cf485ff9de8462d937e59f4de34 (diff)
Updated toolbars.
-rw-r--r--ControlToolbar.py38
-rw-r--r--jukeboxactivity.py68
-rw-r--r--mybutton.py53
3 files changed, 129 insertions, 30 deletions
diff --git a/ControlToolbar.py b/ControlToolbar.py
index b9b80e1..d41406b 100644
--- a/ControlToolbar.py
+++ b/ControlToolbar.py
@@ -46,13 +46,10 @@ class ControlToolbar(gtk.Toolbar):
self.open_button = gtk.ToolButton(gtk.STOCK_FILE)
self.open_button.show()
self.open_button.connect('clicked', jukebox.open_button_clicked_cb)
- self.insert(self.open_button, -1)
self.prev_button = gtk.ToolButton(gtk.STOCK_MEDIA_PREVIOUS)
self.prev_button.show()
self.prev_button.connect('clicked', self.prev_button_clicked_cb)
- self.insert(self.prev_button, -1)
-
self.pause_image = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PAUSE,
gtk.ICON_SIZE_BUTTON)
@@ -67,14 +64,17 @@ class ControlToolbar(gtk.Toolbar):
self.button.show()
self.button.connect('clicked', self._button_clicked_cb)
- self.insert(self.button, -1)
-
self.next_button = gtk.ToolButton(gtk.STOCK_MEDIA_NEXT)
self.next_button.show()
self.next_button.connect('clicked', self.next_button_clicked_cb)
- self.insert(self.next_button, -1)
-
+ self.ctl_group = gtk.HBox()
+ self.ctl_group.pack_start(self.open_button, expand=False, fill=False)
+ self.ctl_group.pack_start(self.prev_button, expand=False, fill=False)
+ self.ctl_group.pack_start(self.button, expand=False, fill=False)
+ self.ctl_group.pack_end(self.next_button, expand=False,fill=False)
+
+ self.adj_group = gtk.HBox()
self.adjustment = gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0)
self.hscale = gtk.HScale(self.adjustment)
self.hscale.set_draw_value(False)
@@ -85,11 +85,13 @@ class ControlToolbar(gtk.Toolbar):
self.scale_item = gtk.ToolItem()
self.scale_item.set_expand(True)
self.scale_item.add(self.hscale)
- self.insert(self.scale_item, -1)
+ #self.insert(self.scale_item, -1)
+ self.adj_group.pack_start(self.scale_item, expand=True, fill=True)
spacer = gtk.SeparatorToolItem()
spacer.props.draw = False
- self.insert(spacer, -1)
+ self.adj_group.pack_start(spacer, expand=False, fill=False)
+ #self.insert(spacer, -1)
spacer.show()
self.audioscale = gtk.VolumeButton()
@@ -99,18 +101,30 @@ class ControlToolbar(gtk.Toolbar):
self.audio_scale_item = gtk.ToolItem()
self.audio_scale_item.set_expand(False)
self.audio_scale_item.add(self.audioscale)
- self.insert(self.audio_scale_item, -1)
+ #self.insert(self.audio_scale_item, -1)
+ self.adj_group.pack_start(self.audio_scale_item, expand=False, fill=False)
spacer = gtk.SeparatorToolItem()
spacer.props.draw = False
- self.insert(spacer, -1)
+ #self.insert(spacer, -1)
+ self.adj_group.pack_start(spacer, expand=False, fill=False)
spacer.show()
+
self._fullscreen = ToolButton('view-fullscreen')
self._fullscreen.set_tooltip(_('Fullscreen'))
self._fullscreen.connect('clicked', self._fullscreen_cb)
- self.insert(self._fullscreen, -1)
+ #self.insert(self._fullscreen, -1)
+ self.adj_group.pack_start(self._fullscreen, expand=False, fill=False)
self._fullscreen.show()
+ self.bigbox = gtk.HBox()
+ self.bigbox.pack_start(self.ctl_group, expand=False, fill=False)
+ self.bigbox.pack_end(self.adj_group, expand=True)
+ toolitem = gtk.ToolItem()
+ toolitem.set_expand(True)
+ toolitem.add(self.bigbox)
+ self.insert(toolitem, -1)
+
def prev_button_clicked_cb(self,widget):
self.jukebox.songchange('prev')
diff --git a/jukeboxactivity.py b/jukeboxactivity.py
index fc20f2b..738caea 100644
--- a/jukeboxactivity.py
+++ b/jukeboxactivity.py
@@ -57,24 +57,57 @@ class JukeboxActivity(activity.Activity):
self._object_id = handle.object_id
self.set_title(_('Jukebox Activity'))
self.player = None
+ # we do not have collaboration features
+ # make the share option insensitive
+ self.max_participants = 1
- toolbox = activity.ActivityToolbox(self)
- self.set_toolbox(toolbox)
-
- self.toolbar = toolbar = ControlToolbar(toolbox, self)
- toolbox.add_toolbar(_('Play'), toolbar)
-
- toolbar.show()
- toolbox.show()
- self.toolbar.connect('go-fullscreen', self.__go_fullscreen_cb)
-
- self.toolbar.grab_focus()
- #self.connect("shared", self._shared_cb)
- activity_toolbar = toolbox.get_activity_toolbar()
- activity_toolbar.remove(activity_toolbar.share)
- activity_toolbar.share = None
- activity_toolbar.remove(activity_toolbar.keep)
- activity_toolbar.keep = None
+ try:
+ from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
+ from sugar.activity.widgets import ActivityToolbarButton, StopButton, \
+ ShareButton, KeepButton
+ from mybutton import MyActivityToolbarButton
+
+ toolbar_box = ToolbarBox()
+ activity_button = MyActivityToolbarButton(self)
+ toolbar_box.toolbar.insert(activity_button, 0)
+ activity_button.show()
+
+ self.toolbar = toolbar = ControlToolbar(toolbar_box, self)
+ toolitem = gtk.ToolItem()
+ self.toolbar.bigbox.reparent(toolitem)
+ toolbar_box.toolbar.insert(toolitem, -1)
+ self.toolbar.bigbox.show()
+ toolitem.set_expand(True)
+ toolitem.show()
+
+ stop_button = StopButton(self)
+ stop_button.props.accelerator = '<Ctrl><Shift>Q'
+ toolbar_box.toolbar.insert(stop_button, -1)
+ stop_button.show()
+
+ toolbar_box.connect("key_press_event", self._key_press_event_cb)
+ self.set_toolbar_box(toolbar_box)
+ toolbar_box.show()
+ except ImportError:
+ toolbox = activity.ActivityToolbox(self)
+ self.set_toolbox(toolbox)
+
+ self.toolbar = toolbar = ControlToolbar(toolbox, self)
+ toolbox.add_toolbar(_('Play'), toolbar)
+
+ toolbar.show()
+ toolbox.show()
+ self.toolbar.connect('go-fullscreen', self.__go_fullscreen_cb)
+
+ self.toolbar.grab_focus()
+ #self.connect("shared", self._shared_cb)
+ activity_toolbar = toolbox.get_activity_toolbar()
+ activity_toolbar.remove(activity_toolbar.share)
+ activity_toolbar.share = None
+ activity_toolbar.remove(activity_toolbar.keep)
+ activity_toolbar.keep = None
+
+ self.toolbox.connect("key_press_event", self._key_press_event_cb)
if handle.uri:
pass
@@ -117,7 +150,6 @@ class JukeboxActivity(activity.Activity):
self.uri = handle.uri
gobject.idle_add(self._start, self.uri)
- self.toolbox.connect("key_press_event", self._key_press_event_cb)
def open_button_clicked_cb(self, widget):
""" To open the dialog to select a new file"""
diff --git a/mybutton.py b/mybutton.py
new file mode 100644
index 0000000..b1f1f84
--- /dev/null
+++ b/mybutton.py
@@ -0,0 +1,53 @@
+# mybutton.py A version of ActivityToolbarButton that hides the "Keep"
+# button.
+
+# Copyright (C) 2010 James D. Simmons
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
+import gtk
+import gconf
+
+from sugar.graphics.toolbarbox import ToolbarButton
+from sugar.activity.widgets import ActivityToolbar
+from sugar.graphics.xocolor import XoColor
+from sugar.graphics.icon import Icon
+from sugar.bundle.activitybundle import ActivityBundle
+
+def _create_activity_icon(metadata):
+ if metadata.get('icon-color', ''):
+ color = XoColor(metadata['icon-color'])
+ else:
+ client = gconf.client_get_default()
+ color = XoColor(client.get_string('/desktop/sugar/user/color'))
+
+ from sugar.activity.activity import get_bundle_path
+ bundle = ActivityBundle(get_bundle_path())
+ icon = Icon(file=bundle.get_icon(), xo_color=color)
+
+ return icon
+
+class MyActivityToolbarButton(ToolbarButton):
+
+ def __init__(self, activity, **kwargs):
+ toolbar = ActivityToolbar(activity, orientation_left=True)
+ toolbar.stop.hide()
+ toolbar.keep.hide()
+ toolbar.title.unset_flags(gtk.CAN_FOCUS)
+
+ ToolbarButton.__init__(self, page=toolbar, **kwargs)
+
+ icon = _create_activity_icon(activity.metadata)
+ self.set_icon_widget(icon)
+ icon.show()