From f1335d9259f60a4f2d021333af7d077ab8aa43bf Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Tue, 26 Jun 2012 16:09:50 -0300
Subject: [PATCH Jukebox] 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 <humitos@gmail.com>
---
ControlToolbar.py | 20 +++++++++++---------
jukeboxactivity.py | 17 ++++++++++++-----
2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/ControlToolbar.py b/ControlToolbar.py
index 4bb4935..d3cdfed 100644
a
|
b
|
class Control(gobject.GObject): |
112 | 112 | self.next_button.connect('clicked', self.next_button_clicked_cb) |
113 | 113 | self.toolbar.insert(self.next_button, -1) |
114 | 114 | |
| 115 | current_time = gtk.ToolItem() |
| 116 | self.current_time_label = gtk.Label('') |
| 117 | current_time.add(self.current_time_label) |
| 118 | current_time.show() |
| 119 | toolbar.insert(current_time, -1) |
| 120 | |
115 | 121 | self.adjustment = gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0) |
116 | 122 | self.hscale = gtk.HScale(self.adjustment) |
117 | 123 | self.hscale.set_draw_value(False) |
… |
… |
class Control(gobject.GObject): |
126 | 132 | self.scale_item.add(self.hscale) |
127 | 133 | self.toolbar.insert(self.scale_item, -1) |
128 | 134 | |
129 | | spacer = gtk.SeparatorToolItem() |
130 | | spacer.props.draw = False |
131 | | self.toolbar.insert(spacer, -1) |
132 | | spacer.show() |
133 | | |
134 | | spacer = gtk.SeparatorToolItem() |
135 | | spacer.props.draw = False |
136 | | self.toolbar.insert(spacer, -1) |
137 | | spacer.show() |
| 135 | total_time = gtk.ToolItem() |
| 136 | self.total_time_label = gtk.Label('') |
| 137 | total_time.add(self.total_time_label) |
| 138 | total_time.show() |
| 139 | toolbar.insert(total_time, -1) |
138 | 140 | |
139 | 141 | def prev_button_clicked_cb(self, widget): |
140 | 142 | self.jukebox.songchange('prev') |
diff --git a/jukeboxactivity.py b/jukeboxactivity.py
index a16fbd1..952a998 100644
a
|
b
|
class JukeboxActivity(activity.Activity): |
124 | 124 | |
125 | 125 | self.control = Control(toolbar_box.toolbar, self) |
126 | 126 | |
127 | | separator = gtk.SeparatorToolItem() |
128 | | separator.props.draw = False |
129 | | separator.set_expand(True) |
130 | | toolbar_box.toolbar.insert(separator, -1) |
131 | | |
132 | 127 | toolbar_box.toolbar.insert(StopButton(self), -1) |
133 | 128 | |
134 | 129 | self.set_toolbar_box(toolbar_box) |
… |
… |
class JukeboxActivity(activity.Activity): |
597 | 592 | value = self.p_position * 100.0 / self.p_duration |
598 | 593 | self.control.adjustment.set_value(value) |
599 | 594 | |
| 595 | # Update the current time |
| 596 | seconds = self.p_position * 10 ** -9 |
| 597 | time = '%2d:%02d' % (int(seconds / 60), int(seconds % 60)) |
| 598 | self.control.current_time_label.set_text(time) |
| 599 | |
| 600 | # FIXME: this should be updated just once when the file starts |
| 601 | # the first time |
| 602 | if self.p_duration != gst.CLOCK_TIME_NONE: |
| 603 | seconds = self.p_duration * 10 ** -9 |
| 604 | time = '%2d:%02d' % (int(seconds / 60), int(seconds % 60)) |
| 605 | self.control.total_time_label.set_text(time) |
| 606 | |
600 | 607 | return True |
601 | 608 | |
602 | 609 | def _erase_playlist_entry_clicked_cb(self, widget): |