gtk4/auto/
popover.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Native,
7    Overflow, PositionType, ShortcutManager, Widget,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// Presents a bubble-like popup.
19    ///
20    /// <picture>
21    ///   <source srcset="popover-dark.png" media="(prefers-color-scheme: dark)">
22    ///   <img alt="An example GtkPopover" src="popover.png">
23    /// </picture>
24    ///
25    /// It is primarily meant to provide context-dependent information
26    /// or options. Popovers are attached to a parent widget. By default,
27    /// they point to the whole widget area, although this behavior can be
28    /// changed with [`PopoverExt::set_pointing_to()`][crate::prelude::PopoverExt::set_pointing_to()].
29    ///
30    /// The position of a popover relative to the widget it is attached to
31    /// can also be changed with [`PopoverExt::set_position()`][crate::prelude::PopoverExt::set_position()]
32    ///
33    /// By default, [`Popover`][crate::Popover] performs a grab, in order to ensure input
34    /// events get redirected to it while it is shown, and also so the popover
35    /// is dismissed in the expected situations (clicks outside the popover,
36    /// or the Escape key being pressed). If no such modal behavior is desired
37    /// on a popover, [`PopoverExt::set_autohide()`][crate::prelude::PopoverExt::set_autohide()] may be called on it to
38    /// tweak its behavior.
39    ///
40    /// ## GtkPopover as menu replacement
41    ///
42    /// [`Popover`][crate::Popover] is often used to replace menus. The best way to do this
43    /// is to use the [`PopoverMenu`][crate::PopoverMenu] subclass which supports being
44    /// populated from a `GMenuModel` with [`PopoverMenu::from_model()`][crate::PopoverMenu::from_model()].
45    ///
46    /// ```xml
47    /// <section>
48    ///   <attribute name="display-hint">horizontal-buttons</attribute>
49    ///   <item>
50    ///     <attribute name="label">Cut</attribute>
51    ///     <attribute name="action">app.cut</attribute>
52    ///     <attribute name="verb-icon">edit-cut-symbolic</attribute>
53    ///   </item>
54    ///   <item>
55    ///     <attribute name="label">Copy</attribute>
56    ///     <attribute name="action">app.copy</attribute>
57    ///     <attribute name="verb-icon">edit-copy-symbolic</attribute>
58    ///   </item>
59    ///   <item>
60    ///     <attribute name="label">Paste</attribute>
61    ///     <attribute name="action">app.paste</attribute>
62    ///     <attribute name="verb-icon">edit-paste-symbolic</attribute>
63    ///   </item>
64    /// </section>
65    /// ```
66    ///
67    /// # Shortcuts and Gestures
68    ///
69    /// [`Popover`][crate::Popover] supports the following keyboard shortcuts:
70    ///
71    /// - <kbd>Escape</kbd> closes the popover.
72    /// - <kbd>Alt</kbd> makes the mnemonics visible.
73    ///
74    /// The following signals have default keybindings:
75    ///
76    /// - [`activate-default`][struct@crate::Popover#activate-default]
77    ///
78    /// # CSS nodes
79    ///
80    /// ```text
81    /// popover.background[.menu]
82    /// ├── arrow
83    /// ╰── contents
84    ///     ╰── <child>
85    /// ```
86    ///
87    /// [`Popover`][crate::Popover] has a main node with name `popover`, an arrow with name `arrow`,
88    /// and another node for the content named `contents`. The `popover` node always
89    /// gets the `.background` style class. It also gets the `.menu` style class
90    /// if the popover is menu-like, e.g. is a [`PopoverMenu`][crate::PopoverMenu].
91    ///
92    /// Particular uses of [`Popover`][crate::Popover], such as touch selection popups or
93    /// magnifiers in [`Entry`][crate::Entry] or [`TextView`][crate::TextView] get style classes like
94    /// `.touch-selection` or `.magnifier` to differentiate from plain popovers.
95    ///
96    /// When styling a popover directly, the `popover` node should usually
97    /// not have any background. The visible part of the popover can have
98    /// a shadow. To specify it in CSS, set the box-shadow of the `contents` node.
99    ///
100    /// Note that, in order to accomplish appropriate arrow visuals, [`Popover`][crate::Popover]
101    /// uses custom drawing for the `arrow` node. This makes it possible for the
102    /// arrow to change its shape dynamically, but it also limits the possibilities
103    /// of styling it using CSS. In particular, the `arrow` gets drawn over the
104    /// `content` node's border and shadow, so they look like one shape, which
105    /// means that the border width of the `content` node and the `arrow` node should
106    /// be the same. The arrow also does not support any border shape other than
107    /// solid, no border-radius, only one border width (border-bottom-width is
108    /// used) and no box-shadow.
109    ///
110    /// ## Properties
111    ///
112    ///
113    /// #### `autohide`
114    ///  Whether to dismiss the popover on outside clicks.
115    ///
116    /// Readable | Writeable
117    ///
118    ///
119    /// #### `cascade-popdown`
120    ///  Whether the popover pops down after a child popover.
121    ///
122    /// This is used to implement the expected behavior of submenus.
123    ///
124    /// Readable | Writeable
125    ///
126    ///
127    /// #### `child`
128    ///  The child widget.
129    ///
130    /// Readable | Writeable
131    ///
132    ///
133    /// #### `default-widget`
134    ///  The default widget inside the popover.
135    ///
136    /// Readable | Writeable
137    ///
138    ///
139    /// #### `has-arrow`
140    ///  Whether to draw an arrow.
141    ///
142    /// Readable | Writeable
143    ///
144    ///
145    /// #### `mnemonics-visible`
146    ///  Whether mnemonics are currently visible in this popover.
147    ///
148    /// Readable | Writeable
149    ///
150    ///
151    /// #### `pointing-to`
152    ///  Rectangle in the parent widget that the popover points to.
153    ///
154    /// Readable | Writeable
155    ///
156    ///
157    /// #### `position`
158    ///  How to place the popover, relative to its parent.
159    ///
160    /// Readable | Writeable
161    /// <details><summary><h4>Widget</h4></summary>
162    ///
163    ///
164    /// #### `can-focus`
165    ///  Whether the widget or any of its descendents can accept
166    /// the input focus.
167    ///
168    /// This property is meant to be set by widget implementations,
169    /// typically in their instance init function.
170    ///
171    /// Readable | Writeable
172    ///
173    ///
174    /// #### `can-target`
175    ///  Whether the widget can receive pointer events.
176    ///
177    /// Readable | Writeable
178    ///
179    ///
180    /// #### `css-classes`
181    ///  A list of css classes applied to this widget.
182    ///
183    /// Readable | Writeable
184    ///
185    ///
186    /// #### `css-name`
187    ///  The name of this widget in the CSS tree.
188    ///
189    /// This property is meant to be set by widget implementations,
190    /// typically in their instance init function.
191    ///
192    /// Readable | Writeable | Construct Only
193    ///
194    ///
195    /// #### `cursor`
196    ///  The cursor used by @widget.
197    ///
198    /// Readable | Writeable
199    ///
200    ///
201    /// #### `focus-on-click`
202    ///  Whether the widget should grab focus when it is clicked with the mouse.
203    ///
204    /// This property is only relevant for widgets that can take focus.
205    ///
206    /// Readable | Writeable
207    ///
208    ///
209    /// #### `focusable`
210    ///  Whether this widget itself will accept the input focus.
211    ///
212    /// Readable | Writeable
213    ///
214    ///
215    /// #### `halign`
216    ///  How to distribute horizontal space if widget gets extra space.
217    ///
218    /// Readable | Writeable
219    ///
220    ///
221    /// #### `has-default`
222    ///  Whether the widget is the default widget.
223    ///
224    /// Readable
225    ///
226    ///
227    /// #### `has-focus`
228    ///  Whether the widget has the input focus.
229    ///
230    /// Readable
231    ///
232    ///
233    /// #### `has-tooltip`
234    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
235    /// signal on @widget.
236    ///
237    /// A true value indicates that @widget can have a tooltip, in this case
238    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
239    /// determine whether it will provide a tooltip or not.
240    ///
241    /// Readable | Writeable
242    ///
243    ///
244    /// #### `height-request`
245    ///  Overrides for height request of the widget.
246    ///
247    /// If this is -1, the natural request will be used.
248    ///
249    /// Readable | Writeable
250    ///
251    ///
252    /// #### `hexpand`
253    ///  Whether to expand horizontally.
254    ///
255    /// Readable | Writeable
256    ///
257    ///
258    /// #### `hexpand-set`
259    ///  Whether to use the `hexpand` property.
260    ///
261    /// Readable | Writeable
262    ///
263    ///
264    /// #### `layout-manager`
265    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
266    /// the preferred size of the widget, and allocate its children.
267    ///
268    /// This property is meant to be set by widget implementations,
269    /// typically in their instance init function.
270    ///
271    /// Readable | Writeable
272    ///
273    ///
274    /// #### `limit-events`
275    ///  Makes this widget act like a modal dialog, with respect to
276    /// event delivery.
277    ///
278    /// Global event controllers will not handle events with targets
279    /// inside the widget, unless they are set up to ignore propagation
280    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
281    ///
282    /// Readable | Writeable
283    ///
284    ///
285    /// #### `margin-bottom`
286    ///  Margin on bottom side of widget.
287    ///
288    /// This property adds margin outside of the widget's normal size
289    /// request, the margin will be added in addition to the size from
290    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
291    ///
292    /// Readable | Writeable
293    ///
294    ///
295    /// #### `margin-end`
296    ///  Margin on end of widget, horizontally.
297    ///
298    /// This property supports left-to-right and right-to-left text
299    /// directions.
300    ///
301    /// This property adds margin outside of the widget's normal size
302    /// request, the margin will be added in addition to the size from
303    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
304    ///
305    /// Readable | Writeable
306    ///
307    ///
308    /// #### `margin-start`
309    ///  Margin on start of widget, horizontally.
310    ///
311    /// This property supports left-to-right and right-to-left text
312    /// directions.
313    ///
314    /// This property adds margin outside of the widget's normal size
315    /// request, the margin will be added in addition to the size from
316    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
317    ///
318    /// Readable | Writeable
319    ///
320    ///
321    /// #### `margin-top`
322    ///  Margin on top side of widget.
323    ///
324    /// This property adds margin outside of the widget's normal size
325    /// request, the margin will be added in addition to the size from
326    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
327    ///
328    /// Readable | Writeable
329    ///
330    ///
331    /// #### `name`
332    ///  The name of the widget.
333    ///
334    /// Readable | Writeable
335    ///
336    ///
337    /// #### `opacity`
338    ///  The requested opacity of the widget.
339    ///
340    /// Readable | Writeable
341    ///
342    ///
343    /// #### `overflow`
344    ///  How content outside the widget's content area is treated.
345    ///
346    /// This property is meant to be set by widget implementations,
347    /// typically in their instance init function.
348    ///
349    /// Readable | Writeable
350    ///
351    ///
352    /// #### `parent`
353    ///  The parent widget of this widget.
354    ///
355    /// Readable
356    ///
357    ///
358    /// #### `receives-default`
359    ///  Whether the widget will receive the default action when it is focused.
360    ///
361    /// Readable | Writeable
362    ///
363    ///
364    /// #### `root`
365    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
366    ///
367    /// This will be `NULL` if the widget is not contained in a root widget.
368    ///
369    /// Readable
370    ///
371    ///
372    /// #### `scale-factor`
373    ///  The scale factor of the widget.
374    ///
375    /// Readable
376    ///
377    ///
378    /// #### `sensitive`
379    ///  Whether the widget responds to input.
380    ///
381    /// Readable | Writeable
382    ///
383    ///
384    /// #### `tooltip-markup`
385    ///  Sets the text of tooltip to be the given string, which is marked up
386    /// with Pango markup.
387    ///
388    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
389    ///
390    /// This is a convenience property which will take care of getting the
391    /// tooltip shown if the given string is not `NULL`:
392    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
393    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
394    /// the default signal handler.
395    ///
396    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
397    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
398    ///
399    /// Readable | Writeable
400    ///
401    ///
402    /// #### `tooltip-text`
403    ///  Sets the text of tooltip to be the given string.
404    ///
405    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
406    ///
407    /// This is a convenience property which will take care of getting the
408    /// tooltip shown if the given string is not `NULL`:
409    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
410    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
411    /// the default signal handler.
412    ///
413    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
414    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
415    ///
416    /// Readable | Writeable
417    ///
418    ///
419    /// #### `valign`
420    ///  How to distribute vertical space if widget gets extra space.
421    ///
422    /// Readable | Writeable
423    ///
424    ///
425    /// #### `vexpand`
426    ///  Whether to expand vertically.
427    ///
428    /// Readable | Writeable
429    ///
430    ///
431    /// #### `vexpand-set`
432    ///  Whether to use the `vexpand` property.
433    ///
434    /// Readable | Writeable
435    ///
436    ///
437    /// #### `visible`
438    ///  Whether the widget is visible.
439    ///
440    /// Readable | Writeable
441    ///
442    ///
443    /// #### `width-request`
444    ///  Overrides for width request of the widget.
445    ///
446    /// If this is -1, the natural request will be used.
447    ///
448    /// Readable | Writeable
449    /// </details>
450    /// <details><summary><h4>Accessible</h4></summary>
451    ///
452    ///
453    /// #### `accessible-role`
454    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
455    ///
456    /// The accessible role cannot be changed once set.
457    ///
458    /// Readable | Writeable
459    /// </details>
460    ///
461    /// ## Signals
462    ///
463    ///
464    /// #### `activate-default`
465    ///  Emitted whend the user activates the default widget.
466    ///
467    /// This is a [keybinding signal](class.SignalAction.html).
468    ///
469    /// The default binding for this signal is <kbd>Enter</kbd>.
470    ///
471    /// Action
472    ///
473    ///
474    /// #### `closed`
475    ///  Emitted when the popover is closed.
476    ///
477    ///
478    /// <details><summary><h4>Widget</h4></summary>
479    ///
480    ///
481    /// #### `destroy`
482    ///  Signals that all holders of a reference to the widget should release
483    /// the reference that they hold.
484    ///
485    /// May result in finalization of the widget if all references are released.
486    ///
487    /// This signal is not suitable for saving widget state.
488    ///
489    ///
490    ///
491    ///
492    /// #### `direction-changed`
493    ///  Emitted when the text direction of a widget changes.
494    ///
495    ///
496    ///
497    ///
498    /// #### `hide`
499    ///  Emitted when @widget is hidden.
500    ///
501    ///
502    ///
503    ///
504    /// #### `keynav-failed`
505    ///  Emitted if keyboard navigation fails.
506    ///
507    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
508    ///
509    ///
510    ///
511    ///
512    /// #### `map`
513    ///  Emitted when @widget is going to be mapped.
514    ///
515    /// A widget is mapped when the widget is visible (which is controlled with
516    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
517    /// are also visible.
518    ///
519    /// The `::map` signal can be used to determine whether a widget will be drawn,
520    /// for instance it can resume an animation that was stopped during the
521    /// emission of [`unmap`][struct@crate::Widget#unmap].
522    ///
523    ///
524    ///
525    ///
526    /// #### `mnemonic-activate`
527    ///  Emitted when a widget is activated via a mnemonic.
528    ///
529    /// The default handler for this signal activates @widget if @group_cycling
530    /// is false, or just makes @widget grab focus if @group_cycling is true.
531    ///
532    ///
533    ///
534    ///
535    /// #### `move-focus`
536    ///  Emitted when the focus is moved.
537    ///
538    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
539    ///
540    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
541    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
542    ///
543    /// Action
544    ///
545    ///
546    /// #### `query-tooltip`
547    ///  Emitted when the widget’s tooltip is about to be shown.
548    ///
549    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
550    /// is true and the hover timeout has expired with the cursor hovering
551    /// above @widget; or emitted when @widget got focus in keyboard mode.
552    ///
553    /// Using the given coordinates, the signal handler should determine
554    /// whether a tooltip should be shown for @widget. If this is the case
555    /// true should be returned, false otherwise. Note that if @keyboard_mode
556    /// is true, the values of @x and @y are undefined and should not be used.
557    ///
558    /// The signal handler is free to manipulate @tooltip with the therefore
559    /// destined function calls.
560    ///
561    ///
562    ///
563    ///
564    /// #### `realize`
565    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
566    ///
567    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
568    /// or the widget has been mapped (that is, it is going to be drawn).
569    ///
570    ///
571    ///
572    ///
573    /// #### `show`
574    ///  Emitted when @widget is shown.
575    ///
576    ///
577    ///
578    ///
579    /// #### `state-flags-changed`
580    ///  Emitted when the widget state changes.
581    ///
582    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
583    ///
584    ///
585    ///
586    ///
587    /// #### `unmap`
588    ///  Emitted when @widget is going to be unmapped.
589    ///
590    /// A widget is unmapped when either it or any of its parents up to the
591    /// toplevel widget have been set as hidden.
592    ///
593    /// As `::unmap` indicates that a widget will not be shown any longer,
594    /// it can be used to, for example, stop an animation on the widget.
595    ///
596    ///
597    ///
598    ///
599    /// #### `unrealize`
600    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
601    ///
602    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
603    /// or the widget has been unmapped (that is, it is going to be hidden).
604    ///
605    ///
606    /// </details>
607    ///
608    /// # Implements
609    ///
610    /// [`PopoverExt`][trait@crate::prelude::PopoverExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`NativeExt`][trait@crate::prelude::NativeExt], [`ShortcutManagerExt`][trait@crate::prelude::ShortcutManagerExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
611    #[doc(alias = "GtkPopover")]
612    pub struct Popover(Object<ffi::GtkPopover, ffi::GtkPopoverClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Native, ShortcutManager;
613
614    match fn {
615        type_ => || ffi::gtk_popover_get_type(),
616    }
617}
618
619impl Popover {
620    pub const NONE: Option<&'static Popover> = None;
621
622    /// Creates a new [`Popover`][crate::Popover].
623    ///
624    /// # Returns
625    ///
626    /// the new [`Popover`][crate::Popover]
627    #[doc(alias = "gtk_popover_new")]
628    pub fn new() -> Popover {
629        assert_initialized_main_thread!();
630        unsafe { Widget::from_glib_none(ffi::gtk_popover_new()).unsafe_cast() }
631    }
632
633    // rustdoc-stripper-ignore-next
634    /// Creates a new builder-pattern struct instance to construct [`Popover`] objects.
635    ///
636    /// This method returns an instance of [`PopoverBuilder`](crate::builders::PopoverBuilder) which can be used to create [`Popover`] objects.
637    pub fn builder() -> PopoverBuilder {
638        PopoverBuilder::new()
639    }
640}
641
642impl Default for Popover {
643    fn default() -> Self {
644        Self::new()
645    }
646}
647
648// rustdoc-stripper-ignore-next
649/// A [builder-pattern] type to construct [`Popover`] objects.
650///
651/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
652#[must_use = "The builder must be built to be used"]
653pub struct PopoverBuilder {
654    builder: glib::object::ObjectBuilder<'static, Popover>,
655}
656
657impl PopoverBuilder {
658    fn new() -> Self {
659        Self {
660            builder: glib::object::Object::builder(),
661        }
662    }
663
664    /// Whether to dismiss the popover on outside clicks.
665    pub fn autohide(self, autohide: bool) -> Self {
666        Self {
667            builder: self.builder.property("autohide", autohide),
668        }
669    }
670
671    /// Whether the popover pops down after a child popover.
672    ///
673    /// This is used to implement the expected behavior of submenus.
674    pub fn cascade_popdown(self, cascade_popdown: bool) -> Self {
675        Self {
676            builder: self.builder.property("cascade-popdown", cascade_popdown),
677        }
678    }
679
680    /// The child widget.
681    pub fn child(self, child: &impl IsA<Widget>) -> Self {
682        Self {
683            builder: self.builder.property("child", child.clone().upcast()),
684        }
685    }
686
687    /// The default widget inside the popover.
688    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
689        Self {
690            builder: self
691                .builder
692                .property("default-widget", default_widget.clone().upcast()),
693        }
694    }
695
696    /// Whether to draw an arrow.
697    pub fn has_arrow(self, has_arrow: bool) -> Self {
698        Self {
699            builder: self.builder.property("has-arrow", has_arrow),
700        }
701    }
702
703    /// Whether mnemonics are currently visible in this popover.
704    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
705        Self {
706            builder: self
707                .builder
708                .property("mnemonics-visible", mnemonics_visible),
709        }
710    }
711
712    /// Rectangle in the parent widget that the popover points to.
713    pub fn pointing_to(self, pointing_to: &gdk::Rectangle) -> Self {
714        Self {
715            builder: self.builder.property("pointing-to", pointing_to),
716        }
717    }
718
719    /// How to place the popover, relative to its parent.
720    pub fn position(self, position: PositionType) -> Self {
721        Self {
722            builder: self.builder.property("position", position),
723        }
724    }
725
726    /// Whether the widget or any of its descendents can accept
727    /// the input focus.
728    ///
729    /// This property is meant to be set by widget implementations,
730    /// typically in their instance init function.
731    pub fn can_focus(self, can_focus: bool) -> Self {
732        Self {
733            builder: self.builder.property("can-focus", can_focus),
734        }
735    }
736
737    /// Whether the widget can receive pointer events.
738    pub fn can_target(self, can_target: bool) -> Self {
739        Self {
740            builder: self.builder.property("can-target", can_target),
741        }
742    }
743
744    /// A list of css classes applied to this widget.
745    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
746        Self {
747            builder: self.builder.property("css-classes", css_classes.into()),
748        }
749    }
750
751    /// The name of this widget in the CSS tree.
752    ///
753    /// This property is meant to be set by widget implementations,
754    /// typically in their instance init function.
755    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
756        Self {
757            builder: self.builder.property("css-name", css_name.into()),
758        }
759    }
760
761    /// The cursor used by @widget.
762    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
763        Self {
764            builder: self.builder.property("cursor", cursor.clone()),
765        }
766    }
767
768    /// Whether the widget should grab focus when it is clicked with the mouse.
769    ///
770    /// This property is only relevant for widgets that can take focus.
771    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
772        Self {
773            builder: self.builder.property("focus-on-click", focus_on_click),
774        }
775    }
776
777    /// Whether this widget itself will accept the input focus.
778    pub fn focusable(self, focusable: bool) -> Self {
779        Self {
780            builder: self.builder.property("focusable", focusable),
781        }
782    }
783
784    /// How to distribute horizontal space if widget gets extra space.
785    pub fn halign(self, halign: Align) -> Self {
786        Self {
787            builder: self.builder.property("halign", halign),
788        }
789    }
790
791    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
792    /// signal on @widget.
793    ///
794    /// A true value indicates that @widget can have a tooltip, in this case
795    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
796    /// determine whether it will provide a tooltip or not.
797    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
798        Self {
799            builder: self.builder.property("has-tooltip", has_tooltip),
800        }
801    }
802
803    /// Overrides for height request of the widget.
804    ///
805    /// If this is -1, the natural request will be used.
806    pub fn height_request(self, height_request: i32) -> Self {
807        Self {
808            builder: self.builder.property("height-request", height_request),
809        }
810    }
811
812    /// Whether to expand horizontally.
813    pub fn hexpand(self, hexpand: bool) -> Self {
814        Self {
815            builder: self.builder.property("hexpand", hexpand),
816        }
817    }
818
819    /// Whether to use the `hexpand` property.
820    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
821        Self {
822            builder: self.builder.property("hexpand-set", hexpand_set),
823        }
824    }
825
826    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
827    /// the preferred size of the widget, and allocate its children.
828    ///
829    /// This property is meant to be set by widget implementations,
830    /// typically in their instance init function.
831    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
832        Self {
833            builder: self
834                .builder
835                .property("layout-manager", layout_manager.clone().upcast()),
836        }
837    }
838
839    /// Makes this widget act like a modal dialog, with respect to
840    /// event delivery.
841    ///
842    /// Global event controllers will not handle events with targets
843    /// inside the widget, unless they are set up to ignore propagation
844    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
845    #[cfg(feature = "v4_18")]
846    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
847    pub fn limit_events(self, limit_events: bool) -> Self {
848        Self {
849            builder: self.builder.property("limit-events", limit_events),
850        }
851    }
852
853    /// Margin on bottom side of widget.
854    ///
855    /// This property adds margin outside of the widget's normal size
856    /// request, the margin will be added in addition to the size from
857    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
858    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
859        Self {
860            builder: self.builder.property("margin-bottom", margin_bottom),
861        }
862    }
863
864    /// Margin on end of widget, horizontally.
865    ///
866    /// This property supports left-to-right and right-to-left text
867    /// directions.
868    ///
869    /// This property adds margin outside of the widget's normal size
870    /// request, the margin will be added in addition to the size from
871    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
872    pub fn margin_end(self, margin_end: i32) -> Self {
873        Self {
874            builder: self.builder.property("margin-end", margin_end),
875        }
876    }
877
878    /// Margin on start of widget, horizontally.
879    ///
880    /// This property supports left-to-right and right-to-left text
881    /// directions.
882    ///
883    /// This property adds margin outside of the widget's normal size
884    /// request, the margin will be added in addition to the size from
885    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
886    pub fn margin_start(self, margin_start: i32) -> Self {
887        Self {
888            builder: self.builder.property("margin-start", margin_start),
889        }
890    }
891
892    /// Margin on top side of widget.
893    ///
894    /// This property adds margin outside of the widget's normal size
895    /// request, the margin will be added in addition to the size from
896    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
897    pub fn margin_top(self, margin_top: i32) -> Self {
898        Self {
899            builder: self.builder.property("margin-top", margin_top),
900        }
901    }
902
903    /// The name of the widget.
904    pub fn name(self, name: impl Into<glib::GString>) -> Self {
905        Self {
906            builder: self.builder.property("name", name.into()),
907        }
908    }
909
910    /// The requested opacity of the widget.
911    pub fn opacity(self, opacity: f64) -> Self {
912        Self {
913            builder: self.builder.property("opacity", opacity),
914        }
915    }
916
917    /// How content outside the widget's content area is treated.
918    ///
919    /// This property is meant to be set by widget implementations,
920    /// typically in their instance init function.
921    pub fn overflow(self, overflow: Overflow) -> Self {
922        Self {
923            builder: self.builder.property("overflow", overflow),
924        }
925    }
926
927    /// Whether the widget will receive the default action when it is focused.
928    pub fn receives_default(self, receives_default: bool) -> Self {
929        Self {
930            builder: self.builder.property("receives-default", receives_default),
931        }
932    }
933
934    /// Whether the widget responds to input.
935    pub fn sensitive(self, sensitive: bool) -> Self {
936        Self {
937            builder: self.builder.property("sensitive", sensitive),
938        }
939    }
940
941    /// Sets the text of tooltip to be the given string, which is marked up
942    /// with Pango markup.
943    ///
944    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
945    ///
946    /// This is a convenience property which will take care of getting the
947    /// tooltip shown if the given string is not `NULL`:
948    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
949    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
950    /// the default signal handler.
951    ///
952    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
953    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
954    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
955        Self {
956            builder: self
957                .builder
958                .property("tooltip-markup", tooltip_markup.into()),
959        }
960    }
961
962    /// Sets the text of tooltip to be the given string.
963    ///
964    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
965    ///
966    /// This is a convenience property which will take care of getting the
967    /// tooltip shown if the given string is not `NULL`:
968    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
969    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
970    /// the default signal handler.
971    ///
972    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
973    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
974    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
975        Self {
976            builder: self.builder.property("tooltip-text", tooltip_text.into()),
977        }
978    }
979
980    /// How to distribute vertical space if widget gets extra space.
981    pub fn valign(self, valign: Align) -> Self {
982        Self {
983            builder: self.builder.property("valign", valign),
984        }
985    }
986
987    /// Whether to expand vertically.
988    pub fn vexpand(self, vexpand: bool) -> Self {
989        Self {
990            builder: self.builder.property("vexpand", vexpand),
991        }
992    }
993
994    /// Whether to use the `vexpand` property.
995    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
996        Self {
997            builder: self.builder.property("vexpand-set", vexpand_set),
998        }
999    }
1000
1001    /// Whether the widget is visible.
1002    pub fn visible(self, visible: bool) -> Self {
1003        Self {
1004            builder: self.builder.property("visible", visible),
1005        }
1006    }
1007
1008    /// Overrides for width request of the widget.
1009    ///
1010    /// If this is -1, the natural request will be used.
1011    pub fn width_request(self, width_request: i32) -> Self {
1012        Self {
1013            builder: self.builder.property("width-request", width_request),
1014        }
1015    }
1016
1017    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1018    ///
1019    /// The accessible role cannot be changed once set.
1020    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1021        Self {
1022            builder: self.builder.property("accessible-role", accessible_role),
1023        }
1024    }
1025
1026    // rustdoc-stripper-ignore-next
1027    /// Build the [`Popover`].
1028    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1029    pub fn build(self) -> Popover {
1030        assert_initialized_main_thread!();
1031        self.builder.build()
1032    }
1033}
1034
1035/// Trait containing all [`struct@Popover`] methods.
1036///
1037/// # Implementors
1038///
1039/// [`EmojiChooser`][struct@crate::EmojiChooser], [`PopoverMenu`][struct@crate::PopoverMenu], [`Popover`][struct@crate::Popover]
1040pub trait PopoverExt: IsA<Popover> + 'static {
1041    /// Returns whether the popover is modal.
1042    ///
1043    /// See [`set_autohide()`][Self::set_autohide()] for the
1044    /// implications of this.
1045    ///
1046    /// # Returns
1047    ///
1048    /// [`true`] if @self is modal
1049    #[doc(alias = "gtk_popover_get_autohide")]
1050    #[doc(alias = "get_autohide")]
1051    #[doc(alias = "autohide")]
1052    fn is_autohide(&self) -> bool {
1053        unsafe {
1054            from_glib(ffi::gtk_popover_get_autohide(
1055                self.as_ref().to_glib_none().0,
1056            ))
1057        }
1058    }
1059
1060    /// Returns whether the popover will close after a modal child is closed.
1061    ///
1062    /// # Returns
1063    ///
1064    /// [`true`] if @self will close after a modal child.
1065    #[doc(alias = "gtk_popover_get_cascade_popdown")]
1066    #[doc(alias = "get_cascade_popdown")]
1067    #[doc(alias = "cascade-popdown")]
1068    fn is_cascade_popdown(&self) -> bool {
1069        unsafe {
1070            from_glib(ffi::gtk_popover_get_cascade_popdown(
1071                self.as_ref().to_glib_none().0,
1072            ))
1073        }
1074    }
1075
1076    /// Gets the child widget of @self.
1077    ///
1078    /// # Returns
1079    ///
1080    /// the child widget of @self
1081    #[doc(alias = "gtk_popover_get_child")]
1082    #[doc(alias = "get_child")]
1083    fn child(&self) -> Option<Widget> {
1084        unsafe { from_glib_none(ffi::gtk_popover_get_child(self.as_ref().to_glib_none().0)) }
1085    }
1086
1087    /// Gets whether this popover is showing an arrow
1088    /// pointing at the widget that it is relative to.
1089    ///
1090    /// # Returns
1091    ///
1092    /// whether the popover has an arrow
1093    #[doc(alias = "gtk_popover_get_has_arrow")]
1094    #[doc(alias = "get_has_arrow")]
1095    #[doc(alias = "has-arrow")]
1096    fn has_arrow(&self) -> bool {
1097        unsafe {
1098            from_glib(ffi::gtk_popover_get_has_arrow(
1099                self.as_ref().to_glib_none().0,
1100            ))
1101        }
1102    }
1103
1104    /// Gets whether mnemonics are visible.
1105    ///
1106    /// # Returns
1107    ///
1108    /// [`true`] if mnemonics are supposed to be visible
1109    ///   in this popover
1110    #[doc(alias = "gtk_popover_get_mnemonics_visible")]
1111    #[doc(alias = "get_mnemonics_visible")]
1112    #[doc(alias = "mnemonics-visible")]
1113    fn is_mnemonics_visible(&self) -> bool {
1114        unsafe {
1115            from_glib(ffi::gtk_popover_get_mnemonics_visible(
1116                self.as_ref().to_glib_none().0,
1117            ))
1118        }
1119    }
1120
1121    /// Gets the offset previous set with [`set_offset()`][Self::set_offset()]()].
1122    ///
1123    /// # Returns
1124    ///
1125    ///
1126    /// ## `x_offset`
1127    /// a location for the x_offset
1128    ///
1129    /// ## `y_offset`
1130    /// a location for the y_offset
1131    #[doc(alias = "gtk_popover_get_offset")]
1132    #[doc(alias = "get_offset")]
1133    fn offset(&self) -> (i32, i32) {
1134        unsafe {
1135            let mut x_offset = std::mem::MaybeUninit::uninit();
1136            let mut y_offset = std::mem::MaybeUninit::uninit();
1137            ffi::gtk_popover_get_offset(
1138                self.as_ref().to_glib_none().0,
1139                x_offset.as_mut_ptr(),
1140                y_offset.as_mut_ptr(),
1141            );
1142            (x_offset.assume_init(), y_offset.assume_init())
1143        }
1144    }
1145
1146    /// Gets the rectangle that the popover points to.
1147    ///
1148    /// If a rectangle to point to has been set, this function will
1149    /// return [`true`] and fill in @rect with such rectangle, otherwise
1150    /// it will return [`false`] and fill in @rect with the parent
1151    /// widget coordinates.
1152    ///
1153    /// # Returns
1154    ///
1155    /// [`true`] if a rectangle to point to was set.
1156    ///
1157    /// ## `rect`
1158    /// location to store the rectangle
1159    #[doc(alias = "gtk_popover_get_pointing_to")]
1160    #[doc(alias = "get_pointing_to")]
1161    #[doc(alias = "pointing-to")]
1162    fn pointing_to(&self) -> (bool, gdk::Rectangle) {
1163        unsafe {
1164            let mut rect = gdk::Rectangle::uninitialized();
1165            let ret = from_glib(ffi::gtk_popover_get_pointing_to(
1166                self.as_ref().to_glib_none().0,
1167                rect.to_glib_none_mut().0,
1168            ));
1169            (ret, rect)
1170        }
1171    }
1172
1173    /// Returns the preferred position of @self.
1174    ///
1175    /// # Returns
1176    ///
1177    /// The preferred position.
1178    #[doc(alias = "gtk_popover_get_position")]
1179    #[doc(alias = "get_position")]
1180    fn position(&self) -> PositionType {
1181        unsafe {
1182            from_glib(ffi::gtk_popover_get_position(
1183                self.as_ref().to_glib_none().0,
1184            ))
1185        }
1186    }
1187
1188    /// Pops @self down.
1189    ///
1190    /// This may have the side-effect of closing a parent popover
1191    /// as well. See [`cascade-popdown`][struct@crate::Popover#cascade-popdown].
1192    #[doc(alias = "gtk_popover_popdown")]
1193    fn popdown(&self) {
1194        unsafe {
1195            ffi::gtk_popover_popdown(self.as_ref().to_glib_none().0);
1196        }
1197    }
1198
1199    /// Pops @self up.
1200    #[doc(alias = "gtk_popover_popup")]
1201    fn popup(&self) {
1202        unsafe {
1203            ffi::gtk_popover_popup(self.as_ref().to_glib_none().0);
1204        }
1205    }
1206
1207    /// Allocate a size for the [`Popover`][crate::Popover].
1208    ///
1209    /// This function needs to be called in size-allocate by widgets
1210    /// who have a [`Popover`][crate::Popover] as child. When using a layout manager,
1211    /// this is happening automatically.
1212    ///
1213    /// To make a popover appear on screen, use [`popup()`][Self::popup()].
1214    #[doc(alias = "gtk_popover_present")]
1215    fn present(&self) {
1216        unsafe {
1217            ffi::gtk_popover_present(self.as_ref().to_glib_none().0);
1218        }
1219    }
1220
1221    /// Sets whether @self is modal.
1222    ///
1223    /// A modal popover will grab the keyboard focus on it when being
1224    /// displayed. Focus will wrap around within the popover. Clicking
1225    /// outside the popover area or pressing Esc will dismiss the popover.
1226    ///
1227    /// Called this function on an already showing popup with a new
1228    /// autohide value different from the current one, will cause the
1229    /// popup to be hidden.
1230    /// ## `autohide`
1231    /// [`true`] to dismiss the popover on outside clicks
1232    #[doc(alias = "gtk_popover_set_autohide")]
1233    #[doc(alias = "autohide")]
1234    fn set_autohide(&self, autohide: bool) {
1235        unsafe {
1236            ffi::gtk_popover_set_autohide(self.as_ref().to_glib_none().0, autohide.into_glib());
1237        }
1238    }
1239
1240    /// If @cascade_popdown is [`true`], the popover will be
1241    /// closed when a child modal popover is closed.
1242    ///
1243    /// If [`false`], @self will stay visible.
1244    /// ## `cascade_popdown`
1245    /// [`true`] if the popover should follow a child closing
1246    #[doc(alias = "gtk_popover_set_cascade_popdown")]
1247    #[doc(alias = "cascade-popdown")]
1248    fn set_cascade_popdown(&self, cascade_popdown: bool) {
1249        unsafe {
1250            ffi::gtk_popover_set_cascade_popdown(
1251                self.as_ref().to_glib_none().0,
1252                cascade_popdown.into_glib(),
1253            );
1254        }
1255    }
1256
1257    /// Sets the child widget of @self.
1258    /// ## `child`
1259    /// the child widget
1260    #[doc(alias = "gtk_popover_set_child")]
1261    #[doc(alias = "child")]
1262    fn set_child(&self, child: Option<&impl IsA<Widget>>) {
1263        unsafe {
1264            ffi::gtk_popover_set_child(
1265                self.as_ref().to_glib_none().0,
1266                child.map(|p| p.as_ref()).to_glib_none().0,
1267            );
1268        }
1269    }
1270
1271    /// Sets the default widget of a [`Popover`][crate::Popover].
1272    ///
1273    /// The default widget is the widget that’s activated when the user
1274    /// presses Enter in a dialog (for example). This function sets or
1275    /// unsets the default widget for a [`Popover`][crate::Popover].
1276    /// ## `widget`
1277    /// a child widget of @self to set as
1278    ///   the default, or [`None`] to unset the default widget for the popover
1279    #[doc(alias = "gtk_popover_set_default_widget")]
1280    #[doc(alias = "default-widget")]
1281    fn set_default_widget(&self, widget: Option<&impl IsA<Widget>>) {
1282        unsafe {
1283            ffi::gtk_popover_set_default_widget(
1284                self.as_ref().to_glib_none().0,
1285                widget.map(|p| p.as_ref()).to_glib_none().0,
1286            );
1287        }
1288    }
1289
1290    /// Sets whether this popover should draw an arrow
1291    /// pointing at the widget it is relative to.
1292    /// ## `has_arrow`
1293    /// [`true`] to draw an arrow
1294    #[doc(alias = "gtk_popover_set_has_arrow")]
1295    #[doc(alias = "has-arrow")]
1296    fn set_has_arrow(&self, has_arrow: bool) {
1297        unsafe {
1298            ffi::gtk_popover_set_has_arrow(self.as_ref().to_glib_none().0, has_arrow.into_glib());
1299        }
1300    }
1301
1302    /// Sets whether mnemonics should be visible.
1303    /// ## `mnemonics_visible`
1304    /// the new value
1305    #[doc(alias = "gtk_popover_set_mnemonics_visible")]
1306    #[doc(alias = "mnemonics-visible")]
1307    fn set_mnemonics_visible(&self, mnemonics_visible: bool) {
1308        unsafe {
1309            ffi::gtk_popover_set_mnemonics_visible(
1310                self.as_ref().to_glib_none().0,
1311                mnemonics_visible.into_glib(),
1312            );
1313        }
1314    }
1315
1316    /// Sets the offset to use when calculating the position
1317    /// of the popover.
1318    ///
1319    /// These values are used when preparing the `Gdk::PopupLayout`
1320    /// for positioning the popover.
1321    /// ## `x_offset`
1322    /// the x offset to adjust the position by
1323    /// ## `y_offset`
1324    /// the y offset to adjust the position by
1325    #[doc(alias = "gtk_popover_set_offset")]
1326    fn set_offset(&self, x_offset: i32, y_offset: i32) {
1327        unsafe {
1328            ffi::gtk_popover_set_offset(self.as_ref().to_glib_none().0, x_offset, y_offset);
1329        }
1330    }
1331
1332    /// Sets the rectangle that @self points to.
1333    ///
1334    /// This is in the coordinate space of the @self parent.
1335    /// ## `rect`
1336    /// rectangle to point to
1337    #[doc(alias = "gtk_popover_set_pointing_to")]
1338    #[doc(alias = "pointing-to")]
1339    fn set_pointing_to(&self, rect: Option<&gdk::Rectangle>) {
1340        unsafe {
1341            ffi::gtk_popover_set_pointing_to(self.as_ref().to_glib_none().0, rect.to_glib_none().0);
1342        }
1343    }
1344
1345    /// Sets the preferred position for @self to appear.
1346    ///
1347    /// If the @self is currently visible, it will be immediately
1348    /// updated.
1349    ///
1350    /// This preference will be respected where possible, although
1351    /// on lack of space (eg. if close to the window edges), the
1352    /// [`Popover`][crate::Popover] may choose to appear on the opposite side.
1353    /// ## `position`
1354    /// preferred popover position
1355    #[doc(alias = "gtk_popover_set_position")]
1356    #[doc(alias = "position")]
1357    fn set_position(&self, position: PositionType) {
1358        unsafe {
1359            ffi::gtk_popover_set_position(self.as_ref().to_glib_none().0, position.into_glib());
1360        }
1361    }
1362
1363    /// The default widget inside the popover.
1364    #[doc(alias = "default-widget")]
1365    fn default_widget(&self) -> Option<Widget> {
1366        ObjectExt::property(self.as_ref(), "default-widget")
1367    }
1368
1369    /// Emitted whend the user activates the default widget.
1370    ///
1371    /// This is a [keybinding signal](class.SignalAction.html).
1372    ///
1373    /// The default binding for this signal is <kbd>Enter</kbd>.
1374    #[doc(alias = "activate-default")]
1375    fn connect_activate_default<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1376        unsafe extern "C" fn activate_default_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1377            this: *mut ffi::GtkPopover,
1378            f: glib::ffi::gpointer,
1379        ) {
1380            let f: &F = &*(f as *const F);
1381            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1382        }
1383        unsafe {
1384            let f: Box_<F> = Box_::new(f);
1385            connect_raw(
1386                self.as_ptr() as *mut _,
1387                c"activate-default".as_ptr() as *const _,
1388                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1389                    activate_default_trampoline::<Self, F> as *const (),
1390                )),
1391                Box_::into_raw(f),
1392            )
1393        }
1394    }
1395
1396    fn emit_activate_default(&self) {
1397        self.emit_by_name::<()>("activate-default", &[]);
1398    }
1399
1400    /// Emitted when the popover is closed.
1401    #[doc(alias = "closed")]
1402    fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1403        unsafe extern "C" fn closed_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1404            this: *mut ffi::GtkPopover,
1405            f: glib::ffi::gpointer,
1406        ) {
1407            let f: &F = &*(f as *const F);
1408            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1409        }
1410        unsafe {
1411            let f: Box_<F> = Box_::new(f);
1412            connect_raw(
1413                self.as_ptr() as *mut _,
1414                c"closed".as_ptr() as *const _,
1415                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1416                    closed_trampoline::<Self, F> as *const (),
1417                )),
1418                Box_::into_raw(f),
1419            )
1420        }
1421    }
1422
1423    #[doc(alias = "autohide")]
1424    fn connect_autohide_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1425        unsafe extern "C" fn notify_autohide_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1426            this: *mut ffi::GtkPopover,
1427            _param_spec: glib::ffi::gpointer,
1428            f: glib::ffi::gpointer,
1429        ) {
1430            let f: &F = &*(f as *const F);
1431            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1432        }
1433        unsafe {
1434            let f: Box_<F> = Box_::new(f);
1435            connect_raw(
1436                self.as_ptr() as *mut _,
1437                c"notify::autohide".as_ptr() as *const _,
1438                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1439                    notify_autohide_trampoline::<Self, F> as *const (),
1440                )),
1441                Box_::into_raw(f),
1442            )
1443        }
1444    }
1445
1446    #[doc(alias = "cascade-popdown")]
1447    fn connect_cascade_popdown_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1448        unsafe extern "C" fn notify_cascade_popdown_trampoline<
1449            P: IsA<Popover>,
1450            F: Fn(&P) + 'static,
1451        >(
1452            this: *mut ffi::GtkPopover,
1453            _param_spec: glib::ffi::gpointer,
1454            f: glib::ffi::gpointer,
1455        ) {
1456            let f: &F = &*(f as *const F);
1457            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1458        }
1459        unsafe {
1460            let f: Box_<F> = Box_::new(f);
1461            connect_raw(
1462                self.as_ptr() as *mut _,
1463                c"notify::cascade-popdown".as_ptr() as *const _,
1464                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1465                    notify_cascade_popdown_trampoline::<Self, F> as *const (),
1466                )),
1467                Box_::into_raw(f),
1468            )
1469        }
1470    }
1471
1472    #[doc(alias = "child")]
1473    fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1474        unsafe extern "C" fn notify_child_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1475            this: *mut ffi::GtkPopover,
1476            _param_spec: glib::ffi::gpointer,
1477            f: glib::ffi::gpointer,
1478        ) {
1479            let f: &F = &*(f as *const F);
1480            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1481        }
1482        unsafe {
1483            let f: Box_<F> = Box_::new(f);
1484            connect_raw(
1485                self.as_ptr() as *mut _,
1486                c"notify::child".as_ptr() as *const _,
1487                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1488                    notify_child_trampoline::<Self, F> as *const (),
1489                )),
1490                Box_::into_raw(f),
1491            )
1492        }
1493    }
1494
1495    #[doc(alias = "default-widget")]
1496    fn connect_default_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1497        unsafe extern "C" fn notify_default_widget_trampoline<
1498            P: IsA<Popover>,
1499            F: Fn(&P) + 'static,
1500        >(
1501            this: *mut ffi::GtkPopover,
1502            _param_spec: glib::ffi::gpointer,
1503            f: glib::ffi::gpointer,
1504        ) {
1505            let f: &F = &*(f as *const F);
1506            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1507        }
1508        unsafe {
1509            let f: Box_<F> = Box_::new(f);
1510            connect_raw(
1511                self.as_ptr() as *mut _,
1512                c"notify::default-widget".as_ptr() as *const _,
1513                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1514                    notify_default_widget_trampoline::<Self, F> as *const (),
1515                )),
1516                Box_::into_raw(f),
1517            )
1518        }
1519    }
1520
1521    #[doc(alias = "has-arrow")]
1522    fn connect_has_arrow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1523        unsafe extern "C" fn notify_has_arrow_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1524            this: *mut ffi::GtkPopover,
1525            _param_spec: glib::ffi::gpointer,
1526            f: glib::ffi::gpointer,
1527        ) {
1528            let f: &F = &*(f as *const F);
1529            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1530        }
1531        unsafe {
1532            let f: Box_<F> = Box_::new(f);
1533            connect_raw(
1534                self.as_ptr() as *mut _,
1535                c"notify::has-arrow".as_ptr() as *const _,
1536                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1537                    notify_has_arrow_trampoline::<Self, F> as *const (),
1538                )),
1539                Box_::into_raw(f),
1540            )
1541        }
1542    }
1543
1544    #[doc(alias = "mnemonics-visible")]
1545    fn connect_mnemonics_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1546        unsafe extern "C" fn notify_mnemonics_visible_trampoline<
1547            P: IsA<Popover>,
1548            F: Fn(&P) + 'static,
1549        >(
1550            this: *mut ffi::GtkPopover,
1551            _param_spec: glib::ffi::gpointer,
1552            f: glib::ffi::gpointer,
1553        ) {
1554            let f: &F = &*(f as *const F);
1555            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1556        }
1557        unsafe {
1558            let f: Box_<F> = Box_::new(f);
1559            connect_raw(
1560                self.as_ptr() as *mut _,
1561                c"notify::mnemonics-visible".as_ptr() as *const _,
1562                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1563                    notify_mnemonics_visible_trampoline::<Self, F> as *const (),
1564                )),
1565                Box_::into_raw(f),
1566            )
1567        }
1568    }
1569
1570    #[doc(alias = "pointing-to")]
1571    fn connect_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1572        unsafe extern "C" fn notify_pointing_to_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1573            this: *mut ffi::GtkPopover,
1574            _param_spec: glib::ffi::gpointer,
1575            f: glib::ffi::gpointer,
1576        ) {
1577            let f: &F = &*(f as *const F);
1578            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1579        }
1580        unsafe {
1581            let f: Box_<F> = Box_::new(f);
1582            connect_raw(
1583                self.as_ptr() as *mut _,
1584                c"notify::pointing-to".as_ptr() as *const _,
1585                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1586                    notify_pointing_to_trampoline::<Self, F> as *const (),
1587                )),
1588                Box_::into_raw(f),
1589            )
1590        }
1591    }
1592
1593    #[doc(alias = "position")]
1594    fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1595        unsafe extern "C" fn notify_position_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1596            this: *mut ffi::GtkPopover,
1597            _param_spec: glib::ffi::gpointer,
1598            f: glib::ffi::gpointer,
1599        ) {
1600            let f: &F = &*(f as *const F);
1601            f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1602        }
1603        unsafe {
1604            let f: Box_<F> = Box_::new(f);
1605            connect_raw(
1606                self.as_ptr() as *mut _,
1607                c"notify::position".as_ptr() as *const _,
1608                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1609                    notify_position_trampoline::<Self, F> as *const (),
1610                )),
1611                Box_::into_raw(f),
1612            )
1613        }
1614    }
1615}
1616
1617impl<O: IsA<Popover>> PopoverExt for O {}