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