client/args.c

changeset 948
94bc57d63128
parent 942
488178e3e328
child 966
e411ed7c5f10
--- a/client/args.c	Wed Dec 03 18:45:05 2025 +0100
+++ b/client/args.c	Thu Dec 04 19:04:08 2025 +0100
@@ -232,3 +232,40 @@
     
     return args;
 }
+
+UiToggleArgs* json2toggle_args(const CxJsonValue *value) {
+    UiToggleArgs *args = ui_toggle_args_new();
+    if(value->type != CX_JSON_OBJECT) {
+        return args;
+    }
+    
+    init_common_args(value, args, &button_args);
+    init_groups(value, args, (argfunc_set_intarray)ui_button_args_set_groups);
+    
+    CxJsonValue *val = cxJsonObjGet(value, "label");
+    if(val && val->type == CX_JSON_STRING) {
+        ui_toggle_args_set_label(args, val->value.string.ptr);
+    }
+    
+    val = cxJsonObjGet(value, "icon");
+    if(val && val->type == CX_JSON_STRING) {
+        ui_toggle_args_set_icon(args, val->value.string.ptr);
+    }
+    
+    val = cxJsonObjGet(value, "tooltip");
+    if(val && val->type == CX_JSON_STRING) {
+        ui_toggle_args_set_tooltip(args, val->value.string.ptr);
+    }
+    
+    val = cxJsonObjGet(value, "labeltype");
+    if(val && val->type == CX_JSON_INTEGER) {
+        ui_toggle_args_set_labeltype(args, (int)val->value.integer);
+    }
+    
+    val = cxJsonObjGet(value, "enable_group");
+    if(val && val->type == CX_JSON_INTEGER) {
+        ui_toggle_args_set_enablegroup(args, (int)val->value.integer);
+    }
+    
+    return args;
+}

mercurial