61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
/*
|
|
* Copyright 2015 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/idle.h>
|
|
#include <core/playlist.h>
|
|
#include <gui/builder.h>
|
|
#include <gui/idle.h>
|
|
#include <gui/playlist.h>
|
|
#include <glib/gi18n.h>
|
|
|
|
static void __collection_add(GtkFileChooser *chooser)
|
|
{
|
|
gchar *filename = gtk_file_chooser_get_filename(chooser);
|
|
|
|
if (playlist_new(PL_LIBRARY, filename))
|
|
gui_playlist_add_library(library_lookup(filename));
|
|
|
|
gui_idle_enable();
|
|
g_free(filename);
|
|
}
|
|
|
|
void __collection_choose(GtkButton *button, gpointer data)
|
|
{
|
|
GtkFileFilter *filter;
|
|
GtkWidget *dialog;
|
|
gint res;
|
|
|
|
filter = gtk_file_filter_new();
|
|
gtk_file_filter_add_mime_type(filter, "inode/directory");
|
|
|
|
dialog = gtk_file_chooser_dialog_new("Chooser a Path",
|
|
GTK_WINDOW(gui_builder_widget("o_window")),
|
|
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
_("_Open"), GTK_RESPONSE_ACCEPT,
|
|
NULL);
|
|
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
|
|
|
|
res = gtk_dialog_run(GTK_DIALOG(dialog));
|
|
if (res == GTK_RESPONSE_ACCEPT)
|
|
__collection_add(GTK_FILE_CHOOSER(dialog));
|
|
|
|
gtk_widget_destroy(dialog);
|
|
g_object_unref(filter);
|
|
}
|
|
|
|
bool __gui_collection_init_idle()
|
|
{
|
|
struct db_entry *library, *next;
|
|
|
|
db_for_each(library, next, library_db_get())
|
|
gui_playlist_add_library(LIBRARY(library));
|
|
|
|
return true;
|
|
}
|
|
|
|
void gui_collection_init()
|
|
{
|
|
idle_schedule(IDLE_SYNC, __gui_collection_init_idle, NULL);
|
|
}
|