Toggling on/off icon visibility in GMenu items


I am populating a GMenu from a .ui file and then setting it as the application menu bar with Gtk::ApplicationWindow::set_menubar(). Some of the items have icons. The icons are by default visible with GTK3 but not with GTK4. I can use the Inspector to turn on/off icon visibility in both GTK3 and GTK4 by toggling the ‘visible’ property but can’t figure out how to do in programmatically.

Inkscape using GtkMenu offers users a preference option to choose between:

  1. All icons hidden
  2. All icons visible
  3. A small subset of icons visible (the default).

How can implement this with a GMenu?


You don’t.

Icons in menus should be limited to “objects”, like file types or bookmarks; “actions”, like “Open” or “Copy”, should not have icons.

For objects, you can set an icon to menu items by using attributes in the XML.

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