From 7e53019d6433f7ed857480baba7d54e41d82fce8 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 26 Jun 2012 19:11:24 +0000 Subject: Current and total time SL #3714 Added the current and total time of the actual stream in the toolbar and removed the separators to make them fit. Signed-off-by: Manuel Kaufmann Reviewed-by: Gonzalo Odiard --- diff --git a/ControlToolbar.py b/ControlToolbar.py index 4ddb137..87a9b50 100644 --- a/ControlToolbar.py +++ b/ControlToolbar.py @@ -111,6 +111,12 @@ class Control(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_label = gtk.Label('') + current_time.add(self.current_time_label) + current_time.show() + toolbar.insert(current_time, -1) + 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) @@ -125,15 +131,11 @@ class Control(gobject.GObject): self.scale_item.add(self.hscale) self.toolbar.insert(self.scale_item, -1) - spacer = gtk.SeparatorToolItem() - spacer.props.draw = False - self.toolbar.insert(spacer, -1) - spacer.show() - - spacer = gtk.SeparatorToolItem() - spacer.props.draw = False - self.toolbar.insert(spacer, -1) - spacer.show() + total_time = gtk.ToolItem() + self.total_time_label = gtk.Label('') + total_time.add(self.total_time_label) + total_time.show() + toolbar.insert(total_time, -1) def prev_button_clicked_cb(self, widget): self.jukebox.songchange('prev') diff --git a/jukeboxactivity.py b/jukeboxactivity.py index a16fbd1..952a998 100644 --- a/jukeboxactivity.py +++ b/jukeboxactivity.py @@ -124,11 +124,6 @@ class JukeboxActivity(activity.Activity): self.control = Control(toolbar_box.toolbar, self) - separator = gtk.SeparatorToolItem() - separator.props.draw = False - separator.set_expand(True) - toolbar_box.toolbar.insert(separator, -1) - toolbar_box.toolbar.insert(StopButton(self), -1) self.set_toolbar_box(toolbar_box) @@ -597,6 +592,18 @@ class JukeboxActivity(activity.Activity): value = self.p_position * 100.0 / self.p_duration self.control.adjustment.set_value(value) + # Update the current time + seconds = self.p_position * 10 ** -9 + time = '%2d:%02d' % (int(seconds / 60), int(seconds % 60)) + self.control.current_time_label.set_text(time) + + # FIXME: this should be updated just once when the file starts + # the first time + if self.p_duration != gst.CLOCK_TIME_NONE: + seconds = self.p_duration * 10 ** -9 + time = '%2d:%02d' % (int(seconds / 60), int(seconds % 60)) + self.control.total_time_label.set_text(time) + return True def _erase_playlist_entry_clicked_cb(self, widget): -- cgit v0.9.1