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.
PopoverGidBuilder builder()Get builder for [gtk.popover.Popover] Returns: New builder objectgtk.types.PopoverConstraint constrainTo() @propertyGet `constrainTo` property. Returns: Sets a constraint for the popover position.void constrainTo(gtk.types.PopoverConstraint propval) @propertySet `constrainTo` property. Params: propval = Sets a constraint for the popover position.bool modal() @propertyGet `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) @propertySet `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() @propertyGet `pointingTo` property. Returns: Marks a specific rectangle to be pointed.void pointingTo(gdk.rectangle.Rectangle propval) @propertySet `pointingTo` property. Params: propval = Marks a specific rectangle to be pointed.gtk.types.PositionType position() @propertyGet `position` property. Returns: Sets the preferred position of the popover.void position(gtk.types.PositionType propval) @propertySet `position` property. Params: propval = Sets the preferred position of the popover.gtk.widget.Widget relativeTo() @propertyGet `relativeTo` property. Returns: Sets the attached widget.void relativeTo(gtk.widget.Widget propval) @propertySet `relativeTo` property. Params: propval = Sets the attached widget.bool transitionsEnabled() @propertyGet `transitionsEnabled` property. Returns: Whether show/hide transitions are enabled for this popover.void transitionsEnabled(bool propval) @propertySet `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)Creates 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)Establishes a binding between a #GtkPopover and a #GMenuModel.gtk.types.PopoverConstraint getConstrainTo()Returns the constraint for placing this popover. See [gtk.popover.Popover.setConstrainTo]. Returns: the constraint for placing this popover.gtk.widget.Widget getDefaultWidget()Gets the widget that should be set as the default while the popover is shown. Returns: the default widget, or null if there is nonebool getModal()Returns whether the popover is modal, see gtkpopoverset_modal to see the implications of this. Returns: #TRUE if popover is modalbool getPointingTo(out 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 heig...gtk.types.PositionType getPosition()Returns the preferred position of popover. Returns: The preferred position.gtk.widget.Widget getRelativeTo()Returns the widget popover is currently attached to Returns: a #GtkWidgetbool getTransitionsEnabled()Returns 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()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...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....void setConstrainTo(gtk.types.PopoverConstraint constraint)Sets a constraint for positioning this popover.void setDefaultWidget(gtk.widget.Widget widget = null)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...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...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].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.void setRelativeTo(gtk.widget.Widget relativeTo = null)Sets a new widget to be attached to popover. If popover is visible, the position will be updated.void setTransitionsEnabled(bool transitionsEnabled)Sets whether show/hide transitions are enabled on this popovergulong 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)Connect to `Closed` signal.this(gtk.widget.Widget relativeTo = null)Creates a new popover to point to relative_toT constrainTo(gtk.types.PopoverConstraint propval)Set `constrainTo` property. Params: propval = Sets a constraint for the popover position. Returns: Builder instance for fluent chainingT modal(bool propval)Set `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)Set `pointingTo` property. Params: propval = Marks a specific rectangle to be pointed. Returns: Builder instance for fluent chainingT position(gtk.types.PositionType propval)Set `position` property. Params: propval = Sets the preferred position of the popover. Returns: Builder instance for fluent chainingT relativeTo(gtk.widget.Widget propval)Set `relativeTo` property. Params: propval = Sets the attached widget. Returns: Builder instance for fluent chainingT transitionsEnabled(bool propval)Set `transitionsEnabled` property. Params: propval = Whether show/hide transitions are enabled for this popover. Returns: Builder instance for fluent chaining