Mercurial > audlegacy
changeset 1889:597bd579d9af trunk
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
author | nemo |
---|---|
date | Sun, 22 Oct 2006 11:38:20 -0700 |
parents | 802c9f8461e0 |
children | 90d95cd7edb5 |
files | ChangeLog audacious/glade/prefswin.glade audacious/main.c audacious/main.h audacious/prefswin.c audacious/ui_fileinfo.c audacious/ui_fileinfo.h |
diffstat | 7 files changed, 284 insertions(+), 179 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Oct 20 17:00:45 2006 -0700 +++ b/ChangeLog Sun Oct 22 11:38:20 2006 -0700 @@ -1,3 +1,11 @@ +2006-10-21 00:00:45 +0000 William Pitcock <nenolod@nenolod.net> + revision [2733] + - enforce extern status here. we do not provide an inlined iir(), so that shouldn't be declared inline. + + trunk/audacious/iir.h | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + + 2006-10-20 23:58:06 +0000 William Pitcock <nenolod@nenolod.net> revision [2731] - icc warning fixes (pass 1)
--- a/audacious/glade/prefswin.glade Fri Oct 20 17:00:45 2006 -0700 +++ b/audacious/glade/prefswin.glade Sun Oct 22 11:38:20 2006 -0700 @@ -4328,97 +4328,145 @@ <property name="fill">False</property> </packing> </child> + <child> - <widget class="GtkAlignment" id="alignment80"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">12</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkCheckButton" id="recurse_for_cover"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Recursively search for cover</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - </child> - </widget> + <widget class="GtkAlignment" id="alignment80"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkCheckButton" id="filepopup_settings_recurse_for_cover"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Recursively search for cover</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> </child> <child> - <widget class="GtkAlignment" id="alignment22"> + <widget class="GtkAlignment" id="alignment22"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">45</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="filepopup_settings_recurse_for_cover_depth_box"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label41"> <property name="visible">True</property> + <property name="label" translatable="yes">Search depth: </property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">45</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="recurse_for_cover_depth_box"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label41"> - <property name="visible">True</property> - <property name="label" translatable="yes">Search depth: </property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">4</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - </child> - - <child> - <widget class="GtkSpinButton" id="recurse_for_cover_depth"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">False</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">2 0 100 1 10 10</property> - <signal name="realize" handler="on_recurse_for_cover_depth_realize" after="yes" last_modification_time="Mon, 24 Jul 2004 23:36:20 GMT"/> - <signal name="value_changed" handler="on_recurse_for_cover_depth_changed" last_modification_time="Mon, 24 Jul 2004 23:36:20 GMT"/> - </widget> - </child> - </widget> - </child> + <property name="xpad">4</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="filepopup_settings_recurse_for_cover_depth"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">0 0 100 1 10 10</property> </widget> <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> </child> - <child> + + <child> + <widget class="GtkAlignment" id="alignment87"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkCheckButton" id="filepopup_settings_use_file_cover"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Use per-file cover</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> <widget class="GtkHButtonBox" id="hbuttonbox10"> <property name="visible">True</property> <property name="layout_style">GTK_BUTTONBOX_END</property>
--- a/audacious/main.c Fri Oct 20 17:00:45 2006 -0700 +++ b/audacious/main.c Sun Oct 22 11:38:20 2006 -0700 @@ -301,7 +301,8 @@ {"resume_playback_on_startup", &cfg.resume_playback_on_startup, TRUE}, {"playlist_detect", &cfg.playlist_detect, TRUE}, {"show_filepopup_for_tuple", &cfg.show_filepopup_for_tuple, TRUE}, - {"recurse_for_cover", &cfg.recurse_for_cover, TRUE} + {"recurse_for_cover", &cfg.recurse_for_cover, TRUE}, + {"use_file_cover", &cfg.use_file_cover, TRUE}, }; static gint ncfgbent = G_N_ELEMENTS(bmp_boolents);
--- a/audacious/main.h Fri Oct 20 17:00:45 2006 -0700 +++ b/audacious/main.h Sun Oct 22 11:38:20 2006 -0700 @@ -125,6 +125,7 @@ gchar *session_uri_base; gint filepopup_pixelsize; gint filepopup_delay; + gboolean use_file_cover; }; typedef struct _BmpConfig BmpConfig;
--- a/audacious/prefswin.c Fri Oct 20 17:00:45 2006 -0700 +++ b/audacious/prefswin.c Sun Oct 22 11:38:20 2006 -0700 @@ -2038,66 +2038,61 @@ } static void -on_filepopup_for_tuple_settings_clicked(GtkButton *button, gpointer data) +on_recurse_for_cover_toggled(GtkToggleButton *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_recurse_for_cover_depth_realize(GtkSpinButton * button, - gpointer data) -{ - gtk_spin_button_set_value(button, cfg.recurse_for_cover_depth); + gtk_widget_set_sensitive(GTK_WIDGET(data), + gtk_toggle_button_get_active(button)); } static void -on_recurse_for_cover_depth_changed(GtkSpinButton * button, - gpointer data) -{ - cfg.recurse_for_cover_depth = gtk_spin_button_get_value_as_int(button); -} - -static void -on_recurse_for_cover_realize(GtkToggleButton * button, - gpointer data) +on_filepopup_for_tuple_settings_clicked(GtkButton *button, gpointer data) { - gboolean state = cfg.recurse_for_cover; - gtk_toggle_button_set_active(button, state); - gtk_widget_set_sensitive(GTK_WIDGET(data), state); -} - -static void -on_recurse_for_cover_toggled(GtkToggleButton * button, - gpointer data) -{ - gboolean state = gtk_toggle_button_get_active(button); - cfg.recurse_for_cover = state; - gtk_widget_set_sensitive(GTK_WIDGET(data), state); + GladeXML *xml = prefswin_get_xml(); + GtkWidget *widget, *widget2; + + widget = glade_xml_get_widget(xml, "filepopup_settings_cover_name_include"); + gtk_entry_set_text(GTK_ENTRY(widget), cfg.cover_name_include); + + widget = glade_xml_get_widget(xml, "filepopup_settings_cover_name_exclude"); + gtk_entry_set_text(GTK_ENTRY(widget), cfg.cover_name_exclude); + + widget2 = glade_xml_get_widget(xml, "filepopup_settings_recurse_for_cover"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget2), cfg.recurse_for_cover); + + widget = glade_xml_get_widget(xml, "filepopup_settings_recurse_for_cover_depth"); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), cfg.recurse_for_cover_depth); + + widget = glade_xml_get_widget(xml, "filepopup_settings_recurse_for_cover_depth_box"); + on_recurse_for_cover_toggled(GTK_TOGGLE_BUTTON(widget2), widget); + + widget = glade_xml_get_widget(xml, "filepopup_settings_use_file_cover"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), cfg.use_file_cover); + + 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"); - + GtkWidget *widget; + + widget = glade_xml_get_widget(xml, "filepopup_settings_cover_name_include"); g_free(cfg.cover_name_include); - cfg.cover_name_include = g_strdup(gtk_entry_get_text(cover_name_include)); - + cfg.cover_name_include = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + + widget = glade_xml_get_widget(xml, "filepopup_settings_cover_name_exclude"); g_free(cfg.cover_name_exclude); - cfg.cover_name_exclude = g_strdup(gtk_entry_get_text(cover_name_exclude)); + cfg.cover_name_exclude = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + + widget = glade_xml_get_widget(xml, "filepopup_settings_recurse_for_cover"); + cfg.recurse_for_cover = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + + widget = glade_xml_get_widget(xml, "filepopup_settings_recurse_for_cover_depth"); + cfg.recurse_for_cover_depth = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); + + widget = glade_xml_get_widget(xml, "filepopup_settings_use_file_cover"); + cfg.use_file_cover = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); gtk_widget_hide(filepopup_settings); } @@ -2180,8 +2175,6 @@ 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_recurse_for_cover_depth_realize) - FUNC_MAP_ENTRY(on_recurse_for_cover_depth_changed) 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) @@ -2417,14 +2410,12 @@ /* 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)); - widget = glade_xml_get_widget(xml, "recurse_for_cover_depth_box"); - widget2 = glade_xml_get_widget(xml, "recurse_for_cover"); - g_signal_connect_after(G_OBJECT(widget2), "realize", - G_CALLBACK(on_recurse_for_cover_realize), - widget); - g_signal_connect(G_OBJECT(widget2), "toggled", - G_CALLBACK(on_recurse_for_cover_toggled), - widget); + + widget = glade_xml_get_widget(xml, "filepopup_settings_recurse_for_cover_depth_box"); + widget2 = glade_xml_get_widget(xml, "filepopup_settings_recurse_for_cover"); + g_signal_connect(G_OBJECT(widget2), "toggled", + G_CALLBACK(on_recurse_for_cover_toggled), + widget); } void
--- a/audacious/ui_fileinfo.c Fri Oct 20 17:00:45 2006 -0700 +++ b/audacious/ui_fileinfo.c Sun Oct 22 11:38:20 2006 -0700 @@ -380,7 +380,7 @@ if (tuple->track_number != 0) fileinfo_entry_set_text_free("entry_track", g_strdup_printf("%d", tuple->track_number)); - tmp = fileinfo_recursive_get_image(tuple->file_path, 0); + tmp = fileinfo_recursive_get_image(tuple->file_path, tuple->file_name, 0); if(tmp) { @@ -392,6 +392,22 @@ } static gboolean +has_front_cover_extension(const gchar *name) +{ + char *ext; + + ext = strrchr(name, '.'); + if (!ext) { + /* No file extension */ + return FALSE; + } + + return g_strcasecmp(ext, ".jpg") == 0 || + g_strcasecmp(ext, ".jpeg") == 0 || + g_strcasecmp(ext, ".png") == 0; +} + +static gboolean cover_name_filter(const gchar *name, const gchar *filter, const gboolean ret_on_empty) { gboolean result = FALSE; @@ -426,29 +442,44 @@ /* Check wether it's an image we want */ static gboolean -is_front_cover_image(const gchar *name) +is_front_cover_image(const gchar *imgfile) { - char *ext; + return cover_name_filter(imgfile, cfg.cover_name_include, TRUE) && + !cover_name_filter(imgfile, cfg.cover_name_exclude, FALSE); +} - ext = strrchr(name, '.'); - if (!ext) { +static gboolean +is_file_image(const gchar *imgfile, const gchar *file_name) +{ + char *imgfile_ext, *file_name_ext; + size_t imgfile_len, file_name_len; + gboolean matches; + + imgfile_ext = strrchr(imgfile, '.'); + if (!imgfile_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 */ + file_name_ext = strrchr(file_name, '.'); + if (!file_name_ext) { + /* No file extension */ return FALSE; } - return cover_name_filter(name, cfg.cover_name_include, TRUE) && - !cover_name_filter(name, cfg.cover_name_exclude, FALSE); + imgfile_len = (imgfile_ext - imgfile); + file_name_len = (file_name_ext - file_name); + + if (imgfile_len == file_name_len) { + return (g_ascii_strncasecmp(imgfile, file_name, imgfile_len) == 0); + } else { + return FALSE; + } } gchar* -fileinfo_recursive_get_image(const gchar* path, gint depth) +fileinfo_recursive_get_image(const gchar* path, + const gchar* file_name, gint depth) { GDir *d; @@ -458,59 +489,76 @@ d = g_dir_open(path, 0, NULL); if (d) { - const gchar *f = g_dir_read_name(d); - - /* first pass only searches for files. */ - while(f) { - gchar *newpath = g_strdup_printf("%s/%s", path, f); + const gchar *f; - if(!g_file_test(newpath, G_FILE_TEST_IS_DIR)) { - if(is_front_cover_image(f)) { + if (cfg.use_file_cover && file_name) { + /* Look for images matching file name */ + while(f = g_dir_read_name(d)) { + gchar *newpath = g_strconcat(path, "/", f, NULL); + + if (!g_file_test(newpath, G_FILE_TEST_IS_DIR) && + has_front_cover_extension(f) && + is_file_image(f, file_name)) { g_dir_close(d); return newpath; } + + g_free(newpath); } + g_dir_rewind(d); + } + + /* Search for files using filter */ + while (f = g_dir_read_name(d)) { + gchar *newpath = g_strconcat(path, "/", f, NULL); + + if (!g_file_test(newpath, G_FILE_TEST_IS_DIR) && + has_front_cover_extension(f) && + is_front_cover_image(f)) { + g_dir_close(d); + return newpath; + } + g_free(newpath); - f = g_dir_read_name(d); } + g_dir_rewind(d); /* checks whether recursive or not. */ - if(!cfg.recurse_for_cover) { + if (!cfg.recurse_for_cover) { g_dir_close(d); return NULL; } - /* second pass descends directory recursively. */ - g_dir_rewind(d); - f = g_dir_read_name(d); - - while(f) { - gchar *newpath = g_strdup_printf("%s/%s", path, f); + /* Descend into directories recursively. */ + while (f = g_dir_read_name(d)) { + gchar *newpath = g_strconcat(path, "/", f, NULL); if(g_file_test(newpath, G_FILE_TEST_IS_DIR)) { - gchar *tmp = fileinfo_recursive_get_image(newpath, depth+1); + gchar *tmp = fileinfo_recursive_get_image(newpath, + NULL, depth + 1); if(tmp) { g_free(newpath); g_dir_close(d); return tmp; } } + g_free(newpath); - f = g_dir_read_name(d); } g_dir_close(d); - } + } + return NULL; } void filepopup_show_for_tuple(TitleInput *tuple) { - gchar *tmp = NULL; + gchar *tmp = NULL, *fullpath = NULL; gint x, y, x_off = 3, y_off = 3, h, w; - static gchar *lastpath = NULL; + static gchar *last_artwork = NULL; if (tuple == NULL) return; @@ -531,21 +579,29 @@ if (tuple->track_number != 0) filepopup_entry_set_text_free("label_track", g_strdup_printf("%d", tuple->track_number)); - if(strcmp(lastpath?lastpath:"", tuple->file_path)){ - tmp = fileinfo_recursive_get_image(tuple->file_path, 0); - - if(tmp) + if (cfg.use_file_cover) { + /* Use the file name */ + fullpath = g_strconcat(tuple->file_path, "/", tuple->file_name, NULL); + } else { + fullpath = g_strconcat(tuple->file_path, "/", NULL); + } + + if (!last_artwork || strcmp(last_artwork, fullpath)){ + g_free(last_artwork); + last_artwork = g_strdup(fullpath); + + tmp = fileinfo_recursive_get_image(tuple->file_path, tuple->file_name, 0); + if (tmp) { filepopup_entry_set_image("image_artwork", tmp); g_free(tmp); - g_free(lastpath); - lastpath = g_strdup(tuple->file_path); } else { filepopup_entry_set_image("image_artwork", DATA_DIR "/images/audio.png"); - g_free(lastpath); - lastpath = g_strdup(tuple->file_path); } } + + g_free(fullpath); + gdk_window_get_pointer(NULL, &x, &y, NULL); gtk_window_get_size(GTK_WINDOW(filepopup_win), &w, &h); if (gdk_screen_width()-(w+3) < x) x_off = (w*-1)-3;
--- a/audacious/ui_fileinfo.h Fri Oct 20 17:00:45 2006 -0700 +++ b/audacious/ui_fileinfo.h Sun Oct 22 11:38:20 2006 -0700 @@ -25,7 +25,7 @@ void create_filepopup_window(void); void fileinfo_show_for_tuple(TitleInput *tuple); void filepopup_show_for_tuple(TitleInput *tuple); -gchar* fileinfo_recursive_get_image(const gchar* path, gint depth); +gchar* fileinfo_recursive_get_image(const gchar* path, const gchar* file_name, gint depth); void fileinfo_show_for_path(gchar *path); void filepopup_hide(gpointer unused);