Popover

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.

class Popover : Bin {}

Constructors

this
this(void* ptr, Flag!"Take" take)
this
this(gtk.widget.Widget relativeTo)

Creates a new popover to point to relative_to

Members

Functions

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

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

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

Connect to Closed signal.

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.

self
Popover self()

Returns this, for use in with statements.

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

Properties

_gType
GType _gType [@property getter]
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.

Static functions

_getGType
GType _getGType()
builder
PopoverGidBuilder builder()

Get builder for gtk.popover.Popover

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.

Inherited Members

From Bin

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

Returns this, for use in with statements.

builder
BinGidBuilder builder()

Get builder for gtk.bin.Bin

getChild
gtk.widget.Widget getChild()

Gets the child of the #GtkBin, or null if the bin contains no child widget. The returned widget does not have a reference added, so you do not need to unref it.