port radiobutton to the new API (GTK) newapi

Wed, 14 Feb 2024 22:00:41 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 14 Feb 2024 22:00:41 +0100
branch
newapi
changeset 258
a252f68c665a
parent 257
a334f9ebc5d0
child 259
8cce275d2847

port radiobutton to the new API (GTK)

ui/gtk/button.c file | annotate | diff | comparison | revisions
--- a/ui/gtk/button.c	Mon Feb 12 22:11:33 2024 +0100
+++ b/ui/gtk/button.c	Wed Feb 14 22:00:41 2024 +0100
@@ -163,16 +163,25 @@
 
 
 
-UIWIDGET ui_radiobutton_var(UiObject *obj, char *label, UiVar *var) {
+UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs args) {
+    UiObject* current = uic_current_obj(obj);
+    
     GSList *rg = NULL;
     UiInteger *rgroup;
     
+    UiVar* var = NULL;
+    if (args.value) {
+        var = uic_create_value_var(current->ctx, args.value);
+    } else if (args.varname) {
+        var = uic_create_var(obj->ctx, args.varname, UI_VAR_INTEGER);
+    }
+    
     if(var) {
         rgroup = var->value;
         rg = rgroup->obj;
     }
     
-    GtkWidget *rbutton = gtk_radio_button_new_with_label(rg, label);
+    GtkWidget *rbutton = gtk_radio_button_new_with_label(rg, args.label ? args.label : "");
     rg = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbutton));
     
     if(rgroup) {
@@ -205,21 +214,6 @@
     return rbutton;
 }
 
-UIWIDGET ui_radiobutton_deprecated(UiObject *obj, char *label, UiInteger *rgroup) {
-    UiVar *var = NULL;
-    if(rgroup) {
-        var = malloc(sizeof(UiVar));
-        var->value = rgroup;
-        var->type = UI_VAR_SPECIAL;
-    }
-    return ui_radiobutton_var(obj, label, var);
-}
-
-UIWIDGET ui_radiobutton_nv(UiObject *obj, char *label, char *varname) {
-    UiVar *var = uic_create_var(obj->ctx, varname, UI_VAR_INTEGER);
-    return ui_radiobutton_var(obj, label, var);
-}
-
 void ui_radio_obs(GtkToggleToolButton *widget, UiVarEventData *event) {
     UiInteger *i = event->var->value;
     

mercurial