diff options
Diffstat (limited to 'plugins/gtkui')
-rw-r--r-- | plugins/gtkui/coverart.c | 40 | ||||
-rw-r--r-- | plugins/gtkui/coverart.h | 3 | ||||
-rw-r--r-- | plugins/gtkui/deadbeef.glade | 4 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 1 | ||||
-rw-r--r-- | plugins/gtkui/interface.c | 4 | ||||
-rw-r--r-- | plugins/gtkui/widgets.c | 3 |
6 files changed, 46 insertions, 9 deletions
diff --git a/plugins/gtkui/coverart.c b/plugins/gtkui/coverart.c index f7d78696..0ff63ceb 100644 --- a/plugins/gtkui/coverart.c +++ b/plugins/gtkui/coverart.c @@ -43,6 +43,7 @@ GdkPixbuf *pixbuf_default; typedef struct { struct timeval tm; + time_t file_time; char *fname; int width; GdkPixbuf *pixbuf; @@ -71,6 +72,8 @@ static uintptr_t tid; load_query_t *queue; load_query_t *tail; +static int64_t artwork_reset_time; + static void queue_add (const char *fname, int width, void (*callback) (void *user_data), void *user_data) { deadbeef->mutex_lock (mutex); @@ -175,11 +178,14 @@ loading_thread (void *none) { } GdkPixbuf *pixbuf = NULL; GError *error = NULL; - pixbuf = gdk_pixbuf_new_from_file_at_scale (queue->fname, queue->width, queue->width, TRUE, &error); - if (error) { - //fprintf (stderr, "gdk_pixbuf_new_from_file_at_scale %s %d failed, error: %s\n", queue->fname, queue->width, error ? error->message : "n/a"); - g_error_free (error); - error = NULL; + struct stat stat_buf; + if (!stat (queue->fname, &stat_buf)) { + pixbuf = gdk_pixbuf_new_from_file_at_scale (queue->fname, queue->width, queue->width, TRUE, &error); + if (error) { + //fprintf (stderr, "gdk_pixbuf_new_from_file_at_scale %s %d failed, error: %s\n", queue->fname, queue->width, error ? error->message : "n/a"); + g_error_free (error); + error = NULL; + } } if (!pixbuf) { pixbuf = pixbuf_default; @@ -189,6 +195,7 @@ loading_thread (void *none) { deadbeef->mutex_lock (mutex); cache[cache_min].pixbuf = pixbuf; cache[cache_min].fname = strdup (queue->fname); + cache[cache_min].file_time = stat_buf.st_mtime; gettimeofday (&cache[cache_min].tm, NULL); cache[cache_min].width = queue->width; deadbeef->mutex_unlock (mutex); @@ -406,3 +413,26 @@ int gtkui_is_default_pixbuf (GdkPixbuf *pb) { return pb == pixbuf_default; } + +int +gtkui_cover_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { + switch (id) { + case DB_EV_PLAYLIST_REFRESH: + { + int64_t reset_time = deadbeef->conf_get_int64 ("artwork.cache_reset_time", 0);; + if (reset_time != artwork_reset_time) { + artwork_reset_time = reset_time; + deadbeef->mutex_lock (mutex); + for (int i = 0; i < CACHE_SIZE; i++) { + if (cache[i].pixbuf) { + g_object_unref (cache[i].pixbuf); + } + } + memset (cache, 0, sizeof (cache)); + deadbeef->mutex_unlock (mutex); + } + } + break; + } + return 0; +} diff --git a/plugins/gtkui/coverart.h b/plugins/gtkui/coverart.h index bacbfd92..47627fe7 100644 --- a/plugins/gtkui/coverart.h +++ b/plugins/gtkui/coverart.h @@ -51,5 +51,8 @@ cover_get_default_pixbuf (void); int gtkui_is_default_pixbuf (GdkPixbuf *pb); +int +gtkui_cover_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2); + #endif diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index 57dd0cbe..59ac4533 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -6349,7 +6349,7 @@ if you don't press Apply.</property> <widget class="GtkCheckButton" id="set_custom_title"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Set custom title</property> + <property name="label" translatable="yes">Set Custom Title</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> @@ -8827,7 +8827,7 @@ Descending</property> <widget class="GtkCheckButton" id="set_custom_title"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Set custom title</property> + <property name="label" translatable="yes">Set Custom Title</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 5e2cbd2f..a3cca159 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -772,6 +772,7 @@ gtkui_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { if (rootwidget) { send_messages_to_widgets (rootwidget, id, ctx, p1, p2); } + gtkui_cover_message (id, ctx, p1, p2); switch (id) { case DB_EV_ACTIVATED: g_idle_add (activate_cb, NULL); diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index c4c02b73..d17269c6 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -3225,7 +3225,7 @@ create_addlocationdlg (void) hbox122 = gtk_hbox_new (FALSE, 8); gtk_box_pack_start (GTK_BOX (vbox45), hbox122, TRUE, TRUE, 0); - set_custom_title = gtk_check_button_new_with_mnemonic (_("Set custom title")); + set_custom_title = gtk_check_button_new_with_mnemonic (_("Set Custom Title")); gtk_widget_show (set_custom_title); gtk_box_pack_start (GTK_BOX (hbox122), set_custom_title, FALSE, FALSE, 0); @@ -4439,7 +4439,7 @@ create_setcustomtitledlg (void) gtk_widget_show (hbox123); gtk_box_pack_start (GTK_BOX (vbox46), hbox123, FALSE, TRUE, 0); - set_custom_title = gtk_check_button_new_with_mnemonic (_("Set custom title")); + set_custom_title = gtk_check_button_new_with_mnemonic (_("Set Custom Title")); gtk_widget_show (set_custom_title); gtk_box_pack_start (GTK_BOX (hbox123), set_custom_title, FALSE, FALSE, 0); diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c index 1bacb50e..51b37c28 100644 --- a/plugins/gtkui/widgets.c +++ b/plugins/gtkui/widgets.c @@ -2349,6 +2349,9 @@ static int coverart_message (ddb_gtkui_widget_t *w, uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { w_coverart_t *ca = (w_coverart_t *)w; switch (id) { + case DB_EV_PLAYLIST_REFRESH: + g_idle_add (coverart_redraw_cb, w); + break; case DB_EV_SONGSTARTED: g_idle_add (coverart_redraw_cb, w); break; |