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