Closed danirabbit closed 2 years ago
This doesn't do much for preparing for GTK4 unfortunately. :)
I'd suggest to instead keep GtkMenu but create it from a menu model. Then it would be fairly easy to replace it with a popover in GTK4 (and also it won't introduce an unwanted arrow - GtkPopover:has-arrow is GTK4-only).
You can synthesise a rectangle at which to popup the menu from the button event that triggers it - presumably this can also be done in Gtk4. However, you may be right that there is not much to gain dealing with this menu in advance of the port.
In gtk4 there's no need to do that because you do popover.set_offset (x, y);
But I mean:
In gtk4 you don't create a popover for a widget - the popover is instead a widget's child. Your size_allocate() must be aware of it and do popover.present(). etc. And implementation-wise it's a completely different widget really, if anything it behaves more like the current GtkMenu. :)
But you can't have GtkModelButtons, so pretty much all of your code will have to go away. You instantiate GtkPopoverMenu from a menu model - that's the only way to create menus, and in gtk3 you can create GtkMenus from the same models. But as is you're replacing one non-portable implementation with another - either way as is you'll have to replace most of it.
Yeah closing. Not sure where I was going with this
In preparation for Gtk4