diff options
author | Arisotura <thetotalworm@gmail.com> | 2020-04-25 18:51:08 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2020-04-25 18:51:08 +0200 |
commit | a85d41c53eed50f188502925ed34674397b86550 (patch) | |
tree | e33b042b8114f7ad587257d79bad021d5e617a44 /src/libui_sdl/libui/unix/checkbox.c | |
parent | 3b3a09ed2b7a1f3d6f81ba6d1ddd7fbf17acd52d (diff) |
berp.
Diffstat (limited to 'src/libui_sdl/libui/unix/checkbox.c')
-rw-r--r-- | src/libui_sdl/libui/unix/checkbox.c | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/libui_sdl/libui/unix/checkbox.c b/src/libui_sdl/libui/unix/checkbox.c deleted file mode 100644 index 47f8514..0000000 --- a/src/libui_sdl/libui/unix/checkbox.c +++ /dev/null @@ -1,78 +0,0 @@ -// 10 june 2015 -#include "uipriv_unix.h" - -struct uiCheckbox { - uiUnixControl c; - GtkWidget *widget; - GtkButton *button; - GtkToggleButton *toggleButton; - GtkCheckButton *checkButton; - void (*onToggled)(uiCheckbox *, void *); - void *onToggledData; - gulong onToggledSignal; -}; - -uiUnixControlAllDefaults(uiCheckbox) - -static void onToggled(GtkToggleButton *b, gpointer data) -{ - uiCheckbox *c = uiCheckbox(data); - - (*(c->onToggled))(c, c->onToggledData); -} - -static void defaultOnToggled(uiCheckbox *c, void *data) -{ - // do nothing -} - -char *uiCheckboxText(uiCheckbox *c) -{ - return uiUnixStrdupText(gtk_button_get_label(c->button)); -} - -void uiCheckboxSetText(uiCheckbox *c, const char *text) -{ - gtk_button_set_label(GTK_BUTTON(c->button), text); -} - -void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *, void *), void *data) -{ - c->onToggled = f; - c->onToggledData = data; -} - -int uiCheckboxChecked(uiCheckbox *c) -{ - return gtk_toggle_button_get_active(c->toggleButton) != FALSE; -} - -void uiCheckboxSetChecked(uiCheckbox *c, int checked) -{ - gboolean active; - - active = FALSE; - if (checked) - active = TRUE; - // we need to inhibit sending of ::toggled because this WILL send a ::toggled otherwise - g_signal_handler_block(c->toggleButton, c->onToggledSignal); - gtk_toggle_button_set_active(c->toggleButton, active); - g_signal_handler_unblock(c->toggleButton, c->onToggledSignal); -} - -uiCheckbox *uiNewCheckbox(const char *text) -{ - uiCheckbox *c; - - uiUnixNewControl(uiCheckbox, c); - - c->widget = gtk_check_button_new_with_label(text); - c->button = GTK_BUTTON(c->widget); - c->toggleButton = GTK_TOGGLE_BUTTON(c->widget); - c->checkButton = GTK_CHECK_BUTTON(c->widget); - - c->onToggledSignal = g_signal_connect(c->widget, "toggled", G_CALLBACK(onToggled), c); - uiCheckboxOnToggled(c, defaultOnToggled, NULL); - - return c; -} |