changeset 4228:9f3cc7f3aaf6

update titles after 3 sec. delay when custom template changed
author Eugene Zagidullin <e.asphyx@gmail.com>
date Wed, 30 Jan 2008 20:32:50 +0300
parents 206378f34610
children 386c712a5b5b 8b9b5d04aac4
files src/audacious/playlist.c src/audacious/ui_preferences.c
diffstat 2 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/playlist.c	Wed Jan 30 19:41:03 2008 +0300
+++ b/src/audacious/playlist.c	Wed Jan 30 20:32:50 2008 +0300
@@ -26,7 +26,7 @@
  *  Audacious or using our public API to be a derived work.
  */
 
-#define AUD_DEBUG 1
+/* #define AUD_DEBUG 1 */
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
--- a/src/audacious/ui_preferences.c	Wed Jan 30 19:41:03 2008 +0300
+++ b/src/audacious/ui_preferences.c	Wed Jan 30 20:32:50 2008 +0300
@@ -63,6 +63,8 @@
 
 #include "build_stamp.h"
 
+#define TITLESTRING_UPDATE_TIMEOUT 3
+
 enum CategoryViewCols {
     CATEGORY_VIEW_COL_ICON,
     CATEGORY_VIEW_COL_NAME,
@@ -189,6 +191,7 @@
 static void mainwin_font_set_cb();
 static void playlist_font_set_cb();
 GtkWidget *ui_preferences_chardet_table_populate(void);
+static gint titlestring_timeout_counter = 0;
 
 static PreferencesWidget appearance_misc_widgets[] = {
     {WIDGET_LABEL, N_("<b>_Fonts</b>"), NULL, NULL, NULL, FALSE},
@@ -564,12 +567,32 @@
     gtk_entry_set_text(GTK_ENTRY(entry), cfg.gentitle_format);
 }
 
+static gboolean
+titlestring_timeout_proc (gpointer data)
+{
+    titlestring_timeout_counter--;
+
+    if(titlestring_timeout_counter <= 0) {
+        titlestring_timeout_counter = 0;
+        playlist_update_all_titles();
+        return FALSE;
+    } else {
+        return TRUE;
+    }
+}
+
 static void
 on_titlestring_entry_changed(GtkWidget * entry,
                              gpointer data) 
 {
     g_free(cfg.gentitle_format);
     cfg.gentitle_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
+
+    if(titlestring_timeout_counter == 0) {
+        g_timeout_add_seconds (1, (GSourceFunc) titlestring_timeout_proc, NULL);
+    }
+    
+    titlestring_timeout_counter = TITLESTRING_UPDATE_TIMEOUT;
 }
 
 static void