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