How can I define submenus in a PopoverMenu with GJS?

36 Views Asked by At

Documentation says:

GtkPopoverMenu is a subclass of Gtk.Popover that treats its children like menus and allows switching between them. [...]

To add a child as a submenu, set the #GtkPopoverMenu:submenu child property to the name of the submenu.

I don't really understand how I should set submenus here: PopoverMenu has no attribute names submenu and it also appears to accept only a single widget as child. Every example of usage I see is in XML, which makes me think that this can not be define programmatically.

Please note: I'm using GTK3. I don't want to "import" from a MenuModel.

1

There are 1 best solutions below

0
cidra On

Just found it by myself: Container#child_set_property(icon, property_name, value)

Example of usage:

myPopOverMenu.add(child1);
myPopOverMenu.child_set_property(child1, "submenu", "main");
myPopOverMenu.add(child2);
myPopOverMenu.child_set_property(child2, "submenu", "some_menu");