Examples/application4 in gtk-main.tar.gz

Hi,
I am trying to implement the menu exactly as is shown in gtk-main/examples/application4 but quite honestly, it is absolutely impossible for me to follow the source. I am not a complete newbee either and I have a fairly nice gtk4 application going that passes messages between threads that analyze images and sends opengl commands to a compositor that draws GL stuff.
The only thing I cannot get to work is the menu. Do I really need to put my stuff into that 500 extra lines of code to get that menu?

I have no idea why you think you need “500 extra lines of code”.

You need to describe your menu using the XML format, extract the model object, and set the model property in a GtkMenuButton, GtkPopoverMenu or a GtkPopoverMenuBar, depending on the type of menu widget you are creating. Then you need to add actions that match the ones that menu items will activate. Actions are full objects that you add to the application or window instances, depending on their scope; you can also use convenience API like gtk_widget_class_install_action() when you write your own widgets.

A simple example is available in the GTK reference, and there are tutorials on actions and menus in the GNOME developer documentation.

I confess that 500 LOC was a bit of hyperbole on my part but that was the number of lines in the example that I could not follow. Actually, your description here gives me a little more help just by isolating the steps I need to take. Thank you for that.

And btw, thank you for writing about how to use OpenGL in GTK-3 (I know, that was long ago). It was just the help I needed to get going (and I am still going).

Regards

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