changeset 4694:f0cc355c4660

Update time.
author William Pitcock <nenolod@atheme.org>
date Sat, 05 Jul 2008 17:23:12 -0500
parents 463675303b6f
children 225f78715e65
files src/audacious/ui_new.c
diffstat 1 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_new.c	Sat Jul 05 17:08:37 2008 -0500
+++ b/src/audacious/ui_new.c	Sat Jul 05 17:23:12 2008 -0500
@@ -26,7 +26,7 @@
 #include "ui_fileopener.h"
 #include "ui_new.h"
 
-static GtkWidget *label_prev, *label_current, *label_next;
+static GtkWidget *label_prev, *label_current, *label_next, *label_time;
 static GtkWidget *slider;
 
 static gulong slider_change_handler_id;
@@ -104,6 +104,8 @@
 static gboolean
 ui_update_song_info(gpointer hook_data, gpointer user_data)
 {
+    gchar text[128];
+
     if (!playback_get_playing())
     {
         gtk_range_set_value(GTK_RANGE(slider), (gdouble)0);
@@ -121,6 +123,13 @@
     gtk_range_set_value(GTK_RANGE(slider), (gdouble)time);
     g_signal_handler_unblock(slider, slider_change_handler_id);
 
+    time /= 1000;
+    length /= 1000;
+
+    g_snprintf(text, 128, "<tt><b>%d:%.2d/%d:%.2d</b></tt>", time / 60, time % 60,
+        length / 60, length % 60);
+    gtk_label_set_markup(GTK_LABEL(label_time), text);
+
     return TRUE;
 }
 
@@ -202,6 +211,7 @@
                            about current track */
     GtkWidget *cvbox;	/* box containing information about current track
                            and some control elements like position bar */
+    GtkWidget *shbox;   /* box for slider + time combo --nenolod */
 
     GtkToolItem *button_open, *button_add,
                 *button_play, *button_pause,
@@ -254,11 +264,17 @@
 
     gtk_box_pack_start(GTK_BOX(vbox), pcnbox, TRUE, TRUE, 0);
 
+    shbox = gtk_hbox_new(FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(cvbox), shbox, TRUE, TRUE, 0);
+
     slider = gtk_hscale_new(NULL);
     gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
     /* TODO: make this configureable */
     gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DELAYED);
-    gtk_box_pack_end(GTK_BOX(cvbox), slider, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(shbox), slider, TRUE, TRUE, 0);
+
+    label_time = gtk_markup_label_new("<tt><b>0:00/0:00</b></tt>");
+    gtk_box_pack_start(GTK_BOX(shbox), label_time, FALSE, FALSE, 0);
 
     hook_associate("title change", (HookFunction) ui_set_current_song_title, NULL);
     hook_associate("playback seek", (HookFunction) ui_update_song_info, NULL);