GNOME Bugzilla – Bug 163345
Playback time should optional count down rather than up
Last modified: 2013-03-18 07:31:26 UTC
This bug has been opened here: http://bugs.debian.org/269901 "When I'm playing a song, the main window says in the bottom left corner: Spelar | 1:42 / 4:12 This is with a Swedish locale, so "Spelar" is probably "Playing" in English. Anyway, the left time counts up until it reaches the right time. I'd like to be able to get it to count down from the right time towards zero. I've tried right-clicking the time but I didn't get a context menu for this. I also looked through the preferences without finding anything relevant-looking. Regards //Johan"
what about just being able to change the counting (down/up) by just single-clicking it ? Though not as a real 'button'.
If that was the only way to toggle the counter's direction, nobody would ever find it. I don't have anything against having that *in addition to* a more obvious UI (like a preferences item or a right-click menu) though.
Confirming the enhancement request. As I see it, the most obvious thing would be a preference setting that does this.
Created attachment 80100 [details] [review] First go I already know I have to revise a few things. I just need a little direction what I should change.
Created attachment 80337 [details] [review] Playback countdown patch I've added a preference option. The playback time now will go backwards and forwards.
I don't think this needs a preference option, or needs to be saved. Simply make it so that, when clicked, the statusbar time label counts down rather than up.
Created attachment 80351 [details] [review] click status label or full screen time label to switch playback time I've removed the preference and saving it. If you click on the status bar or full screen it will switch the time from count up to down or count down to up.
If this isn't saved I'd request for it to default to counting down rather than up. Saving the setting might be better though, since some people might prefer counting up.
> label->label = gtk_label_new (time); That should be cast to GtkLabel before assignment, using GTK_LABEL (...). > gtk_container_add (GTK_CONTAINER (box), label->label); The second argument should be cast to GtkWidget. I also get the following warning when compiling, which should be fixed: totem-time-label.c: At top level: totem-time-label.c:79: warning: ‘totem_time_label_on_press’ was used with no prototype before its definition
Created attachment 103054 [details] [review] Fixes the bug, so the time optionally can count down. I have some problems running totem_statusbar_update_time. I wonder if the g_signal_connect should be put in another file (totem.c?).
Created attachment 103062 [details] [review] Makes countdown available This patch has functionality in fullscreen too. Same problems as before, has to wait for next tick before it switches.
> + //totem_statusbar_update_time( statusbar ); I can't get this to work, "statusbar" points to the wrong memory address. Your function gets: > +static void totem_statusbar_toggle_time ( GtkWidget *widget, TotemStatusbar *statusbar) The prototype for button-press-event signals is: gboolean user_function (GtkWidget *widget, GdkEventButton *event, gpointer user_data) Your statusbar is pointing to a GdkEventButton event.
Created attachment 103137 [details] [review] Fixed problems i had with previous patches Now I've fixed the problems i had earlier. Now the time updates when you click on the label and i moved the boolean variables to the header files.
Comment on attachment 103137 [details] [review] Fixed problems i had with previous patches There's seems to be no code to make sure the time labels are in the same mode in fullscreen and in the windowed mode. > static void > totem_statusbar_update_time (TotemStatusbar *statusbar) > { >- char *time, *length, *label; >+ char *time, *length, *remaining, *label; > > time = totem_time_to_string (statusbar->time * 1000); > >@@ -129,15 +136,20 @@ > } else { > length = totem_time_to_string > (statusbar->length == -1 ? 0 : statusbar->length * 1000); >- >+ remaining = totem_time_to_string >+ (statusbar->length == -1 ? 0 : (statusbar->length - statusbar->time) * 1000); Only create the string if you're actually going to use it. > if (statusbar->seeking == FALSE) >- /* Elapsed / Total Length */ >- label = g_strdup_printf (_("%s / %s"), time, length); >+ if(statusbar->time_toggle) >+ /* Elapsed / Total Length */ >+ label = g_strdup_printf (_("%s / %s"), time, length); >+ else Missing a translators comment here. >+ label = g_strdup_printf (_("-%s / %s"), remaining, length); > else > /* Seeking to Time / Total Length */ > label = g_strdup_printf (_("Seek to %s / %s"), time, length); >+ label->label = gtk_label_new( time ); Please the same identation and spacing as in other parts of the code. > g_free (time); > >+ gtk_container_add(GTK_CONTAINER(box), label->label); >+ gtk_widget_set_events(box, GDK_BUTTON_PRESS_MASK); >+ g_signal_connect(G_OBJECT(box), "button-press-event", >+ G_CALLBACK(totem_time_label_toggle), label); >+ gtk_widget_set_size_request(label->label,170,20); //So the seekbar doesn't resize in fullscreen when you seek. Don't do that. The fullscreen code is getting rewritten, and that's broken, as it will break with large fonts, or large values, and just clip the label. >+static void >+totem_time_label_toggle(GtkWidget *widget, GdkEvent *event, TotemTimeLabel *label) >+{ >+ label->time_toggle = !label->time_toggle; Maybe you could update the label here as well? >+ if( label->time_toggle ) >+ time_str = totem_time_to_string (time); >+ else >+ time_str = totem_time_to_string (length - time); > length_str = totem_time_to_string (length); > if (label->priv->seeking == FALSE) > /* Elapsed / Total Length */ >- label_str = g_strdup_printf (_("%s / %s"), time_str, length_str); >+ label_str = g_strdup_printf (_("%s%s / %s"), label->time_toggle ? "" : "-", time_str, length_str); This is broken, see how you use it in the statusbar for the correct way to use translatable strings. >+ gboolean time_toggle; This should be a guint : 1 at the end of the struct.
Created attachment 103874 [details] [review] Togglevalue still not saved when switcing to and from fullscreen I've been looking at some different ways of having the same toggle value in fullscreen and windowed mode. 1. Make the totem_fullscreen_set_fullscreen function set the toggle value in totem-time-label.c to the value in totem-statusbar.c when you go into fullscreen and vica versa. (Will run into problems getting the TotemStatusbar object in totem-statusbar.c etc.) 2. Make the toggle functions change value in both totem-statusbar.c and totem-time-label.c. (Will run into same problems as in #1). 3. Use one variable for both fullscreen and windowed. (Where should this variable be declared?)
We'll be showing the time left next to the seek bar in the new media controls. Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of bug 694435 ***