I’m trying to understand how popup menus work in Gtk nowadays ; I used to be able to do it before with uibuilder’s menu.popup() but now it’s deprecated, I also see in Glade that the “tearoff” attribute for menus is deprecated too (and indeed just checking it in breaks everything) so I’m a bit confused about what the good practice is.
I have my menu defined in Glade, it shows and works, I have an Eventbox around the zone I want to cover, I’m passing the “file” submenu though the “user_data” param of the “button-pressed” event of the Eventbox in Glade, and I do get the event.button == 3 back alright, but when I menu.show() nothing happens, not even a warning…?
I tried passing the whole menu but then I got errors, so it seems like I got the right object, I just don’t know how to show it / pop it open
Maybe I’m missing some Gtk.FLAG in the main window, but I can’t find where, in Glade, would I set such flags…?
1-It is my understanding that in order to use Gio actions one must adopt the Application framework and I’d love to; The thing is, I’m using Glade to define my window, so the whole
# We only allow a single window and raise any existing ones
if not self.window:
# Windows are associated with the application
# when the last one is closed the application shuts down
self.window = AppWindow(application=self, title="Main Window")
Breaks my subsequently (the sequence is startup -activate - window) defined window (in AppWindow) ; At this point I obviously have two windows, and the app quits gracefully. I could not overcome this in a whole day of trying, if you know how to do that I would be eternally grateful for your enlightenment it would make my code so much cleaner.
2-Sooo the option of just poping up the menu in the old fashion way (like not in a popover, that BTW has compositing / transparency problems on other WMs, notably i3 here, I’m just saying, I like the popover don’t get me wrong) by just building a temporary structure containing the existing menu items that I want to show is… Out now ?
will create a new window every time the application gets activated. The important part is setting the application property when creating the new window. Once every window tracked by the application gets closed, the application will automatically terminate.
with GTK3 you can create a Gtk.Menu instance from a Gio.Menu model, and then pop up the menu widget; in GTK4, menus-as-widgets have been removed, which means you cannot construct a menu out of widgets, but you can only use the Gio.Menu model to describe its contents.
If your window manager does not support compositing on X11, please: fix the window manager, or require a compositor. It’s 2022, not 1997, and the only way app developers and toolkit developers test their project is under a compositing window manager—either X11 or, more likely, Wayland. Uncomposited X11 is broken by design.
That didn’t work, and I understand, you can’t have two main windows definitions ; I found a workaround by just getting the main box from the Glade file, on which I used “remove parent” I mean you gotta love Glade. I’m gonna use it for just what you said: Fragments of xml, and it’s going to work great. And when I’m done with Glade I can write my own definitions, but for now I’m learning.
Seriously, there will be no official Gtk4 interface designer? That’s a sad thing to hear.
I am one of the admins of the GNOME Discourse and one of the people working on GTK (and a bunch of other GNOME projects), but I have never contributed to GIMP, so I can’t take the credit for anything done by the GIMP developers.