ocarina: Add the chooser to the ocarina namespace
This removes some ocarina_*() functions
This commit is contained in:
parent
7c79aab787
commit
0b1684620d
|
@ -4,7 +4,12 @@
|
|||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
string ocarina_choose_file();
|
||||
string ocarina_choose_dir();
|
||||
namespace ocarina
|
||||
{
|
||||
|
||||
string choose_file();
|
||||
string choose_dir();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -59,7 +59,7 @@ GtkWidget *make_text_button(const gchar *stockid,
|
|||
|
||||
static void on_click_open_file(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
string file = ocarina_choose_file();
|
||||
string file = ocarina::choose_file();
|
||||
if (file != "") {
|
||||
println("Playing file: " + file);
|
||||
libsaria::audio::load(file);
|
||||
|
|
|
@ -2,32 +2,36 @@
|
|||
#include <ocarina/gtk.h>
|
||||
#include <ocarina/chooser.h>
|
||||
|
||||
static string ocarina_generic_chooser(GtkFileChooserAction action)
|
||||
namespace ocarina
|
||||
{
|
||||
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);
|
||||
static string 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;
|
||||
}
|
||||
gtk_widget_destroy(chooser);
|
||||
return filename;
|
||||
}
|
||||
|
||||
string ocarina_choose_file()
|
||||
{
|
||||
return ocarina_generic_chooser(GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
}
|
||||
string choose_file()
|
||||
{
|
||||
return generic_chooser(GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
}
|
||||
|
||||
string ocarina_choose_dir()
|
||||
{
|
||||
return ocarina_generic_chooser(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
}
|
||||
string choose_dir()
|
||||
{
|
||||
return generic_chooser(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ static list<PathInfo> path_widgets;
|
|||
|
||||
static void on_click_add(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
string dir = ocarina_choose_dir();
|
||||
string dir = ocarina::choose_dir();
|
||||
if (dir != "" ) {
|
||||
println("Scanning dir: " + dir);
|
||||
libsaria::library::add_path(dir);
|
||||
|
|
Loading…
Reference in New Issue