Using GtkPopoverMenu as a GtkMenu replacement

I don’t understand what this means.

You can use GtkPopover:autohide.

Well, for one we can’t move a widget out of process, so we can’t really do that. Since the API is the same, we would not be able to distinguish the case.

From an API perspective, adding widgets is a generic code path; when setting a menu model, we are going to add widgets internally, so we can’t distinguish between a widget that was added by you and one added by a model, unless we make the code more brittle. Then it becomes a case of erroring out with a critical warning if you decide to add a widget to a menu that was populate by a model.

In practice, I think you’re kind of overstating your case. There’s nothing that inherently requires that you use menus and/or menu semantics for your UI outside of a main menu bar. We have widgets like overlays to put complex widgets on top of the content area; and popovers, when you need menu-like behaviour.

In some, niche cases, it may require changing how your code is structured, or changing your UI; it can be problematic or it can be a chance to rethink some of the user experience.

You also don’t need to port to GTK4 right away: GTK3 isn’t going anywhere. Maybe in a couple of years we’re going to have more convenience API that will make your use case easier to port to.

In menus, the item the cursor is over is displayed inverted (dark/blue background, light text). Listboxes only display items in this style if it was selected by clicking.

Reading the docs, this only appears to apply to clicks, not to letting go of the mouse button.

Well, since I’m not going to simultaneously maintain a GTK3 and GTK4 version of my app, I’ll have to wait until Gtk 4 is available in all major distros, especially the more slow-moving ones. Rather than complaining when Gtk4 has reached maturity, I prefer getting the discussion going as early as possible.

If that’s an option, popovers should be able to faithfully emulate the behavior of GtkMenu such as activating an item when letting go of the mouse button.

GtkListBox is good example that manually adding widgets and setting models can coexist. Just make it clear that widgets shouldn’t be touched if a model is set.

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