
#include <ocarina/settings.h>
#include <ocarina/chooser.h>
#include <ocarina/button.h>
#include <ocarina/gtk.h>

#include <libsaria/library.h>
#include <libsaria/print.h>

/* This is a gtk vbox */
static GtkWidget *library_settings = NULL;

static void on_click_add(GtkWidget *b, GdkEvent *e, gpointer d)
{
	string dir = ocarina_choose_dir();
	if (dir != "" ) {
		println("Scanning dir: " + dir);
		libsaria_add_library(dir);
	}
}

static GtkWidget *make_add_button()
{
	return make_text_button(GTK_STOCK_ADD,
				"Add to Library",
				on_click_add,
				true);
}

void library_settings_init()
{
	GtkWidget *add_button = gtk_hbox_new(FALSE, 0);
	library_settings      = gtk_vbox_new(FALSE, 0);

	box_pack_start(library_settings, add_button, FALSE, FALSE, 0);
	box_pack_end(add_button, make_add_button(),  FALSE, FALSE, 0);

	gtk_widget_show(library_settings);
	gtk_widget_show(add_button);
	add_settings_page("Library", library_settings);
}
