ocarina/ocarina/buttons/button.cpp

35 lines
807 B
C++

#include <ocarina/button.h>
#include <ocarina/chooser.h>
#include <libsaria/print.h>
#include <libsaria/controls.h>
GtkWidget *make_button(const gchar *stockid,
void (* func)(GtkWidget *, GdkEvent *, gpointer),
bool show)
{
GtkWidget *button = gtk_button_new();
GtkWidget *image = gtk_image_new_from_stock(stockid,
GTK_ICON_SIZE_MENU);
gtk_widget_show(image);
GTK_CONNECT(button, "clicked", func, NULL);
container_add(button, image);
if (show == true)
gtk_widget_show_all(button);
return button;
}
static void on_click_open_file(GtkWidget *b, GdkEvent *e, gpointer d)
{
string file = ocarina_choose_file();
print("Playing file: " + file);
libsaria_load(file);
}
GtkWidget *make_open_button()
{
return make_button(GTK_STOCK_OPEN, on_click_open_file, true);
}