# HG changeset patch # User Olaf Wintermann # Date 1781723210 -7200 # Node ID 833c37fc5475961cb551be2d175a2678e9870629 # Parent 4637da12bc6c0bdeea145720b6d2747ac93af4c9 implement toggled_by_state arg for the content toggle button (GTK) diff -r 4637da12bc6c -r 833c37fc5475 application/main.c --- a/application/main.c Wed Jun 17 20:54:22 2026 +0200 +++ b/application/main.c Wed Jun 17 21:06:50 2026 +0200 @@ -731,7 +731,8 @@ ui_button(obj, .label = "Disable Group 2", .onclick = action_group2, .onclickdata = "disable"); ui_newline(obj); - ui_content_togglebutton(obj, .label0 = "Off", .label1 = "On", .tooltip0 = "enable", .tooltip1 = "disable", .istogglebutton = TRUE, .onchange = content_toggled, .varname = "ctntoggle"); + ui_content_togglebutton(obj, .label0 = "Off", .label1 = "On", .tooltip0 = "enable", .tooltip1 = "disable", .istogglebutton = TRUE, .onchange = content_toggled, .varname = "ctntoggle", .toggled_by_state = 2501); + ui_togglebutton(obj, .label = "Toggle", .enable_state = 2501); ui_newline(obj); ui_button(obj, .label = "Groups 1,2", .colspan = 2, .states = UI_STATES(1, 2)); diff -r 4637da12bc6c -r 833c37fc5475 ui/gtk/button.c --- a/ui/gtk/button.c Wed Jun 17 20:54:22 2026 +0200 +++ b/ui/gtk/button.c Wed Jun 17 21:06:50 2026 +0200 @@ -629,6 +629,14 @@ free(button); } +static void ui_content_togglebutton_enabled_by_state(void *data, int enabled) { + UiContentToggleButton *button = data; + if(button->toggled != enabled) { + button->toggled = enabled; + content_toggle_button_changed(button); + } +} + UIWIDGET ui_create_content_togglebutton(UiObject *obj, UiContentToggleArgs *args) { UiContentToggleButton *button = malloc(sizeof(UiContentToggleButton)); memset(button, 0, sizeof(UiContentToggleButton)); @@ -684,6 +692,13 @@ gtk_widget_set_tooltip_text(widget, tooltip); button->widget = widget; + if(args->toggled_by_state != 0) { + CxList *ls = cxArrayListCreate(NULL, sizeof(int), 1); + cxListAdd(ls, &args->toggled_by_state); + uic_add_state_widget(obj->ctx, button, ui_content_togglebutton_enabled_by_state, ls); + cxListFree(ls); + } + g_signal_connect( widget, "destroy",