Skip to main content

gtk/auto/
popover_menu.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    Align, Bin, Buildable, Container, Popover, PopoverConstraint, PositionType, ResizeMode, Widget,
7    ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// GtkPopoverMenu is a subclass of [`Popover`][crate::Popover] that treats its
18    /// children like menus and allows switching between them. It is
19    /// meant to be used primarily together with [`ModelButton`][crate::ModelButton], but
20    /// any widget can be used, such as [`SpinButton`][crate::SpinButton] or [`Scale`][crate::Scale].
21    /// In this respect, GtkPopoverMenu is more flexible than popovers
22    /// that are created from a [`gio::MenuModel`][crate::gio::MenuModel] with [`Popover::from_model()`][crate::Popover::from_model()].
23    ///
24    /// To add a child as a submenu, set the [`submenu`][struct@crate::PopoverMenu#submenu]
25    /// child property to the name of the submenu. To let the user open
26    /// this submenu, add a [`ModelButton`][crate::ModelButton] whose [`menu-name`][struct@crate::ModelButton#menu-name]
27    /// property is set to the name you've given to the submenu.
28    ///
29    /// By convention, the first child of a submenu should be a [`ModelButton`][crate::ModelButton]
30    /// to switch back to the parent menu. Such a button should use the
31    /// [`inverted`][struct@crate::ModelButton#inverted] and [`centered`][struct@crate::ModelButton#centered] properties
32    /// to achieve a title-like appearance and place the submenu indicator
33    /// at the opposite side. To switch back to the main menu, use "main"
34    /// as the menu name.
35    ///
36    /// # Example
37    ///
38    ///
39    ///
40    /// **⚠️ The following code is in xml ⚠️**
41    ///
42    /// ```xml
43    /// <object class="GtkPopoverMenu">
44    ///   <child>
45    ///     <object class="GtkBox">
46    ///       <property name="visible">True</property>
47    ///       <property name="margin">10</property>
48    ///       <child>
49    ///         <object class="GtkModelButton">
50    ///           <property name="visible">True</property>
51    ///           <property name="action-name">win.frob</property>
52    ///           <property name="text" translatable="yes">Frob</property>
53    ///         </object>
54    ///       </child>
55    ///       <child>
56    ///         <object class="GtkModelButton">
57    ///           <property name="visible">True</property>
58    ///           <property name="menu-name">more</property>
59    ///           <property name="text" translatable="yes">More</property>
60    ///         </object>
61    ///       </child>
62    ///     </object>
63    ///   </child>
64    ///   <child>
65    ///     <object class="GtkBox">
66    ///       <property name="visible">True</property>
67    ///       <property name="margin">10</property>
68    ///       <child>
69    ///         <object class="GtkModelButton">
70    ///           <property name="visible">True</property>
71    ///           <property name="action-name">win.foo</property>
72    ///           <property name="text" translatable="yes">Foo</property>
73    ///         </object>
74    ///       </child>
75    ///       <child>
76    ///         <object class="GtkModelButton">
77    ///           <property name="visible">True</property>
78    ///           <property name="action-name">win.bar</property>
79    ///           <property name="text" translatable="yes">Bar</property>
80    ///         </object>
81    ///       </child>
82    ///     </object>
83    ///     <packing>
84    ///       <property name="submenu">more</property>
85    ///     </packing>
86    ///   </child>
87    /// </object>
88    /// ```
89    ///
90    /// Just like normal popovers created using gtk_popover_new_from_model,
91    /// [`PopoverMenu`][crate::PopoverMenu] instances have a single css node called "popover"
92    /// and get the .menu style class.
93    ///
94    /// ## Properties
95    ///
96    ///
97    /// #### `visible-submenu`
98    ///  Readable | Writable
99    /// <details><summary><h4>Popover</h4></summary>
100    ///
101    ///
102    /// #### `constrain-to`
103    ///  Sets a constraint for the popover position.
104    ///
105    /// Readable | Writable
106    ///
107    ///
108    /// #### `modal`
109    ///  Sets whether the popover is modal (so other elements in the window do not
110    /// receive input while the popover is visible).
111    ///
112    /// Readable | Writable
113    ///
114    ///
115    /// #### `pointing-to`
116    ///  Marks a specific rectangle to be pointed.
117    ///
118    /// Readable | Writable
119    ///
120    ///
121    /// #### `position`
122    ///  Sets the preferred position of the popover.
123    ///
124    /// Readable | Writable
125    ///
126    ///
127    /// #### `relative-to`
128    ///  Sets the attached widget.
129    ///
130    /// Readable | Writable
131    ///
132    ///
133    /// #### `transitions-enabled`
134    ///  Whether show/hide transitions are enabled for this popover.
135    ///
136    /// Readable | Writable
137    /// </details>
138    /// <details><summary><h4>Container</h4></summary>
139    ///
140    ///
141    /// #### `border-width`
142    ///  Readable | Writable
143    ///
144    ///
145    /// #### `child`
146    ///  Writable
147    ///
148    ///
149    /// #### `resize-mode`
150    ///  Readable | Writable
151    /// </details>
152    /// <details><summary><h4>Widget</h4></summary>
153    ///
154    ///
155    /// #### `app-paintable`
156    ///  Readable | Writable
157    ///
158    ///
159    /// #### `can-default`
160    ///  Readable | Writable
161    ///
162    ///
163    /// #### `can-focus`
164    ///  Readable | Writable
165    ///
166    ///
167    /// #### `composite-child`
168    ///  Readable
169    ///
170    ///
171    /// #### `double-buffered`
172    ///  Whether the widget is double buffered.
173    ///
174    /// Readable | Writable
175    ///
176    ///
177    /// #### `events`
178    ///  Readable | Writable
179    ///
180    ///
181    /// #### `expand`
182    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
183    ///
184    /// Readable | Writable
185    ///
186    ///
187    /// #### `focus-on-click`
188    ///  Whether the widget should grab focus when it is clicked with the mouse.
189    ///
190    /// This property is only relevant for widgets that can take focus.
191    ///
192    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
193    /// GtkComboBox) implemented this property individually.
194    ///
195    /// Readable | Writable
196    ///
197    ///
198    /// #### `halign`
199    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
200    ///
201    /// Readable | Writable
202    ///
203    ///
204    /// #### `has-default`
205    ///  Readable | Writable
206    ///
207    ///
208    /// #### `has-focus`
209    ///  Readable | Writable
210    ///
211    ///
212    /// #### `has-tooltip`
213    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
214    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
215    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
216    /// whether it will provide a tooltip or not.
217    ///
218    /// Note that setting this property to [`true`] for the first time will change
219    /// the event masks of the GdkWindows of this widget to include leave-notify
220    /// and motion-notify events. This cannot and will not be undone when the
221    /// property is set to [`false`] again.
222    ///
223    /// Readable | Writable
224    ///
225    ///
226    /// #### `height-request`
227    ///  Readable | Writable
228    ///
229    ///
230    /// #### `hexpand`
231    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
232    ///
233    /// Readable | Writable
234    ///
235    ///
236    /// #### `hexpand-set`
237    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
238    ///
239    /// Readable | Writable
240    ///
241    ///
242    /// #### `is-focus`
243    ///  Readable | Writable
244    ///
245    ///
246    /// #### `margin`
247    ///  Sets all four sides' margin at once. If read, returns max
248    /// margin on any side.
249    ///
250    /// Readable | Writable
251    ///
252    ///
253    /// #### `margin-bottom`
254    ///  Margin on bottom side of widget.
255    ///
256    /// This property adds margin outside of the widget's normal size
257    /// request, the margin will be added in addition to the size from
258    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
259    ///
260    /// Readable | Writable
261    ///
262    ///
263    /// #### `margin-end`
264    ///  Margin on end of widget, horizontally. This property supports
265    /// left-to-right and right-to-left text directions.
266    ///
267    /// This property adds margin outside of the widget's normal size
268    /// request, the margin will be added in addition to the size from
269    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
270    ///
271    /// Readable | Writable
272    ///
273    ///
274    /// #### `margin-left`
275    ///  Margin on left side of widget.
276    ///
277    /// This property adds margin outside of the widget's normal size
278    /// request, the margin will be added in addition to the size from
279    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
280    ///
281    /// Readable | Writable
282    ///
283    ///
284    /// #### `margin-right`
285    ///  Margin on right side of widget.
286    ///
287    /// This property adds margin outside of the widget's normal size
288    /// request, the margin will be added in addition to the size from
289    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
290    ///
291    /// Readable | Writable
292    ///
293    ///
294    /// #### `margin-start`
295    ///  Margin on start of widget, horizontally. This property supports
296    /// left-to-right and right-to-left text directions.
297    ///
298    /// This property adds margin outside of the widget's normal size
299    /// request, the margin will be added in addition to the size from
300    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
301    ///
302    /// Readable | Writable
303    ///
304    ///
305    /// #### `margin-top`
306    ///  Margin on top side of widget.
307    ///
308    /// This property adds margin outside of the widget's normal size
309    /// request, the margin will be added in addition to the size from
310    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
311    ///
312    /// Readable | Writable
313    ///
314    ///
315    /// #### `name`
316    ///  Readable | Writable
317    ///
318    ///
319    /// #### `no-show-all`
320    ///  Readable | Writable
321    ///
322    ///
323    /// #### `opacity`
324    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
325    /// more details about window opacity.
326    ///
327    /// Before 3.8 this was only available in GtkWindow
328    ///
329    /// Readable | Writable
330    ///
331    ///
332    /// #### `parent`
333    ///  Readable | Writable
334    ///
335    ///
336    /// #### `receives-default`
337    ///  Readable | Writable
338    ///
339    ///
340    /// #### `scale-factor`
341    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
342    /// more details about widget scaling.
343    ///
344    /// Readable
345    ///
346    ///
347    /// #### `sensitive`
348    ///  Readable | Writable
349    ///
350    ///
351    /// #### `style`
352    ///  The style of the widget, which contains information about how it will look (colors, etc).
353    ///
354    /// Readable | Writable
355    ///
356    ///
357    /// #### `tooltip-markup`
358    ///  Sets the text of tooltip to be the given string, which is marked up
359    /// with the [Pango text markup language][PangoMarkupFormat].
360    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
361    ///
362    /// This is a convenience property which will take care of getting the
363    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
364    /// will automatically be set to [`true`] and there will be taken care of
365    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
366    ///
367    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
368    /// are set, the last one wins.
369    ///
370    /// Readable | Writable
371    ///
372    ///
373    /// #### `tooltip-text`
374    ///  Sets the text of tooltip to be the given string.
375    ///
376    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
377    ///
378    /// This is a convenience property which will take care of getting the
379    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
380    /// will automatically be set to [`true`] and there will be taken care of
381    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
382    ///
383    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
384    /// are set, the last one wins.
385    ///
386    /// Readable | Writable
387    ///
388    ///
389    /// #### `valign`
390    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
391    ///
392    /// Readable | Writable
393    ///
394    ///
395    /// #### `vexpand`
396    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
397    ///
398    /// Readable | Writable
399    ///
400    ///
401    /// #### `vexpand-set`
402    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
403    ///
404    /// Readable | Writable
405    ///
406    ///
407    /// #### `visible`
408    ///  Readable | Writable
409    ///
410    ///
411    /// #### `width-request`
412    ///  Readable | Writable
413    ///
414    ///
415    /// #### `window`
416    ///  The widget's window if it is realized, [`None`] otherwise.
417    ///
418    /// Readable
419    /// </details>
420    ///
421    /// # Implements
422    ///
423    /// [`PopoverExt`][trait@crate::prelude::PopoverExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
424    #[doc(alias = "GtkPopoverMenu")]
425    pub struct PopoverMenu(Object<ffi::GtkPopoverMenu, ffi::GtkPopoverMenuClass>) @extends Popover, Bin, Container, Widget, @implements Buildable;
426
427    match fn {
428        type_ => || ffi::gtk_popover_menu_get_type(),
429    }
430}
431
432impl PopoverMenu {
433    /// Creates a new popover menu.
434    ///
435    /// # Returns
436    ///
437    /// a new [`PopoverMenu`][crate::PopoverMenu]
438    #[doc(alias = "gtk_popover_menu_new")]
439    pub fn new() -> PopoverMenu {
440        assert_initialized_main_thread!();
441        unsafe { Widget::from_glib_none(ffi::gtk_popover_menu_new()).unsafe_cast() }
442    }
443
444    // rustdoc-stripper-ignore-next
445    /// Creates a new builder-pattern struct instance to construct [`PopoverMenu`] objects.
446    ///
447    /// This method returns an instance of [`PopoverMenuBuilder`](crate::builders::PopoverMenuBuilder) which can be used to create [`PopoverMenu`] objects.
448    pub fn builder() -> PopoverMenuBuilder {
449        PopoverMenuBuilder::new()
450    }
451
452    /// Opens a submenu of the `self`. The `name`
453    /// must be one of the names given to the submenus
454    /// of `self` with [`submenu`][struct@crate::PopoverMenu#submenu], or
455    /// "main" to switch back to the main menu.
456    ///
457    /// [`ModelButton`][crate::ModelButton] will open submenus automatically
458    /// when the [`menu-name`][struct@crate::ModelButton#menu-name] property is set,
459    /// so this function is only needed when you are using
460    /// other kinds of widgets to initiate menu changes.
461    /// ## `name`
462    /// the name of the menu to switch to
463    #[doc(alias = "gtk_popover_menu_open_submenu")]
464    pub fn open_submenu(&self, name: &str) {
465        unsafe {
466            ffi::gtk_popover_menu_open_submenu(self.to_glib_none().0, name.to_glib_none().0);
467        }
468    }
469
470    #[doc(alias = "visible-submenu")]
471    pub fn visible_submenu(&self) -> Option<glib::GString> {
472        ObjectExt::property(self, "visible-submenu")
473    }
474
475    #[doc(alias = "visible-submenu")]
476    pub fn set_visible_submenu(&self, visible_submenu: Option<&str>) {
477        ObjectExt::set_property(self, "visible-submenu", visible_submenu)
478    }
479
480    pub fn child_position<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
481        crate::prelude::ContainerExtManual::child_property(self, &item.clone().upcast(), "position")
482    }
483
484    pub fn set_child_position<T: IsA<crate::Widget>>(&self, item: &T, position: i32) {
485        crate::prelude::ContainerExtManual::child_set_property(
486            self,
487            &item.clone().upcast(),
488            "position",
489            &position,
490        )
491    }
492
493    pub fn child_submenu<T: IsA<crate::Widget>>(&self, item: &T) -> Option<glib::GString> {
494        crate::prelude::ContainerExtManual::child_property(self, &item.clone().upcast(), "submenu")
495    }
496
497    pub fn set_child_submenu<T: IsA<crate::Widget>>(&self, item: &T, submenu: Option<&str>) {
498        crate::prelude::ContainerExtManual::child_set_property(
499            self,
500            &item.clone().upcast(),
501            "submenu",
502            &submenu,
503        )
504    }
505
506    #[doc(alias = "visible-submenu")]
507    pub fn connect_visible_submenu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
508        unsafe extern "C" fn notify_visible_submenu_trampoline<F: Fn(&PopoverMenu) + 'static>(
509            this: *mut ffi::GtkPopoverMenu,
510            _param_spec: glib::ffi::gpointer,
511            f: glib::ffi::gpointer,
512        ) {
513            unsafe {
514                let f: &F = &*(f as *const F);
515                f(&from_glib_borrow(this))
516            }
517        }
518        unsafe {
519            let f: Box_<F> = Box_::new(f);
520            connect_raw(
521                self.as_ptr() as *mut _,
522                c"notify::visible-submenu".as_ptr(),
523                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
524                    notify_visible_submenu_trampoline::<F> as *const (),
525                )),
526                Box_::into_raw(f),
527            )
528        }
529    }
530}
531
532impl Default for PopoverMenu {
533    fn default() -> Self {
534        Self::new()
535    }
536}
537
538// rustdoc-stripper-ignore-next
539/// A [builder-pattern] type to construct [`PopoverMenu`] objects.
540///
541/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
542#[must_use = "The builder must be built to be used"]
543pub struct PopoverMenuBuilder {
544    builder: glib::object::ObjectBuilder<'static, PopoverMenu>,
545}
546
547impl PopoverMenuBuilder {
548    fn new() -> Self {
549        Self {
550            builder: glib::object::Object::builder(),
551        }
552    }
553
554    pub fn visible_submenu(self, visible_submenu: impl Into<glib::GString>) -> Self {
555        Self {
556            builder: self
557                .builder
558                .property("visible-submenu", visible_submenu.into()),
559        }
560    }
561
562    /// Sets a constraint for the popover position.
563    pub fn constrain_to(self, constrain_to: PopoverConstraint) -> Self {
564        Self {
565            builder: self.builder.property("constrain-to", constrain_to),
566        }
567    }
568
569    /// Sets whether the popover is modal (so other elements in the window do not
570    /// receive input while the popover is visible).
571    pub fn modal(self, modal: bool) -> Self {
572        Self {
573            builder: self.builder.property("modal", modal),
574        }
575    }
576
577    /// Marks a specific rectangle to be pointed.
578    pub fn pointing_to(self, pointing_to: &gdk::Rectangle) -> Self {
579        Self {
580            builder: self.builder.property("pointing-to", pointing_to),
581        }
582    }
583
584    /// Sets the preferred position of the popover.
585    pub fn position(self, position: PositionType) -> Self {
586        Self {
587            builder: self.builder.property("position", position),
588        }
589    }
590
591    /// Sets the attached widget.
592    pub fn relative_to(self, relative_to: &impl IsA<Widget>) -> Self {
593        Self {
594            builder: self
595                .builder
596                .property("relative-to", relative_to.clone().upcast()),
597        }
598    }
599
600    pub fn border_width(self, border_width: u32) -> Self {
601        Self {
602            builder: self.builder.property("border-width", border_width),
603        }
604    }
605
606    pub fn child(self, child: &impl IsA<Widget>) -> Self {
607        Self {
608            builder: self.builder.property("child", child.clone().upcast()),
609        }
610    }
611
612    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
613        Self {
614            builder: self.builder.property("resize-mode", resize_mode),
615        }
616    }
617
618    pub fn app_paintable(self, app_paintable: bool) -> Self {
619        Self {
620            builder: self.builder.property("app-paintable", app_paintable),
621        }
622    }
623
624    pub fn can_default(self, can_default: bool) -> Self {
625        Self {
626            builder: self.builder.property("can-default", can_default),
627        }
628    }
629
630    pub fn can_focus(self, can_focus: bool) -> Self {
631        Self {
632            builder: self.builder.property("can-focus", can_focus),
633        }
634    }
635
636    pub fn events(self, events: gdk::EventMask) -> Self {
637        Self {
638            builder: self.builder.property("events", events),
639        }
640    }
641
642    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
643    pub fn expand(self, expand: bool) -> Self {
644        Self {
645            builder: self.builder.property("expand", expand),
646        }
647    }
648
649    /// Whether the widget should grab focus when it is clicked with the mouse.
650    ///
651    /// This property is only relevant for widgets that can take focus.
652    ///
653    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
654    /// GtkComboBox) implemented this property individually.
655    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
656        Self {
657            builder: self.builder.property("focus-on-click", focus_on_click),
658        }
659    }
660
661    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
662    pub fn halign(self, halign: Align) -> Self {
663        Self {
664            builder: self.builder.property("halign", halign),
665        }
666    }
667
668    pub fn has_default(self, has_default: bool) -> Self {
669        Self {
670            builder: self.builder.property("has-default", has_default),
671        }
672    }
673
674    pub fn has_focus(self, has_focus: bool) -> Self {
675        Self {
676            builder: self.builder.property("has-focus", has_focus),
677        }
678    }
679
680    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
681    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
682    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
683    /// whether it will provide a tooltip or not.
684    ///
685    /// Note that setting this property to [`true`] for the first time will change
686    /// the event masks of the GdkWindows of this widget to include leave-notify
687    /// and motion-notify events. This cannot and will not be undone when the
688    /// property is set to [`false`] again.
689    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
690        Self {
691            builder: self.builder.property("has-tooltip", has_tooltip),
692        }
693    }
694
695    pub fn height_request(self, height_request: i32) -> Self {
696        Self {
697            builder: self.builder.property("height-request", height_request),
698        }
699    }
700
701    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
702    pub fn hexpand(self, hexpand: bool) -> Self {
703        Self {
704            builder: self.builder.property("hexpand", hexpand),
705        }
706    }
707
708    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
709    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
710        Self {
711            builder: self.builder.property("hexpand-set", hexpand_set),
712        }
713    }
714
715    pub fn is_focus(self, is_focus: bool) -> Self {
716        Self {
717            builder: self.builder.property("is-focus", is_focus),
718        }
719    }
720
721    /// Sets all four sides' margin at once. If read, returns max
722    /// margin on any side.
723    pub fn margin(self, margin: i32) -> Self {
724        Self {
725            builder: self.builder.property("margin", margin),
726        }
727    }
728
729    /// Margin on bottom side of widget.
730    ///
731    /// This property adds margin outside of the widget's normal size
732    /// request, the margin will be added in addition to the size from
733    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
734    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
735        Self {
736            builder: self.builder.property("margin-bottom", margin_bottom),
737        }
738    }
739
740    /// Margin on end of widget, horizontally. This property supports
741    /// left-to-right and right-to-left text directions.
742    ///
743    /// This property adds margin outside of the widget's normal size
744    /// request, the margin will be added in addition to the size from
745    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
746    pub fn margin_end(self, margin_end: i32) -> Self {
747        Self {
748            builder: self.builder.property("margin-end", margin_end),
749        }
750    }
751
752    /// Margin on start of widget, horizontally. This property supports
753    /// left-to-right and right-to-left text directions.
754    ///
755    /// This property adds margin outside of the widget's normal size
756    /// request, the margin will be added in addition to the size from
757    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
758    pub fn margin_start(self, margin_start: i32) -> Self {
759        Self {
760            builder: self.builder.property("margin-start", margin_start),
761        }
762    }
763
764    /// Margin on top side of widget.
765    ///
766    /// This property adds margin outside of the widget's normal size
767    /// request, the margin will be added in addition to the size from
768    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
769    pub fn margin_top(self, margin_top: i32) -> Self {
770        Self {
771            builder: self.builder.property("margin-top", margin_top),
772        }
773    }
774
775    pub fn name(self, name: impl Into<glib::GString>) -> Self {
776        Self {
777            builder: self.builder.property("name", name.into()),
778        }
779    }
780
781    pub fn no_show_all(self, no_show_all: bool) -> Self {
782        Self {
783            builder: self.builder.property("no-show-all", no_show_all),
784        }
785    }
786
787    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
788    /// more details about window opacity.
789    ///
790    /// Before 3.8 this was only available in GtkWindow
791    pub fn opacity(self, opacity: f64) -> Self {
792        Self {
793            builder: self.builder.property("opacity", opacity),
794        }
795    }
796
797    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
798        Self {
799            builder: self.builder.property("parent", parent.clone().upcast()),
800        }
801    }
802
803    pub fn receives_default(self, receives_default: bool) -> Self {
804        Self {
805            builder: self.builder.property("receives-default", receives_default),
806        }
807    }
808
809    pub fn sensitive(self, sensitive: bool) -> Self {
810        Self {
811            builder: self.builder.property("sensitive", sensitive),
812        }
813    }
814
815    /// Sets the text of tooltip to be the given string, which is marked up
816    /// with the [Pango text markup language][PangoMarkupFormat].
817    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
818    ///
819    /// This is a convenience property which will take care of getting the
820    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
821    /// will automatically be set to [`true`] and there will be taken care of
822    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
823    ///
824    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
825    /// are set, the last one wins.
826    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
827        Self {
828            builder: self
829                .builder
830                .property("tooltip-markup", tooltip_markup.into()),
831        }
832    }
833
834    /// Sets the text of tooltip to be the given string.
835    ///
836    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
837    ///
838    /// This is a convenience property which will take care of getting the
839    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
840    /// will automatically be set to [`true`] and there will be taken care of
841    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
842    ///
843    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
844    /// are set, the last one wins.
845    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
846        Self {
847            builder: self.builder.property("tooltip-text", tooltip_text.into()),
848        }
849    }
850
851    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
852    pub fn valign(self, valign: Align) -> Self {
853        Self {
854            builder: self.builder.property("valign", valign),
855        }
856    }
857
858    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
859    pub fn vexpand(self, vexpand: bool) -> Self {
860        Self {
861            builder: self.builder.property("vexpand", vexpand),
862        }
863    }
864
865    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
866    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
867        Self {
868            builder: self.builder.property("vexpand-set", vexpand_set),
869        }
870    }
871
872    pub fn visible(self, visible: bool) -> Self {
873        Self {
874            builder: self.builder.property("visible", visible),
875        }
876    }
877
878    pub fn width_request(self, width_request: i32) -> Self {
879        Self {
880            builder: self.builder.property("width-request", width_request),
881        }
882    }
883
884    // rustdoc-stripper-ignore-next
885    /// Build the [`PopoverMenu`].
886    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
887    pub fn build(self) -> PopoverMenu {
888        assert_initialized_main_thread!();
889        self.builder.build()
890    }
891}