ui/gtk/menu.c

branch
newapi
changeset 392
df62b7205bd3
parent 391
fc0df448dfbc
child 395
b8277deb75b8
--- a/ui/gtk/menu.c	Tue Nov 26 10:02:04 2024 +0100
+++ b/ui/gtk/menu.c	Tue Nov 26 10:40:03 2024 +0100
@@ -432,12 +432,23 @@
     g_menu_append_submenu(parent, mi->label, G_MENU_MODEL(menu));
 }
 
+static void action_enable(GSimpleAction *action, int enabled) {
+    g_simple_action_set_enabled(action, enabled);
+}
+
 void ui_gmenu_add_menuitem(GMenu *parent, int index, UiMenuItemI *item, UiObject *obj) {
     UiMenuItem *i = (UiMenuItem*)item;
-
+     
     GSimpleAction *action = g_simple_action_new(item->id, NULL);
     g_action_map_add_action(obj->ctx->action_map, G_ACTION(action));
     
+    if(i->groups) {
+        CxList *groups = cxArrayListCreateSimple(sizeof(int), i->ngroups);
+        cxListAddArray(groups, i->groups, i->ngroups);
+        uic_add_group_widget(obj->ctx, action, (ui_enablefunc)action_enable, groups);
+        cxListDestroy(groups);
+    }
+    
     if(i->callback != NULL) {
         UiEventData *event = malloc(sizeof(UiEventData));
         event->obj = obj;

mercurial