# HG changeset patch # User nenolod # Date 1163329768 28800 # Node ID f027afc2ca2ef5d1888a9baeaf2108eeab3a547e # Parent 8cca76c8f5c33e18c6a15c17e988007fb1f3adfc [svn] - avoid freeing a NULL pointer in ui_fileinfo.c - add some hooks for newui - implement album art support in newui diff -r 8cca76c8f5c3 -r f027afc2ca2e ChangeLog --- a/ChangeLog Sun Nov 12 02:37:32 2006 -0800 +++ b/ChangeLog Sun Nov 12 03:09:28 2006 -0800 @@ -1,3 +1,12 @@ +2006-11-12 10:37:32 +0000 William Pitcock + revision [2901] + - show_newui_window() implementation + + trunk/audacious/newui/newui_window.c | 6 ++++++ + trunk/audacious/newui/newui_window.h | 1 + + 2 files changed, 7 insertions(+) + + 2006-11-12 10:36:47 +0000 William Pitcock revision [2899] - some code diff -r 8cca76c8f5c3 -r f027afc2ca2e audacious/glade/newui.glade --- a/audacious/glade/newui.glade Sun Nov 12 02:37:32 2006 -0800 +++ b/audacious/glade/newui.glade Sun Nov 12 03:09:28 2006 -0800 @@ -338,7 +338,7 @@ - + True False @@ -365,7 +365,7 @@ - + True False @@ -392,7 +392,7 @@ - + True False @@ -419,7 +419,7 @@ - + True False @@ -446,7 +446,7 @@ - + True False @@ -473,7 +473,7 @@ - + True False @@ -500,7 +500,7 @@ - + True False diff -r 8cca76c8f5c3 -r f027afc2ca2e audacious/newui/newui_window.c --- a/audacious/newui/newui_window.c Sun Nov 12 02:37:32 2006 -0800 +++ b/audacious/newui/newui_window.c Sun Nov 12 03:09:28 2006 -0800 @@ -56,6 +56,7 @@ #include "audacious/playlist.h" #include "audacious/mainwin.h" +#include "audacious/ui_fileinfo.h" GtkWidget *newui_win; @@ -85,15 +86,114 @@ gtk_widget_show(newui_win); } +static void +newui_entry_set_image(const char *text) +{ + GladeXML *xml = g_object_get_data(G_OBJECT(newui_win), "glade-xml"); + GtkWidget *widget = glade_xml_get_widget(xml, "newui_albumart_img"); + GdkPixbuf *pixbuf; + int width, height; + double aspect; + + if (xml == NULL || widget == NULL) + return; + + pixbuf = gdk_pixbuf_new_from_file(text, NULL); + + if (pixbuf == NULL) + return; + + width = gdk_pixbuf_get_width(GDK_PIXBUF(pixbuf)); + height = gdk_pixbuf_get_height(GDK_PIXBUF(pixbuf)); + + if(strcmp(DATA_DIR "/images/audio.png", text)) + { + if(width == 0) + width = 1; + aspect = (double)height / (double)width; + if(aspect > 1.0) { + height = (int)(cfg.filepopup_pixelsize * aspect); + width = cfg.filepopup_pixelsize; + } else { + height = cfg.filepopup_pixelsize; + width = (int)(cfg.filepopup_pixelsize / aspect); + } + GdkPixbuf *pixbuf2 = gdk_pixbuf_scale_simple(GDK_PIXBUF(pixbuf), width, height, GDK_INTERP_BILINEAR); + g_object_unref(G_OBJECT(pixbuf)); + pixbuf = pixbuf2; + } + + gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf)); + g_object_unref(G_OBJECT(pixbuf)); +} + void newui_update_nowplaying_from_entry(PlaylistEntry *entry) { GladeXML *xml = g_object_get_data(G_OBJECT(newui_win), "glade-xml"); GtkWidget *widget; gchar *tmp; + static gchar *last_artwork = NULL; + gchar *fullpath; widget = glade_xml_get_widget(xml, "newui_titlestring"); tmp = g_strdup_printf("%s", entry->title); gtk_label_set_markup(GTK_LABEL(widget), tmp); g_free(tmp); + + if (entry->tuple == NULL) + return; + + widget = glade_xml_get_widget(xml, "newui_label_title"); + gtk_label_set_text(GTK_LABEL(widget), entry->tuple->track_name); + + widget = glade_xml_get_widget(xml, "newui_label_artist"); + gtk_label_set_text(GTK_LABEL(widget), entry->tuple->performer); + + widget = glade_xml_get_widget(xml, "newui_label_album"); + gtk_label_set_text(GTK_LABEL(widget), entry->tuple->album_name); + + widget = glade_xml_get_widget(xml, "newui_label_genre"); + gtk_label_set_text(GTK_LABEL(widget), entry->tuple->genre); + + widget = glade_xml_get_widget(xml, "newui_label_year"); + tmp = g_strdup_printf("%d", entry->tuple->year); + gtk_label_set_text(GTK_LABEL(widget), tmp); + g_free(tmp); + + widget = glade_xml_get_widget(xml, "newui_label_tracknum"); + tmp = g_strdup_printf("%d", entry->tuple->track_number); + gtk_label_set_text(GTK_LABEL(widget), tmp); + g_free(tmp); + + widget = glade_xml_get_widget(xml, "newui_label_tracklen"); + tmp = g_strdup_printf("%d:%02d", entry->tuple->length / 60000, (entry->tuple->length / 1000) % 60); + gtk_label_set_text(GTK_LABEL(widget), tmp); + g_free(tmp); + + if (cfg.use_file_cover) { + /* Use the file name */ + fullpath = g_strconcat(entry->tuple->file_path, "/", entry->tuple->file_name, NULL); + } else { + fullpath = g_strconcat(entry->tuple->file_path, "/", NULL); + } + + if (!last_artwork || strcmp(last_artwork, fullpath)) + { + if (last_artwork != NULL) + g_free(last_artwork); + + last_artwork = g_strdup(fullpath); + + tmp = fileinfo_recursive_get_image(entry->tuple->file_path, entry->tuple->file_name, 0); + if (tmp) + { + newui_entry_set_image(tmp); + g_free(tmp); + } else { + newui_entry_set_image(DATA_DIR "/images/audio.png"); + } + } + + g_free(fullpath); } diff -r 8cca76c8f5c3 -r f027afc2ca2e audacious/playlist.c --- a/audacious/playlist.c Sun Nov 12 02:37:32 2006 -0800 +++ b/audacious/playlist.c Sun Nov 12 03:09:28 2006 -0800 @@ -57,6 +57,8 @@ #include "debug.h" +#include "newui/newui_window.h" + typedef gint (*PlaylistCompareFunc) (PlaylistEntry * a, PlaylistEntry * b); typedef void (*PlaylistSaveFunc) (FILE * file); @@ -847,6 +849,7 @@ playlist_recalc_total_time(); mainwin_set_song_info(rate, freq, nch); + newui_update_nowplaying_from_entry(playlist_position); } void diff -r 8cca76c8f5c3 -r f027afc2ca2e audacious/ui_fileinfo.c --- a/audacious/ui_fileinfo.c Sun Nov 12 02:37:32 2006 -0800 +++ b/audacious/ui_fileinfo.c Sun Nov 12 03:09:28 2006 -0800 @@ -586,8 +586,11 @@ fullpath = g_strconcat(tuple->file_path, "/", NULL); } - if (!last_artwork || strcmp(last_artwork, fullpath)){ - g_free(last_artwork); + if (!last_artwork || strcmp(last_artwork, fullpath)) + { + if (last_artwork != NULL) + g_free(last_artwork); + last_artwork = g_strdup(fullpath); tmp = fileinfo_recursive_get_image(tuple->file_path, tuple->file_name, 0);