Package: gtk

Class gtk-popover-menu

Superclasses

gtk-popover, gtk-bin, gtk-container, gtk-widget, gtk-buildable, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

visible-submenu
The visible-submenu property of type :string (Read / Write)
The name of the visible submenu.
Default value: nil

Details

The gtk-popover-menu class is a subclass of the gtk-popover class that treats its children like menus and allows switching between them. It is meant to be used primarily together with gtk-model-button widgets, but any widget can be used, such as gtk-spin-button or gtk-scale widgets. In this respect, the gtk-popover-menu widget is more flexible than popovers that are created from a g-menu-model class with the gtk-popover-new-from-model function.

To add a child as a submenu, set the submenu child property to the name of the submenu. To let the user open this submenu, add a gtk-model-button widget whose menu-name property is set to the name you have given to the submenu.

By convention, the first child of a submenu should be a gtk-model-button widget to switch back to the parent menu. Such a button should use the inverted and centered properties to achieve a title-like appearance and place the submenu indicator at the opposite side. To switch back to the main menu, use main as the menu name.

Example

<object class="GtkPopoverMenu">
  <child>
    <object class="GtkBox">
      <property name="visible">True</property>
      <property name="margin">10</property>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.frob</property>
          <property name="text" translatable="yes">Frob</property>
        </object>
      </child>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="menu-name">more</property>
          <property name="text" translatable="yes">More</property>
        </object>
      </child>
    </object>
  </child>
  <child>
    <object class="GtkBox">
      <property name="visible">True</property>
      <property name="margin">10</property>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.foo</property>
          <property name="text" translatable="yes">Foo</property>
        </object>
      </child>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.bar</property>
          <property name="text" translatable="yes">Bar</property>
        </object>
      </child>
    </object>
    <packing>
      <property name="submenu">more</property>
    </packing>
  </child>
</object>    

CSS nodes

Just like normal popovers created using the gtk-popover-new-from-model function, the gtk-popover-menu instances have a single CSS node called popover and get the .menu style class.

Child Property Details

position
The position child property of type :int (Read / Write)
The index of the child in the parent.
Allowed values: >= -1
Default value: 0
submenu
The submenu child property of type :string (Read / Write)
Specifies the name of the submenu. If it is nil or main, the child is used as the main menu, which is shown initially when the popover is mapped.
Default value: nil
 

Inherited Slot Access Functions

See also

2021-12-24