--- a/ui/gtk/button.c Wed Dec 17 22:36:41 2025 +0100 +++ b/ui/gtk/button.c Sat Dec 27 22:47:56 2025 +0100 @@ -241,6 +241,8 @@ event->observers = NULL; event->callback = NULL; event->userdata = NULL; + event->customint1 = 0; + event->customint2 = 0; g_signal_connect( widget, @@ -397,7 +399,7 @@ UiVarEventData *event) { GtkSwitch *sw = GTK_SWITCH (gobject); - gboolean active = gtk_switch_get_active (sw); + gboolean active = gtk_switch_get_active(sw); UiEvent e; e.obj = event->obj; @@ -405,6 +407,7 @@ e.window = e.obj->window; e.eventdata = NULL; e.eventdatatype = 0; + e.intval = active; e.set = ui_get_setop(); if(event->callback) { @@ -414,6 +417,13 @@ UiInteger *i = event->var->value; ui_notify_evt(i->observers, &e); } + if(event->customint1 > 0) { + if(active) { + ui_set_state(e.obj->ctx, event->customint1); + } else { + ui_unset_state(e.obj->ctx, event->customint1); + } + } } UIWIDGET ui_switch_create(UiObject* obj, UiToggleArgs *args) { @@ -436,11 +446,13 @@ } UiVarEventData *event = malloc(sizeof(UiVarEventData)); + memset(event, 0, sizeof(UiVarEventData)); event->obj = obj; event->callback = args->onchange; event->userdata = args->onchangedata; event->var = var; event->observers = NULL; + event->customint1 = args->enable_state; g_signal_connect( widget, @@ -453,7 +465,7 @@ "destroy", G_CALLBACK(ui_destroy_vardata), event); - + UiContainerPrivate *ct = (UiContainerPrivate*)obj->container_end; UiLayout layout = UI_ARGS2LAYOUT(args); ct->add(ct, widget, &layout); @@ -565,6 +577,8 @@ event->observers = NULL; event->callback = NULL; event->userdata = NULL; + event->customint1 = 0; + event->customint2 = 0; UiRadioButtonData *rbdata = malloc(sizeof(UiRadioButtonData)); rbdata->value = rgroup; @@ -773,24 +787,24 @@ static char* create_linkbutton_jsonvalue(const char *label, const char *uri, gboolean include_null, gboolean visited, gboolean set_visited) { CxJsonValue *obj = cxJsonCreateObj(NULL); if(label) { - cxJsonObjPutString(obj, CX_STR("label"), label); + cxJsonObjPutString(obj, cx_str("label"), label); } else if(include_null) { - cxJsonObjPutLiteral(obj, CX_STR("label"), CX_JSON_NULL); + cxJsonObjPutLiteral(obj, cx_str("label"), CX_JSON_NULL); } if(uri) { - cxJsonObjPutString(obj, CX_STR("uri"), uri); + cxJsonObjPutString(obj, cx_str("uri"), uri); } else if(include_null) { - cxJsonObjPutLiteral(obj, CX_STR("uri"), CX_JSON_NULL); + cxJsonObjPutLiteral(obj, cx_str("uri"), CX_JSON_NULL); } if(set_visited) { - cxJsonObjPutLiteral(obj, CX_STR("visited"), visited ? CX_JSON_TRUE : CX_JSON_FALSE); + cxJsonObjPutLiteral(obj, cx_str("visited"), visited ? CX_JSON_TRUE : CX_JSON_FALSE); } CxJsonWriter writer = cxJsonWriterCompact(); CxBuffer buf; - cxBufferInit(&buf, NULL, 128, NULL, CX_BUFFER_AUTO_EXTEND); + cxBufferInit(&buf, NULL, NULL, 128, CX_BUFFER_AUTO_EXTEND); cxJsonWrite(&buf, obj, (cx_write_func)cxBufferWrite, &writer); cxJsonValueFree(obj); cxBufferTerminate(&buf);