2015-12-29 09:45:15 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2015 (c) Anna Schumaker.
|
|
|
|
*/
|
2016-04-29 17:03:44 -04:00
|
|
|
#include <core/idle.h>
|
2016-01-21 10:16:37 -05:00
|
|
|
#include <core/playlist.h>
|
2015-12-29 09:45:15 -05:00
|
|
|
#include <gui/builder.h>
|
2016-02-18 08:34:28 -05:00
|
|
|
#include <gui/idle.h>
|
2016-05-11 08:09:27 -04:00
|
|
|
#include <gui/playlist.h>
|
2016-05-11 10:20:21 -04:00
|
|
|
#include <glib/gi18n.h>
|
2015-12-29 09:45:15 -05:00
|
|
|
|
2016-05-11 10:44:12 -04:00
|
|
|
static void __collection_add(GtkFileChooser *chooser)
|
2015-12-30 10:38:32 -05:00
|
|
|
{
|
|
|
|
gchar *filename = gtk_file_chooser_get_filename(chooser);
|
|
|
|
|
2016-05-11 10:44:12 -04:00
|
|
|
if (playlist_new(PL_LIBRARY, filename))
|
|
|
|
gui_playlist_add_library(library_lookup(filename));
|
2015-12-30 10:38:32 -05:00
|
|
|
|
2016-02-18 08:34:28 -05:00
|
|
|
gui_idle_enable();
|
2015-12-30 10:38:32 -05:00
|
|
|
g_free(filename);
|
|
|
|
}
|
|
|
|
|
2016-05-11 10:20:21 -04:00
|
|
|
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)
|
2016-05-11 10:44:12 -04:00
|
|
|
__collection_add(GTK_FILE_CHOOSER(dialog));
|
2016-05-11 10:20:21 -04:00
|
|
|
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
g_object_unref(filter);
|
|
|
|
}
|
|
|
|
|
2016-05-02 18:42:38 -04:00
|
|
|
bool __gui_collection_init_idle()
|
2015-12-29 09:45:15 -05:00
|
|
|
{
|
2015-12-31 09:35:11 -05:00
|
|
|
struct db_entry *library, *next;
|
2016-04-29 17:03:44 -04:00
|
|
|
|
2016-05-11 10:44:12 -04:00
|
|
|
db_for_each(library, next, library_db_get())
|
2016-05-11 08:09:27 -04:00
|
|
|
gui_playlist_add_library(LIBRARY(library));
|
2016-05-11 10:44:12 -04:00
|
|
|
|
2016-05-02 18:42:38 -04:00
|
|
|
return true;
|
2016-04-29 17:03:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_collection_init()
|
|
|
|
{
|
2016-04-30 09:16:02 -04:00
|
|
|
idle_schedule(IDLE_SYNC, __gui_collection_init_idle, NULL);
|
2015-12-30 10:38:32 -05:00
|
|
|
}
|