# HG changeset patch # User nenolod # Date 1153062848 25200 # Node ID 878c7f8d0a8cad652bb77a2c8aca6546938aa09d # Parent c6ac6c61a6fdda6d665c2d867fb69ea7719c3498 [svn] - filepopup albumart stuff, via hansmi diff -r c6ac6c61a6fd -r 878c7f8d0a8c ChangeLog --- a/ChangeLog Sat Jul 15 17:27:49 2006 -0700 +++ b/ChangeLog Sun Jul 16 08:14:08 2006 -0700 @@ -1,3 +1,12 @@ +2006-07-16 00:27:49 +0000 William Pitcock + revision [1738] + - i think this works + + + Changes: Modified: + +1 -1 trunk/Plugins/Input/wma/libffwma/Makefile.in + + 2006-07-16 00:03:07 +0000 Tony Vroon revision [1736] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h). diff -r c6ac6c61a6fd -r 878c7f8d0a8c audacious/glade/prefswin.glade --- a/audacious/glade/prefswin.glade Sat Jul 15 17:27:49 2006 -0700 +++ b/audacious/glade/prefswin.glade Sun Jul 16 08:14:08 2006 -0700 @@ -2351,19 +2351,72 @@ 0 - + True - Toggles popup information window for the pointed entry in the playlist. The window shows title of song, name of album, genre, year of publish, track number, track length, and artwork. - True - Show popup information for playlist entries - True - GTK_RELIEF_NORMAL - True - False - False - True - - + False + 12 + + + + True + False + 0 + + + + True + Toggles popup information window for the pointed entry in the playlist. The window shows title of song, name of album, genre, year of publish, track number, track length, and artwork. + True + Show popup information for playlist entries + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + + 0 + True + False + + + + + 0 + True + True + + + + + + True + Edit settings for popup information + GTK_RELIEF_HALF + True + + + + + True + gtk-properties + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + @@ -4115,4 +4168,208 @@ + + 12 + Popup Information Settings + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + True + False + True + True + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + + + + + True + False + 12 + + + + True + While searching for the album's cover, Audacious looks for certain words in the filename. You can specify those words in the lists below, separated using commas. + False + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + 2 + 2 + False + 4 + 4 + + + + True + True + True + True + 0 + + True + * + True + + + 1 + 2 + 1 + 2 + + + + + + + True + Include: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Exclude: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + True + True + 0 + + True + * + True + + + 1 + 2 + 0 + 1 + + + + + + 0 + False + False + + + + + + True + GTK_BUTTONBOX_END + 6 + + + + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + + + + + + 0 + False + False + + + + + + diff -r c6ac6c61a6fd -r 878c7f8d0a8c audacious/main.c --- a/audacious/main.c Sat Jul 15 17:27:49 2006 -0700 +++ b/audacious/main.c Sun Jul 16 08:14:08 2006 -0700 @@ -203,6 +203,8 @@ 3000, /* audio buffer size */ FALSE, /* whether or not to postpone format detection on initial add */ TRUE, /* show filepopup for tuple */ + NULL, /* words identifying covers */ + NULL, /* words that might not show up in cover names */ }; typedef struct bmp_cfg_boolent_t { @@ -345,6 +347,8 @@ {"generic_title_format", &cfg.gentitle_format, TRUE}, {"chardet_detector", &cfg.chardet_detector, TRUE}, {"chardet_fallback", &cfg.chardet_fallback, TRUE}, + {"cover_name_include", &cfg.cover_name_include, TRUE}, + {"cover_name_exclude", &cfg.cover_name_exclude, TRUE}, }; static gint ncfgsent = G_N_ELEMENTS(bmp_strents); @@ -552,6 +556,12 @@ if (!cfg.eqpreset_extension) cfg.eqpreset_extension = g_strdup(EQUALIZER_DEFAULT_PRESET_EXT); + + if (!cfg.cover_name_include) + cfg.cover_name_include = g_strdup(""); + + if (!cfg.cover_name_exclude) + cfg.cover_name_exclude = g_strdup("back"); } diff -r c6ac6c61a6fd -r 878c7f8d0a8c audacious/main.h --- a/audacious/main.h Sat Jul 15 17:27:49 2006 -0700 +++ b/audacious/main.h Sun Jul 16 08:14:08 2006 -0700 @@ -112,6 +112,7 @@ gint output_buffer_size; gboolean playlist_detect; gboolean show_filepopup_for_tuple; + gchar *cover_name_include, *cover_name_exclude; }; typedef struct _BmpConfig BmpConfig; diff -r c6ac6c61a6fd -r 878c7f8d0a8c audacious/prefswin.c --- a/audacious/prefswin.c Sat Jul 15 17:27:49 2006 -0700 +++ b/audacious/prefswin.c Sun Jul 16 08:14:08 2006 -0700 @@ -90,6 +90,7 @@ TitleFieldTag; static GtkWidget *prefswin = NULL; +static GtkWidget *filepopup_settings = NULL; static GtkWidget *category_treeview = NULL; static GtkWidget *category_notebook = NULL; GtkWidget *filepopupbutton = NULL; @@ -2012,14 +2013,63 @@ static void on_show_filepopup_for_tuple_realize(GtkToggleButton * button, gpointer data) { + GladeXML *xml = prefswin_get_xml(); + GtkWidget *settings_button = glade_xml_get_widget(xml, "filepopup_for_tuple_settings_button"); + gtk_toggle_button_set_active(button, cfg.show_filepopup_for_tuple); filepopupbutton = (GtkWidget *)button; + + gtk_widget_set_sensitive(settings_button, cfg.show_filepopup_for_tuple); } static void on_show_filepopup_for_tuple_toggled(GtkToggleButton * button, gpointer data) { + GladeXML *xml = prefswin_get_xml(); + GtkWidget *settings_button = glade_xml_get_widget(xml, "filepopup_for_tuple_settings_button"); + cfg.show_filepopup_for_tuple = gtk_toggle_button_get_active(button); + + gtk_widget_set_sensitive(settings_button, cfg.show_filepopup_for_tuple); +} + +static void +on_filepopup_for_tuple_settings_clicked(GtkButton *button, gpointer data) +{ + GladeXML *xml = prefswin_get_xml(); + GtkEntry *cover_name_include = + (GtkEntry*)glade_xml_get_widget(xml, "filepopup_settings_cover_name_include"); + GtkEntry *cover_name_exclude = + (GtkEntry*)glade_xml_get_widget(xml, "filepopup_settings_cover_name_exclude"); + + gtk_entry_set_text(cover_name_include, cfg.cover_name_include); + gtk_entry_set_text(cover_name_exclude, cfg.cover_name_exclude); + + gtk_widget_show(filepopup_settings); +} + +static void +on_filepopup_settings_ok_clicked(GtkButton *button, gpointer data) +{ + GladeXML *xml = prefswin_get_xml(); + GtkEntry *cover_name_include = + (GtkEntry*)glade_xml_get_widget(xml, "filepopup_settings_cover_name_include"); + GtkEntry *cover_name_exclude = + (GtkEntry*)glade_xml_get_widget(xml, "filepopup_settings_cover_name_exclude"); + + g_free(cfg.cover_name_include); + cfg.cover_name_include = g_strdup(gtk_entry_get_text(cover_name_include)); + + g_free(cfg.cover_name_exclude); + cfg.cover_name_exclude = g_strdup(gtk_entry_get_text(cover_name_exclude)); + + gtk_widget_hide(filepopup_settings); +} + +static void +on_filepopup_settings_cancel_clicked(GtkButton *button, gpointer data) +{ + gtk_widget_hide(filepopup_settings); } /* FIXME: complete the map */ @@ -2094,8 +2144,13 @@ FUNC_MAP_ENTRY(on_audio_format_det_cb_realize) FUNC_MAP_ENTRY(on_show_filepopup_for_tuple_realize) FUNC_MAP_ENTRY(on_show_filepopup_for_tuple_toggled) + FUNC_MAP_ENTRY(on_filepopup_for_tuple_settings_clicked) FUNC_MAP_ENTRY(on_continue_playback_on_startup_realize) FUNC_MAP_ENTRY(on_continue_playback_on_startup_toggled) + + /* Filepopup settings */ + FUNC_MAP_ENTRY(on_filepopup_settings_ok_clicked) + FUNC_MAP_ENTRY(on_filepopup_settings_cancel_clicked) FUNC_MAP_END void @@ -2319,6 +2374,10 @@ gtk_label_set_markup( GTK_LABEL(widget) , aud_version_string->str ); g_string_free( aud_version_string , TRUE ); + + /* Create window for filepopup settings */ + filepopup_settings = glade_xml_get_widget(xml, "filepopup_for_tuple_settings"); + gtk_window_set_transient_for(GTK_WINDOW(filepopup_settings), GTK_WINDOW(prefswin)); } void diff -r c6ac6c61a6fd -r 878c7f8d0a8c audacious/ui_fileinfo.c --- a/audacious/ui_fileinfo.c Sat Jul 15 17:27:49 2006 -0700 +++ b/audacious/ui_fileinfo.c Sun Jul 16 08:14:08 2006 -0700 @@ -342,6 +342,62 @@ gtk_widget_show(fileinfo_win); } +static gboolean +cover_name_filter(const gchar *name, const gchar *filter, const gboolean ret_on_empty) +{ + gboolean result = FALSE; + gchar **splitted; + gchar *current; + gchar *lname; + gint i; + + if (!filter || strlen(filter) == 0) { + return ret_on_empty; + } + + splitted = g_strsplit(filter, ",", 0); + + lname = g_strdup(name); + g_strdown(lname); + + for (i = 0; !result && (current = splitted[i]); i++) { + gchar *stripped = g_strstrip(g_strdup(current)); + g_strdown(stripped); + + result = result || strstr(lname, stripped); + + g_free(stripped); + } + + g_free(lname); + g_strfreev(splitted); + + return result; +} + +/* Check wether it's an image we want */ +static gboolean +is_front_cover_image(const gchar *name) +{ + char *ext; + + ext = strrchr(name, '.'); + if (!ext) { + /* No file extension */ + return FALSE; + } + + if (g_strcasecmp(ext, ".jpg") != 0 && + g_strcasecmp(ext, ".jpeg") != 0 && + g_strcasecmp(ext, ".png") != 0) { + /* No recognized file extension */ + return FALSE; + } + + return cover_name_filter(name, cfg.cover_name_include, TRUE) && + !cover_name_filter(name, cfg.cover_name_exclude, FALSE); +} + gchar* fileinfo_recursive_get_image(const gchar* path, gint depth) { @@ -359,11 +415,12 @@ while (f) { gchar *newpath = g_strdup_printf("%s/%s", path, f); - - /* ok. why did I not have strcasestr, thought glib had that one */ - if ((strstr(f,".jpg") || strstr(f,".jpeg") || strstr(f,".png") || strstr(f,".JPG") || strstr(f,".JPEG") || strstr(f,".PNG")) && !strstr(f,"back") && !strstr(f,"Back") && !strstr(f,"BACK")) + + if (is_front_cover_image(f)) { - /* We found a suitable file in the current directory, use that. The string will be freed by the caller */ + /* We found a suitable file in the current + * directory, use that. The string will be + * freed by the caller */ return newpath; } else