changeset 2326:258c1b9c29f4

GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on GTK3 and earlier, so the options were just ignored. In GTK4 they are required for creating the GActions so it functions more like OS/2 and Windows now.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 23 Feb 2021 22:43:19 +0000
parents 55524dbe6a54
children 0d7f8136d771
files gtk4/dw.c
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gtk4/dw.c	Tue Feb 23 21:35:06 2021 +0000
+++ b/gtk4/dw.c	Tue Feb 23 22:43:19 2021 +0000
@@ -2839,6 +2839,30 @@
             int menugroup = DW_POINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "_dw_menugroup"));
             char *actionname;
 
+            /* Code to autogenerate a menu ID if not specified or invalid
+             * First pool is smaller for transient popup menus
+             */
+            if(id == (ULONG)-1)
+            {
+               static ULONG tempid = 60000;
+
+               tempid++;
+               id = tempid;
+
+               if(tempid > 65500)
+                  tempid = 60000;
+            }
+            /* Second pool is larger for more static windows */
+            else if(!id || id >= 30000)
+            {
+               static ULONG menuid = 30000;
+
+               menuid++;
+               if(menuid > 60000)
+                  menuid = 30000;
+               id = menuid;
+            }
+
             snprintf(tempbuf, 100, "menu%d.action%lu", menugroup, id);
             actionname = strchr(tempbuf, '.');
             if(check)