changeset 4688:b3e2ea3f9297

display what would be played if user presses play button
author Tomasz Mon <desowin@gmail.com>
date Sat, 05 Jul 2008 15:42:03 +0200
parents 9e70ca57b5dd
children a5707f571100
files src/audacious/ui_new.c
diffstat 1 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_new.c	Sat Jul 05 14:49:22 2008 +0200
+++ b/src/audacious/ui_new.c	Sat Jul 05 15:42:03 2008 +0200
@@ -85,18 +85,24 @@
 }
 
 static void
-set_song_title(gpointer hook_data, gpointer user_data)
+ui_set_current_song_title(gchar *text, gpointer user_data)
 {
-    gchar *title =
-        g_strdup_printf("<big>%s</big>",
-                        playlist_get_info_text(playlist_get_active()));
+    gchar *title = g_strdup_printf("<big>%s</big>", text);
     gtk_label_set_text(GTK_LABEL(label_current), title);
     g_object_set(G_OBJECT(label_current), "use-markup", TRUE, NULL);
     g_free(title);
 }
 
+static void
+ui_playlist_update(Playlist *playlist, gpointer user_data)
+{
+    gchar *text = playlist_get_info_text(playlist);
+    ui_set_current_song_title(text, NULL);
+    g_free(text);
+}
+
 static gboolean
-update_song_info(gpointer hook_data, gpointer user_data)
+ui_update_song_info(gpointer hook_data, gpointer user_data)
 {
     if (!playback_get_playing())
     {
@@ -145,9 +151,9 @@
 static void
 ui_playback_begin(gpointer hook_data, gpointer user_data)
 {
-    update_song_info(NULL, NULL);
+    ui_update_song_info(NULL, NULL);
     update_song_timeout_source =
-        g_timeout_add_seconds(1, (GSourceFunc) update_song_info, NULL);
+        g_timeout_add_seconds(1, (GSourceFunc) ui_update_song_info, NULL);
 }
 
 static void
@@ -162,7 +168,7 @@
 static void
 ui_playback_end(gpointer hook_data, gpointer user_data)
 {
-    update_song_info(NULL, NULL);
+    ui_update_song_info(NULL, NULL);
 }
 
 static GtkToolItem *
@@ -254,11 +260,12 @@
     gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DELAYED);
     gtk_box_pack_end(GTK_BOX(cvbox), slider, TRUE, TRUE, 0);
 
-    hook_associate("title change", set_song_title, NULL);
-    hook_associate("playback seek", (HookFunction) update_song_info, NULL);
+    hook_associate("title change", (HookFunction) ui_set_current_song_title, NULL);
+    hook_associate("playback seek", (HookFunction) ui_update_song_info, NULL);
     hook_associate("playback begin", (HookFunction) ui_playback_begin, NULL);
     hook_associate("playback stop", (HookFunction) ui_playback_stop, NULL);
     hook_associate("playback end", (HookFunction) ui_playback_end, NULL);
+    hook_associate("playlist update", (HookFunction) ui_playlist_update, NULL);
 
     slider_change_handler_id =
         g_signal_connect(slider, "value-changed",
@@ -269,6 +276,8 @@
     g_signal_connect(slider, "button-release-event",
                      G_CALLBACK(ui_slider_button_release_cb), NULL);
 
+    ui_playlist_update(playlist_get_active(), NULL);
+
     gtk_widget_show_all(window);
     gtk_main();