Object Hierarchy:

Object hierarchy for Popover


[ CCode ( type_id = "gtk_popover_get_type ()" ) ]
public class Popover : Widget, Accessible, Buildable, ConstraintTarget, Native, ShortcutManager

GtkPopover is a bubble-like context window, primarily meant to provide context-dependent information or options.

Popovers are attached to a widget, set with set_parent. By default they will point to the whole widget area, although this behavior can be changed through set_pointing_to.

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

By default, 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, set_autohide may be called on it to tweak its behavior.

GtkPopover as menu replacement

GtkPopover is often used to replace menus. The best was to do this is to use the PopoverMenu subclass which supports being populated from a MenuModel with PopoverMenu.from_model.

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

CSS nodes

├── arrow
╰── contents.background
╰── <child>
ld node always gets the .background style class and the popover itself gets the .menu style class if the popover is menu-like (i.e. PopoverMenu).

Particular uses of GtkPopover, such as touch selection popups or magnifiers in Entry or 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.

Note that, in order to accomplish appropriate arrow visuals, 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 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.

All known sub-classes:

Namespace: Gtk
Package: gtk4



Creation methods:



Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from interface Gtk.Native
All known members inherited from interface Gtk.ShortcutManager