GtkPopover

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.

Members

Variables

parentInstance
GtkBin parentInstance;
priv
GtkPopoverPrivate* priv;