diff --git a/gui/audio.c b/gui/audio.c index f25756a6..e193880c 100644 --- a/gui/audio.c +++ b/gui/audio.c @@ -7,8 +7,10 @@ #include #include #include +#include #include +static bool __audio_have_cover = false; static inline void __audio_set_label(const gchar *label, const gchar *size, const gchar *text) @@ -26,6 +28,33 @@ static inline void __audio_set_time_label(const gchar *label, unsigned int time) g_free(str); } +static void __audio_set_cover(gchar *path) +{ + GtkImage *image = GTK_IMAGE(gui_builder_widget("o_cover")); + GtkWidget *tags = gui_builder_widget("o_tags"); + int height = gtk_widget_get_allocated_height(tags); + GdkPixbuf *pix = gdk_pixbuf_new_from_file_at_size(path, height, + height, NULL); + + gtk_image_set_from_pixbuf(image, pix); + gtk_widget_show(GTK_WIDGET(image)); + __audio_have_cover = true; +} + +static void __audio_get_cover(struct track *track) +{ + gchar *path = album_artwork_path(track->tr_album); + + if (path) { + __audio_set_cover(path); + g_free(path); + } else { + gtk_widget_hide(gui_builder_widget("o_cover")); + gui_idle_enable(); + __audio_have_cover = false; + } +} + static void __audio_load(struct track *track) { __audio_set_label("o_title", "xx-large", track->tr_title); @@ -37,7 +66,9 @@ static void __audio_load(struct track *track) playlist_has(PL_HIDDEN, track)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui_builder_widget("o_favorite")), playlist_has(PL_FAVORITED, track)); + gui_view_scroll(); + __audio_get_cover(track); } static void __audio_change_state(GstState state) @@ -87,12 +118,21 @@ void __audio_hide(GtkToggleButton *toggle, gpointer data) static int __audio_timeout(gpointer data) { + struct track *track = audio_cur_track(); GtkAdjustment *progress = data; gtk_adjustment_set_upper(progress, audio_duration() / GST_SECOND); gtk_adjustment_set_value(progress, audio_position() / GST_SECOND); __audio_set_time_label("o_position", audio_position() / GST_SECOND); + if (track && !__audio_have_cover) { + gchar *path = album_artwork_path(track->tr_album); + if (path) { + __audio_set_cover(path); + g_free(path); + } + } + return G_SOURCE_CONTINUE; } diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index a02b4ded..c73532de 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -303,7 +303,7 @@ True False - True + 5 True @@ -453,12 +453,11 @@ 0 0 - 2 3 - + True True 5 @@ -551,7 +550,6 @@ 2 0 - 4 2 @@ -559,6 +557,7 @@ True False + True 5 @@ -571,7 +570,7 @@ False - True + False 0 @@ -580,6 +579,7 @@ True False center + True o_progress 0 False @@ -597,12 +597,13 @@ True False center + 15 <span size='large'>0:00</span> True False - True + False 2 @@ -610,7 +611,6 @@ 2 2 - 3 @@ -754,9 +754,8 @@ - 5 + 3 1 - 2 2 @@ -806,7 +805,7 @@ - 6 + 3 0 @@ -1437,7 +1436,21 @@ 0 3 - 7 + 4 + + + + + True + False + 10 + 10 + 6 + + + 1 + 0 + 3 @@ -1452,6 +1465,7 @@ + True