#include #include #include #include static GtkWidget *get_toggle_button(void (* func)(GtkWidget *, GdkEvent *, gpointer), bool state, bool show) { GtkWidget *button = gtk_toggle_button_new(); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), state == TRUE); GTK_CONNECT(button, "toggled", func, NULL); if (show == true) gtk_widget_show(button); return button; } static GtkWidget *get_image(string path) { GtkWidget *image = gtk_image_new(); gtk_image_set_from_file(GTK_IMAGE(image), path.c_str()); gtk_widget_show(image); return image; } static GtkWidget *make_toggle_button(string file, void (* func)(GtkWidget *, GdkEvent *, gpointer), bool state, bool show) { GtkWidget *button = get_toggle_button(func, state, show); GtkWidget *image = get_image(file); container_add(button, image); return button; } static void toggle_random(GtkWidget *b, GdkEvent *e, gpointer d) { bool active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b)) == TRUE; libsaria::prefs::set("random", active); } GtkWidget *make_random_button() { return make_toggle_button(ocarina::full_path("images/random.png"), toggle_random, libsaria::prefs::get_bool("random"), true); }