gui/audio: Add support for manually setting album art
Implements #58: Manually set album art Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
e30f7f8115
commit
c62a88ce09
32
gui/audio.c
32
gui/audio.c
|
@ -9,6 +9,7 @@
|
|||
#include <gui/builder.h>
|
||||
#include <gui/idle.h>
|
||||
#include <gui/view.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
static bool __audio_have_cover = false;
|
||||
|
||||
|
@ -54,11 +55,40 @@ static void __audio_get_cover(struct track *track)
|
|||
gtk_image_set_from_pixbuf(cover, pix);
|
||||
g_object_unref(G_OBJECT(pix));
|
||||
} else
|
||||
gtk_image_set_from_icon_name(cover, NULL, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_image_set_from_icon_name(cover, "image-missing", GTK_ICON_SIZE_DIALOG);
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(cover), pix != NULL);
|
||||
__audio_have_cover = (pix != NULL);
|
||||
}
|
||||
|
||||
void __audio_select_cover(GtkButton *button)
|
||||
{
|
||||
GtkFileFilter *filter;
|
||||
GtkWidget *dialog;
|
||||
gchar *path;
|
||||
|
||||
filter = gtk_file_filter_new();
|
||||
dialog = gtk_file_chooser_dialog_new("Choose an image",
|
||||
GTK_WINDOW(gui_builder_widget("o_window")),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_("_Open"), GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
gtk_file_filter_add_mime_type(filter, "image/*");
|
||||
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
|
||||
gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(dialog), true);
|
||||
|
||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
||||
path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
||||
album_artwork_import(audio_cur_track()->tr_album, path);
|
||||
g_free(path);
|
||||
}
|
||||
|
||||
gtk_widget_destroy(dialog);
|
||||
g_object_unref(filter);
|
||||
}
|
||||
|
||||
static void __audio_load(struct track *track)
|
||||
{
|
||||
__audio_set_label("o_title", "xx-large", track->tr_title);
|
||||
|
|
|
@ -245,6 +245,11 @@
|
|||
<column type="gpointer"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkImage" id="o_cover">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_size">6</property>
|
||||
</object>
|
||||
<object class="GtkTreeStore" id="o_playlist_store">
|
||||
<columns>
|
||||
<!-- column-name Image -->
|
||||
|
@ -452,10 +457,13 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="o_cover">
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_size">6</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">o_cover</property>
|
||||
<property name="relief">none</property>
|
||||
<signal name="clicked" handler="__audio_select_cover" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -1447,10 +1455,10 @@
|
|||
</object>
|
||||
<object class="GtkSizeGroup">
|
||||
<widgets>
|
||||
<widget name="o_cover"/>
|
||||
<widget name="buttonbox4"/>
|
||||
<widget name="o_pause_after"/>
|
||||
<widget name="o_enable"/>
|
||||
<widget name="button1"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkSizeGroup">
|
||||
|
|
Loading…
Reference in New Issue