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