It derives from <GtkPopover>.
A subclass of <GtkPopover> that implements menu
behavior.
<GtkPopoverMenu> treats its children like
menus and allows switching between them. It can open submenus as
traditional, nested submenus, or in a more touch-friendly sliding
fashion. The property popover-menu:flags controls this appearance.
<GtkPopoverMenu> is meant to be used primarily
with menu models, using popover-menu:new-from-model. If you need to put other
widgets such as a <GtkSpinButton> or a
<GtkSwitch> into a popover, you can use
popover-menu:add-child?.
For more dialog-like behavior, use a plain
<GtkPopover>.
The XML format understood by <GtkBuilder> for
<GMenuModel> consists of a toplevel
<menu> element, which contains one or more <item>
elements. Each <item> element contains <attribute> and
<link> elements with a mandatory name attribute. <link>
elements have the same content model as <menu>. Instead of
<link name="submenu"> or <link name="section">, you can
use <submenu> or <section> elements.
<menu id='app-menu'>
<section>
<item>
<attribute name='label' translatable='yes'>_New Window</attribute>
<attribute name='action'>app.new</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_About Sunny</attribute>
<attribute name='action'>app.about</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_Quit</attribute>
<attribute name='action'>app.quit</attribute>
</item>
</section>
</menu>
Attribute values can be translated using gettext, like other
<GtkBuilder> content. <attribute> elements
can be marked for translation with a translatable="yes"
attribute. It is also possible to specify message context and
translator comments, using the context and comments attributes. To make
use of this, the <GtkBuilder> must have been given
the gettext domain to use.
The following attributes are used when constructing menu items:
application:set-menubar.
popover-menu:add-child?,
popover-menu-bar:add-child?, or
in the ui file with <child type="ID">.
The following attributes are used when constructing sections:
<GtkTextDirection> to use when
"display-hint" is set to "horizontal-buttons". Possible values include
"rtl", "ltr", and "none".
The following attributes are used when constructing submenus:
Menu items will also show accelerators, which are usually associated
with actions via application:set-accels-for-action,
WidgetClass.add_binding_action or shortcut-controller:add-shortcut.
<GtkPopoverMenu> supports the following
keyboard shortcuts:
<GtkPopoverMenu> is just a subclass of
<GtkPopover> that adds custom content to it,
therefore it has the same CSS nodes. It is one of the cases that add a
.menu style class to the main popover node.
Menu items have nodes with name button and class .model.
If a section display-hint is set, the section gets a node box
with class horizontal plus a class with the same text as the
display hint. Note that said box may not be the direct ancestor of the
item buttons. Thus, for example, to style items in an
inline-buttons section, select .inline-buttons
button.model. Other things that may be of interest to style in menus
include label nodes.
<GtkPopoverMenu> uses the
Gtk.AccessibleRole.menu role, and its items use the
Gtk.AccessibleRole.menu_item, Gtk.AccessibleRole.checkbox
or Gtk.AccessibleRole.menu_item_radio roles, depending on the
action they are connected to.
The flags that popover uses to create/display a menu from its model.
If a model is set and the flags change, contents are rebuilt, so if setting properties individually, set flags before model to avoid a redundant rebuild.
Its value is a <GtkPopoverMenuFlags> (or,
to set it, a list of its symbols, or one of them).
Set it with (set! (popover-menu:flags self) value).
The model from which the menu is made.
Its value is a <GMenuModel>, or #f.
Set it with (set! (popover-menu:menu-model self) value).
The name of the visible submenu.
Its value is a string, or #f.
Set it with (set! (popover-menu:visible-submenu self) value).
Adds a custom widget to a generated menu.
For this to work, the menu model of self must have an item with a
custom attribute that matches id.
Passed: a <GtkPopoverMenu>.
Passed: a <GtkWidget>.
the <GtkWidget> to add
Passed: a string.
the ID to insert child at
Returned: a boolean.
#t if id was found and the widget added
Returns the flags that self uses to create/display a menu from its model.
Passed: a <GtkPopoverMenu>.
Returned: a <GtkPopoverMenuFlags>.
Returns the menu model used to populate the popover.
Passed: a <GtkPopoverMenu>.
Returned: a <GMenuModel>, or #f.
the menu model of self
Creates a <GtkPopoverMenu> and populates it
according to model.
The created buttons are connected to actions found in the
<GtkApplicationWindow> to which the
popover belongs - typically by means of being attached to a widget that
is contained within the
<GtkApplicationWindow>s widget
hierarchy.
Actions can also be added using widget:insert-action-group on the menus attach
widget or on any of its parent widgets.
This function creates menus with sliding submenus. See
popover-menu:new-from-model-full for a way to
control this.
Passed, or left out: a <GMenuModel>, or
#f.
Returned: a <GtkWidget>.
the new <GtkPopoverMenu>
Creates a <GtkPopoverMenu> and populates it
according to model.
The created buttons are connected to actions found in the action groups
that are accessible from the parent widget. This includes the
<GtkApplicationWindow> to which the
popover belongs. Actions can also be added using widget:insert-action-group on the parent widget
or on any of its parent widgets.
Passed: a <GMenuModel>.
Passed: a <GtkPopoverMenuFlags>, or a
list of its symbols, or one of them.
flags that affect how the menu is created
Returned: a <GtkWidget>.
the new <GtkPopoverMenu>
Removes a widget that has previously been added with
popover-menu:add-child?
Passed: a <GtkPopoverMenu>.
Passed: a <GtkWidget>.
the <GtkWidget> to remove
Returned: a boolean.
#t if the widget was removed
Sets the flags that self uses to create/display a menu from its model.
If a model is set and the flags change, contents are rebuilt, so if setting properties individually, set flags before model to avoid a redundant rebuild.
Passed: a <GtkPopoverMenu>.
Passed: a <GtkPopoverMenuFlags>, or a
list of its symbols, or one of them.
a set of <GtkPopoverMenuFlags>
Sets a new menu model on self.
The existing contents of self are removed, and the self is populated with new contents according to model.
Passed: a <GtkPopoverMenu>.
Passed, or left out: a <GMenuModel>, or
#f.