gtk.popover

Module for [Popover] class

Types 3

GtkPopover is a bubble-like context window, primarily meant to provide context-dependent information or options. Popovers are attached to a widget, passed at construction time on gtk.popover.Popover.new_, or updated afterwards through gtk.popover.Popover.setRelativeTo, by default they will point to the whole widget area, although this behavior can be changed through gtk.popover.Popover.setPointingTo.

The position of a popover relative to the widget it is attached to can also be changed through gtk.popover.Popover.setPosition.

By default, #GtkPopover performs a GTK+ grab, in order to ensure input events get redirected to it while it is shown, and also so the popover is dismissed in the expected situations (clicks outside the popover, or the Esc key being pressed). If no such modal behavior is desired on a popover, gtk.popover.Popover.setModal may be called on it to tweak its behavior.

GtkPopover as menu replacement

GtkPopover is often used to replace menus. To facilitate this, it supports being populated from a #GMenuModel, using gtk.popover.Popover.newFromModel. In addition to all the regular menu model features, this function supports rendering sections in the model in a more compact form, as a row of icon buttons instead of menu items.

To use this rendering, set the ”display-hint” attribute of the section to ”horizontal-buttons” and set the icons of your items with the ”verb-icon” attribute.

<section>
  <attribute name="display-hint">horizontal-buttons</attribute>
  <item>
    <attribute name="label">Cut</attribute>
    <attribute name="action">app.cut</attribute>
    <attribute name="verb-icon">edit-cut-symbolic</attribute>
  </item>
  <item>
    <attribute name="label">Copy</attribute>
    <attribute name="action">app.copy</attribute>
    <attribute name="verb-icon">edit-copy-symbolic</attribute>
  </item>
  <item>
    <attribute name="label">Paste</attribute>
    <attribute name="action">app.paste</attribute>
    <attribute name="verb-icon">edit-paste-symbolic</attribute>
  </item>
</section>

CSS nodes

GtkPopover has a single css node called popover. It always gets the .background style class and it gets the .menu style class if it is menu-like (e.g. #GtkPopoverMenu or created using gtk.popover.Popover.newFromModel.

Particular uses of GtkPopover, such as touch selection popups or magnifiers in #GtkEntry or #GtkTextView get style classes like .touch-selection or .magnifier to differentiate from plain popovers.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
Popover self() nothrowReturns `this`, for use in `with` statements.
PopoverGidBuilder builder() static nothrowGet builder for [gtk.popover.Popover] Returns: New builder object
gtk.types.PopoverConstraint constrainTo() @property nothrowGet `constrainTo` property. Returns: Sets a constraint for the popover position.
void constrainTo(gtk.types.PopoverConstraint propval) @property nothrowSet `constrainTo` property. Params: propval = Sets a constraint for the popover position.
bool modal() @property nothrowGet `modal` property. Returns: Sets whether the popover is modal (so other elements in the window do not receive input while the popover is visible).
void modal(bool propval) @property nothrowSet `modal` property. Params: propval = Sets whether the popover is modal (so other elements in the window do not receive input while the popover is visible).
gdk.rectangle.Rectangle pointingTo() @property nothrowGet `pointingTo` property. Returns: Marks a specific rectangle to be pointed.
void pointingTo(gdk.rectangle.Rectangle propval) @property nothrowSet `pointingTo` property. Params: propval = Marks a specific rectangle to be pointed.
gtk.types.PositionType position() @property nothrowGet `position` property. Returns: Sets the preferred position of the popover.
void position(gtk.types.PositionType propval) @property nothrowSet `position` property. Params: propval = Sets the preferred position of the popover.
gtk.widget.Widget relativeTo() @property nothrowGet `relativeTo` property. Returns: Sets the attached widget.
void relativeTo(gtk.widget.Widget propval) @property nothrowSet `relativeTo` property. Params: propval = Sets the attached widget.
bool transitionsEnabled() @property nothrowGet `transitionsEnabled` property. Returns: Whether show/hide transitions are enabled for this popover.
void transitionsEnabled(bool propval) @property nothrowSet `transitionsEnabled` property. Params: propval = Whether show/hide transitions are enabled for this popover.
gtk.popover.Popover newFromModel(gtk.widget.Widget relativeTo, gio.menu_model.MenuModel model) static nothrowCreates a #GtkPopover and populates it according to model. The popover is pointed to the relative_to widget.
void bindModel(gio.menu_model.MenuModel model = null, string actionNamespace = null) nothrowEstablishes a binding between a #GtkPopover and a #GMenuModel.
gtk.types.PopoverConstraint getConstrainTo() nothrowReturns the constraint for placing this popover. See [gtk.popover.Popover.setConstrainTo]. Returns: the constraint for placing this popover.
gtk.widget.Widget getDefaultWidget() nothrowGets the widget that should be set as the default while the popover is shown. Returns: the default widget, or null if there is none
bool getModal() nothrowReturns whether the popover is modal, see gtk_popover_set_modal to see the implications of this. Returns: #TRUE if popover is modal
bool getPointingTo(out gdk.rectangle.Rectangle rect) nothrowIf 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 heig...
gtk.types.PositionType getPosition() nothrowReturns the preferred position of popover. Returns: The preferred position.
gtk.widget.Widget getRelativeTo() nothrowReturns the widget popover is currently attached to Returns: a #GtkWidget
bool getTransitionsEnabled() nothrowReturns whether show/hide transitions are enabled on this popover. Returns: #TRUE if the show and hide transitions of the given popover are enabled, #FALSE otherwise.
void popdown() nothrowPops 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...
void popup() nothrowPops 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....
void setConstrainTo(gtk.types.PopoverConstraint constraint) nothrowSets a constraint for positioning this popover.
void setDefaultWidget(gtk.widget.Widget widget = null) nothrowSets 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...
void setModal(bool modal) nothrowSets 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...
void setPointingTo(gdk.rectangle.Rectangle rect) nothrowSets the rectangle that popover will point to, in the coordinate space of the widget popover is attached to, see [gtk.popover.Popover.setRelativeTo].
void setPosition(gtk.types.PositionType position) nothrowSets the preferred position for popover to appear. If the popover is currently visible, it will be immediately updated.
void setRelativeTo(gtk.widget.Widget relativeTo = null) nothrowSets a new widget to be attached to popover. If popover is visible, the position will be updated.
void setTransitionsEnabled(bool transitionsEnabled) nothrowSets whether show/hide transitions are enabled on this popover
gulong connectClosed(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.popover.Popover))) && Parameters!T.length < 2) nothrowConnect to `Closed` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this(gtk.widget.Widget relativeTo = null)Creates a new popover to point to relative_to

Fluent builder implementation template for gtk.popover.Popover

Methods
T constrainTo(gtk.types.PopoverConstraint propval) nothrowSet `constrainTo` property. Params: propval = Sets a constraint for the popover position. Returns: Builder instance for fluent chaining
T modal(bool propval) nothrowSet `modal` property. Params: propval = Sets whether the popover is modal (so other elements in the window do not receive input while the popover is visible). Returns: Builder instance for fluent c...
T pointingTo(gdk.rectangle.Rectangle propval) nothrowSet `pointingTo` property. Params: propval = Marks a specific rectangle to be pointed. Returns: Builder instance for fluent chaining
T position(gtk.types.PositionType propval) nothrowSet `position` property. Params: propval = Sets the preferred position of the popover. Returns: Builder instance for fluent chaining
T relativeTo(gtk.widget.Widget propval) nothrowSet `relativeTo` property. Params: propval = Sets the attached widget. Returns: Builder instance for fluent chaining
T transitionsEnabled(bool propval) nothrowSet `transitionsEnabled` property. Params: propval = Whether show/hide transitions are enabled for this popover. Returns: Builder instance for fluent chaining

Fluent builder for gtk.popover.Popover

Methods
Popover build() nothrowCreate object from builder. Returns: New object