Presents a bubble-like popup.
<picture> <source srcset="popover-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkPopover" src="popover.png"> </picture> It is primarily meant to provide context-dependent information or options. Popovers are attached to a parent widget. The parent widget must support popover children, as [classGtk.MenuButton] and [classGtk.PopoverMenuBar] do. If you want to make a custom widget that has an attached popover, you need to call [methodGtk.Popover.present] in your [vfuncGtk.Widget.size_allocate] vfunc, in order to update the positioning of the popover.
The position of a popover relative to the widget it is attached to can also be changed with [methodGtk.Popover.set_position]. By default, it points to the whole widget area, but it can be made to point to a specific area using [methodGtk.Popover.set_pointing_to].
By default, GtkPopover 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, [methodGtk.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 way to do this is to use the [classGtk.PopoverMenu] subclass which supports being populated from a GMenuModel with [ctorGtk.PopoverMenu.new_from_model].
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> ```
# Shortcuts and Gestures
`GtkPopover` supports the following keyboard shortcuts:
- <kbd>Escape</kbd> closes the popover. - <kbd>Alt</kbd> makes the
mnemonics visible.
The following signals have default keybindings:
- [signalGtk.Popover::activate-default]
# CSS nodes
``` popover.background[.menu] âââ arrow â°ââ contents â°ââ <child> ```
`GtkPopover` 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 [classGtk.PopoverMenu].
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.
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, `GtkPopover`
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.
<group>Menus and Toolbars</group>
<gtkada_demo>create_menu.adb</gtkada_demo>
function "+"
(Widget : access Gtk_Popover_Record'Class)
return Gtk.Accessible.Gtk_Accessible
function "+"
(Widget : access Gtk_Popover_Record'Class)
return Gtk.Buildable.Gtk_Buildable
function "+"
(Widget : access Gtk_Popover_Record'Class)
return Gtk.Constraint_Target.Gtk_Constraint_Target
function "+"
(Widget : access Gtk_Popover_Record'Class)
return Gtk.Native.Gtk_Native
function "+"
(Widget : access Gtk_Popover_Record'Class)
return Gtk.Shortcut_Manager.Gtk_Shortcut_Manager
function "-"
(Interf : Gtk.Accessible.Gtk_Accessible)
return Gtk_Popover
function "-"
(Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Popover
function "-"
(Interf : Gtk.Constraint_Target.Gtk_Constraint_Target)
return Gtk_Popover
function "-"
(Interf : Gtk.Native.Gtk_Native)
return Gtk_Popover
function "-"
(Interf : Gtk.Shortcut_Manager.Gtk_Shortcut_Manager)
return Gtk_Popover
procedure Announce
(Self : not null access Gtk_Popover_Record;
Message : UTF8_String;
Priority : Gtk.Accessible.Gtk_Accessible_Announcement_Priority)
Autohide_Property : constant Glib.Properties.Property_Boolean;
Whether to dismiss the popover on outside clicks.
Cascade_Popdown_Property : constant Glib.Properties.Property_Boolean;
Whether the popover pops down after a child popover.
This is used to implement the expected behavior of submenus.
type Cb_GObject_Void is not null access procedure
(Self : access Glib.Object.GObject_Record'Class);
type Cb_Gtk_Popover_Void is not null access procedure (Self : access Gtk_Popover_Record'Class);
Child_Property : constant Glib.Properties.Property_Object;
Type: Gtk.Widget.Gtk_Widget The child widget.
Default_Widget_Property : constant Glib.Properties.Property_Object;
Type: Gtk.Widget.Gtk_Widget The default widget inside the popover.
function Get_Accessible_Id
(Self : not null access Gtk_Popover_Record) return UTF8_String
function Get_Accessible_Parent
(Self : not null access Gtk_Popover_Record)
return Gtk.Accessible.Gtk_Accessible
function Get_Accessible_Role
(Self : not null access Gtk_Popover_Record)
return Gtk.Accessible.Gtk_Accessible_Role
function Get_At_Context
(Self : not null access Gtk_Popover_Record)
return Gtk.Atcontext.Gtk_Atcontext
function Get_Autohide
(Self : not null access Gtk_Popover_Record) return Boolean
Returns whether the popover is modal. See [methodGtk.Popover.set_autohide] for the implications of this.
True if Popover is modal
function Get_Bounds
(Self : not null access Gtk_Popover_Record;
X : out Glib.Gint;
Y : out Glib.Gint;
Width : out Glib.Gint;
Height : out Glib.Gint) return Boolean
function Get_Cascade_Popdown
(Self : not null access Gtk_Popover_Record) return Boolean
Returns whether the popover will close after a modal child is closed.
True if Popover will close after a modal child.
function Get_Child
(Self : not null access Gtk_Popover_Record)
return Gtk.Widget.Gtk_Widget
Gets the child widget of Popover.
the child widget of Popover. Has transfer-ownership='none'.
function Get_First_Accessible_Child
(Self : not null access Gtk_Popover_Record)
return Gtk.Accessible.Gtk_Accessible
function Get_Has_Arrow
(Self : not null access Gtk_Popover_Record) return Boolean
Gets whether this popover is showing an arrow pointing at the widget that it is relative to.
whether the popover has an arrow
function Get_Mnemonics_Visible
(Self : not null access Gtk_Popover_Record) return Boolean
Gets whether mnemonics are visible.
True if mnemonics are supposed to be visible in this popover
function Get_Next_Accessible_Sibling
(Self : not null access Gtk_Popover_Record)
return Gtk.Accessible.Gtk_Accessible
procedure Get_Offset
(Self : not null access Gtk_Popover_Record;
X_Offset : out Glib.Gint;
Y_Offset : out Glib.Gint)
Gets the offset previous set with [methodGtk.Popover.set_offset].
a location for the x_offset
a location for the y_offset
function Get_Platform_State
(Self : not null access Gtk_Popover_Record;
State : Gtk.Accessible.Gtk_Accessible_Platform_State) return Boolean
function Get_Pointing_To
(Self : not null access Gtk_Popover_Record;
Rect : out Gdk.Rectangle.Gdk_Rectangle) return Boolean
Gets the rectangle that the popover points to. 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 parent widget coordinates.
location to store the rectangle
True if a rectangle to point to was set.
function Get_Position
(Self : not null access Gtk_Popover_Record)
return Gtk.Enums.Gtk_Position_Type
Returns the preferred position of Popover.
The preferred position.
function Get_Surface
(Self : not null access Gtk_Popover_Record) return Gdk.Gdk_Surface
procedure Get_Surface_Transform
(Self : not null access Gtk_Popover_Record;
X : out Gdouble;
Y : out Gdouble)
function Get_Type return Glib.GType
procedure Gtk_New (Self : out Gtk_Popover)
Creates a new GtkPopover. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
type Gtk_Popover is access all Gtk_Popover_Record'Class;
function Gtk_Popover_New return Gtk_Popover
Creates a new GtkPopover.
type Gtk_Popover_Record is new Gtk_Widget_Record with null record;
Has_Arrow_Property : constant Glib.Properties.Property_Boolean;
Whether to draw an arrow.
package Implements_Gtk_Accessible is new Glib.Types.Implements
(Gtk.Accessible.Gtk_Accessible, Gtk_Popover_Record, Gtk_Popover);
package Implements_Gtk_Buildable is new Glib.Types.Implements
(Gtk.Buildable.Gtk_Buildable, Gtk_Popover_Record, Gtk_Popover);
package Implements_Gtk_Constraint_Target is new Glib.Types.Implements
(Gtk.Constraint_Target.Gtk_Constraint_Target, Gtk_Popover_Record, Gtk_Popover);
package Implements_Gtk_Native is new Glib.Types.Implements
(Gtk.Native.Gtk_Native, Gtk_Popover_Record, Gtk_Popover);
package Implements_Gtk_Shortcut_Manager is new Glib.Types.Implements
(Gtk.Shortcut_Manager.Gtk_Shortcut_Manager, Gtk_Popover_Record, Gtk_Popover);
procedure Initialize (Self : not null access Gtk_Popover_Record'Class)
Creates a new GtkPopover. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
Mnemonics_Visible_Property : constant Glib.Properties.Property_Boolean;
Whether mnemonics are currently visible in this popover.
procedure On_Activate_Default
(Self : not null access Gtk_Popover_Record;
Call : Cb_GObject_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
Emitted whend the user activates the default widget.
This is a keybinding signal.
The default binding for this signal is <kbd>Enter</kbd>.
procedure On_Activate_Default
(Self : not null access Gtk_Popover_Record;
Call : Cb_Gtk_Popover_Void;
After : Boolean := False)
Emitted whend the user activates the default widget.
This is a keybinding signal.
The default binding for this signal is <kbd>Enter</kbd>.
procedure On_Closed
(Self : not null access Gtk_Popover_Record;
Call : Cb_GObject_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
Emitted when the popover is closed.
procedure On_Closed
(Self : not null access Gtk_Popover_Record;
Call : Cb_Gtk_Popover_Void;
After : Boolean := False)
Emitted when the popover is closed.
Pointing_To_Property : constant Glib.Properties.Property_Boxed;
Type: Gdk.Rectangle Rectangle in the parent widget that the popover points to.
procedure Popdown (Self : not null access Gtk_Popover_Record)
Pops Popover down. This may have the side-effect of closing a parent popover as well. See [propertyGtk.Popover:cascade-popdown].
procedure Popup (Self : not null access Gtk_Popover_Record)
Pops Popover up.
Position_Property : constant Gtk.Enums.Property_Gtk_Position_Type;
How to place the popover, relative to its parent.
procedure Present (Self : not null access Gtk_Popover_Record)
Allocate a size for the GtkPopover. This function needs to be called in size-allocate by widgets who have a GtkPopover as child. When using a layout manager, this is happening automatically. To make a popover appear on screen, use [methodGtk.Popover.popup].
procedure Realize (Self : not null access Gtk_Popover_Record)
procedure Reset_Property
(Self : not null access Gtk_Popover_Record;
Property : Gtk.Accessible.Gtk_Accessible_Property)
procedure Reset_Relation
(Self : not null access Gtk_Popover_Record;
Relation : Gtk.Accessible.Gtk_Accessible_Relation)
procedure Reset_State
(Self : not null access Gtk_Popover_Record;
State : Gtk.Accessible.Gtk_Accessible_State)
procedure Set_Accessible_Parent
(Self : not null access Gtk_Popover_Record;
Parent : Gtk.Accessible.Gtk_Accessible;
Next_Sibling : Gtk.Accessible.Gtk_Accessible)
procedure Set_Autohide
(Self : not null access Gtk_Popover_Record;
Autohide : Boolean)
Sets whether Popover is modal. A modal popover will grab the keyboard focus on it when being displayed. Focus will wrap around within the popover. Clicking outside the popover area or pressing Esc will dismiss the popover. Called this function on an already showing popup with a new autohide value different from the current one, will cause the popup to be hidden.
True to dismiss the popover on outside clicks
procedure Set_Cascade_Popdown
(Self : not null access Gtk_Popover_Record;
Cascade_Popdown : Boolean)
If Cascade_Popdown is True, the popover will be closed when a child modal popover is closed. If False, Popover will stay visible.
True if the popover should follow a child closing
procedure Set_Child
(Self : not null access Gtk_Popover_Record;
Child : access Gtk.Widget.Gtk_Widget_Record'Class)
Sets the child widget of Popover.
the child widget
procedure Set_Default_Widget
(Self : not null access Gtk_Popover_Record;
Widget : access Gtk.Widget.Gtk_Widget_Record'Class)
Sets the default widget of a GtkPopover. The default widget is the widget that's activated when the user presses Enter in a dialog (for example). This function sets or unsets the default widget for a GtkPopover.
a child widget of Popover to set as the default, or null to unset the default widget for the popover
procedure Set_Has_Arrow
(Self : not null access Gtk_Popover_Record;
Has_Arrow : Boolean)
Sets whether this popover should draw an arrow pointing at the widget it is relative to.
True to draw an arrow
procedure Set_Mnemonics_Visible
(Self : not null access Gtk_Popover_Record;
Mnemonics_Visible : Boolean)
Sets whether mnemonics should be visible.
the new value
procedure Set_Offset
(Self : not null access Gtk_Popover_Record;
X_Offset : Glib.Gint;
Y_Offset : Glib.Gint)
Sets the offset to use when calculating the position of the popover. These values are used when preparing the [structGdk.PopupLayout] for positioning the popover.
the x offset to adjust the position by
the y offset to adjust the position by
procedure Set_Pointing_To
(Self : not null access Gtk_Popover_Record;
Rect : Gdk.Rectangle.Gdk_Rectangle)
Sets the rectangle that Popover points to. This is in the coordinate space of the Popover parent.
rectangle to point to
procedure Set_Position
(Self : not null access Gtk_Popover_Record;
Position : Gtk.Enums.Gtk_Position_Type)
Sets the preferred position for Popover to appear. If the Popover is currently visible, it will be immediately updated. This preference will be respected where possible, although on lack of space (eg. if close to the window edges), the GtkPopover may choose to appear on the opposite side.
preferred popover position
Signal_Activate_Default : constant Glib.Signal_Name := "activate-default";
Emitted whend the user activates the default widget.
This is a keybinding signal.
The default binding for this signal is <kbd>Enter</kbd>.
Signal_Closed : constant Glib.Signal_Name := "closed";
Emitted when the popover is closed.
procedure Unrealize (Self : not null access Gtk_Popover_Record)
procedure Update_Next_Accessible_Sibling
(Self : not null access Gtk_Popover_Record;
New_Sibling : Gtk.Accessible.Gtk_Accessible)
procedure Update_Platform_State
(Self : not null access Gtk_Popover_Record;
State : Gtk.Accessible.Gtk_Accessible_Platform_State)