diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-09 23:47:03 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-09 23:48:04 -0400 |
| commit | 64b746c9a11ad644c0482824c59bd5542e5697b3 (patch) | |
| tree | eed8cb341240bf08e9c2f14e748b7b02eb9289a6 /new/checkbox_unix.c | |
| parent | a9115b352c5b1ec6ba37c483d69d816757652d72 (diff) | |
Decided that uiCheckboxSetChecked() should NOT trigger an event. This required changing the GTK+ backend to make it so; the Windows and Mac OS X backends are fine (setting their checkbox state programmatically will not send a signal; thanks to ThunderSnow in irc.freenode.net/#macdev for confirming this for Mac OS X).
Diffstat (limited to 'new/checkbox_unix.c')
| -rw-r--r-- | new/checkbox_unix.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/new/checkbox_unix.c b/new/checkbox_unix.c index c0d509e..ddf9eda 100644 --- a/new/checkbox_unix.c +++ b/new/checkbox_unix.c @@ -4,6 +4,7 @@ struct checkbox { void (*onToggled)(uiControl *, void *); void *onToggledData; + gulong onToggledSignal; }; static void onToggled(GtkToggleButton *b, gpointer data) @@ -38,10 +39,10 @@ uiControl *uiNewCheckbox(const char *text) NULL); widget = GTK_WIDGET(uiControlHandle(c)); - g_signal_connect(widget, "toggled", G_CALLBACK(onToggled), c); cc = uiNew(struct checkbox); g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), cc); + cc->onToggledSignal = g_signal_connect(widget, "toggled", G_CALLBACK(onToggled), c); cc->onToggled = defaultOnToggled; c->data = cc; @@ -73,10 +74,16 @@ int uiCheckboxChecked(uiControl *c) void uiCheckboxSetChecked(uiControl *c, int checked) { + struct checkbox *cc = (struct checkbox *) (c->data); + GtkToggleButton *button; gboolean active; active = FALSE; if (checked) active = TRUE; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(uiControlHandle(c)), active); + // we need to inhibit sending of ::toggled because this WILL send a ::toggled otherwise + button = GTK_TOGGLE_BUTTON(uiControlHandle(c)); + g_signal_handler_block(button, cc->onToggledSignal); + gtk_toggle_button_set_active(button, active); + g_signal_handler_unblock(button, cc->onToggledSignal); } |
