ui/gtk/menu.c

changeset 32
e5f4d8af567e
parent 29
3fc287f06305
child 35
834d9c15a69f
--- a/ui/gtk/menu.c	Mon Feb 12 21:13:23 2024 +0100
+++ b/ui/gtk/menu.c	Sun Jun 09 15:43:08 2024 +0200
@@ -74,6 +74,16 @@
     return mb;
 }
 
+void ui_add_menu_items(GtkWidget *parent, int i, UiMenu *menu, UiObject *obj) {
+    UiMenuItemI *it = menu->items_begin;
+    int index = 0;
+    while(it) {
+        createMenuItem[it->type](parent, index, it, obj);
+        it = it->next;
+        index++;
+    }
+}
+
 void add_menu_widget(GtkWidget *parent, int i, UiMenuItemI *item, UiObject *obj) {
     UiMenu *menu = (UiMenu*)item;
     
@@ -81,14 +91,8 @@
     GtkWidget *menu_item = gtk_menu_item_new_with_mnemonic(menu->label);
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu_widget);
     
-    UiMenuItemI *it = menu->items_begin;
-    int index = 0;
-    while(it) {
-        createMenuItem[it->type](menu_widget, index, it, obj);
-        
-        it = it->next;
-        index++;
-    }
+    ui_add_menu_items(menu_widget, i, menu, obj);
+    
     
     gtk_menu_shell_append(GTK_MENU_SHELL(parent), menu_item);
 }
@@ -105,6 +109,7 @@
         event->userdata = i->userdata;
         event->callback = i->callback;
         event->value = 0;
+        event->customdata = NULL;
 
         g_signal_connect(
                 widget,
@@ -121,7 +126,10 @@
     gtk_menu_shell_append(GTK_MENU_SHELL(parent), widget);
     
     if(i->groups) {
-        uic_add_group_widget(obj->ctx, widget, (ui_enablefunc)ui_set_enabled, i->groups);
+        CxList *groups = cxArrayListCreateSimple(sizeof(int), i->ngroups);
+        cxListAddArray(groups, i->groups, i->ngroups);
+        uic_add_group_widget(obj->ctx, widget, (ui_enablefunc)ui_set_enabled, groups);
+        cxListDestroy(groups);
     }
 }
 
@@ -185,7 +193,8 @@
         event->userdata = ci->userdata;
         event->callback = ci->callback;
         event->value = 0;
-
+        event->customdata = NULL;
+        
         g_signal_connect(
                 widget,
                 "toggled",
@@ -235,8 +244,8 @@
     ls->index = index;
     ls->oldcount = 0;
     
-    // TODO:
-    //ls->list = il->list;
+    UiVar* var = uic_create_var(ui_global_context(), il->varname, UI_VAR_LIST);
+    ls->list = var->value;
     
     ls->callback = il->callback;
     ls->userdata = il->userdata;
@@ -284,6 +293,7 @@
             event->userdata = list->userdata;
             event->callback = list->callback;
             event->value = i - 1;
+            event->customdata = NULL;
 
             g_signal_connect(
                 widget,
@@ -408,6 +418,7 @@
         event->userdata = userdata;
         event->callback = f;
         event->value = 0;
+        event->customdata = NULL;
 
         g_signal_connect(
                 widget,
@@ -462,6 +473,7 @@
         event->userdata = userdata;
         event->callback = f;
         event->value = 0;
+        event->customdata = NULL;
 
         g_signal_connect(
                 widget,

mercurial