Thanks<div><br></div><div>Reviewed-by: Gonzalo Odiard <<a href="mailto:gonzalo@laptop.org">gonzalo@laptop.org</a>><br><br><div class="gmail_quote">On Tue, Jun 26, 2012 at 4:11 PM, Manuel Kaufmann <span dir="ltr"><<a href="mailto:humitos@gmail.com" target="_blank">humitos@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Added the current and total time of the actual stream in the toolbar<br>
and removed the separators to make them fit.<br>
<br>
Signed-off-by: Manuel Kaufmann <<a href="mailto:humitos@gmail.com">humitos@gmail.com</a>><br>
---<br>
ControlToolbar.py | 20 +++++++++++---------<br>
jukeboxactivity.py | 17 ++++++++++++-----<br>
2 files changed, 23 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/ControlToolbar.py b/ControlToolbar.py<br>
index 4bb4935..d3cdfed 100644<br>
--- a/ControlToolbar.py<br>
+++ b/ControlToolbar.py<br>
@@ -112,6 +112,12 @@ class Control(gobject.GObject):<br>
self.next_button.connect('clicked', self.next_button_clicked_cb)<br>
self.toolbar.insert(self.next_button, -1)<br>
<br>
+ current_time = gtk.ToolItem()<br>
+ self.current_time_label = gtk.Label('')<br>
+ current_time.add(self.current_time_label)<br>
+ current_time.show()<br>
+ toolbar.insert(current_time, -1)<br>
+<br>
self.adjustment = gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0)<br>
self.hscale = gtk.HScale(self.adjustment)<br>
self.hscale.set_draw_value(False)<br>
@@ -126,15 +132,11 @@ class Control(gobject.GObject):<br>
self.scale_item.add(self.hscale)<br>
self.toolbar.insert(self.scale_item, -1)<br>
<br>
- spacer = gtk.SeparatorToolItem()<br>
- spacer.props.draw = False<br>
- self.toolbar.insert(spacer, -1)<br>
- spacer.show()<br>
-<br>
- spacer = gtk.SeparatorToolItem()<br>
- spacer.props.draw = False<br>
- self.toolbar.insert(spacer, -1)<br>
- spacer.show()<br>
+ total_time = gtk.ToolItem()<br>
+ self.total_time_label = gtk.Label('')<br>
+ total_time.add(self.total_time_label)<br>
+ total_time.show()<br>
+ toolbar.insert(total_time, -1)<br>
<br>
def prev_button_clicked_cb(self, widget):<br>
self.jukebox.songchange('prev')<br>
diff --git a/jukeboxactivity.py b/jukeboxactivity.py<br>
index a16fbd1..952a998 100644<br>
--- a/jukeboxactivity.py<br>
+++ b/jukeboxactivity.py<br>
@@ -124,11 +124,6 @@ class JukeboxActivity(activity.Activity):<br>
<br>
self.control = Control(toolbar_box.toolbar, self)<br>
<br>
- separator = gtk.SeparatorToolItem()<br>
- separator.props.draw = False<br>
- separator.set_expand(True)<br>
- toolbar_box.toolbar.insert(separator, -1)<br>
-<br>
toolbar_box.toolbar.insert(StopButton(self), -1)<br>
<br>
self.set_toolbar_box(toolbar_box)<br>
@@ -597,6 +592,18 @@ class JukeboxActivity(activity.Activity):<br>
value = self.p_position * 100.0 / self.p_duration<br>
self.control.adjustment.set_value(value)<br>
<br>
+ # Update the current time<br>
+ seconds = self.p_position * 10 ** -9<br>
+ time = '%2d:%02d' % (int(seconds / 60), int(seconds % 60))<br>
+ self.control.current_time_label.set_text(time)<br>
+<br>
+ # FIXME: this should be updated just once when the file starts<br>
+ # the first time<br>
+ if self.p_duration != gst.CLOCK_TIME_NONE:<br>
+ seconds = self.p_duration * 10 ** -9<br>
+ time = '%2d:%02d' % (int(seconds / 60), int(seconds % 60))<br>
+ self.control.total_time_label.set_text(time)<br>
+<br>
return True<br>
<br>
def _erase_playlist_entry_clicked_cb(self, widget):<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.10.2<br>
<br>
_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</font></span></blockquote></div><br></div>