Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2013-05-31 19:31:29 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-06-03 19:50:22 (GMT)
commit6e5262af1039d658625473bb6303a14077c168cb (patch)
treef494bd8f2e2babcab8cc822e8da7aa3a2b855c6f
parent7b79f07a32711908826089b3abbf057d0cff349f (diff)
Rearrange toolbars in Portrait mode
Signed-off-by: Walter Bender <walter@sugarlabs.org> Reviewed-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--activity.py48
-rw-r--r--controls.py55
2 files changed, 83 insertions, 20 deletions
diff --git a/activity.py b/activity.py
index d4bf2ff..a450898 100644
--- a/activity.py
+++ b/activity.py
@@ -71,10 +71,10 @@ class JukeboxActivity(activity.Activity):
self.set_title(_('Jukebox Activity'))
self.max_participants = 1
- toolbar_box = ToolbarBox()
+ self._toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
activity_toolbar = activity_button.page
- toolbar_box.toolbar.insert(activity_button, 0)
+ self._toolbar_box.toolbar.insert(activity_button, 0)
self.title_entry = activity_toolbar.title
self._view_toolbar = ViewToolbar()
@@ -86,11 +86,19 @@ class JukeboxActivity(activity.Activity):
page=self._view_toolbar,
icon_name='toolbar-view')
self._view_toolbar.show()
- toolbar_box.toolbar.insert(view_toolbar_button, -1)
+ self._toolbar_box.toolbar.insert(view_toolbar_button, -1)
view_toolbar_button.show()
- self.set_toolbar_box(toolbar_box)
- toolbar_box.show_all()
+ self._control_toolbar = Gtk.Toolbar()
+ self._control_toolbar_button = ToolbarButton(
+ page=self._control_toolbar,
+ icon_name='media-playback-start')
+ self._control_toolbar.show()
+ self._toolbar_box.toolbar.insert(self._control_toolbar_button, -1)
+ self._control_toolbar_button.hide()
+
+ self.set_toolbar_box(self._toolbar_box)
+ self._toolbar_box.show_all()
self.connect('key_press_event', self.__key_press_event_cb)
self.connect('playlist-finished', self.__playlist_finished_cb)
@@ -118,9 +126,17 @@ class JukeboxActivity(activity.Activity):
self.player.connect('error', self.__player_error_cb)
self.player.connect('play', self.__player_play_cb)
- self.control = Controls(self, toolbar_box.toolbar)
+ self.control = Controls(self, self._toolbar_box.toolbar,
+ self._control_toolbar)
+
+ self._separator = Gtk.SeparatorToolItem()
+ self._separator.props.draw = False
+ self._separator.set_expand(True)
+ self._separator.show()
+ self._toolbar_box.toolbar.insert(self._separator, -1)
- toolbar_box.toolbar.insert(StopButton(self), -1)
+ self._stop = StopButton(self)
+ self._toolbar_box.toolbar.insert(self._stop, -1)
self._empty_widget = Gtk.Label(label="")
self._empty_widget.show()
@@ -129,6 +145,8 @@ class JukeboxActivity(activity.Activity):
self._init_view_area()
self.show_all()
+ self._configure_cb()
+
self.player.init_view_area(self.videowidget)
self._volume_monitor = Gio.VolumeMonitor.get()
@@ -145,6 +163,22 @@ class JukeboxActivity(activity.Activity):
self.control.check_if_next_prev()
+ Gdk.Screen.get_default().connect('size-changed', self._configure_cb)
+
+ def _configure_cb(self, event=None):
+ self._toolbar_box.toolbar.remove(self._stop)
+ self._toolbar_box.toolbar.remove(self._separator)
+ if Gdk.Screen.width() < Gdk.Screen.height():
+ self._control_toolbar_button.show()
+ self._control_toolbar_button.set_expanded(True)
+ self.control.update_layout(landscape=False)
+ self._toolbar_box.toolbar.insert(self._separator, -1)
+ else:
+ self._control_toolbar_button.set_expanded(False)
+ self._control_toolbar_button.hide()
+ self.control.update_layout(landscape=True)
+ self._toolbar_box.toolbar.insert(self._stop, -1)
+
def __notify_active_cb(self, widget, event):
"""Sugar notify us that the activity is becoming active or inactive.
When we are inactive, we stop the player if it is reproducing
diff --git a/controls.py b/controls.py
index cde298c..f88e2a9 100644
--- a/controls.py
+++ b/controls.py
@@ -36,11 +36,12 @@ class Controls(GObject.GObject):
SCALE_DURATION_TEXT = 100
RESEEK_TIMEOUT = 250 # ms
- def __init__(self, activity, toolbar):
+ def __init__(self, activity, main_toolbar, secondary_toolbar):
GObject.GObject.__init__(self)
self.activity = activity
- self.toolbar = toolbar
+ self.toolbar = main_toolbar
+ self.secondary_toolbar = secondary_toolbar
self._scale_update_id = -1
self._scale_value_changed_id = -1
@@ -58,9 +59,11 @@ class Controls(GObject.GObject):
self.__erase_playlist_entry_clicked_cb)
self.toolbar.insert(erase_playlist_entry_btn, -1)
- spacer = Gtk.SeparatorToolItem()
- self.toolbar.insert(spacer, -1)
- spacer.show()
+ self._spacer = Gtk.SeparatorToolItem()
+ self._spacer.props.draw = True
+ self._spacer.set_expand(False)
+ self.toolbar.insert(self._spacer, -1)
+ self._spacer.show()
self.prev_button = ToolButton('player_rew')
self.prev_button.set_tooltip(_('Previous'))
@@ -89,11 +92,11 @@ class Controls(GObject.GObject):
self.next_button.connect('clicked', self.__next_button_clicked_cb)
self.toolbar.insert(self.next_button, -1)
- current_time = Gtk.ToolItem()
+ self._current_time = Gtk.ToolItem()
self.current_time_label = Gtk.Label(label='')
- current_time.add(self.current_time_label)
- current_time.show()
- self.toolbar.insert(current_time, -1)
+ self._current_time.add(self.current_time_label)
+ self._current_time.show()
+ self.toolbar.insert(self._current_time, -1)
self.adjustment = Gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0)
self.hscale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
@@ -113,15 +116,41 @@ class Controls(GObject.GObject):
self.scale_item.add(self.hscale)
self.toolbar.insert(self.scale_item, -1)
- total_time = Gtk.ToolItem()
+ self._total_time = Gtk.ToolItem()
self.total_time_label = Gtk.Label(label='')
- total_time.add(self.total_time_label)
- total_time.show()
- self.toolbar.insert(total_time, -1)
+ self._total_time.add(self.total_time_label)
+ self._total_time.show()
+ self.toolbar.insert(self._total_time, -1)
self.activity.connect('playlist-finished', self.__playlist_finished_cb)
self.activity.player.connect('play', self.__player_play)
+ def update_layout(self, landscape=True):
+ if landscape:
+ self._remove_controls(self.secondary_toolbar)
+ self._add_controls(self.toolbar)
+ else:
+ self._remove_controls(self.toolbar)
+ self._add_controls(self.secondary_toolbar)
+ self._spacer.hide()
+
+ def _remove_controls(self, toolbar):
+ for control in [self._spacer, self.prev_button,
+ self.button, self.next_button,
+ self._current_time, self.scale_item,
+ self._total_time]:
+ if control in toolbar:
+ toolbar.remove(control)
+
+ def _add_controls(self, toolbar):
+ for control in [self._spacer, self.prev_button,
+ self.button, self.next_button,
+ self._current_time, self.scale_item,
+ self._total_time]:
+ if not control in toolbar:
+ toolbar.insert(control, -1)
+ control.show()
+
def __player_play(self, widget):
if self._scale_update_id == -1:
self._scale_update_id = GObject.timeout_add(