ocarina/ocarina/chooser.cpp
Bryan Schumaker 705ca61e6a ocarina: Select a directory to scan
This directory will eventually be scanned and added to the library.
Right now I just print it to the screen.
2011-09-10 10:45:52 -04:00

34 lines
779 B
C++

#include <ocarina/gtk.h>
#include <ocarina/chooser.h>
static string ocarina_generic_chooser(GtkFileChooserAction action)
{
GtkWidget *chooser = gtk_file_chooser_dialog_new(
"Open File", NULL, action,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
char *c_file;
string filename = "";
if ( gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) {
c_file = gtk_file_chooser_get_filename(
GTK_FILE_CHOOSER(chooser));
filename = c_file;
g_free(c_file);
}
gtk_widget_destroy(chooser);
return filename;
}
string ocarina_choose_file()
{
return ocarina_generic_chooser(GTK_FILE_CHOOSER_ACTION_OPEN);
}
string ocarina_choose_dir()
{
return ocarina_generic_chooser(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
}