PopoverMenu

GtkPopoverMenu is a subclass of #GtkPopover that treats its children like menus and allows switching between them. It is meant to be used primarily together with #GtkModelButton, but any widget can be used, such as #GtkSpinButton or #GtkScale. In this respect, GtkPopoverMenu is more flexible than popovers that are created from a #GMenuModel with gtk.popover.Popover.newFromModel.

To add a child as a submenu, set the #GtkPopoverMenu:submenu child property to the name of the submenu. To let the user open this submenu, add a #GtkModelButton whose #GtkModelButton:menu-name property is set to the name you've given to the submenu.

By convention, the first child of a submenu should be a #GtkModelButton to switch back to the parent menu. Such a button should use the #GtkModelButton:inverted and #GtkModelButton: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>

Just like normal popovers created using gtk_popover_new_from_model, #GtkPopoverMenu instances have a single css node called "popover" and get the .menu style class.

Constructors

this
this(void* ptr, Flag!"Take" take)
this
this()

Creates a new popover menu.

Members

Functions

openSubmenu
void openSubmenu(string name)

Opens a submenu of the popover. The name must be one of the names given to the submenus of popover with #GtkPopoverMenu:submenu, or "main" to switch back to the main menu.

self
PopoverMenu self()

Returns this, for use in with statements.

Properties

_gType
GType _gType [@property getter]
visibleSubmenu
string visibleSubmenu [@property getter]
visibleSubmenu
string visibleSubmenu [@property setter]

Static functions

_getGType
GType _getGType()
builder
PopoverMenuGidBuilder builder()

Get builder for gtk.popover_menu.PopoverMenu

Inherited Members

From Popover

_getGType
GType _getGType()
_gType
GType _gType [@property getter]
self
Popover self()

Returns this, for use in with statements.

builder
PopoverGidBuilder builder()

Get builder for gtk.popover.Popover

constrainTo
gtk.types.PopoverConstraint constrainTo [@property getter]

Get constrainTo property.

constrainTo
gtk.types.PopoverConstraint constrainTo [@property setter]

Set constrainTo property.

modal
bool modal [@property getter]

Get modal property.

modal
bool modal [@property setter]

Set modal property.

pointingTo
gdk.rectangle.Rectangle pointingTo [@property getter]

Get pointingTo property.

pointingTo
gdk.rectangle.Rectangle pointingTo [@property setter]

Set pointingTo property.

position
gtk.types.PositionType position [@property getter]

Get position property.

position
gtk.types.PositionType position [@property setter]

Set position property.

relativeTo
gtk.widget.Widget relativeTo [@property getter]

Get relativeTo property.

relativeTo
gtk.widget.Widget relativeTo [@property setter]

Set relativeTo property.

transitionsEnabled
bool transitionsEnabled [@property getter]

Get transitionsEnabled property.

transitionsEnabled
bool transitionsEnabled [@property setter]

Set transitionsEnabled property.

newFromModel
gtk.popover.Popover newFromModel(gtk.widget.Widget relativeTo, gio.menu_model.MenuModel model)

Creates a #GtkPopover and populates it according to model. The popover is pointed to the relative_to widget.

bindModel
void bindModel(gio.menu_model.MenuModel model, string actionNamespace)

Establishes a binding between a #GtkPopover and a #GMenuModel.

getConstrainTo
gtk.types.PopoverConstraint getConstrainTo()

Returns the constraint for placing this popover. See gtk.popover.Popover.setConstrainTo.

getDefaultWidget
gtk.widget.Widget getDefaultWidget()

Gets the widget that should be set as the default while the popover is shown.

getModal
bool getModal()

Returns whether the popover is modal, see gtk_popover_set_modal to see the implications of this.

getPointingTo
bool getPointingTo(gdk.rectangle.Rectangle rect)

If a rectangle to point to has been set, this function will return true and fill in rect with such rectangle, otherwise it will return false and fill in rect with the attached widget width and height if a widget exists, otherwise it will zero-out rect.

getPosition
gtk.types.PositionType getPosition()

Returns the preferred position of popover.

getRelativeTo
gtk.widget.Widget getRelativeTo()

Returns the widget popover is currently attached to

getTransitionsEnabled
bool getTransitionsEnabled()

Returns whether show/hide transitions are enabled on this popover.

popdown
void popdown()

Pops popover down.This is different than a gtk.widget.Widget.hide call in that it shows the popover with a transition. If you want to hide the popover without a transition, use gtk.widget.Widget.hide.

popup
void popup()

Pops popover up. This is different than a gtk.widget.Widget.show call in that it shows the popover with a transition. If you want to show the popover without a transition, use gtk.widget.Widget.show.

setConstrainTo
void setConstrainTo(gtk.types.PopoverConstraint constraint)

Sets a constraint for positioning this popover.

setDefaultWidget
void setDefaultWidget(gtk.widget.Widget widget)

Sets the widget that should be set as default widget while the popover is shown (see gtk.window.Window.setDefault). #GtkPopover remembers the previous default widget and reestablishes it when the popover is dismissed.

setModal
void setModal(bool modal)

Sets whether popover is modal, a modal popover will grab all input within the toplevel and grab the keyboard focus on it when being displayed. Clicking outside the popover area or pressing Esc will dismiss the popover and ungrab input.

setPointingTo
void setPointingTo(gdk.rectangle.Rectangle rect)

Sets the rectangle that popover will point to, in the coordinate space of the widget popover is attached to, see gtk.popover.Popover.setRelativeTo.

setPosition
void setPosition(gtk.types.PositionType position)

Sets the preferred position for popover to appear. If the popover is currently visible, it will be immediately updated.

setRelativeTo
void setRelativeTo(gtk.widget.Widget relativeTo)

Sets a new widget to be attached to popover. If popover is visible, the position will be updated.

setTransitionsEnabled
void setTransitionsEnabled(bool transitionsEnabled)

Sets whether show/hide transitions are enabled on this popover

connectClosed
gulong connectClosed(T callback, Flag!"After" after)

Connect to Closed signal.