[Sugar-devel] [PATCH Jukebox] Current and total time SL #3714

Gonzalo Odiard gonzalo at laptop.org
Wed Jun 27 11:08:43 EDT 2012


Thanks

Reviewed-by: Gonzalo Odiard <gonzalo at laptop.org>

On Tue, Jun 26, 2012 at 4:11 PM, Manuel Kaufmann <humitos at gmail.com> wrote:

> 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 at 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/ControlToolbar.py
> +++ b/ControlToolbar.py
> @@ -112,6 +112,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)
> @@ -126,15 +132,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):
> --
> 1.7.10.2
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120627/713564bd/attachment.html>


More information about the Sugar-devel mailing list