Skip to main content

gtk4/auto/
popover_bin.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7    Popover, Widget, ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// A single child container with a popover.
18    ///
19    /// You should use [`PopoverBin`][crate::PopoverBin] whenever you need to present a [`Popover`][crate::Popover]
20    /// to the user.
21    ///
22    /// ## Actions
23    ///
24    /// [`PopoverBin`][crate::PopoverBin] defines the `menu.popup` action, which can be activated
25    /// to present the popover to the user.
26    ///
27    /// ## CSS nodes
28    ///
29    /// [`PopoverBin`][crate::PopoverBin] has a single CSS node with the name `popoverbin`.
30    ///
31    /// ## Properties
32    ///
33    ///
34    /// #### `child`
35    ///  The child widget of the popover bin.
36    ///
37    /// Readable | Writeable
38    ///
39    ///
40    /// #### `handle-input`
41    ///  Whether the popover bin will handle input
42    /// to trigger the popup.
43    ///
44    /// Readable | Writeable
45    ///
46    ///
47    /// #### `menu-model`
48    ///  The `GMenuModel` from which the popup will be created.
49    ///
50    /// See [`PopoverBin::set_menu_model()`][crate::PopoverBin::set_menu_model()] for the interaction
51    /// with the [`popover`][struct@crate::PopoverBin#popover] property.
52    ///
53    /// Readable | Writeable
54    ///
55    ///
56    /// #### `popover`
57    ///  The [`Popover`][crate::Popover] that will be popped up when calling
58    /// [`PopoverBin::popup()`][crate::PopoverBin::popup()].
59    ///
60    /// Readable | Writeable
61    /// <details><summary><h4>Widget</h4></summary>
62    ///
63    ///
64    /// #### `can-focus`
65    ///  Whether the widget or any of its descendents can accept
66    /// the input focus.
67    ///
68    /// This property is meant to be set by widget implementations,
69    /// typically in their instance init function.
70    ///
71    /// Readable | Writeable
72    ///
73    ///
74    /// #### `can-target`
75    ///  Whether the widget can receive pointer events.
76    ///
77    /// Readable | Writeable
78    ///
79    ///
80    /// #### `css-classes`
81    ///  A list of css classes applied to this widget.
82    ///
83    /// Readable | Writeable
84    ///
85    ///
86    /// #### `css-name`
87    ///  The name of this widget in the CSS tree.
88    ///
89    /// This property is meant to be set by widget implementations,
90    /// typically in their instance init function.
91    ///
92    /// Readable | Writeable | Construct Only
93    ///
94    ///
95    /// #### `cursor`
96    ///  The cursor used by @widget.
97    ///
98    /// Readable | Writeable
99    ///
100    ///
101    /// #### `focus-on-click`
102    ///  Whether the widget should grab focus when it is clicked with the mouse.
103    ///
104    /// This property is only relevant for widgets that can take focus.
105    ///
106    /// Readable | Writeable
107    ///
108    ///
109    /// #### `focusable`
110    ///  Whether this widget itself will accept the input focus.
111    ///
112    /// Readable | Writeable
113    ///
114    ///
115    /// #### `halign`
116    ///  How to distribute horizontal space if widget gets extra space.
117    ///
118    /// Readable | Writeable
119    ///
120    ///
121    /// #### `has-default`
122    ///  Whether the widget is the default widget.
123    ///
124    /// Readable
125    ///
126    ///
127    /// #### `has-focus`
128    ///  Whether the widget has the input focus.
129    ///
130    /// Readable
131    ///
132    ///
133    /// #### `has-tooltip`
134    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
135    /// signal on @widget.
136    ///
137    /// A true value indicates that @widget can have a tooltip, in this case
138    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
139    /// determine whether it will provide a tooltip or not.
140    ///
141    /// Readable | Writeable
142    ///
143    ///
144    /// #### `height-request`
145    ///  Overrides for height request of the widget.
146    ///
147    /// If this is -1, the natural request will be used.
148    ///
149    /// Readable | Writeable
150    ///
151    ///
152    /// #### `hexpand`
153    ///  Whether to expand horizontally.
154    ///
155    /// Readable | Writeable
156    ///
157    ///
158    /// #### `hexpand-set`
159    ///  Whether to use the `hexpand` property.
160    ///
161    /// Readable | Writeable
162    ///
163    ///
164    /// #### `layout-manager`
165    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
166    /// the preferred size of the widget, and allocate its children.
167    ///
168    /// This property is meant to be set by widget implementations,
169    /// typically in their instance init function.
170    ///
171    /// Readable | Writeable
172    ///
173    ///
174    /// #### `limit-events`
175    ///  Makes this widget act like a modal dialog, with respect to
176    /// event delivery.
177    ///
178    /// Global event controllers will not handle events with targets
179    /// inside the widget, unless they are set up to ignore propagation
180    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
181    ///
182    /// Readable | Writeable
183    ///
184    ///
185    /// #### `margin-bottom`
186    ///  Margin on bottom side of widget.
187    ///
188    /// This property adds margin outside of the widget's normal size
189    /// request, the margin will be added in addition to the size from
190    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
191    ///
192    /// Readable | Writeable
193    ///
194    ///
195    /// #### `margin-end`
196    ///  Margin on end of widget, horizontally.
197    ///
198    /// This property supports left-to-right and right-to-left text
199    /// directions.
200    ///
201    /// This property adds margin outside of the widget's normal size
202    /// request, the margin will be added in addition to the size from
203    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
204    ///
205    /// Readable | Writeable
206    ///
207    ///
208    /// #### `margin-start`
209    ///  Margin on start of widget, horizontally.
210    ///
211    /// This property supports left-to-right and right-to-left text
212    /// directions.
213    ///
214    /// This property adds margin outside of the widget's normal size
215    /// request, the margin will be added in addition to the size from
216    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
217    ///
218    /// Readable | Writeable
219    ///
220    ///
221    /// #### `margin-top`
222    ///  Margin on top side of widget.
223    ///
224    /// This property adds margin outside of the widget's normal size
225    /// request, the margin will be added in addition to the size from
226    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
227    ///
228    /// Readable | Writeable
229    ///
230    ///
231    /// #### `name`
232    ///  The name of the widget.
233    ///
234    /// Readable | Writeable
235    ///
236    ///
237    /// #### `opacity`
238    ///  The requested opacity of the widget.
239    ///
240    /// Readable | Writeable
241    ///
242    ///
243    /// #### `overflow`
244    ///  How content outside the widget's content area is treated.
245    ///
246    /// This property is meant to be set by widget implementations,
247    /// typically in their instance init function.
248    ///
249    /// Readable | Writeable
250    ///
251    ///
252    /// #### `parent`
253    ///  The parent widget of this widget.
254    ///
255    /// Readable
256    ///
257    ///
258    /// #### `receives-default`
259    ///  Whether the widget will receive the default action when it is focused.
260    ///
261    /// Readable | Writeable
262    ///
263    ///
264    /// #### `root`
265    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
266    ///
267    /// This will be `NULL` if the widget is not contained in a root widget.
268    ///
269    /// Readable
270    ///
271    ///
272    /// #### `scale-factor`
273    ///  The scale factor of the widget.
274    ///
275    /// Readable
276    ///
277    ///
278    /// #### `sensitive`
279    ///  Whether the widget responds to input.
280    ///
281    /// Readable | Writeable
282    ///
283    ///
284    /// #### `tooltip-markup`
285    ///  Sets the text of tooltip to be the given string, which is marked up
286    /// with Pango markup.
287    ///
288    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
289    ///
290    /// This is a convenience property which will take care of getting the
291    /// tooltip shown if the given string is not `NULL`:
292    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
293    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
294    /// the default signal handler.
295    ///
296    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
297    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
298    ///
299    /// Readable | Writeable
300    ///
301    ///
302    /// #### `tooltip-text`
303    ///  Sets the text of tooltip to be the given string.
304    ///
305    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
306    ///
307    /// This is a convenience property which will take care of getting the
308    /// tooltip shown if the given string is not `NULL`:
309    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
310    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
311    /// the default signal handler.
312    ///
313    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
314    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
315    ///
316    /// Readable | Writeable
317    ///
318    ///
319    /// #### `valign`
320    ///  How to distribute vertical space if widget gets extra space.
321    ///
322    /// Readable | Writeable
323    ///
324    ///
325    /// #### `vexpand`
326    ///  Whether to expand vertically.
327    ///
328    /// Readable | Writeable
329    ///
330    ///
331    /// #### `vexpand-set`
332    ///  Whether to use the `vexpand` property.
333    ///
334    /// Readable | Writeable
335    ///
336    ///
337    /// #### `visible`
338    ///  Whether the widget is visible.
339    ///
340    /// Readable | Writeable
341    ///
342    ///
343    /// #### `width-request`
344    ///  Overrides for width request of the widget.
345    ///
346    /// If this is -1, the natural request will be used.
347    ///
348    /// Readable | Writeable
349    /// </details>
350    /// <details><summary><h4>Accessible</h4></summary>
351    ///
352    ///
353    /// #### `accessible-role`
354    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
355    ///
356    /// The accessible role cannot be changed once set.
357    ///
358    /// Readable | Writeable
359    /// </details>
360    ///
361    /// # Implements
362    ///
363    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
364    #[doc(alias = "GtkPopoverBin")]
365    pub struct PopoverBin(Object<ffi::GtkPopoverBin, ffi::GtkPopoverBinClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
366
367    match fn {
368        type_ => || ffi::gtk_popover_bin_get_type(),
369    }
370}
371
372impl PopoverBin {
373    /// Creates a new popover bin widget.
374    ///
375    /// # Returns
376    ///
377    /// the newly created popover bin
378    #[doc(alias = "gtk_popover_bin_new")]
379    pub fn new() -> PopoverBin {
380        assert_initialized_main_thread!();
381        unsafe { Widget::from_glib_none(ffi::gtk_popover_bin_new()).unsafe_cast() }
382    }
383
384    // rustdoc-stripper-ignore-next
385    /// Creates a new builder-pattern struct instance to construct [`PopoverBin`] objects.
386    ///
387    /// This method returns an instance of [`PopoverBinBuilder`](crate::builders::PopoverBinBuilder) which can be used to create [`PopoverBin`] objects.
388    pub fn builder() -> PopoverBinBuilder {
389        PopoverBinBuilder::new()
390    }
391
392    /// Retrieves the child widget of the popover bin.
393    ///
394    /// # Returns
395    ///
396    /// the child widget
397    #[doc(alias = "gtk_popover_bin_get_child")]
398    #[doc(alias = "get_child")]
399    pub fn child(&self) -> Option<Widget> {
400        unsafe { from_glib_none(ffi::gtk_popover_bin_get_child(self.to_glib_none().0)) }
401    }
402
403    #[doc(alias = "gtk_popover_bin_get_handle_input")]
404    #[doc(alias = "get_handle_input")]
405    #[doc(alias = "handle-input")]
406    pub fn is_handle_input(&self) -> bool {
407        unsafe { from_glib(ffi::gtk_popover_bin_get_handle_input(self.to_glib_none().0)) }
408    }
409
410    /// Retrieves the menu model set using [`set_menu_model()`][Self::set_menu_model()].
411    ///
412    /// # Returns
413    ///
414    /// the menu model for the popover
415    #[doc(alias = "gtk_popover_bin_get_menu_model")]
416    #[doc(alias = "get_menu_model")]
417    #[doc(alias = "menu-model")]
418    pub fn menu_model(&self) -> Option<gio::MenuModel> {
419        unsafe { from_glib_none(ffi::gtk_popover_bin_get_menu_model(self.to_glib_none().0)) }
420    }
421
422    /// Retrieves the [`Popover`][crate::Popover] set using [`set_popover()`][Self::set_popover()].
423    ///
424    /// # Returns
425    ///
426    /// a popover widget
427    #[doc(alias = "gtk_popover_bin_get_popover")]
428    #[doc(alias = "get_popover")]
429    pub fn popover(&self) -> Option<Popover> {
430        unsafe { from_glib_none(ffi::gtk_popover_bin_get_popover(self.to_glib_none().0)) }
431    }
432
433    /// Hides the popover from the user.
434    ///
435    /// See: [`popup()`][Self::popup()]
436    #[doc(alias = "gtk_popover_bin_popdown")]
437    pub fn popdown(&self) {
438        unsafe {
439            ffi::gtk_popover_bin_popdown(self.to_glib_none().0);
440        }
441    }
442
443    /// Presents the popover to the user.
444    ///
445    /// Use [`set_popover()`][Self::set_popover()] or
446    /// [`set_menu_model()`][Self::set_menu_model()] to define the popover.
447    ///
448    /// See: [`popdown()`][Self::popdown()]
449    #[doc(alias = "gtk_popover_bin_popup")]
450    pub fn popup(&self) {
451        unsafe {
452            ffi::gtk_popover_bin_popup(self.to_glib_none().0);
453        }
454    }
455
456    /// Sets the child of the popover bin.
457    /// ## `child`
458    /// the child of the popover bin
459    #[doc(alias = "gtk_popover_bin_set_child")]
460    #[doc(alias = "child")]
461    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
462        unsafe {
463            ffi::gtk_popover_bin_set_child(
464                self.to_glib_none().0,
465                child.map(|p| p.as_ref()).to_glib_none().0,
466            );
467        }
468    }
469
470    /// Enables or disables input handling.
471    ///
472    /// If enabled, the popover bin will pop up the
473    /// popover on right-click or long press, as expected
474    /// for a context menu.
475    /// ## `handle_input`
476    /// whether to handle input
477    #[doc(alias = "gtk_popover_bin_set_handle_input")]
478    #[doc(alias = "handle-input")]
479    pub fn set_handle_input(&self, handle_input: bool) {
480        unsafe {
481            ffi::gtk_popover_bin_set_handle_input(self.to_glib_none().0, handle_input.into_glib());
482        }
483    }
484
485    /// Sets the menu model used to create the popover that will be
486    /// presented when calling [`popup()`][Self::popup()].
487    ///
488    /// If @model is `NULL`, the popover will be unset.
489    ///
490    /// A [`Popover`][crate::Popover] will be created from the menu model with
491    /// [`PopoverMenu::from_model()`][crate::PopoverMenu::from_model()]. Actions will be connected
492    /// as documented for this function.
493    ///
494    /// If [`popover`][struct@crate::PopoverBin#popover] is already set, it will be
495    /// dissociated from the popover bin, and the property is set to `NULL`.
496    ///
497    /// See: [`set_popover()`][Self::set_popover()]
498    /// ## `model`
499    /// a menu model
500    #[doc(alias = "gtk_popover_bin_set_menu_model")]
501    #[doc(alias = "menu-model")]
502    pub fn set_menu_model(&self, model: Option<&impl IsA<gio::MenuModel>>) {
503        unsafe {
504            ffi::gtk_popover_bin_set_menu_model(
505                self.to_glib_none().0,
506                model.map(|p| p.as_ref()).to_glib_none().0,
507            );
508        }
509    }
510
511    /// Sets the [`Popover`][crate::Popover] that will be presented when calling
512    /// [`popup()`][Self::popup()].
513    ///
514    /// If @popover is `NULL`, the popover will be unset.
515    ///
516    /// If [`menu-model`][struct@crate::PopoverBin#menu-model] is set before calling
517    /// this function, then the menu model property will be unset.
518    ///
519    /// See: [`set_menu_model()`][Self::set_menu_model()]
520    /// ## `popover`
521    /// a [`Popover`][crate::Popover]
522    #[doc(alias = "gtk_popover_bin_set_popover")]
523    #[doc(alias = "popover")]
524    pub fn set_popover(&self, popover: Option<&impl IsA<Popover>>) {
525        unsafe {
526            ffi::gtk_popover_bin_set_popover(
527                self.to_glib_none().0,
528                popover.map(|p| p.as_ref()).to_glib_none().0,
529            );
530        }
531    }
532
533    #[cfg(feature = "v4_22")]
534    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
535    #[doc(alias = "child")]
536    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
537        unsafe extern "C" fn notify_child_trampoline<F: Fn(&PopoverBin) + 'static>(
538            this: *mut ffi::GtkPopoverBin,
539            _param_spec: glib::ffi::gpointer,
540            f: glib::ffi::gpointer,
541        ) {
542            unsafe {
543                let f: &F = &*(f as *const F);
544                f(&from_glib_borrow(this))
545            }
546        }
547        unsafe {
548            let f: Box_<F> = Box_::new(f);
549            connect_raw(
550                self.as_ptr() as *mut _,
551                c"notify::child".as_ptr() as *const _,
552                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
553                    notify_child_trampoline::<F> as *const (),
554                )),
555                Box_::into_raw(f),
556            )
557        }
558    }
559
560    #[cfg(feature = "v4_22")]
561    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
562    #[doc(alias = "handle-input")]
563    pub fn connect_handle_input_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
564        unsafe extern "C" fn notify_handle_input_trampoline<F: Fn(&PopoverBin) + 'static>(
565            this: *mut ffi::GtkPopoverBin,
566            _param_spec: glib::ffi::gpointer,
567            f: glib::ffi::gpointer,
568        ) {
569            unsafe {
570                let f: &F = &*(f as *const F);
571                f(&from_glib_borrow(this))
572            }
573        }
574        unsafe {
575            let f: Box_<F> = Box_::new(f);
576            connect_raw(
577                self.as_ptr() as *mut _,
578                c"notify::handle-input".as_ptr() as *const _,
579                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
580                    notify_handle_input_trampoline::<F> as *const (),
581                )),
582                Box_::into_raw(f),
583            )
584        }
585    }
586
587    #[cfg(feature = "v4_22")]
588    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
589    #[doc(alias = "menu-model")]
590    pub fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
591        unsafe extern "C" fn notify_menu_model_trampoline<F: Fn(&PopoverBin) + 'static>(
592            this: *mut ffi::GtkPopoverBin,
593            _param_spec: glib::ffi::gpointer,
594            f: glib::ffi::gpointer,
595        ) {
596            unsafe {
597                let f: &F = &*(f as *const F);
598                f(&from_glib_borrow(this))
599            }
600        }
601        unsafe {
602            let f: Box_<F> = Box_::new(f);
603            connect_raw(
604                self.as_ptr() as *mut _,
605                c"notify::menu-model".as_ptr() as *const _,
606                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
607                    notify_menu_model_trampoline::<F> as *const (),
608                )),
609                Box_::into_raw(f),
610            )
611        }
612    }
613
614    #[cfg(feature = "v4_22")]
615    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
616    #[doc(alias = "popover")]
617    pub fn connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
618        unsafe extern "C" fn notify_popover_trampoline<F: Fn(&PopoverBin) + 'static>(
619            this: *mut ffi::GtkPopoverBin,
620            _param_spec: glib::ffi::gpointer,
621            f: glib::ffi::gpointer,
622        ) {
623            unsafe {
624                let f: &F = &*(f as *const F);
625                f(&from_glib_borrow(this))
626            }
627        }
628        unsafe {
629            let f: Box_<F> = Box_::new(f);
630            connect_raw(
631                self.as_ptr() as *mut _,
632                c"notify::popover".as_ptr() as *const _,
633                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
634                    notify_popover_trampoline::<F> as *const (),
635                )),
636                Box_::into_raw(f),
637            )
638        }
639    }
640}
641
642#[cfg(feature = "v4_22")]
643#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
644impl Default for PopoverBin {
645    fn default() -> Self {
646        Self::new()
647    }
648}
649
650// rustdoc-stripper-ignore-next
651/// A [builder-pattern] type to construct [`PopoverBin`] objects.
652///
653/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
654#[must_use = "The builder must be built to be used"]
655pub struct PopoverBinBuilder {
656    builder: glib::object::ObjectBuilder<'static, PopoverBin>,
657}
658
659impl PopoverBinBuilder {
660    fn new() -> Self {
661        Self {
662            builder: glib::object::Object::builder(),
663        }
664    }
665
666    /// The child widget of the popover bin.
667    #[cfg(feature = "v4_22")]
668    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
669    pub fn child(self, child: &impl IsA<Widget>) -> Self {
670        Self {
671            builder: self.builder.property("child", child.clone().upcast()),
672        }
673    }
674
675    /// Whether the popover bin will handle input
676    /// to trigger the popup.
677    #[cfg(feature = "v4_22")]
678    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
679    pub fn handle_input(self, handle_input: bool) -> Self {
680        Self {
681            builder: self.builder.property("handle-input", handle_input),
682        }
683    }
684
685    /// The `GMenuModel` from which the popup will be created.
686    ///
687    /// See [`PopoverBin::set_menu_model()`][crate::PopoverBin::set_menu_model()] for the interaction
688    /// with the [`popover`][struct@crate::PopoverBin#popover] property.
689    #[cfg(feature = "v4_22")]
690    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
691    pub fn menu_model(self, menu_model: &impl IsA<gio::MenuModel>) -> Self {
692        Self {
693            builder: self
694                .builder
695                .property("menu-model", menu_model.clone().upcast()),
696        }
697    }
698
699    /// The [`Popover`][crate::Popover] that will be popped up when calling
700    /// [`PopoverBin::popup()`][crate::PopoverBin::popup()].
701    #[cfg(feature = "v4_22")]
702    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
703    pub fn popover(self, popover: &impl IsA<Popover>) -> Self {
704        Self {
705            builder: self.builder.property("popover", popover.clone().upcast()),
706        }
707    }
708
709    /// Whether the widget or any of its descendents can accept
710    /// the input focus.
711    ///
712    /// This property is meant to be set by widget implementations,
713    /// typically in their instance init function.
714    pub fn can_focus(self, can_focus: bool) -> Self {
715        Self {
716            builder: self.builder.property("can-focus", can_focus),
717        }
718    }
719
720    /// Whether the widget can receive pointer events.
721    pub fn can_target(self, can_target: bool) -> Self {
722        Self {
723            builder: self.builder.property("can-target", can_target),
724        }
725    }
726
727    /// A list of css classes applied to this widget.
728    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
729        Self {
730            builder: self.builder.property("css-classes", css_classes.into()),
731        }
732    }
733
734    /// The name of this widget in the CSS tree.
735    ///
736    /// This property is meant to be set by widget implementations,
737    /// typically in their instance init function.
738    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
739        Self {
740            builder: self.builder.property("css-name", css_name.into()),
741        }
742    }
743
744    /// The cursor used by @widget.
745    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
746        Self {
747            builder: self.builder.property("cursor", cursor.clone()),
748        }
749    }
750
751    /// Whether the widget should grab focus when it is clicked with the mouse.
752    ///
753    /// This property is only relevant for widgets that can take focus.
754    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
755        Self {
756            builder: self.builder.property("focus-on-click", focus_on_click),
757        }
758    }
759
760    /// Whether this widget itself will accept the input focus.
761    pub fn focusable(self, focusable: bool) -> Self {
762        Self {
763            builder: self.builder.property("focusable", focusable),
764        }
765    }
766
767    /// How to distribute horizontal space if widget gets extra space.
768    pub fn halign(self, halign: Align) -> Self {
769        Self {
770            builder: self.builder.property("halign", halign),
771        }
772    }
773
774    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
775    /// signal on @widget.
776    ///
777    /// A true value indicates that @widget can have a tooltip, in this case
778    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
779    /// determine whether it will provide a tooltip or not.
780    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
781        Self {
782            builder: self.builder.property("has-tooltip", has_tooltip),
783        }
784    }
785
786    /// Overrides for height request of the widget.
787    ///
788    /// If this is -1, the natural request will be used.
789    pub fn height_request(self, height_request: i32) -> Self {
790        Self {
791            builder: self.builder.property("height-request", height_request),
792        }
793    }
794
795    /// Whether to expand horizontally.
796    pub fn hexpand(self, hexpand: bool) -> Self {
797        Self {
798            builder: self.builder.property("hexpand", hexpand),
799        }
800    }
801
802    /// Whether to use the `hexpand` property.
803    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
804        Self {
805            builder: self.builder.property("hexpand-set", hexpand_set),
806        }
807    }
808
809    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
810    /// the preferred size of the widget, and allocate its children.
811    ///
812    /// This property is meant to be set by widget implementations,
813    /// typically in their instance init function.
814    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
815        Self {
816            builder: self
817                .builder
818                .property("layout-manager", layout_manager.clone().upcast()),
819        }
820    }
821
822    /// Makes this widget act like a modal dialog, with respect to
823    /// event delivery.
824    ///
825    /// Global event controllers will not handle events with targets
826    /// inside the widget, unless they are set up to ignore propagation
827    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
828    #[cfg(feature = "v4_18")]
829    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
830    pub fn limit_events(self, limit_events: bool) -> Self {
831        Self {
832            builder: self.builder.property("limit-events", limit_events),
833        }
834    }
835
836    /// Margin on bottom side of widget.
837    ///
838    /// This property adds margin outside of the widget's normal size
839    /// request, the margin will be added in addition to the size from
840    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
841    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
842        Self {
843            builder: self.builder.property("margin-bottom", margin_bottom),
844        }
845    }
846
847    /// Margin on end of widget, horizontally.
848    ///
849    /// This property supports left-to-right and right-to-left text
850    /// directions.
851    ///
852    /// This property adds margin outside of the widget's normal size
853    /// request, the margin will be added in addition to the size from
854    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
855    pub fn margin_end(self, margin_end: i32) -> Self {
856        Self {
857            builder: self.builder.property("margin-end", margin_end),
858        }
859    }
860
861    /// Margin on start of widget, horizontally.
862    ///
863    /// This property supports left-to-right and right-to-left text
864    /// directions.
865    ///
866    /// This property adds margin outside of the widget's normal size
867    /// request, the margin will be added in addition to the size from
868    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
869    pub fn margin_start(self, margin_start: i32) -> Self {
870        Self {
871            builder: self.builder.property("margin-start", margin_start),
872        }
873    }
874
875    /// Margin on top side of widget.
876    ///
877    /// This property adds margin outside of the widget's normal size
878    /// request, the margin will be added in addition to the size from
879    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
880    pub fn margin_top(self, margin_top: i32) -> Self {
881        Self {
882            builder: self.builder.property("margin-top", margin_top),
883        }
884    }
885
886    /// The name of the widget.
887    pub fn name(self, name: impl Into<glib::GString>) -> Self {
888        Self {
889            builder: self.builder.property("name", name.into()),
890        }
891    }
892
893    /// The requested opacity of the widget.
894    pub fn opacity(self, opacity: f64) -> Self {
895        Self {
896            builder: self.builder.property("opacity", opacity),
897        }
898    }
899
900    /// How content outside the widget's content area is treated.
901    ///
902    /// This property is meant to be set by widget implementations,
903    /// typically in their instance init function.
904    pub fn overflow(self, overflow: Overflow) -> Self {
905        Self {
906            builder: self.builder.property("overflow", overflow),
907        }
908    }
909
910    /// Whether the widget will receive the default action when it is focused.
911    pub fn receives_default(self, receives_default: bool) -> Self {
912        Self {
913            builder: self.builder.property("receives-default", receives_default),
914        }
915    }
916
917    /// Whether the widget responds to input.
918    pub fn sensitive(self, sensitive: bool) -> Self {
919        Self {
920            builder: self.builder.property("sensitive", sensitive),
921        }
922    }
923
924    /// Sets the text of tooltip to be the given string, which is marked up
925    /// with Pango markup.
926    ///
927    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
928    ///
929    /// This is a convenience property which will take care of getting the
930    /// tooltip shown if the given string is not `NULL`:
931    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
932    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
933    /// the default signal handler.
934    ///
935    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
936    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
937    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
938        Self {
939            builder: self
940                .builder
941                .property("tooltip-markup", tooltip_markup.into()),
942        }
943    }
944
945    /// Sets the text of tooltip to be the given string.
946    ///
947    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
948    ///
949    /// This is a convenience property which will take care of getting the
950    /// tooltip shown if the given string is not `NULL`:
951    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
952    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
953    /// the default signal handler.
954    ///
955    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
956    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
957    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
958        Self {
959            builder: self.builder.property("tooltip-text", tooltip_text.into()),
960        }
961    }
962
963    /// How to distribute vertical space if widget gets extra space.
964    pub fn valign(self, valign: Align) -> Self {
965        Self {
966            builder: self.builder.property("valign", valign),
967        }
968    }
969
970    /// Whether to expand vertically.
971    pub fn vexpand(self, vexpand: bool) -> Self {
972        Self {
973            builder: self.builder.property("vexpand", vexpand),
974        }
975    }
976
977    /// Whether to use the `vexpand` property.
978    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
979        Self {
980            builder: self.builder.property("vexpand-set", vexpand_set),
981        }
982    }
983
984    /// Whether the widget is visible.
985    pub fn visible(self, visible: bool) -> Self {
986        Self {
987            builder: self.builder.property("visible", visible),
988        }
989    }
990
991    /// Overrides for width request of the widget.
992    ///
993    /// If this is -1, the natural request will be used.
994    pub fn width_request(self, width_request: i32) -> Self {
995        Self {
996            builder: self.builder.property("width-request", width_request),
997        }
998    }
999
1000    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1001    ///
1002    /// The accessible role cannot be changed once set.
1003    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1004        Self {
1005            builder: self.builder.property("accessible-role", accessible_role),
1006        }
1007    }
1008
1009    // rustdoc-stripper-ignore-next
1010    /// Build the [`PopoverBin`].
1011    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1012    pub fn build(self) -> PopoverBin {
1013        assert_initialized_main_thread!();
1014        self.builder.build()
1015    }
1016}