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