comparison src/audacious/ui_new.c @ 4694:f0cc355c4660

Update time.
author William Pitcock <nenolod@atheme.org>
date Sat, 05 Jul 2008 17:23:12 -0500
parents a5707f571100
children 225f78715e65
comparison
equal deleted inserted replaced
4693:463675303b6f 4694:f0cc355c4660
24 #include "playback.h" 24 #include "playback.h"
25 #include "playlist.h" 25 #include "playlist.h"
26 #include "ui_fileopener.h" 26 #include "ui_fileopener.h"
27 #include "ui_new.h" 27 #include "ui_new.h"
28 28
29 static GtkWidget *label_prev, *label_current, *label_next; 29 static GtkWidget *label_prev, *label_current, *label_next, *label_time;
30 static GtkWidget *slider; 30 static GtkWidget *slider;
31 31
32 static gulong slider_change_handler_id; 32 static gulong slider_change_handler_id;
33 static gboolean slider_is_moving = FALSE; 33 static gboolean slider_is_moving = FALSE;
34 static gint update_song_timeout_source = 0; 34 static gint update_song_timeout_source = 0;
102 } 102 }
103 103
104 static gboolean 104 static gboolean
105 ui_update_song_info(gpointer hook_data, gpointer user_data) 105 ui_update_song_info(gpointer hook_data, gpointer user_data)
106 { 106 {
107 gchar text[128];
108
107 if (!playback_get_playing()) 109 if (!playback_get_playing())
108 { 110 {
109 gtk_range_set_value(GTK_RANGE(slider), (gdouble)0); 111 gtk_range_set_value(GTK_RANGE(slider), (gdouble)0);
110 return FALSE; 112 return FALSE;
111 } 113 }
119 g_signal_handler_block(slider, slider_change_handler_id); 121 g_signal_handler_block(slider, slider_change_handler_id);
120 gtk_range_set_range(GTK_RANGE(slider), 0.0, (gdouble)length); 122 gtk_range_set_range(GTK_RANGE(slider), 0.0, (gdouble)length);
121 gtk_range_set_value(GTK_RANGE(slider), (gdouble)time); 123 gtk_range_set_value(GTK_RANGE(slider), (gdouble)time);
122 g_signal_handler_unblock(slider, slider_change_handler_id); 124 g_signal_handler_unblock(slider, slider_change_handler_id);
123 125
126 time /= 1000;
127 length /= 1000;
128
129 g_snprintf(text, 128, "<tt><b>%d:%.2d/%d:%.2d</b></tt>", time / 60, time % 60,
130 length / 60, length % 60);
131 gtk_label_set_markup(GTK_LABEL(label_time), text);
132
124 return TRUE; 133 return TRUE;
125 } 134 }
126 135
127 static gboolean 136 static gboolean
128 ui_slider_value_changed_cb(GtkRange *range, gpointer user_data) 137 ui_slider_value_changed_cb(GtkRange *range, gpointer user_data)
200 209
201 GtkWidget *chbox; /* box containing album art and information 210 GtkWidget *chbox; /* box containing album art and information
202 about current track */ 211 about current track */
203 GtkWidget *cvbox; /* box containing information about current track 212 GtkWidget *cvbox; /* box containing information about current track
204 and some control elements like position bar */ 213 and some control elements like position bar */
214 GtkWidget *shbox; /* box for slider + time combo --nenolod */
205 215
206 GtkToolItem *button_open, *button_add, 216 GtkToolItem *button_open, *button_add,
207 *button_play, *button_pause, 217 *button_play, *button_pause,
208 *button_previous, *button_next; 218 *button_previous, *button_next;
209 219
252 gtk_box_pack_start(GTK_BOX(pcnbox), chbox, TRUE, TRUE, 0); 262 gtk_box_pack_start(GTK_BOX(pcnbox), chbox, TRUE, TRUE, 0);
253 gtk_box_pack_start(GTK_BOX(pcnbox), label_next, TRUE, TRUE, 0); 263 gtk_box_pack_start(GTK_BOX(pcnbox), label_next, TRUE, TRUE, 0);
254 264
255 gtk_box_pack_start(GTK_BOX(vbox), pcnbox, TRUE, TRUE, 0); 265 gtk_box_pack_start(GTK_BOX(vbox), pcnbox, TRUE, TRUE, 0);
256 266
267 shbox = gtk_hbox_new(FALSE, 0);
268 gtk_box_pack_end(GTK_BOX(cvbox), shbox, TRUE, TRUE, 0);
269
257 slider = gtk_hscale_new(NULL); 270 slider = gtk_hscale_new(NULL);
258 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE); 271 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
259 /* TODO: make this configureable */ 272 /* TODO: make this configureable */
260 gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DELAYED); 273 gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DELAYED);
261 gtk_box_pack_end(GTK_BOX(cvbox), slider, TRUE, TRUE, 0); 274 gtk_box_pack_start(GTK_BOX(shbox), slider, TRUE, TRUE, 0);
275
276 label_time = gtk_markup_label_new("<tt><b>0:00/0:00</b></tt>");
277 gtk_box_pack_start(GTK_BOX(shbox), label_time, FALSE, FALSE, 0);
262 278
263 hook_associate("title change", (HookFunction) ui_set_current_song_title, NULL); 279 hook_associate("title change", (HookFunction) ui_set_current_song_title, NULL);
264 hook_associate("playback seek", (HookFunction) ui_update_song_info, NULL); 280 hook_associate("playback seek", (HookFunction) ui_update_song_info, NULL);
265 hook_associate("playback begin", (HookFunction) ui_playback_begin, NULL); 281 hook_associate("playback begin", (HookFunction) ui_playback_begin, NULL);
266 hook_associate("playback stop", (HookFunction) ui_playback_stop, NULL); 282 hook_associate("playback stop", (HookFunction) ui_playback_stop, NULL);