GTK4 and dynamical menus

Dear GTK developers and users,
first of all happy new year 2022 !

I write this message today in the hope to get some follow up on my previous post about the gtk_popover_menu_bar_add_child function.

I am in the process of migrating my program from GTK3 to GTK4. For the migration to be complete and the GTK4 version to be working I really need to have the freedom to add and/or remove items from menus, but so far I was not able to find any way to achieve it.
Could anyone help me to clarify the following:

  • is it worth it to spend some time working on a GTK4 version of my app as of today, considering that I need some “add / remove item from menu functions” to be available ?

  • Will these kind of menu functions be available latter on in GTK4, I am not in a position to discuss whether or not it should be the case, but considering that I really need it, It would help me decide if I can keep using GTK, and I would like to, or if I should start thinking about using another API.

Again thanks in advance for your reply and again all the best for 2022.


Epiphany also wants this feature.

Of course the workaround is not very complicated: destroy the menu and use a different menu instead. But it becomes a combinatorial problem when you have several different menu items that have to be displayed or hidden independently…

Pretty sure nautilus (at least nautilus extensions) wants it too.

You can of course build dynamic menus out of the GMenu and GMenuModel API. The things become slightly more complex if you have extension points, like plugins, that add and remove menus and menu items depending on whether they have been enabled or disabled at run time. We lack a decent API for that.

AFAIR, @hergertme had some wrapper API for GNOME Builder; I think we could expand the API in GIO to have a better story for extensible menus.

1 Like

This can already be somewhat handled by hidden-when

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.