Package: gtk

Class gtk:popover

Superclasses

Documented Subclasses

Direct Slots

autohide
The autohide property of type :boolean (Read / Write)
Whether to dismiss the popover on outside clicks.
Default value: true
cascade-popdown
The cascade-popdown property of type :boolean (Read / Write)
Whether the popover pops down after a child popover.
Default value: false
child
The child property of type gtk:widget (Read / Write)
The child widget.
default-widget
The default-widget property of type gtk:widget (Read / Write)
The default widget.
has-arrow
The has-arrow property of type :boolean (Read / Write)
Whether to draw an arrow.
Default value: true
mnemonics-visible
The mnemonics-visible property of type :boolean (Read / Write)
Whether mnemonics are currently visible in this popover.
Default value: false
pointing-to
The pointing-to property of type gdk:rectangle (Read / Write)
Marks a specific rectangle to be pointed.
position
The position property of type gtk:position-type (Read / Write)
Sets the preferred position of the popover.
Default value: :top

Details

The gtk:popover widget is a bubble-like context window, 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 the gtk:popover-pointing-to function.

Figure: GtkPopover

The position of a popover relative to the widget it is attached to can also be changed through the gtk:popover-position function.

By default, the gtk:popover widget 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 Escape key being pressed. If no such modal behavior is desired on a popover, the gtk:popover-autohide function may be called on it to tweak its behavior.

GtkPopover as menu replacement
The gtk:popover widget is often used to replace menus. The best was to do this is to use the gtk:popover-menu subclass which supports being populated from a g:menu-model object with the gtk:popover-menu-new-from-model function.

Examples

<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

The contents child node always gets the .background style class and the popover itself gets the .menu style class if the popover is menu-like, that is a gtk:popover-menu widget.

Particular uses of the gtk:popover widget, such as touch selection popups or magnifiers in gtk:entry or gtk:text-view widgets 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, the gtk:popover widget 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.

Signal Details

The "activate-default" signal
lambda (popover)    :action      
popover
The gtk:popover widget which received the signal.
The signal is a keybinding signal which gets emitted when the user activates the default widget of the popover.
The "closed" signal
lambda (popover)    :run-last      
popover
The gtk:popover widget which received the signal.
The signal is emitted when the popover is dismissed either through API or user interaction.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2024-10-26