ui/gtk/menu.c

branch
newapi
changeset 322
22f6dadd9f46
parent 312
3f2b3d15668b
--- a/ui/gtk/menu.c	Thu Oct 03 11:58:09 2024 +0200
+++ b/ui/gtk/menu.c	Thu Oct 03 15:37:55 2024 +0200
@@ -522,10 +522,22 @@
 void ui_gmenu_add_menu_items(GMenu *parent, int i, UiMenu *menu, UiObject *obj) {
     UiMenuItemI *it = menu->items_begin;
     int index = 0;
+    int index_section = 0;
+    GMenu *section = NULL;
     while(it) {
-        createMenuItem[it->type](parent, index, it, obj);
+        if(it->type == UI_MENU_SEPARATOR) {
+            section = g_menu_new();
+            g_menu_append_section(parent, NULL, G_MENU_MODEL(section));
+            index++;
+            index_section = 0;
+        } else {
+            if(section) {
+                createMenuItem[it->type](section, index_section++, it, obj);
+            } else {
+                createMenuItem[it->type](parent, index++, it, obj);
+            }
+        }
         it = it->next;
-        index++;
     }
 }
 
@@ -563,7 +575,7 @@
     }
     
     char action_name[32];
-    snprintf(action_name, 32, "win.%s", item->id);
+    snprintf(action_name, 32, "win.%s", item->id); 
     g_menu_append(parent, i->label, action_name);
 }
 

mercurial