gtk.popover

Module for [Popover] class

Types 3

[gtk.popover.Popover] is a bubble-like context popup.

!An example GtkPopover

It is primarily meant to provide context-dependent information or options. Popovers are attached to a parent widget. By default, they point to the whole widget area, although this behavior can be changed with [gtk.popover.Popover.setPointingTo].

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

By default, [gtk.popover.Popover] performs a 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 Escape key being pressed). If no such modal behavior is desired on a popover, [gtk.popover.Popover.setAutohide] may be called on it to tweak its behavior.

GtkPopover as menu replacement

[gtk.popover.Popover] is often used to replace menus. The best was to do this is to use the [gtk.popover_menu.PopoverMenu] subclass which supports being populated from a [gio.menu_model.MenuModel] with [gtk.popover_menu.PopoverMenu.newFromModel].

<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

popover.background[.menu]
├── arrow
╰── contents
   ╰── <child>

[gtk.popover.Popover] has a main node with name popover, an arrow with name arrow, and another node for the content named contents. The popover node always gets the .background style class. It also gets the .menu style class if the popover is menu-like, e.g. is a [gtk.popover_menu.PopoverMenu].

Particular uses of [gtk.popover.Popover], such as touch selection popups or magnifiers in [gtk.entry.Entry] or [gtk.text_view.TextView] get style classes like .touch-selection or .magnifier to differentiate from plain popovers.

When styling a popover directly, the popover node should usually not have any background. The visible part of the popover can have a shadow. To specify it in CSS, set the box-shadow of the contents node.

Note that, in order to accomplish appropriate arrow visuals, [gtk.popover.Popover] uses custom drawing for the arrow node. This makes it possible for the arrow to change its shape dynamically, but it also limits the possibilities of styling it using CSS. In particular, the arrow gets drawn over the content node's border and shadow, so they look like one shape, which means that the border width of the content node and the arrow node should be the same. The arrow also does not support any border shape other than solid, no border-radius, only one border width (border-bottom-width is used) and no box-shadow.

Methods
GType _gType() @property
Popover self()Returns `this`, for use in `with` statements.
PopoverGidBuilder builder()Get builder for [gtk.popover.Popover] Returns: New builder object
bool autohide() @propertyGet `autohide` property. Returns: Whether to dismiss the popover on outside clicks.
void autohide(bool propval) @propertySet `autohide` property. Params: propval = Whether to dismiss the popover on outside clicks.
bool cascadePopdown() @propertyGet `cascadePopdown` property. Returns: Whether the popover pops down after a child popover.
void cascadePopdown(bool propval) @propertySet `cascadePopdown` property. Params: propval = Whether the popover pops down after a child popover.
gtk.widget.Widget child() @propertyGet `child` property. Returns: The child widget.
void child(gtk.widget.Widget propval) @propertySet `child` property. Params: propval = The child widget.
gtk.widget.Widget defaultWidget() @propertyGet `defaultWidget` property. Returns: The default widget inside the popover.
void defaultWidget(gtk.widget.Widget propval) @propertySet `defaultWidget` property. Params: propval = The default widget inside the popover.
bool hasArrow() @propertyGet `hasArrow` property. Returns: Whether to draw an arrow.
void hasArrow(bool propval) @propertySet `hasArrow` property. Params: propval = Whether to draw an arrow.
bool mnemonicsVisible() @propertyGet `mnemonicsVisible` property. Returns: Whether mnemonics are currently visible in this popover.
void mnemonicsVisible(bool propval) @propertySet `mnemonicsVisible` property. Params: propval = Whether mnemonics are currently visible in this popover.
gdk.rectangle.Rectangle pointingTo() @propertyGet `pointingTo` property. Returns: Rectangle in the parent widget that the popover points to.
void pointingTo(gdk.rectangle.Rectangle propval) @propertySet `pointingTo` property. Params: propval = Rectangle in the parent widget that the popover points to.
gtk.types.PositionType position() @propertyGet `position` property. Returns: How to place the popover, relative to its parent.
void position(gtk.types.PositionType propval) @propertySet `position` property. Params: propval = How to place the popover, relative to its parent.
bool getAutohide()Returns whether the popover is modal.
bool getCascadePopdown()Returns whether the popover will close after a modal child is closed. Returns: true if popover will close after a modal child.
gtk.widget.Widget getChild()Gets the child widget of popover. Returns: the child widget of popover
bool getHasArrow()Gets whether this popover is showing an arrow pointing at the widget that it is relative to. Returns: whether the popover has an arrow
bool getMnemonicsVisible()Gets whether mnemonics are visible. Returns: true if mnemonics are supposed to be visible in this popover
void getOffset(out int xOffset, out int yOffset)Gets the offset previous set with [gtk.popover.Popover.setOffset].
bool getPointingTo(out gdk.rectangle.Rectangle rect)Gets the rectangle that the popover points to.
gtk.types.PositionType getPosition()Returns the preferred position of popover. Returns: The preferred position.
void popdown()Pops popover down.
void popup()Pops popover up.
void present()Allocate a size for the [gtk.popover.Popover].
void setAutohide(bool autohide)Sets whether popover is modal.
void setCascadePopdown(bool cascadePopdown)If cascade_popdown is true, the popover will be closed when a child modal popover is closed.
void setChild(gtk.widget.Widget child = null)Sets the child widget of popover.
void setDefaultWidget(gtk.widget.Widget widget = null)Sets the default widget of a [gtk.popover.Popover].
void setHasArrow(bool hasArrow)Sets whether this popover should draw an arrow pointing at the widget it is relative to.
void setMnemonicsVisible(bool mnemonicsVisible)Sets whether mnemonics should be visible.
void setOffset(int xOffset, int yOffset)Sets the offset to use when calculating the position of the popover.
void setPointingTo(gdk.rectangle.Rectangle rect)Sets the rectangle that popover points to.
void setPosition(gtk.types.PositionType position)Sets the preferred position for popover to appear.
gulong connectActivateDefault(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 `ActivateDefault` signal.
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)Connect to `Closed` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.popover.Popover]. Returns: the new [gtk.popover.Popover]
Methods
T autohide(bool propval)Set `autohide` property. Params: propval = Whether to dismiss the popover on outside clicks. Returns: Builder instance for fluent chaining
T cascadePopdown(bool propval)Set `cascadePopdown` property. Params: propval = Whether the popover pops down after a child popover.
T child(gtk.widget.Widget propval)Set `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chaining
T defaultWidget(gtk.widget.Widget propval)Set `defaultWidget` property. Params: propval = The default widget inside the popover. Returns: Builder instance for fluent chaining
T hasArrow(bool propval)Set `hasArrow` property. Params: propval = Whether to draw an arrow. Returns: Builder instance for fluent chaining
T mnemonicsVisible(bool propval)Set `mnemonicsVisible` property. Params: propval = Whether mnemonics are currently visible in this popover. Returns: Builder instance for fluent chaining
T pointingTo(gdk.rectangle.Rectangle propval)Set `pointingTo` property. Params: propval = Rectangle in the parent widget that the popover points to. Returns: Builder instance for fluent chaining
T position(gtk.types.PositionType propval)Set `position` property. Params: propval = How to place the popover, relative to its parent. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.popover.Popover]

Methods