Skip to main content

gtk/auto/
menu_button.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    Actionable, Align, ArrowType, Bin, Buildable, Button, Container, Menu, Popover, PositionType,
7    ReliefStyle, ResizeMode, ToggleButton, 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    /// The [`MenuButton`][crate::MenuButton] widget is used to display a popup when clicked on.
18    /// This popup can be provided either as a [`Menu`][crate::Menu], a [`Popover`][crate::Popover] or an
19    /// abstract [`gio::MenuModel`][crate::gio::MenuModel].
20    ///
21    /// The [`MenuButton`][crate::MenuButton] widget can hold any valid child widget. That is, it
22    /// can hold almost any other standard [`Widget`][crate::Widget]. The most commonly used
23    /// child is [`Image`][crate::Image]. If no widget is explicitely added to the [`MenuButton`][crate::MenuButton],
24    /// a [`Image`][crate::Image] is automatically created, using an arrow image oriented
25    /// according to [`direction`][struct@crate::MenuButton#direction] or the generic “open-menu-symbolic”
26    /// icon if the direction is not set.
27    ///
28    /// The positioning of the popup is determined by the [`direction`][struct@crate::MenuButton#direction]
29    /// property of the menu button.
30    ///
31    /// For menus, the [`halign`][struct@crate::Widget#halign] and [`valign`][struct@crate::Widget#valign] properties of the
32    /// menu are also taken into account. For example, when the direction is
33    /// [`ArrowType::Down`][crate::ArrowType::Down] and the horizontal alignment is [`Align::Start`][crate::Align::Start], the
34    /// menu will be positioned below the button, with the starting edge
35    /// (depending on the text direction) of the menu aligned with the starting
36    /// edge of the button. If there is not enough space below the button, the
37    /// menu is popped up above the button instead. If the alignment would move
38    /// part of the menu offscreen, it is “pushed in”.
39    ///
40    /// ## Direction = Down
41    ///
42    /// - halign = start
43    ///
44    ///  ![](down-start.png)
45    ///
46    /// - halign = center
47    ///
48    ///  ![](down-center.png)
49    ///
50    /// - halign = end
51    ///
52    ///  ![](down-end.png)
53    ///
54    /// ## Direction = Up
55    ///
56    /// - halign = start
57    ///
58    ///  ![](up-start.png)
59    ///
60    /// - halign = center
61    ///
62    ///  ![](up-center.png)
63    ///
64    /// - halign = end
65    ///
66    ///  ![](up-end.png)
67    ///
68    /// ## Direction = Left
69    ///
70    /// - valign = start
71    ///
72    ///  ![](left-start.png)
73    ///
74    /// - valign = center
75    ///
76    ///  ![](left-center.png)
77    ///
78    /// - valign = end
79    ///
80    ///  ![](left-end.png)
81    ///
82    /// ## Direction = Right
83    ///
84    /// - valign = start
85    ///
86    ///  ![](right-start.png)
87    ///
88    /// - valign = center
89    ///
90    ///  ![](right-center.png)
91    ///
92    /// - valign = end
93    ///
94    ///  ![](right-end.png)
95    ///
96    /// # CSS nodes
97    ///
98    /// GtkMenuButton has a single CSS node with name button. To differentiate
99    /// it from a plain [`Button`][crate::Button], it gets the .popup style class.
100    ///
101    /// ## Properties
102    ///
103    ///
104    /// #### `align-widget`
105    ///  The [`Widget`][crate::Widget] to use to align the menu with.
106    ///
107    /// Readable | Writable
108    ///
109    ///
110    /// #### `direction`
111    ///  The [`ArrowType`][crate::ArrowType] representing the direction in which the
112    /// menu or popover will be popped out.
113    ///
114    /// Readable | Writable
115    ///
116    ///
117    /// #### `menu-model`
118    ///  The [`gio::MenuModel`][crate::gio::MenuModel] from which the popup will be created.
119    /// Depending on the [`use-popover`][struct@crate::MenuButton#use-popover] property, that may
120    /// be a menu or a popover.
121    ///
122    /// See [`MenuButtonExt::set_menu_model()`][crate::prelude::MenuButtonExt::set_menu_model()] for the interaction with the
123    /// [`popup`][struct@crate::MenuButton#popup] property.
124    ///
125    /// Readable | Writable
126    ///
127    ///
128    /// #### `popover`
129    ///  The [`Popover`][crate::Popover] that will be popped up when the button is clicked.
130    ///
131    /// Readable | Writable
132    ///
133    ///
134    /// #### `popup`
135    ///  The [`Menu`][crate::Menu] that will be popped up when the button is clicked.
136    ///
137    /// Readable | Writable
138    ///
139    ///
140    /// #### `use-popover`
141    ///  Whether to construct a [`Popover`][crate::Popover] from the menu model,
142    /// or a [`Menu`][crate::Menu].
143    ///
144    /// Readable | Writable
145    /// <details><summary><h4>ToggleButton</h4></summary>
146    ///
147    ///
148    /// #### `active`
149    ///  Readable | Writable
150    ///
151    ///
152    /// #### `draw-indicator`
153    ///  Readable | Writable
154    ///
155    ///
156    /// #### `inconsistent`
157    ///  Readable | Writable
158    /// </details>
159    /// <details><summary><h4>Button</h4></summary>
160    ///
161    ///
162    /// #### `always-show-image`
163    ///  If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
164    /// setting and always show the image, if available.
165    ///
166    /// Use this property if the button would be useless or hard to use
167    /// without the image.
168    ///
169    /// Readable | Writable | Construct
170    ///
171    ///
172    /// #### `image`
173    ///  The child widget to appear next to the button text.
174    ///
175    /// Readable | Writable
176    ///
177    ///
178    /// #### `image-position`
179    ///  The position of the image relative to the text inside the button.
180    ///
181    /// Readable | Writable
182    ///
183    ///
184    /// #### `label`
185    ///  Readable | Writable | Construct
186    ///
187    ///
188    /// #### `relief`
189    ///  Readable | Writable
190    ///
191    ///
192    /// #### `use-stock`
193    ///  Readable | Writable | Construct
194    ///
195    ///
196    /// #### `use-underline`
197    ///  Readable | Writable | Construct
198    ///
199    ///
200    /// #### `xalign`
201    ///  If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
202    /// can be used to control its horizontal alignment. 0.0 is left aligned,
203    /// 1.0 is right aligned.
204    ///
205    /// Readable | Writable
206    ///
207    ///
208    /// #### `yalign`
209    ///  If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
210    /// can be used to control its vertical alignment. 0.0 is top aligned,
211    /// 1.0 is bottom aligned.
212    ///
213    /// Readable | Writable
214    /// </details>
215    /// <details><summary><h4>Container</h4></summary>
216    ///
217    ///
218    /// #### `border-width`
219    ///  Readable | Writable
220    ///
221    ///
222    /// #### `child`
223    ///  Writable
224    ///
225    ///
226    /// #### `resize-mode`
227    ///  Readable | Writable
228    /// </details>
229    /// <details><summary><h4>Widget</h4></summary>
230    ///
231    ///
232    /// #### `app-paintable`
233    ///  Readable | Writable
234    ///
235    ///
236    /// #### `can-default`
237    ///  Readable | Writable
238    ///
239    ///
240    /// #### `can-focus`
241    ///  Readable | Writable
242    ///
243    ///
244    /// #### `composite-child`
245    ///  Readable
246    ///
247    ///
248    /// #### `double-buffered`
249    ///  Whether the widget is double buffered.
250    ///
251    /// Readable | Writable
252    ///
253    ///
254    /// #### `events`
255    ///  Readable | Writable
256    ///
257    ///
258    /// #### `expand`
259    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
260    ///
261    /// Readable | Writable
262    ///
263    ///
264    /// #### `focus-on-click`
265    ///  Whether the widget should grab focus when it is clicked with the mouse.
266    ///
267    /// This property is only relevant for widgets that can take focus.
268    ///
269    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
270    /// GtkComboBox) implemented this property individually.
271    ///
272    /// Readable | Writable
273    ///
274    ///
275    /// #### `halign`
276    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
277    ///
278    /// Readable | Writable
279    ///
280    ///
281    /// #### `has-default`
282    ///  Readable | Writable
283    ///
284    ///
285    /// #### `has-focus`
286    ///  Readable | Writable
287    ///
288    ///
289    /// #### `has-tooltip`
290    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
291    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
292    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
293    /// whether it will provide a tooltip or not.
294    ///
295    /// Note that setting this property to [`true`] for the first time will change
296    /// the event masks of the GdkWindows of this widget to include leave-notify
297    /// and motion-notify events. This cannot and will not be undone when the
298    /// property is set to [`false`] again.
299    ///
300    /// Readable | Writable
301    ///
302    ///
303    /// #### `height-request`
304    ///  Readable | Writable
305    ///
306    ///
307    /// #### `hexpand`
308    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
309    ///
310    /// Readable | Writable
311    ///
312    ///
313    /// #### `hexpand-set`
314    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
315    ///
316    /// Readable | Writable
317    ///
318    ///
319    /// #### `is-focus`
320    ///  Readable | Writable
321    ///
322    ///
323    /// #### `margin`
324    ///  Sets all four sides' margin at once. If read, returns max
325    /// margin on any side.
326    ///
327    /// Readable | Writable
328    ///
329    ///
330    /// #### `margin-bottom`
331    ///  Margin on bottom side of widget.
332    ///
333    /// This property adds margin outside of the widget's normal size
334    /// request, the margin will be added in addition to the size from
335    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
336    ///
337    /// Readable | Writable
338    ///
339    ///
340    /// #### `margin-end`
341    ///  Margin on end of widget, horizontally. This property supports
342    /// left-to-right and right-to-left text directions.
343    ///
344    /// This property adds margin outside of the widget's normal size
345    /// request, the margin will be added in addition to the size from
346    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
347    ///
348    /// Readable | Writable
349    ///
350    ///
351    /// #### `margin-left`
352    ///  Margin on left side of widget.
353    ///
354    /// This property adds margin outside of the widget's normal size
355    /// request, the margin will be added in addition to the size from
356    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
357    ///
358    /// Readable | Writable
359    ///
360    ///
361    /// #### `margin-right`
362    ///  Margin on right side of widget.
363    ///
364    /// This property adds margin outside of the widget's normal size
365    /// request, the margin will be added in addition to the size from
366    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
367    ///
368    /// Readable | Writable
369    ///
370    ///
371    /// #### `margin-start`
372    ///  Margin on start of widget, horizontally. This property supports
373    /// left-to-right and right-to-left text directions.
374    ///
375    /// This property adds margin outside of the widget's normal size
376    /// request, the margin will be added in addition to the size from
377    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
378    ///
379    /// Readable | Writable
380    ///
381    ///
382    /// #### `margin-top`
383    ///  Margin on top side of widget.
384    ///
385    /// This property adds margin outside of the widget's normal size
386    /// request, the margin will be added in addition to the size from
387    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
388    ///
389    /// Readable | Writable
390    ///
391    ///
392    /// #### `name`
393    ///  Readable | Writable
394    ///
395    ///
396    /// #### `no-show-all`
397    ///  Readable | Writable
398    ///
399    ///
400    /// #### `opacity`
401    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
402    /// more details about window opacity.
403    ///
404    /// Before 3.8 this was only available in GtkWindow
405    ///
406    /// Readable | Writable
407    ///
408    ///
409    /// #### `parent`
410    ///  Readable | Writable
411    ///
412    ///
413    /// #### `receives-default`
414    ///  Readable | Writable
415    ///
416    ///
417    /// #### `scale-factor`
418    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
419    /// more details about widget scaling.
420    ///
421    /// Readable
422    ///
423    ///
424    /// #### `sensitive`
425    ///  Readable | Writable
426    ///
427    ///
428    /// #### `style`
429    ///  The style of the widget, which contains information about how it will look (colors, etc).
430    ///
431    /// Readable | Writable
432    ///
433    ///
434    /// #### `tooltip-markup`
435    ///  Sets the text of tooltip to be the given string, which is marked up
436    /// with the [Pango text markup language][PangoMarkupFormat].
437    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
438    ///
439    /// This is a convenience property which will take care of getting the
440    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
441    /// will automatically be set to [`true`] and there will be taken care of
442    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
443    ///
444    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
445    /// are set, the last one wins.
446    ///
447    /// Readable | Writable
448    ///
449    ///
450    /// #### `tooltip-text`
451    ///  Sets the text of tooltip to be the given string.
452    ///
453    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
454    ///
455    /// This is a convenience property which will take care of getting the
456    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
457    /// will automatically be set to [`true`] and there will be taken care of
458    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
459    ///
460    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
461    /// are set, the last one wins.
462    ///
463    /// Readable | Writable
464    ///
465    ///
466    /// #### `valign`
467    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
468    ///
469    /// Readable | Writable
470    ///
471    ///
472    /// #### `vexpand`
473    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
474    ///
475    /// Readable | Writable
476    ///
477    ///
478    /// #### `vexpand-set`
479    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
480    ///
481    /// Readable | Writable
482    ///
483    ///
484    /// #### `visible`
485    ///  Readable | Writable
486    ///
487    ///
488    /// #### `width-request`
489    ///  Readable | Writable
490    ///
491    ///
492    /// #### `window`
493    ///  The widget's window if it is realized, [`None`] otherwise.
494    ///
495    /// Readable
496    /// </details>
497    /// <details><summary><h4>Actionable</h4></summary>
498    ///
499    ///
500    /// #### `action-name`
501    ///  Readable | Writable
502    ///
503    ///
504    /// #### `action-target`
505    ///  Readable | Writable
506    /// </details>
507    /// <details><summary><h4>Activatable</h4></summary>
508    ///
509    ///
510    /// #### `related-action`
511    ///  The action that this activatable will activate and receive
512    /// updates from for various states and possibly appearance.
513    ///
514    /// > `GtkActivatable` implementors need to handle the this property and
515    /// > call `gtk_activatable_do_set_related_action()` when it changes.
516    ///
517    /// Readable | Writable
518    ///
519    ///
520    /// #### `use-action-appearance`
521    ///  Whether this activatable should reset its layout
522    /// and appearance when setting the related action or when
523    /// the action changes appearance.
524    ///
525    /// See the `GtkAction` documentation directly to find which properties
526    /// should be ignored by the `GtkActivatable` when this property is [`false`].
527    ///
528    /// > `GtkActivatable` implementors need to handle this property
529    /// > and call `gtk_activatable_sync_action_properties()` on the activatable
530    /// > widget when it changes.
531    ///
532    /// Readable | Writable
533    /// </details>
534    ///
535    /// # Implements
536    ///
537    /// [`MenuButtonExt`][trait@crate::prelude::MenuButtonExt], [`ToggleButtonExt`][trait@crate::prelude::ToggleButtonExt], [`ButtonExt`][trait@crate::prelude::ButtonExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
538    #[doc(alias = "GtkMenuButton")]
539    pub struct MenuButton(Object<ffi::GtkMenuButton, ffi::GtkMenuButtonClass>) @extends ToggleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable;
540
541    match fn {
542        type_ => || ffi::gtk_menu_button_get_type(),
543    }
544}
545
546impl MenuButton {
547    pub const NONE: Option<&'static MenuButton> = None;
548
549    /// Creates a new [`MenuButton`][crate::MenuButton] widget with downwards-pointing
550    /// arrow as the only child. You can replace the child widget
551    /// with another [`Widget`][crate::Widget] should you wish to.
552    ///
553    /// # Returns
554    ///
555    /// The newly created [`MenuButton`][crate::MenuButton] widget
556    #[doc(alias = "gtk_menu_button_new")]
557    pub fn new() -> MenuButton {
558        assert_initialized_main_thread!();
559        unsafe { Widget::from_glib_none(ffi::gtk_menu_button_new()).unsafe_cast() }
560    }
561
562    // rustdoc-stripper-ignore-next
563    /// Creates a new builder-pattern struct instance to construct [`MenuButton`] objects.
564    ///
565    /// This method returns an instance of [`MenuButtonBuilder`](crate::builders::MenuButtonBuilder) which can be used to create [`MenuButton`] objects.
566    pub fn builder() -> MenuButtonBuilder {
567        MenuButtonBuilder::new()
568    }
569}
570
571impl Default for MenuButton {
572    fn default() -> Self {
573        Self::new()
574    }
575}
576
577// rustdoc-stripper-ignore-next
578/// A [builder-pattern] type to construct [`MenuButton`] objects.
579///
580/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
581#[must_use = "The builder must be built to be used"]
582pub struct MenuButtonBuilder {
583    builder: glib::object::ObjectBuilder<'static, MenuButton>,
584}
585
586impl MenuButtonBuilder {
587    fn new() -> Self {
588        Self {
589            builder: glib::object::Object::builder(),
590        }
591    }
592
593    /// The [`Widget`][crate::Widget] to use to align the menu with.
594    pub fn align_widget(self, align_widget: &impl IsA<Container>) -> Self {
595        Self {
596            builder: self
597                .builder
598                .property("align-widget", align_widget.clone().upcast()),
599        }
600    }
601
602    /// The [`ArrowType`][crate::ArrowType] representing the direction in which the
603    /// menu or popover will be popped out.
604    pub fn direction(self, direction: ArrowType) -> Self {
605        Self {
606            builder: self.builder.property("direction", direction),
607        }
608    }
609
610    /// The [`gio::MenuModel`][crate::gio::MenuModel] from which the popup will be created.
611    /// Depending on the [`use-popover`][struct@crate::MenuButton#use-popover] property, that may
612    /// be a menu or a popover.
613    ///
614    /// See [`MenuButtonExt::set_menu_model()`][crate::prelude::MenuButtonExt::set_menu_model()] for the interaction with the
615    /// [`popup`][struct@crate::MenuButton#popup] property.
616    pub fn menu_model(self, menu_model: &impl IsA<gio::MenuModel>) -> Self {
617        Self {
618            builder: self
619                .builder
620                .property("menu-model", menu_model.clone().upcast()),
621        }
622    }
623
624    /// The [`Popover`][crate::Popover] that will be popped up when the button is clicked.
625    pub fn popover(self, popover: &impl IsA<Popover>) -> Self {
626        Self {
627            builder: self.builder.property("popover", popover.clone().upcast()),
628        }
629    }
630
631    /// The [`Menu`][crate::Menu] that will be popped up when the button is clicked.
632    pub fn popup(self, popup: &impl IsA<Menu>) -> Self {
633        Self {
634            builder: self.builder.property("popup", popup.clone().upcast()),
635        }
636    }
637
638    /// Whether to construct a [`Popover`][crate::Popover] from the menu model,
639    /// or a [`Menu`][crate::Menu].
640    pub fn use_popover(self, use_popover: bool) -> Self {
641        Self {
642            builder: self.builder.property("use-popover", use_popover),
643        }
644    }
645
646    pub fn active(self, active: bool) -> Self {
647        Self {
648            builder: self.builder.property("active", active),
649        }
650    }
651
652    pub fn draw_indicator(self, draw_indicator: bool) -> Self {
653        Self {
654            builder: self.builder.property("draw-indicator", draw_indicator),
655        }
656    }
657
658    pub fn inconsistent(self, inconsistent: bool) -> Self {
659        Self {
660            builder: self.builder.property("inconsistent", inconsistent),
661        }
662    }
663
664    /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
665    /// setting and always show the image, if available.
666    ///
667    /// Use this property if the button would be useless or hard to use
668    /// without the image.
669    pub fn always_show_image(self, always_show_image: bool) -> Self {
670        Self {
671            builder: self
672                .builder
673                .property("always-show-image", always_show_image),
674        }
675    }
676
677    /// The child widget to appear next to the button text.
678    pub fn image(self, image: &impl IsA<Widget>) -> Self {
679        Self {
680            builder: self.builder.property("image", image.clone().upcast()),
681        }
682    }
683
684    /// The position of the image relative to the text inside the button.
685    pub fn image_position(self, image_position: PositionType) -> Self {
686        Self {
687            builder: self.builder.property("image-position", image_position),
688        }
689    }
690
691    pub fn label(self, label: impl Into<glib::GString>) -> Self {
692        Self {
693            builder: self.builder.property("label", label.into()),
694        }
695    }
696
697    pub fn relief(self, relief: ReliefStyle) -> Self {
698        Self {
699            builder: self.builder.property("relief", relief),
700        }
701    }
702
703    pub fn use_underline(self, use_underline: bool) -> Self {
704        Self {
705            builder: self.builder.property("use-underline", use_underline),
706        }
707    }
708
709    pub fn border_width(self, border_width: u32) -> Self {
710        Self {
711            builder: self.builder.property("border-width", border_width),
712        }
713    }
714
715    pub fn child(self, child: &impl IsA<Widget>) -> Self {
716        Self {
717            builder: self.builder.property("child", child.clone().upcast()),
718        }
719    }
720
721    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
722        Self {
723            builder: self.builder.property("resize-mode", resize_mode),
724        }
725    }
726
727    pub fn app_paintable(self, app_paintable: bool) -> Self {
728        Self {
729            builder: self.builder.property("app-paintable", app_paintable),
730        }
731    }
732
733    pub fn can_default(self, can_default: bool) -> Self {
734        Self {
735            builder: self.builder.property("can-default", can_default),
736        }
737    }
738
739    pub fn can_focus(self, can_focus: bool) -> Self {
740        Self {
741            builder: self.builder.property("can-focus", can_focus),
742        }
743    }
744
745    pub fn events(self, events: gdk::EventMask) -> Self {
746        Self {
747            builder: self.builder.property("events", events),
748        }
749    }
750
751    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
752    pub fn expand(self, expand: bool) -> Self {
753        Self {
754            builder: self.builder.property("expand", expand),
755        }
756    }
757
758    /// Whether the widget should grab focus when it is clicked with the mouse.
759    ///
760    /// This property is only relevant for widgets that can take focus.
761    ///
762    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
763    /// GtkComboBox) implemented this property individually.
764    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
765        Self {
766            builder: self.builder.property("focus-on-click", focus_on_click),
767        }
768    }
769
770    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
771    pub fn halign(self, halign: Align) -> Self {
772        Self {
773            builder: self.builder.property("halign", halign),
774        }
775    }
776
777    pub fn has_default(self, has_default: bool) -> Self {
778        Self {
779            builder: self.builder.property("has-default", has_default),
780        }
781    }
782
783    pub fn has_focus(self, has_focus: bool) -> Self {
784        Self {
785            builder: self.builder.property("has-focus", has_focus),
786        }
787    }
788
789    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
790    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
791    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
792    /// whether it will provide a tooltip or not.
793    ///
794    /// Note that setting this property to [`true`] for the first time will change
795    /// the event masks of the GdkWindows of this widget to include leave-notify
796    /// and motion-notify events. This cannot and will not be undone when the
797    /// property is set to [`false`] again.
798    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
799        Self {
800            builder: self.builder.property("has-tooltip", has_tooltip),
801        }
802    }
803
804    pub fn height_request(self, height_request: i32) -> Self {
805        Self {
806            builder: self.builder.property("height-request", height_request),
807        }
808    }
809
810    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
811    pub fn hexpand(self, hexpand: bool) -> Self {
812        Self {
813            builder: self.builder.property("hexpand", hexpand),
814        }
815    }
816
817    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
818    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
819        Self {
820            builder: self.builder.property("hexpand-set", hexpand_set),
821        }
822    }
823
824    pub fn is_focus(self, is_focus: bool) -> Self {
825        Self {
826            builder: self.builder.property("is-focus", is_focus),
827        }
828    }
829
830    /// Sets all four sides' margin at once. If read, returns max
831    /// margin on any side.
832    pub fn margin(self, margin: i32) -> Self {
833        Self {
834            builder: self.builder.property("margin", margin),
835        }
836    }
837
838    /// Margin on bottom side of widget.
839    ///
840    /// This property adds margin outside of the widget's normal size
841    /// request, the margin will be added in addition to the size from
842    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
843    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
844        Self {
845            builder: self.builder.property("margin-bottom", margin_bottom),
846        }
847    }
848
849    /// Margin on end of widget, horizontally. This property supports
850    /// left-to-right and right-to-left text 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. This property supports
862    /// left-to-right and right-to-left text directions.
863    ///
864    /// This property adds margin outside of the widget's normal size
865    /// request, the margin will be added in addition to the size from
866    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
867    pub fn margin_start(self, margin_start: i32) -> Self {
868        Self {
869            builder: self.builder.property("margin-start", margin_start),
870        }
871    }
872
873    /// Margin on top side of widget.
874    ///
875    /// This property adds margin outside of the widget's normal size
876    /// request, the margin will be added in addition to the size from
877    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
878    pub fn margin_top(self, margin_top: i32) -> Self {
879        Self {
880            builder: self.builder.property("margin-top", margin_top),
881        }
882    }
883
884    pub fn name(self, name: impl Into<glib::GString>) -> Self {
885        Self {
886            builder: self.builder.property("name", name.into()),
887        }
888    }
889
890    pub fn no_show_all(self, no_show_all: bool) -> Self {
891        Self {
892            builder: self.builder.property("no-show-all", no_show_all),
893        }
894    }
895
896    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
897    /// more details about window opacity.
898    ///
899    /// Before 3.8 this was only available in GtkWindow
900    pub fn opacity(self, opacity: f64) -> Self {
901        Self {
902            builder: self.builder.property("opacity", opacity),
903        }
904    }
905
906    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
907        Self {
908            builder: self.builder.property("parent", parent.clone().upcast()),
909        }
910    }
911
912    pub fn receives_default(self, receives_default: bool) -> Self {
913        Self {
914            builder: self.builder.property("receives-default", receives_default),
915        }
916    }
917
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 the [Pango text markup language][PangoMarkupFormat].
926    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
927    ///
928    /// This is a convenience property which will take care of getting the
929    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
930    /// will automatically be set to [`true`] and there will be taken care of
931    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
932    ///
933    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
934    /// are set, the last one wins.
935    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
936        Self {
937            builder: self
938                .builder
939                .property("tooltip-markup", tooltip_markup.into()),
940        }
941    }
942
943    /// Sets the text of tooltip to be the given string.
944    ///
945    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
946    ///
947    /// This is a convenience property which will take care of getting the
948    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
949    /// will automatically be set to [`true`] and there will be taken care of
950    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
951    ///
952    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
953    /// are set, the last one wins.
954    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
955        Self {
956            builder: self.builder.property("tooltip-text", tooltip_text.into()),
957        }
958    }
959
960    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
961    pub fn valign(self, valign: Align) -> Self {
962        Self {
963            builder: self.builder.property("valign", valign),
964        }
965    }
966
967    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
968    pub fn vexpand(self, vexpand: bool) -> Self {
969        Self {
970            builder: self.builder.property("vexpand", vexpand),
971        }
972    }
973
974    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
975    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
976        Self {
977            builder: self.builder.property("vexpand-set", vexpand_set),
978        }
979    }
980
981    pub fn visible(self, visible: bool) -> Self {
982        Self {
983            builder: self.builder.property("visible", visible),
984        }
985    }
986
987    pub fn width_request(self, width_request: i32) -> Self {
988        Self {
989            builder: self.builder.property("width-request", width_request),
990        }
991    }
992
993    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
994        Self {
995            builder: self.builder.property("action-name", action_name.into()),
996        }
997    }
998
999    pub fn action_target(self, action_target: &glib::Variant) -> Self {
1000        Self {
1001            builder: self
1002                .builder
1003                .property("action-target", action_target.clone()),
1004        }
1005    }
1006
1007    // rustdoc-stripper-ignore-next
1008    /// Build the [`MenuButton`].
1009    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1010    pub fn build(self) -> MenuButton {
1011        assert_initialized_main_thread!();
1012        self.builder.build()
1013    }
1014}
1015
1016/// Trait containing all [`struct@MenuButton`] methods.
1017///
1018/// # Implementors
1019///
1020/// [`MenuButton`][struct@crate::MenuButton]
1021pub trait MenuButtonExt: IsA<MenuButton> + 'static {
1022    /// Returns the parent [`Widget`][crate::Widget] to use to line up with menu.
1023    ///
1024    /// # Returns
1025    ///
1026    /// a [`Widget`][crate::Widget] value or [`None`]
1027    #[doc(alias = "gtk_menu_button_get_align_widget")]
1028    #[doc(alias = "get_align_widget")]
1029    #[doc(alias = "align-widget")]
1030    fn align_widget(&self) -> Option<Widget> {
1031        unsafe {
1032            from_glib_none(ffi::gtk_menu_button_get_align_widget(
1033                self.as_ref().to_glib_none().0,
1034            ))
1035        }
1036    }
1037
1038    /// Returns the direction the popup will be pointing at when popped up.
1039    ///
1040    /// # Returns
1041    ///
1042    /// a [`ArrowType`][crate::ArrowType] value
1043    #[doc(alias = "gtk_menu_button_get_direction")]
1044    #[doc(alias = "get_direction")]
1045    fn direction(&self) -> ArrowType {
1046        unsafe {
1047            from_glib(ffi::gtk_menu_button_get_direction(
1048                self.as_ref().to_glib_none().0,
1049            ))
1050        }
1051    }
1052
1053    /// Returns the [`gio::MenuModel`][crate::gio::MenuModel] used to generate the popup.
1054    ///
1055    /// # Returns
1056    ///
1057    /// a [`gio::MenuModel`][crate::gio::MenuModel] or [`None`]
1058    #[doc(alias = "gtk_menu_button_get_menu_model")]
1059    #[doc(alias = "get_menu_model")]
1060    #[doc(alias = "menu-model")]
1061    fn menu_model(&self) -> Option<gio::MenuModel> {
1062        unsafe {
1063            from_glib_none(ffi::gtk_menu_button_get_menu_model(
1064                self.as_ref().to_glib_none().0,
1065            ))
1066        }
1067    }
1068
1069    /// Returns the [`Popover`][crate::Popover] that pops out of the button.
1070    /// If the button is not using a [`Popover`][crate::Popover], this function
1071    /// returns [`None`].
1072    ///
1073    /// # Returns
1074    ///
1075    /// a [`Popover`][crate::Popover] or [`None`]
1076    #[doc(alias = "gtk_menu_button_get_popover")]
1077    #[doc(alias = "get_popover")]
1078    fn popover(&self) -> Option<Popover> {
1079        unsafe {
1080            from_glib_none(ffi::gtk_menu_button_get_popover(
1081                self.as_ref().to_glib_none().0,
1082            ))
1083        }
1084    }
1085
1086    /// Returns the [`Menu`][crate::Menu] that pops out of the button.
1087    /// If the button does not use a [`Menu`][crate::Menu], this function
1088    /// returns [`None`].
1089    ///
1090    /// # Returns
1091    ///
1092    /// a [`Menu`][crate::Menu] or [`None`]
1093    #[doc(alias = "gtk_menu_button_get_popup")]
1094    #[doc(alias = "get_popup")]
1095    fn popup(&self) -> Option<Menu> {
1096        unsafe {
1097            from_glib_none(ffi::gtk_menu_button_get_popup(
1098                self.as_ref().to_glib_none().0,
1099            ))
1100        }
1101    }
1102
1103    /// Returns whether a [`Popover`][crate::Popover] or a [`Menu`][crate::Menu] will be constructed
1104    /// from the menu model.
1105    ///
1106    /// # Returns
1107    ///
1108    /// [`true`] if using a [`Popover`][crate::Popover]
1109    #[doc(alias = "gtk_menu_button_get_use_popover")]
1110    #[doc(alias = "get_use_popover")]
1111    #[doc(alias = "use-popover")]
1112    fn uses_popover(&self) -> bool {
1113        unsafe {
1114            from_glib(ffi::gtk_menu_button_get_use_popover(
1115                self.as_ref().to_glib_none().0,
1116            ))
1117        }
1118    }
1119
1120    /// Sets the [`Widget`][crate::Widget] to use to line the menu with when popped up.
1121    /// Note that the `align_widget` must contain the [`MenuButton`][crate::MenuButton] itself.
1122    ///
1123    /// Setting it to [`None`] means that the menu will be aligned with the
1124    /// button itself.
1125    ///
1126    /// Note that this property is only used with menus currently,
1127    /// and not for popovers.
1128    /// ## `align_widget`
1129    /// a [`Widget`][crate::Widget]
1130    #[doc(alias = "gtk_menu_button_set_align_widget")]
1131    #[doc(alias = "align-widget")]
1132    fn set_align_widget(&self, align_widget: Option<&impl IsA<Widget>>) {
1133        unsafe {
1134            ffi::gtk_menu_button_set_align_widget(
1135                self.as_ref().to_glib_none().0,
1136                align_widget.map(|p| p.as_ref()).to_glib_none().0,
1137            );
1138        }
1139    }
1140
1141    /// Sets the direction in which the popup will be popped up, as
1142    /// well as changing the arrow’s direction. The child will not
1143    /// be changed to an arrow if it was customized.
1144    ///
1145    /// If the does not fit in the available space in the given direction,
1146    /// GTK+ will its best to keep it inside the screen and fully visible.
1147    ///
1148    /// If you pass [`ArrowType::None`][crate::ArrowType::None] for a `direction`, the popup will behave
1149    /// as if you passed [`ArrowType::Down`][crate::ArrowType::Down] (although you won’t see any arrows).
1150    /// ## `direction`
1151    /// a [`ArrowType`][crate::ArrowType]
1152    #[doc(alias = "gtk_menu_button_set_direction")]
1153    #[doc(alias = "direction")]
1154    fn set_direction(&self, direction: ArrowType) {
1155        unsafe {
1156            ffi::gtk_menu_button_set_direction(
1157                self.as_ref().to_glib_none().0,
1158                direction.into_glib(),
1159            );
1160        }
1161    }
1162
1163    /// Sets the [`gio::MenuModel`][crate::gio::MenuModel] from which the popup will be constructed,
1164    /// or [`None`] to dissociate any existing menu model and disable the button.
1165    ///
1166    /// Depending on the value of [`use-popover`][struct@crate::MenuButton#use-popover], either a
1167    /// [`Menu`][crate::Menu] will be created with [`Menu::from_model()`][crate::Menu::from_model()], or a
1168    /// [`Popover`][crate::Popover] with [`Popover::from_model()`][crate::Popover::from_model()]. In either case,
1169    /// actions will be connected as documented for these functions.
1170    ///
1171    /// If [`popup`][struct@crate::MenuButton#popup] or [`popover`][struct@crate::MenuButton#popover] are already set, those
1172    /// widgets are dissociated from the `self`, and those properties are set
1173    /// to [`None`].
1174    /// ## `menu_model`
1175    /// a [`gio::MenuModel`][crate::gio::MenuModel], or [`None`] to unset and disable the
1176    ///  button
1177    #[doc(alias = "gtk_menu_button_set_menu_model")]
1178    #[doc(alias = "menu-model")]
1179    fn set_menu_model(&self, menu_model: Option<&impl IsA<gio::MenuModel>>) {
1180        unsafe {
1181            ffi::gtk_menu_button_set_menu_model(
1182                self.as_ref().to_glib_none().0,
1183                menu_model.map(|p| p.as_ref()).to_glib_none().0,
1184            );
1185        }
1186    }
1187
1188    /// Sets the [`Popover`][crate::Popover] that will be popped up when the `self` is clicked,
1189    /// or [`None`] to dissociate any existing popover and disable the button.
1190    ///
1191    /// If [`menu-model`][struct@crate::MenuButton#menu-model] or [`popup`][struct@crate::MenuButton#popup] are set, those objects
1192    /// are dissociated from the `self`, and those properties are set to [`None`].
1193    /// ## `popover`
1194    /// a [`Popover`][crate::Popover], or [`None`] to unset and disable the button
1195    #[doc(alias = "gtk_menu_button_set_popover")]
1196    #[doc(alias = "popover")]
1197    fn set_popover(&self, popover: Option<&impl IsA<Widget>>) {
1198        unsafe {
1199            ffi::gtk_menu_button_set_popover(
1200                self.as_ref().to_glib_none().0,
1201                popover.map(|p| p.as_ref()).to_glib_none().0,
1202            );
1203        }
1204    }
1205
1206    /// Sets the [`Menu`][crate::Menu] that will be popped up when the `self` is clicked, or
1207    /// [`None`] to dissociate any existing menu and disable the button.
1208    ///
1209    /// If [`menu-model`][struct@crate::MenuButton#menu-model] or [`popover`][struct@crate::MenuButton#popover] are set, those objects
1210    /// are dissociated from the `self`, and those properties are set to [`None`].
1211    /// ## `menu`
1212    /// a [`Menu`][crate::Menu], or [`None`] to unset and disable the button
1213    #[doc(alias = "gtk_menu_button_set_popup")]
1214    #[doc(alias = "popup")]
1215    fn set_popup(&self, menu: Option<&impl IsA<Widget>>) {
1216        unsafe {
1217            ffi::gtk_menu_button_set_popup(
1218                self.as_ref().to_glib_none().0,
1219                menu.map(|p| p.as_ref()).to_glib_none().0,
1220            );
1221        }
1222    }
1223
1224    /// Sets whether to construct a [`Popover`][crate::Popover] instead of [`Menu`][crate::Menu]
1225    /// when [`set_menu_model()`][Self::set_menu_model()] is called. Note that
1226    /// this property is only consulted when a new menu model is set.
1227    /// ## `use_popover`
1228    /// [`true`] to construct a popover from the menu model
1229    #[doc(alias = "gtk_menu_button_set_use_popover")]
1230    #[doc(alias = "use-popover")]
1231    fn set_use_popover(&self, use_popover: bool) {
1232        unsafe {
1233            ffi::gtk_menu_button_set_use_popover(
1234                self.as_ref().to_glib_none().0,
1235                use_popover.into_glib(),
1236            );
1237        }
1238    }
1239
1240    #[doc(alias = "align-widget")]
1241    fn connect_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1242        unsafe extern "C" fn notify_align_widget_trampoline<
1243            P: IsA<MenuButton>,
1244            F: Fn(&P) + 'static,
1245        >(
1246            this: *mut ffi::GtkMenuButton,
1247            _param_spec: glib::ffi::gpointer,
1248            f: glib::ffi::gpointer,
1249        ) {
1250            unsafe {
1251                let f: &F = &*(f as *const F);
1252                f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1253            }
1254        }
1255        unsafe {
1256            let f: Box_<F> = Box_::new(f);
1257            connect_raw(
1258                self.as_ptr() as *mut _,
1259                c"notify::align-widget".as_ptr(),
1260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1261                    notify_align_widget_trampoline::<Self, F> as *const (),
1262                )),
1263                Box_::into_raw(f),
1264            )
1265        }
1266    }
1267
1268    #[doc(alias = "direction")]
1269    fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1270        unsafe extern "C" fn notify_direction_trampoline<
1271            P: IsA<MenuButton>,
1272            F: Fn(&P) + 'static,
1273        >(
1274            this: *mut ffi::GtkMenuButton,
1275            _param_spec: glib::ffi::gpointer,
1276            f: glib::ffi::gpointer,
1277        ) {
1278            unsafe {
1279                let f: &F = &*(f as *const F);
1280                f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1281            }
1282        }
1283        unsafe {
1284            let f: Box_<F> = Box_::new(f);
1285            connect_raw(
1286                self.as_ptr() as *mut _,
1287                c"notify::direction".as_ptr(),
1288                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1289                    notify_direction_trampoline::<Self, F> as *const (),
1290                )),
1291                Box_::into_raw(f),
1292            )
1293        }
1294    }
1295
1296    #[doc(alias = "menu-model")]
1297    fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1298        unsafe extern "C" fn notify_menu_model_trampoline<
1299            P: IsA<MenuButton>,
1300            F: Fn(&P) + 'static,
1301        >(
1302            this: *mut ffi::GtkMenuButton,
1303            _param_spec: glib::ffi::gpointer,
1304            f: glib::ffi::gpointer,
1305        ) {
1306            unsafe {
1307                let f: &F = &*(f as *const F);
1308                f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1309            }
1310        }
1311        unsafe {
1312            let f: Box_<F> = Box_::new(f);
1313            connect_raw(
1314                self.as_ptr() as *mut _,
1315                c"notify::menu-model".as_ptr(),
1316                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1317                    notify_menu_model_trampoline::<Self, F> as *const (),
1318                )),
1319                Box_::into_raw(f),
1320            )
1321        }
1322    }
1323
1324    #[doc(alias = "popover")]
1325    fn connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1326        unsafe extern "C" fn notify_popover_trampoline<P: IsA<MenuButton>, F: Fn(&P) + 'static>(
1327            this: *mut ffi::GtkMenuButton,
1328            _param_spec: glib::ffi::gpointer,
1329            f: glib::ffi::gpointer,
1330        ) {
1331            unsafe {
1332                let f: &F = &*(f as *const F);
1333                f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1334            }
1335        }
1336        unsafe {
1337            let f: Box_<F> = Box_::new(f);
1338            connect_raw(
1339                self.as_ptr() as *mut _,
1340                c"notify::popover".as_ptr(),
1341                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1342                    notify_popover_trampoline::<Self, F> as *const (),
1343                )),
1344                Box_::into_raw(f),
1345            )
1346        }
1347    }
1348
1349    #[doc(alias = "popup")]
1350    fn connect_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1351        unsafe extern "C" fn notify_popup_trampoline<P: IsA<MenuButton>, F: Fn(&P) + 'static>(
1352            this: *mut ffi::GtkMenuButton,
1353            _param_spec: glib::ffi::gpointer,
1354            f: glib::ffi::gpointer,
1355        ) {
1356            unsafe {
1357                let f: &F = &*(f as *const F);
1358                f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1359            }
1360        }
1361        unsafe {
1362            let f: Box_<F> = Box_::new(f);
1363            connect_raw(
1364                self.as_ptr() as *mut _,
1365                c"notify::popup".as_ptr(),
1366                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1367                    notify_popup_trampoline::<Self, F> as *const (),
1368                )),
1369                Box_::into_raw(f),
1370            )
1371        }
1372    }
1373
1374    #[doc(alias = "use-popover")]
1375    fn connect_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1376        unsafe extern "C" fn notify_use_popover_trampoline<
1377            P: IsA<MenuButton>,
1378            F: Fn(&P) + 'static,
1379        >(
1380            this: *mut ffi::GtkMenuButton,
1381            _param_spec: glib::ffi::gpointer,
1382            f: glib::ffi::gpointer,
1383        ) {
1384            unsafe {
1385                let f: &F = &*(f as *const F);
1386                f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1387            }
1388        }
1389        unsafe {
1390            let f: Box_<F> = Box_::new(f);
1391            connect_raw(
1392                self.as_ptr() as *mut _,
1393                c"notify::use-popover".as_ptr(),
1394                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1395                    notify_use_popover_trampoline::<Self, F> as *const (),
1396                )),
1397                Box_::into_raw(f),
1398            )
1399        }
1400    }
1401}
1402
1403impl<O: IsA<MenuButton>> MenuButtonExt for O {}