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,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute};
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 | Writeable
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 | Writeable
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 | Writeable
126    ///
127    ///
128    /// #### `popover`
129    ///  The [`Popover`][crate::Popover] that will be popped up when the button is clicked.
130    ///
131    /// Readable | Writeable
132    ///
133    ///
134    /// #### `popup`
135    ///  The [`Menu`][crate::Menu] that will be popped up when the button is clicked.
136    ///
137    /// Readable | Writeable
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 | Writeable
145    /// <details><summary><h4>ToggleButton</h4></summary>
146    ///
147    ///
148    /// #### `active`
149    ///  Readable | Writeable
150    ///
151    ///
152    /// #### `draw-indicator`
153    ///  Readable | Writeable
154    ///
155    ///
156    /// #### `inconsistent`
157    ///  Readable | Writeable
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 | Writeable | Construct
170    ///
171    ///
172    /// #### `image`
173    ///  The child widget to appear next to the button text.
174    ///
175    /// Readable | Writeable
176    ///
177    ///
178    /// #### `image-position`
179    ///  The position of the image relative to the text inside the button.
180    ///
181    /// Readable | Writeable
182    ///
183    ///
184    /// #### `label`
185    ///  Readable | Writeable | Construct
186    ///
187    ///
188    /// #### `relief`
189    ///  Readable | Writeable
190    ///
191    ///
192    /// #### `use-stock`
193    ///  Readable | Writeable | Construct
194    ///
195    ///
196    /// #### `use-underline`
197    ///  Readable | Writeable | 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 | Writeable
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 | Writeable
214    /// </details>
215    /// <details><summary><h4>Container</h4></summary>
216    ///
217    ///
218    /// #### `border-width`
219    ///  Readable | Writeable
220    ///
221    ///
222    /// #### `child`
223    ///  Writeable
224    ///
225    ///
226    /// #### `resize-mode`
227    ///  Readable | Writeable
228    /// </details>
229    /// <details><summary><h4>Widget</h4></summary>
230    ///
231    ///
232    /// #### `app-paintable`
233    ///  Readable | Writeable
234    ///
235    ///
236    /// #### `can-default`
237    ///  Readable | Writeable
238    ///
239    ///
240    /// #### `can-focus`
241    ///  Readable | Writeable
242    ///
243    ///
244    /// #### `composite-child`
245    ///  Readable
246    ///
247    ///
248    /// #### `double-buffered`
249    ///  Whether the widget is double buffered.
250    ///
251    /// Readable | Writeable
252    ///
253    ///
254    /// #### `events`
255    ///  Readable | Writeable
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 | Writeable
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 | Writeable
273    ///
274    ///
275    /// #### `halign`
276    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
277    ///
278    /// Readable | Writeable
279    ///
280    ///
281    /// #### `has-default`
282    ///  Readable | Writeable
283    ///
284    ///
285    /// #### `has-focus`
286    ///  Readable | Writeable
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 | Writeable
301    ///
302    ///
303    /// #### `height-request`
304    ///  Readable | Writeable
305    ///
306    ///
307    /// #### `hexpand`
308    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
309    ///
310    /// Readable | Writeable
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 | Writeable
317    ///
318    ///
319    /// #### `is-focus`
320    ///  Readable | Writeable
321    ///
322    ///
323    /// #### `margin`
324    ///  Sets all four sides' margin at once. If read, returns max
325    /// margin on any side.
326    ///
327    /// Readable | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
390    ///
391    ///
392    /// #### `name`
393    ///  Readable | Writeable
394    ///
395    ///
396    /// #### `no-show-all`
397    ///  Readable | Writeable
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 | Writeable
407    ///
408    ///
409    /// #### `parent`
410    ///  Readable | Writeable
411    ///
412    ///
413    /// #### `receives-default`
414    ///  Readable | Writeable
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 | Writeable
426    ///
427    ///
428    /// #### `style`
429    ///  The style of the widget, which contains information about how it will look (colors, etc).
430    ///
431    /// Readable | Writeable
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 | Writeable
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 | Writeable
464    ///
465    ///
466    /// #### `valign`
467    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
468    ///
469    /// Readable | Writeable
470    ///
471    ///
472    /// #### `vexpand`
473    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
474    ///
475    /// Readable | Writeable
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 | Writeable
482    ///
483    ///
484    /// #### `visible`
485    ///  Readable | Writeable
486    ///
487    ///
488    /// #### `width-request`
489    ///  Readable | Writeable
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 | Writeable
502    ///
503    ///
504    /// #### `action-target`
505    ///  Readable | Writeable
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 | Writeable
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 | Writeable
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        self.builder.build()
1012    }
1013}
1014
1015mod sealed {
1016    pub trait Sealed {}
1017    impl<T: super::IsA<super::MenuButton>> Sealed for T {}
1018}
1019
1020/// Trait containing all [`struct@MenuButton`] methods.
1021///
1022/// # Implementors
1023///
1024/// [`MenuButton`][struct@crate::MenuButton]
1025pub trait MenuButtonExt: IsA<MenuButton> + sealed::Sealed + 'static {
1026    /// Returns the parent [`Widget`][crate::Widget] to use to line up with menu.
1027    ///
1028    /// # Returns
1029    ///
1030    /// a [`Widget`][crate::Widget] value or [`None`]
1031    #[doc(alias = "gtk_menu_button_get_align_widget")]
1032    #[doc(alias = "get_align_widget")]
1033    fn align_widget(&self) -> Option<Widget> {
1034        unsafe {
1035            from_glib_none(ffi::gtk_menu_button_get_align_widget(
1036                self.as_ref().to_glib_none().0,
1037            ))
1038        }
1039    }
1040
1041    /// Returns the direction the popup will be pointing at when popped up.
1042    ///
1043    /// # Returns
1044    ///
1045    /// a [`ArrowType`][crate::ArrowType] value
1046    #[doc(alias = "gtk_menu_button_get_direction")]
1047    #[doc(alias = "get_direction")]
1048    fn direction(&self) -> ArrowType {
1049        unsafe {
1050            from_glib(ffi::gtk_menu_button_get_direction(
1051                self.as_ref().to_glib_none().0,
1052            ))
1053        }
1054    }
1055
1056    /// Returns the [`gio::MenuModel`][crate::gio::MenuModel] used to generate the popup.
1057    ///
1058    /// # Returns
1059    ///
1060    /// a [`gio::MenuModel`][crate::gio::MenuModel] or [`None`]
1061    #[doc(alias = "gtk_menu_button_get_menu_model")]
1062    #[doc(alias = "get_menu_model")]
1063    fn menu_model(&self) -> Option<gio::MenuModel> {
1064        unsafe {
1065            from_glib_none(ffi::gtk_menu_button_get_menu_model(
1066                self.as_ref().to_glib_none().0,
1067            ))
1068        }
1069    }
1070
1071    /// Returns the [`Popover`][crate::Popover] that pops out of the button.
1072    /// If the button is not using a [`Popover`][crate::Popover], this function
1073    /// returns [`None`].
1074    ///
1075    /// # Returns
1076    ///
1077    /// a [`Popover`][crate::Popover] or [`None`]
1078    #[doc(alias = "gtk_menu_button_get_popover")]
1079    #[doc(alias = "get_popover")]
1080    fn popover(&self) -> Option<Popover> {
1081        unsafe {
1082            from_glib_none(ffi::gtk_menu_button_get_popover(
1083                self.as_ref().to_glib_none().0,
1084            ))
1085        }
1086    }
1087
1088    /// Returns the [`Menu`][crate::Menu] that pops out of the button.
1089    /// If the button does not use a [`Menu`][crate::Menu], this function
1090    /// returns [`None`].
1091    ///
1092    /// # Returns
1093    ///
1094    /// a [`Menu`][crate::Menu] or [`None`]
1095    #[doc(alias = "gtk_menu_button_get_popup")]
1096    #[doc(alias = "get_popup")]
1097    fn popup(&self) -> Option<Menu> {
1098        unsafe {
1099            from_glib_none(ffi::gtk_menu_button_get_popup(
1100                self.as_ref().to_glib_none().0,
1101            ))
1102        }
1103    }
1104
1105    /// Returns whether a [`Popover`][crate::Popover] or a [`Menu`][crate::Menu] will be constructed
1106    /// from the menu model.
1107    ///
1108    /// # Returns
1109    ///
1110    /// [`true`] if using a [`Popover`][crate::Popover]
1111    #[doc(alias = "gtk_menu_button_get_use_popover")]
1112    #[doc(alias = "get_use_popover")]
1113    fn uses_popover(&self) -> bool {
1114        unsafe {
1115            from_glib(ffi::gtk_menu_button_get_use_popover(
1116                self.as_ref().to_glib_none().0,
1117            ))
1118        }
1119    }
1120
1121    /// Sets the [`Widget`][crate::Widget] to use to line the menu with when popped up.
1122    /// Note that the `align_widget` must contain the [`MenuButton`][crate::MenuButton] itself.
1123    ///
1124    /// Setting it to [`None`] means that the menu will be aligned with the
1125    /// button itself.
1126    ///
1127    /// Note that this property is only used with menus currently,
1128    /// and not for popovers.
1129    /// ## `align_widget`
1130    /// a [`Widget`][crate::Widget]
1131    #[doc(alias = "gtk_menu_button_set_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    fn set_direction(&self, direction: ArrowType) {
1154        unsafe {
1155            ffi::gtk_menu_button_set_direction(
1156                self.as_ref().to_glib_none().0,
1157                direction.into_glib(),
1158            );
1159        }
1160    }
1161
1162    /// Sets the [`gio::MenuModel`][crate::gio::MenuModel] from which the popup will be constructed,
1163    /// or [`None`] to dissociate any existing menu model and disable the button.
1164    ///
1165    /// Depending on the value of [`use-popover`][struct@crate::MenuButton#use-popover], either a
1166    /// [`Menu`][crate::Menu] will be created with [`Menu::from_model()`][crate::Menu::from_model()], or a
1167    /// [`Popover`][crate::Popover] with [`Popover::from_model()`][crate::Popover::from_model()]. In either case,
1168    /// actions will be connected as documented for these functions.
1169    ///
1170    /// If [`popup`][struct@crate::MenuButton#popup] or [`popover`][struct@crate::MenuButton#popover] are already set, those
1171    /// widgets are dissociated from the `self`, and those properties are set
1172    /// to [`None`].
1173    /// ## `menu_model`
1174    /// a [`gio::MenuModel`][crate::gio::MenuModel], or [`None`] to unset and disable the
1175    ///  button
1176    #[doc(alias = "gtk_menu_button_set_menu_model")]
1177    fn set_menu_model(&self, menu_model: Option<&impl IsA<gio::MenuModel>>) {
1178        unsafe {
1179            ffi::gtk_menu_button_set_menu_model(
1180                self.as_ref().to_glib_none().0,
1181                menu_model.map(|p| p.as_ref()).to_glib_none().0,
1182            );
1183        }
1184    }
1185
1186    /// Sets the [`Popover`][crate::Popover] that will be popped up when the `self` is clicked,
1187    /// or [`None`] to dissociate any existing popover and disable the button.
1188    ///
1189    /// If [`menu-model`][struct@crate::MenuButton#menu-model] or [`popup`][struct@crate::MenuButton#popup] are set, those objects
1190    /// are dissociated from the `self`, and those properties are set to [`None`].
1191    /// ## `popover`
1192    /// a [`Popover`][crate::Popover], or [`None`] to unset and disable the button
1193    #[doc(alias = "gtk_menu_button_set_popover")]
1194    fn set_popover(&self, popover: Option<&impl IsA<Widget>>) {
1195        unsafe {
1196            ffi::gtk_menu_button_set_popover(
1197                self.as_ref().to_glib_none().0,
1198                popover.map(|p| p.as_ref()).to_glib_none().0,
1199            );
1200        }
1201    }
1202
1203    /// Sets the [`Menu`][crate::Menu] that will be popped up when the `self` is clicked, or
1204    /// [`None`] to dissociate any existing menu and disable the button.
1205    ///
1206    /// If [`menu-model`][struct@crate::MenuButton#menu-model] or [`popover`][struct@crate::MenuButton#popover] are set, those objects
1207    /// are dissociated from the `self`, and those properties are set to [`None`].
1208    /// ## `menu`
1209    /// a [`Menu`][crate::Menu], or [`None`] to unset and disable the button
1210    #[doc(alias = "gtk_menu_button_set_popup")]
1211    fn set_popup(&self, menu: Option<&impl IsA<Widget>>) {
1212        unsafe {
1213            ffi::gtk_menu_button_set_popup(
1214                self.as_ref().to_glib_none().0,
1215                menu.map(|p| p.as_ref()).to_glib_none().0,
1216            );
1217        }
1218    }
1219
1220    /// Sets whether to construct a [`Popover`][crate::Popover] instead of [`Menu`][crate::Menu]
1221    /// when [`set_menu_model()`][Self::set_menu_model()] is called. Note that
1222    /// this property is only consulted when a new menu model is set.
1223    /// ## `use_popover`
1224    /// [`true`] to construct a popover from the menu model
1225    #[doc(alias = "gtk_menu_button_set_use_popover")]
1226    fn set_use_popover(&self, use_popover: bool) {
1227        unsafe {
1228            ffi::gtk_menu_button_set_use_popover(
1229                self.as_ref().to_glib_none().0,
1230                use_popover.into_glib(),
1231            );
1232        }
1233    }
1234
1235    #[doc(alias = "align-widget")]
1236    fn connect_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1237        unsafe extern "C" fn notify_align_widget_trampoline<
1238            P: IsA<MenuButton>,
1239            F: Fn(&P) + 'static,
1240        >(
1241            this: *mut ffi::GtkMenuButton,
1242            _param_spec: glib::ffi::gpointer,
1243            f: glib::ffi::gpointer,
1244        ) {
1245            let f: &F = &*(f as *const F);
1246            f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1247        }
1248        unsafe {
1249            let f: Box_<F> = Box_::new(f);
1250            connect_raw(
1251                self.as_ptr() as *mut _,
1252                b"notify::align-widget\0".as_ptr() as *const _,
1253                Some(transmute::<_, unsafe extern "C" fn()>(
1254                    notify_align_widget_trampoline::<Self, F> as *const (),
1255                )),
1256                Box_::into_raw(f),
1257            )
1258        }
1259    }
1260
1261    #[doc(alias = "direction")]
1262    fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1263        unsafe extern "C" fn notify_direction_trampoline<
1264            P: IsA<MenuButton>,
1265            F: Fn(&P) + 'static,
1266        >(
1267            this: *mut ffi::GtkMenuButton,
1268            _param_spec: glib::ffi::gpointer,
1269            f: glib::ffi::gpointer,
1270        ) {
1271            let f: &F = &*(f as *const F);
1272            f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1273        }
1274        unsafe {
1275            let f: Box_<F> = Box_::new(f);
1276            connect_raw(
1277                self.as_ptr() as *mut _,
1278                b"notify::direction\0".as_ptr() as *const _,
1279                Some(transmute::<_, unsafe extern "C" fn()>(
1280                    notify_direction_trampoline::<Self, F> as *const (),
1281                )),
1282                Box_::into_raw(f),
1283            )
1284        }
1285    }
1286
1287    #[doc(alias = "menu-model")]
1288    fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1289        unsafe extern "C" fn notify_menu_model_trampoline<
1290            P: IsA<MenuButton>,
1291            F: Fn(&P) + 'static,
1292        >(
1293            this: *mut ffi::GtkMenuButton,
1294            _param_spec: glib::ffi::gpointer,
1295            f: glib::ffi::gpointer,
1296        ) {
1297            let f: &F = &*(f as *const F);
1298            f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1299        }
1300        unsafe {
1301            let f: Box_<F> = Box_::new(f);
1302            connect_raw(
1303                self.as_ptr() as *mut _,
1304                b"notify::menu-model\0".as_ptr() as *const _,
1305                Some(transmute::<_, unsafe extern "C" fn()>(
1306                    notify_menu_model_trampoline::<Self, F> as *const (),
1307                )),
1308                Box_::into_raw(f),
1309            )
1310        }
1311    }
1312
1313    #[doc(alias = "popover")]
1314    fn connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1315        unsafe extern "C" fn notify_popover_trampoline<P: IsA<MenuButton>, F: Fn(&P) + 'static>(
1316            this: *mut ffi::GtkMenuButton,
1317            _param_spec: glib::ffi::gpointer,
1318            f: glib::ffi::gpointer,
1319        ) {
1320            let f: &F = &*(f as *const F);
1321            f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1322        }
1323        unsafe {
1324            let f: Box_<F> = Box_::new(f);
1325            connect_raw(
1326                self.as_ptr() as *mut _,
1327                b"notify::popover\0".as_ptr() as *const _,
1328                Some(transmute::<_, unsafe extern "C" fn()>(
1329                    notify_popover_trampoline::<Self, F> as *const (),
1330                )),
1331                Box_::into_raw(f),
1332            )
1333        }
1334    }
1335
1336    #[doc(alias = "popup")]
1337    fn connect_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1338        unsafe extern "C" fn notify_popup_trampoline<P: IsA<MenuButton>, F: Fn(&P) + 'static>(
1339            this: *mut ffi::GtkMenuButton,
1340            _param_spec: glib::ffi::gpointer,
1341            f: glib::ffi::gpointer,
1342        ) {
1343            let f: &F = &*(f as *const F);
1344            f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1345        }
1346        unsafe {
1347            let f: Box_<F> = Box_::new(f);
1348            connect_raw(
1349                self.as_ptr() as *mut _,
1350                b"notify::popup\0".as_ptr() as *const _,
1351                Some(transmute::<_, unsafe extern "C" fn()>(
1352                    notify_popup_trampoline::<Self, F> as *const (),
1353                )),
1354                Box_::into_raw(f),
1355            )
1356        }
1357    }
1358
1359    #[doc(alias = "use-popover")]
1360    fn connect_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1361        unsafe extern "C" fn notify_use_popover_trampoline<
1362            P: IsA<MenuButton>,
1363            F: Fn(&P) + 'static,
1364        >(
1365            this: *mut ffi::GtkMenuButton,
1366            _param_spec: glib::ffi::gpointer,
1367            f: glib::ffi::gpointer,
1368        ) {
1369            let f: &F = &*(f as *const F);
1370            f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1371        }
1372        unsafe {
1373            let f: Box_<F> = Box_::new(f);
1374            connect_raw(
1375                self.as_ptr() as *mut _,
1376                b"notify::use-popover\0".as_ptr() as *const _,
1377                Some(transmute::<_, unsafe extern "C" fn()>(
1378                    notify_use_popover_trampoline::<Self, F> as *const (),
1379                )),
1380                Box_::into_raw(f),
1381            )
1382        }
1383    }
1384}
1385
1386impl<O: IsA<MenuButton>> MenuButtonExt for O {}
1387
1388impl fmt::Display for MenuButton {
1389    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1390        f.write_str("MenuButton")
1391    }
1392}