Skip to main content

gtk4/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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9    AccessibleRole, Align, ArrowType, Buildable, ConstraintTarget, LayoutManager, Overflow,
10    Popover, Widget, ffi,
11};
12#[cfg(feature = "v4_4")]
13#[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
14use glib::object::ObjectType as _;
15use glib::{
16    prelude::*,
17    signal::{SignalHandlerId, connect_raw},
18    translate::*,
19};
20use std::boxed::Box as Box_;
21
22#[cfg(feature = "v4_10")]
23#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
24glib::wrapper! {
25    ///  [arrow]
26    /// ```text
27    ///
28    /// [`MenuButton`][crate::MenuButton] has a single CSS node with name `menubutton`
29    /// which contains a `button` node with a `.toggle` style class.
30    ///
31    /// If the button contains an icon, it will have the `.image-button` style class,
32    /// if it contains text, it will have `.text-button` style class. If an arrow is
33    /// visible in addition to an icon, text or a custom child, it will also have
34    /// `.arrow-button` style class.
35    ///
36    /// Inside the toggle button content, there is an `arrow` node for
37    /// the indicator, which will carry one of the `.none`, `.up`, `.down`,
38    /// `.left` or `.right` style classes to indicate the direction that
39    /// the menu will appear in. The CSS is expected to provide a suitable
40    /// image for each of these cases using the `-gtk-icon-source` property.
41    ///
42    /// Optionally, the `menubutton` node can carry the `.circular` style class
43    /// to request a round appearance.
44    ///
45    /// # Accessibility
46    ///
47    /// [`MenuButton`][crate::MenuButton] uses the [enum@Gtk.AccessibleRole.button] role.
48    ///
49    /// ## Properties
50    ///
51    ///
52    /// #### `active`
53    ///  Whether the menu button is active.
54    ///
55    /// Readable | Writable
56    ///
57    ///
58    /// #### `always-show-arrow`
59    ///  Whether to show a dropdown arrow even when using an icon or a custom child.
60    ///
61    /// Readable | Writable
62    ///
63    ///
64    /// #### `can-shrink`
65    ///  Whether the size of the button can be made smaller than the natural
66    /// size of its contents.
67    ///
68    /// Readable | Writable
69    ///
70    ///
71    /// #### `child`
72    ///  The child widget.
73    ///
74    /// Readable | Writable
75    ///
76    ///
77    /// #### `direction`
78    ///  The [`ArrowType`][crate::ArrowType] representing the direction in which the
79    /// menu or popover will be popped out.
80    ///
81    /// Readable | Writable
82    ///
83    ///
84    /// #### `has-frame`
85    ///  Whether the button has a frame.
86    ///
87    /// Readable | Writable
88    ///
89    ///
90    /// #### `icon-name`
91    ///  The name of the icon used to automatically populate the button.
92    ///
93    /// Readable | Writable
94    ///
95    ///
96    /// #### `label`
97    ///  The label for the button.
98    ///
99    /// Readable | Writable
100    ///
101    ///
102    /// #### `menu-model`
103    ///  The `GMenuModel` from which the popup will be created.
104    ///
105    /// See [`MenuButton::set_menu_model()`][crate::MenuButton::set_menu_model()] for the interaction
106    /// with the [`popover`][struct@crate::MenuButton#popover] property.
107    ///
108    /// Readable | Writable
109    ///
110    ///
111    /// #### `popover`
112    ///  The [`Popover`][crate::Popover] that will be popped up when the button is clicked.
113    ///
114    /// Readable | Writable
115    ///
116    ///
117    /// #### `primary`
118    ///   key
119    ///
120    /// Readable | Writable
121    ///
122    ///
123    /// #### `use-underline`
124    ///  If set an underscore in the text indicates a mnemonic.
125    ///
126    /// Readable | Writable
127    /// <details><summary><h4>Widget</h4></summary>
128    ///
129    ///
130    /// #### `can-focus`
131    ///  Whether the widget or any of its descendents can accept
132    /// the input focus.
133    ///
134    /// This property is meant to be set by widget implementations,
135    /// typically in their instance init function.
136    ///
137    /// Readable | Writable
138    ///
139    ///
140    /// #### `can-target`
141    ///  Whether the widget can receive pointer events.
142    ///
143    /// Readable | Writable
144    ///
145    ///
146    /// #### `css-classes`
147    ///  A list of css classes applied to this widget.
148    ///
149    /// Readable | Writable
150    ///
151    ///
152    /// #### `css-name`
153    ///  The name of this widget in the CSS tree.
154    ///
155    /// This property is meant to be set by widget implementations,
156    /// typically in their instance init function.
157    ///
158    /// Readable | Writable | Construct Only
159    ///
160    ///
161    /// #### `cursor`
162    ///  The cursor used by @widget.
163    ///
164    /// Readable | Writable
165    ///
166    ///
167    /// #### `focus-on-click`
168    ///  Whether the widget should grab focus when it is clicked with the mouse.
169    ///
170    /// This property is only relevant for widgets that can take focus.
171    ///
172    /// Readable | Writable
173    ///
174    ///
175    /// #### `focusable`
176    ///  Whether this widget itself will accept the input focus.
177    ///
178    /// Readable | Writable
179    ///
180    ///
181    /// #### `halign`
182    ///  How to distribute horizontal space if widget gets extra space.
183    ///
184    /// Readable | Writable
185    ///
186    ///
187    /// #### `has-default`
188    ///  Whether the widget is the default widget.
189    ///
190    /// Readable
191    ///
192    ///
193    /// #### `has-focus`
194    ///  Whether the widget has the input focus.
195    ///
196    /// Readable
197    ///
198    ///
199    /// #### `has-tooltip`
200    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
201    /// signal on @widget.
202    ///
203    /// A true value indicates that @widget can have a tooltip, in this case
204    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
205    /// determine whether it will provide a tooltip or not.
206    ///
207    /// Readable | Writable
208    ///
209    ///
210    /// #### `height-request`
211    ///  Overrides for height request of the widget.
212    ///
213    /// If this is -1, the natural request will be used.
214    ///
215    /// Readable | Writable
216    ///
217    ///
218    /// #### `hexpand`
219    ///  Whether to expand horizontally.
220    ///
221    /// Readable | Writable
222    ///
223    ///
224    /// #### `hexpand-set`
225    ///  Whether to use the `hexpand` property.
226    ///
227    /// Readable | Writable
228    ///
229    ///
230    /// #### `layout-manager`
231    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
232    /// the preferred size of the widget, and allocate its children.
233    ///
234    /// This property is meant to be set by widget implementations,
235    /// typically in their instance init function.
236    ///
237    /// Readable | Writable
238    ///
239    ///
240    /// #### `limit-events`
241    ///  Makes this widget act like a modal dialog, with respect to
242    /// event delivery.
243    ///
244    /// Global event controllers will not handle events with targets
245    /// inside the widget, unless they are set up to ignore propagation
246    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
247    ///
248    /// Readable | Writable
249    ///
250    ///
251    /// #### `margin-bottom`
252    ///  Margin on bottom side of widget.
253    ///
254    /// This property adds margin outside of the widget's normal size
255    /// request, the margin will be added in addition to the size from
256    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
257    ///
258    /// Readable | Writable
259    ///
260    ///
261    /// #### `margin-end`
262    ///  Margin on end of widget, horizontally.
263    ///
264    /// This property supports left-to-right and right-to-left text
265    /// directions.
266    ///
267    /// This property adds margin outside of the widget's normal size
268    /// request, the margin will be added in addition to the size from
269    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
270    ///
271    /// Readable | Writable
272    ///
273    ///
274    /// #### `margin-start`
275    ///  Margin on start of widget, horizontally.
276    ///
277    /// This property supports left-to-right and right-to-left text
278    /// directions.
279    ///
280    /// This property adds margin outside of the widget's normal size
281    /// request, the margin will be added in addition to the size from
282    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
283    ///
284    /// Readable | Writable
285    ///
286    ///
287    /// #### `margin-top`
288    ///  Margin on top side of widget.
289    ///
290    /// This property adds margin outside of the widget's normal size
291    /// request, the margin will be added in addition to the size from
292    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
293    ///
294    /// Readable | Writable
295    ///
296    ///
297    /// #### `name`
298    ///  The name of the widget.
299    ///
300    /// Readable | Writable
301    ///
302    ///
303    /// #### `opacity`
304    ///  The requested opacity of the widget.
305    ///
306    /// Readable | Writable
307    ///
308    ///
309    /// #### `overflow`
310    ///  How content outside the widget's content area is treated.
311    ///
312    /// This property is meant to be set by widget implementations,
313    /// typically in their instance init function.
314    ///
315    /// Readable | Writable
316    ///
317    ///
318    /// #### `parent`
319    ///  The parent widget of this widget.
320    ///
321    /// Readable
322    ///
323    ///
324    /// #### `receives-default`
325    ///  Whether the widget will receive the default action when it is focused.
326    ///
327    /// Readable | Writable
328    ///
329    ///
330    /// #### `root`
331    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
332    ///
333    /// This will be `NULL` if the widget is not contained in a root widget.
334    ///
335    /// Readable
336    ///
337    ///
338    /// #### `scale-factor`
339    ///  The scale factor of the widget.
340    ///
341    /// Readable
342    ///
343    ///
344    /// #### `sensitive`
345    ///  Whether the widget responds to input.
346    ///
347    /// Readable | Writable
348    ///
349    ///
350    /// #### `tooltip-markup`
351    ///  Sets the text of tooltip to be the given string, which is marked up
352    /// with Pango markup.
353    ///
354    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
355    ///
356    /// This is a convenience property which will take care of getting the
357    /// tooltip shown if the given string is not `NULL`:
358    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
359    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
360    /// the default signal handler.
361    ///
362    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
363    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
364    ///
365    /// Readable | Writable
366    ///
367    ///
368    /// #### `tooltip-text`
369    ///  Sets the text of tooltip to be the given string.
370    ///
371    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
372    ///
373    /// This is a convenience property which will take care of getting the
374    /// tooltip shown if the given string is not `NULL`:
375    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
376    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
377    /// the default signal handler.
378    ///
379    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
380    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
381    ///
382    /// Readable | Writable
383    ///
384    ///
385    /// #### `valign`
386    ///  How to distribute vertical space if widget gets extra space.
387    ///
388    /// Readable | Writable
389    ///
390    ///
391    /// #### `vexpand`
392    ///  Whether to expand vertically.
393    ///
394    /// Readable | Writable
395    ///
396    ///
397    /// #### `vexpand-set`
398    ///  Whether to use the `vexpand` property.
399    ///
400    /// Readable | Writable
401    ///
402    ///
403    /// #### `visible`
404    ///  Whether the widget is visible.
405    ///
406    /// Readable | Writable
407    ///
408    ///
409    /// #### `width-request`
410    ///  Overrides for width request of the widget.
411    ///
412    /// If this is -1, the natural request will be used.
413    ///
414    /// Readable | Writable
415    /// </details>
416    /// <details><summary><h4>Accessible</h4></summary>
417    ///
418    ///
419    /// #### `accessible-role`
420    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
421    ///
422    /// The accessible role cannot be changed once set.
423    ///
424    /// Readable | Writable
425    /// </details>
426    ///
427    /// ## Signals
428    ///
429    ///
430    /// #### `activate`
431    ///  Emitted to when the menu button is activated.
432    ///
433    /// The `::activate` signal on [`MenuButton`][crate::MenuButton] is an action signal and
434    /// emitting it causes the button to pop up its menu.
435    ///
436    /// Action
437    /// <details><summary><h4>Widget</h4></summary>
438    ///
439    ///
440    /// #### `destroy`
441    ///  Signals that all holders of a reference to the widget should release
442    /// the reference that they hold.
443    ///
444    /// May result in finalization of the widget if all references are released.
445    ///
446    /// This signal is not suitable for saving widget state.
447    ///
448    ///
449    ///
450    ///
451    /// #### `direction-changed`
452    ///  Emitted when the text direction of a widget changes.
453    ///
454    ///
455    ///
456    ///
457    /// #### `hide`
458    ///  Emitted when @widget is hidden.
459    ///
460    ///
461    ///
462    ///
463    /// #### `keynav-failed`
464    ///  Emitted if keyboard navigation fails.
465    ///
466    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
467    ///
468    ///
469    ///
470    ///
471    /// #### `map`
472    ///  Emitted when @widget is going to be mapped.
473    ///
474    /// A widget is mapped when the widget is visible (which is controlled with
475    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
476    /// are also visible.
477    ///
478    /// The `::map` signal can be used to determine whether a widget will be drawn,
479    /// for instance it can resume an animation that was stopped during the
480    /// emission of [`unmap`][struct@crate::Widget#unmap].
481    ///
482    ///
483    ///
484    ///
485    /// #### `mnemonic-activate`
486    ///  Emitted when a widget is activated via a mnemonic.
487    ///
488    /// The default handler for this signal activates @widget if @group_cycling
489    /// is false, or just makes @widget grab focus if @group_cycling is true.
490    ///
491    ///
492    ///
493    ///
494    /// #### `move-focus`
495    ///   to move backward.
496    ///
497    /// Action
498    ///
499    ///
500    /// #### `query-tooltip`
501    ///  s tooltip is about to be shown.
502    ///
503    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
504    /// is true and the hover timeout has expired with the cursor hovering
505    /// above @widget; or emitted when @widget got focus in keyboard mode.
506    ///
507    /// Using the given coordinates, the signal handler should determine
508    /// whether a tooltip should be shown for @widget. If this is the case
509    /// true should be returned, false otherwise. Note that if @keyboard_mode
510    /// is true, the values of @x and @y are undefined and should not be used.
511    ///
512    /// The signal handler is free to manipulate @tooltip with the therefore
513    /// destined function calls.
514    ///
515    ///
516    ///
517    ///
518    /// #### `realize`
519    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
520    ///
521    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
522    /// or the widget has been mapped (that is, it is going to be drawn).
523    ///
524    ///
525    ///
526    ///
527    /// #### `show`
528    ///  Emitted when @widget is shown.
529    ///
530    ///
531    ///
532    ///
533    /// #### `state-flags-changed`
534    ///  Emitted when the widget state changes.
535    ///
536    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
537    ///
538    ///
539    ///
540    ///
541    /// #### `unmap`
542    ///  Emitted when @widget is going to be unmapped.
543    ///
544    /// A widget is unmapped when either it or any of its parents up to the
545    /// toplevel widget have been set as hidden.
546    ///
547    /// As `::unmap` indicates that a widget will not be shown any longer,
548    /// it can be used to, for example, stop an animation on the widget.
549    ///
550    ///
551    ///
552    ///
553    /// #### `unrealize`
554    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
555    ///
556    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
557    /// or the widget has been unmapped (that is, it is going to be hidden).
558    ///
559    ///
560    /// </details>
561    ///
562    /// # Implements
563    ///
564    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
565    #[doc(alias = "GtkMenuButton")]
566    pub struct MenuButton(Object<ffi::GtkMenuButton>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
567
568    match fn {
569        type_ => || ffi::gtk_menu_button_get_type(),
570    }
571}
572
573#[cfg(not(feature = "v4_10"))]
574glib::wrapper! {
575    #[doc(alias = "GtkMenuButton")]
576    pub struct MenuButton(Object<ffi::GtkMenuButton>) @extends Widget, @implements Buildable, ConstraintTarget;
577
578    match fn {
579        type_ => || ffi::gtk_menu_button_get_type(),
580    }
581}
582
583impl MenuButton {
584    /// Creates a new [`MenuButton`][crate::MenuButton] widget with downwards-pointing
585    /// arrow as the only child.
586    ///
587    /// You can replace the child widget with another [`Widget`][crate::Widget]
588    /// should you wish to.
589    ///
590    /// # Returns
591    ///
592    /// The newly created [`MenuButton`][crate::MenuButton]
593    #[doc(alias = "gtk_menu_button_new")]
594    pub fn new() -> MenuButton {
595        assert_initialized_main_thread!();
596        unsafe { Widget::from_glib_none(ffi::gtk_menu_button_new()).unsafe_cast() }
597    }
598
599    // rustdoc-stripper-ignore-next
600    /// Creates a new builder-pattern struct instance to construct [`MenuButton`] objects.
601    ///
602    /// This method returns an instance of [`MenuButtonBuilder`](crate::builders::MenuButtonBuilder) which can be used to create [`MenuButton`] objects.
603    pub fn builder() -> MenuButtonBuilder {
604        MenuButtonBuilder::new()
605    }
606
607    /// Returns whether the menu button is active.
608    ///
609    /// # Returns
610    ///
611    /// TRUE if the button is active
612    #[cfg(feature = "v4_10")]
613    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
614    #[doc(alias = "gtk_menu_button_get_active")]
615    #[doc(alias = "get_active")]
616    #[doc(alias = "active")]
617    pub fn is_active(&self) -> bool {
618        unsafe { from_glib(ffi::gtk_menu_button_get_active(self.to_glib_none().0)) }
619    }
620
621    /// Gets whether to show a dropdown arrow even when using an icon or a custom
622    /// child.
623    ///
624    /// # Returns
625    ///
626    /// whether to show a dropdown arrow even when using an icon or a custom
627    /// child.
628    #[cfg(feature = "v4_4")]
629    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
630    #[doc(alias = "gtk_menu_button_get_always_show_arrow")]
631    #[doc(alias = "get_always_show_arrow")]
632    #[doc(alias = "always-show-arrow")]
633    pub fn must_always_show_arrow(&self) -> bool {
634        unsafe {
635            from_glib(ffi::gtk_menu_button_get_always_show_arrow(
636                self.to_glib_none().0,
637            ))
638        }
639    }
640
641    /// Retrieves whether the button can be smaller than the natural
642    /// size of its contents.
643    ///
644    /// # Returns
645    ///
646    /// true if the button can shrink, and false otherwise
647    #[cfg(feature = "v4_12")]
648    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
649    #[doc(alias = "gtk_menu_button_get_can_shrink")]
650    #[doc(alias = "get_can_shrink")]
651    #[doc(alias = "can-shrink")]
652    pub fn can_shrink(&self) -> bool {
653        unsafe { from_glib(ffi::gtk_menu_button_get_can_shrink(self.to_glib_none().0)) }
654    }
655
656    /// Gets the child widget of @self.
657    ///
658    /// # Returns
659    ///
660    /// the child widget of @self
661    #[cfg(feature = "v4_6")]
662    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
663    #[doc(alias = "gtk_menu_button_get_child")]
664    #[doc(alias = "get_child")]
665    pub fn child(&self) -> Option<Widget> {
666        unsafe { from_glib_none(ffi::gtk_menu_button_get_child(self.to_glib_none().0)) }
667    }
668
669    /// Returns the direction the popup will be pointing at when popped up.
670    ///
671    /// # Returns
672    ///
673    /// a [`ArrowType`][crate::ArrowType] value
674    #[doc(alias = "gtk_menu_button_get_direction")]
675    #[doc(alias = "get_direction")]
676    pub fn direction(&self) -> ArrowType {
677        unsafe { from_glib(ffi::gtk_menu_button_get_direction(self.to_glib_none().0)) }
678    }
679
680    /// Returns whether the button has a frame.
681    ///
682    /// # Returns
683    ///
684    /// [`true`] if the button has a frame
685    #[doc(alias = "gtk_menu_button_get_has_frame")]
686    #[doc(alias = "get_has_frame")]
687    #[doc(alias = "has-frame")]
688    pub fn has_frame(&self) -> bool {
689        unsafe { from_glib(ffi::gtk_menu_button_get_has_frame(self.to_glib_none().0)) }
690    }
691
692    /// Gets the name of the icon shown in the button.
693    ///
694    /// # Returns
695    ///
696    /// the name of the icon shown in the button
697    #[doc(alias = "gtk_menu_button_get_icon_name")]
698    #[doc(alias = "get_icon_name")]
699    #[doc(alias = "icon-name")]
700    pub fn icon_name(&self) -> Option<glib::GString> {
701        unsafe { from_glib_none(ffi::gtk_menu_button_get_icon_name(self.to_glib_none().0)) }
702    }
703
704    /// Gets the label shown in the button
705    ///
706    /// # Returns
707    ///
708    /// the label shown in the button
709    #[doc(alias = "gtk_menu_button_get_label")]
710    #[doc(alias = "get_label")]
711    pub fn label(&self) -> Option<glib::GString> {
712        unsafe { from_glib_none(ffi::gtk_menu_button_get_label(self.to_glib_none().0)) }
713    }
714
715    /// Returns the `GMenuModel` used to generate the popup.
716    ///
717    /// # Returns
718    ///
719    /// a `GMenuModel`
720    #[doc(alias = "gtk_menu_button_get_menu_model")]
721    #[doc(alias = "get_menu_model")]
722    #[doc(alias = "menu-model")]
723    pub fn menu_model(&self) -> Option<gio::MenuModel> {
724        unsafe { from_glib_none(ffi::gtk_menu_button_get_menu_model(self.to_glib_none().0)) }
725    }
726
727    /// Returns the [`Popover`][crate::Popover] that pops out of the button.
728    ///
729    /// If the button is not using a [`Popover`][crate::Popover], this function
730    /// returns [`None`].
731    ///
732    /// # Returns
733    ///
734    /// a [`Popover`][crate::Popover] or [`None`]
735    #[doc(alias = "gtk_menu_button_get_popover")]
736    #[doc(alias = "get_popover")]
737    pub fn popover(&self) -> Option<Popover> {
738        unsafe { from_glib_none(ffi::gtk_menu_button_get_popover(self.to_glib_none().0)) }
739    }
740
741    /// Returns whether the menu button acts as a primary menu.
742    ///
743    /// # Returns
744    ///
745    /// [`true`] if the button is a primary menu
746    #[cfg(feature = "v4_4")]
747    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
748    #[doc(alias = "gtk_menu_button_get_primary")]
749    #[doc(alias = "get_primary")]
750    #[doc(alias = "primary")]
751    pub fn is_primary(&self) -> bool {
752        unsafe { from_glib(ffi::gtk_menu_button_get_primary(self.to_glib_none().0)) }
753    }
754
755    /// Returns whether an embedded underline in the text indicates a
756    /// mnemonic.
757    ///
758    /// # Returns
759    ///
760    /// [`true`] whether an embedded underline in the text indicates
761    ///   the mnemonic accelerator keys.
762    #[doc(alias = "gtk_menu_button_get_use_underline")]
763    #[doc(alias = "get_use_underline")]
764    #[doc(alias = "use-underline")]
765    pub fn uses_underline(&self) -> bool {
766        unsafe {
767            from_glib(ffi::gtk_menu_button_get_use_underline(
768                self.to_glib_none().0,
769            ))
770        }
771    }
772
773    /// Dismiss the menu.
774    #[doc(alias = "gtk_menu_button_popdown")]
775    pub fn popdown(&self) {
776        unsafe {
777            ffi::gtk_menu_button_popdown(self.to_glib_none().0);
778        }
779    }
780
781    /// Pop up the menu.
782    #[doc(alias = "gtk_menu_button_popup")]
783    pub fn popup(&self) {
784        unsafe {
785            ffi::gtk_menu_button_popup(self.to_glib_none().0);
786        }
787    }
788
789    /// Sets whether the menu button is active.
790    /// ## `active`
791    /// whether the menu button is active
792    #[cfg(feature = "v4_10")]
793    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
794    #[doc(alias = "gtk_menu_button_set_active")]
795    #[doc(alias = "active")]
796    pub fn set_active(&self, active: bool) {
797        unsafe {
798            ffi::gtk_menu_button_set_active(self.to_glib_none().0, active.into_glib());
799        }
800    }
801
802    /// Sets whether to show a dropdown arrow even when using an icon or a custom
803    /// child.
804    /// ## `always_show_arrow`
805    /// whether to show a dropdown arrow even when using an icon
806    /// or a custom child
807    #[cfg(feature = "v4_4")]
808    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
809    #[doc(alias = "gtk_menu_button_set_always_show_arrow")]
810    #[doc(alias = "always-show-arrow")]
811    pub fn set_always_show_arrow(&self, always_show_arrow: bool) {
812        unsafe {
813            ffi::gtk_menu_button_set_always_show_arrow(
814                self.to_glib_none().0,
815                always_show_arrow.into_glib(),
816            );
817        }
818    }
819
820    /// Sets whether the button size can be smaller than the natural size of
821    /// its contents.
822    ///
823    /// For text buttons, setting @can_shrink to true will ellipsize the label.
824    ///
825    /// For icon buttons, this function has no effect.
826    /// ## `can_shrink`
827    /// whether the button can shrink
828    #[cfg(feature = "v4_12")]
829    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
830    #[doc(alias = "gtk_menu_button_set_can_shrink")]
831    #[doc(alias = "can-shrink")]
832    pub fn set_can_shrink(&self, can_shrink: bool) {
833        unsafe {
834            ffi::gtk_menu_button_set_can_shrink(self.to_glib_none().0, can_shrink.into_glib());
835        }
836    }
837
838    /// Sets the child widget of @self.
839    ///
840    /// Setting a child resets [`label`][struct@crate::MenuButton#label] and
841    /// [`icon-name`][struct@crate::MenuButton#icon-name].
842    ///
843    /// If [`always-show-arrow`][struct@crate::MenuButton#always-show-arrow] is set to `TRUE` and
844    /// [`direction`][struct@crate::MenuButton#direction] is not `GTK_ARROW_NONE`, a dropdown arrow
845    /// will be shown next to the child.
846    /// ## `child`
847    /// the child widget
848    #[cfg(feature = "v4_6")]
849    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
850    #[doc(alias = "gtk_menu_button_set_child")]
851    #[doc(alias = "child")]
852    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
853        unsafe {
854            ffi::gtk_menu_button_set_child(
855                self.to_glib_none().0,
856                child.map(|p| p.as_ref()).to_glib_none().0,
857            );
858        }
859    }
860
861    /// Sets @func to be called when a popup is about to be shown.
862    ///
863    /// @func should use one of
864    ///
865    ///  - [`set_popover()`][Self::set_popover()]
866    ///  - [`set_menu_model()`][Self::set_menu_model()]
867    ///
868    /// to set a popup for @self.
869    /// If @func is non-[`None`], @self will always be sensitive.
870    ///
871    /// Using this function will not reset the menu widget attached to
872    /// @self. Instead, this can be done manually in @func.
873    /// ## `func`
874    /// function
875    ///   to call when a popup is about to be shown, but none has been provided via other means,
876    ///   or [`None`] to reset to default behavior
877    /// ## `destroy_notify`
878    /// destroy notify for @user_data
879    #[doc(alias = "gtk_menu_button_set_create_popup_func")]
880    pub fn set_create_popup_func<P: Fn(&MenuButton) + 'static>(&self, func: P) {
881        let func_data: Box_<P> = Box_::new(func);
882        unsafe extern "C" fn func_func<P: Fn(&MenuButton) + 'static>(
883            menu_button: *mut ffi::GtkMenuButton,
884            user_data: glib::ffi::gpointer,
885        ) {
886            unsafe {
887                let menu_button = from_glib_borrow(menu_button);
888                let callback = &*(user_data as *mut P);
889                (*callback)(&menu_button)
890            }
891        }
892        let func = Some(func_func::<P> as _);
893        unsafe extern "C" fn destroy_notify_func<P: Fn(&MenuButton) + 'static>(
894            data: glib::ffi::gpointer,
895        ) {
896            unsafe {
897                let _callback = Box_::from_raw(data as *mut P);
898            }
899        }
900        let destroy_call3 = Some(destroy_notify_func::<P> as _);
901        let super_callback0: Box_<P> = func_data;
902        unsafe {
903            ffi::gtk_menu_button_set_create_popup_func(
904                self.to_glib_none().0,
905                func,
906                Box_::into_raw(super_callback0) as *mut _,
907                destroy_call3,
908            );
909        }
910    }
911
912    /// t see any arrows).
913    /// ## `direction`
914    /// a [`ArrowType`][crate::ArrowType]
915    #[doc(alias = "gtk_menu_button_set_direction")]
916    #[doc(alias = "direction")]
917    pub fn set_direction(&self, direction: ArrowType) {
918        unsafe {
919            ffi::gtk_menu_button_set_direction(self.to_glib_none().0, direction.into_glib());
920        }
921    }
922
923    /// Sets the style of the button.
924    /// ## `has_frame`
925    /// whether the button should have a visible frame
926    #[doc(alias = "gtk_menu_button_set_has_frame")]
927    #[doc(alias = "has-frame")]
928    pub fn set_has_frame(&self, has_frame: bool) {
929        unsafe {
930            ffi::gtk_menu_button_set_has_frame(self.to_glib_none().0, has_frame.into_glib());
931        }
932    }
933
934    /// Sets the name of an icon to show inside the menu button.
935    ///
936    /// Setting icon name resets [`label`][struct@crate::MenuButton#label] and
937    /// [`child`][struct@crate::MenuButton#child].
938    ///
939    /// If [`always-show-arrow`][struct@crate::MenuButton#always-show-arrow] is set to `TRUE` and
940    /// [`direction`][struct@crate::MenuButton#direction] is not `GTK_ARROW_NONE`, a dropdown arrow
941    /// will be shown next to the icon.
942    /// ## `icon_name`
943    /// the icon name
944    #[doc(alias = "gtk_menu_button_set_icon_name")]
945    #[doc(alias = "icon-name")]
946    pub fn set_icon_name(&self, icon_name: &str) {
947        unsafe {
948            ffi::gtk_menu_button_set_icon_name(self.to_glib_none().0, icon_name.to_glib_none().0);
949        }
950    }
951
952    /// Sets the label to show inside the menu button.
953    ///
954    /// Setting a label resets [`icon-name`][struct@crate::MenuButton#icon-name] and
955    /// [`child`][struct@crate::MenuButton#child].
956    ///
957    /// If [`direction`][struct@crate::MenuButton#direction] is not `GTK_ARROW_NONE`, a dropdown
958    /// arrow will be shown next to the label.
959    /// ## `label`
960    /// the label
961    #[doc(alias = "gtk_menu_button_set_label")]
962    #[doc(alias = "label")]
963    pub fn set_label(&self, label: &str) {
964        unsafe {
965            ffi::gtk_menu_button_set_label(self.to_glib_none().0, label.to_glib_none().0);
966        }
967    }
968
969    /// Sets the `GMenuModel` from which the popup will be constructed.
970    ///
971    /// If @menu_model is [`None`], the button is disabled.
972    ///
973    /// A [`Popover`][crate::Popover] will be created from the menu model with
974    /// [`PopoverMenu::from_model()`][crate::PopoverMenu::from_model()]. Actions will be connected
975    /// as documented for this function.
976    ///
977    /// If [`popover`][struct@crate::MenuButton#popover] is already set, it will be
978    /// dissociated from the @self, and the property is set to [`None`].
979    /// ## `menu_model`
980    /// a `GMenuModel`, or [`None`] to unset and disable the
981    ///   button
982    #[doc(alias = "gtk_menu_button_set_menu_model")]
983    #[doc(alias = "menu-model")]
984    pub fn set_menu_model(&self, menu_model: Option<&impl IsA<gio::MenuModel>>) {
985        unsafe {
986            ffi::gtk_menu_button_set_menu_model(
987                self.to_glib_none().0,
988                menu_model.map(|p| p.as_ref()).to_glib_none().0,
989            );
990        }
991    }
992
993    /// Sets the [`Popover`][crate::Popover] that will be popped up when the @self is clicked.
994    ///
995    /// If @popover is [`None`], the button is disabled.
996    ///
997    /// If [`menu-model`][struct@crate::MenuButton#menu-model] is set, the menu model is dissociated
998    /// from the @self, and the property is set to [`None`].
999    /// ## `popover`
1000    /// a [`Popover`][crate::Popover], or [`None`] to unset and
1001    ///   disable the button
1002    #[doc(alias = "gtk_menu_button_set_popover")]
1003    #[doc(alias = "popover")]
1004    pub fn set_popover(&self, popover: Option<&impl IsA<Popover>>) {
1005        unsafe {
1006            ffi::gtk_menu_button_set_popover(
1007                self.to_glib_none().0,
1008                popover.map(|p| p.as_ref()).to_glib_none().0,
1009            );
1010        }
1011    }
1012
1013    ///  key.
1014    /// ## `primary`
1015    /// whether the menubutton should act as a primary menu
1016    #[cfg(feature = "v4_4")]
1017    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
1018    #[doc(alias = "gtk_menu_button_set_primary")]
1019    #[doc(alias = "primary")]
1020    pub fn set_primary(&self, primary: bool) {
1021        unsafe {
1022            ffi::gtk_menu_button_set_primary(self.to_glib_none().0, primary.into_glib());
1023        }
1024    }
1025
1026    /// If true, an underline in the text indicates a mnemonic.
1027    /// ## `use_underline`
1028    /// [`true`] if underlines in the text indicate mnemonics
1029    #[doc(alias = "gtk_menu_button_set_use_underline")]
1030    #[doc(alias = "use-underline")]
1031    pub fn set_use_underline(&self, use_underline: bool) {
1032        unsafe {
1033            ffi::gtk_menu_button_set_use_underline(
1034                self.to_glib_none().0,
1035                use_underline.into_glib(),
1036            );
1037        }
1038    }
1039
1040    /// Emitted to when the menu button is activated.
1041    ///
1042    /// The `::activate` signal on [`MenuButton`][crate::MenuButton] is an action signal and
1043    /// emitting it causes the button to pop up its menu.
1044    #[cfg(feature = "v4_4")]
1045    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
1046    #[doc(alias = "activate")]
1047    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1048        unsafe extern "C" fn activate_trampoline<F: Fn(&MenuButton) + 'static>(
1049            this: *mut ffi::GtkMenuButton,
1050            f: glib::ffi::gpointer,
1051        ) {
1052            unsafe {
1053                let f: &F = &*(f as *const F);
1054                f(&from_glib_borrow(this))
1055            }
1056        }
1057        unsafe {
1058            let f: Box_<F> = Box_::new(f);
1059            connect_raw(
1060                self.as_ptr() as *mut _,
1061                c"activate".as_ptr(),
1062                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1063                    activate_trampoline::<F> as *const (),
1064                )),
1065                Box_::into_raw(f),
1066            )
1067        }
1068    }
1069
1070    #[cfg(feature = "v4_4")]
1071    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
1072    pub fn emit_activate(&self) {
1073        self.emit_by_name::<()>("activate", &[]);
1074    }
1075
1076    #[cfg(feature = "v4_10")]
1077    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
1078    #[doc(alias = "active")]
1079    pub fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1080        unsafe extern "C" fn notify_active_trampoline<F: Fn(&MenuButton) + 'static>(
1081            this: *mut ffi::GtkMenuButton,
1082            _param_spec: glib::ffi::gpointer,
1083            f: glib::ffi::gpointer,
1084        ) {
1085            unsafe {
1086                let f: &F = &*(f as *const F);
1087                f(&from_glib_borrow(this))
1088            }
1089        }
1090        unsafe {
1091            let f: Box_<F> = Box_::new(f);
1092            connect_raw(
1093                self.as_ptr() as *mut _,
1094                c"notify::active".as_ptr(),
1095                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1096                    notify_active_trampoline::<F> as *const (),
1097                )),
1098                Box_::into_raw(f),
1099            )
1100        }
1101    }
1102
1103    #[cfg(feature = "v4_4")]
1104    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
1105    #[doc(alias = "always-show-arrow")]
1106    pub fn connect_always_show_arrow_notify<F: Fn(&Self) + 'static>(
1107        &self,
1108        f: F,
1109    ) -> SignalHandlerId {
1110        unsafe extern "C" fn notify_always_show_arrow_trampoline<F: Fn(&MenuButton) + 'static>(
1111            this: *mut ffi::GtkMenuButton,
1112            _param_spec: glib::ffi::gpointer,
1113            f: glib::ffi::gpointer,
1114        ) {
1115            unsafe {
1116                let f: &F = &*(f as *const F);
1117                f(&from_glib_borrow(this))
1118            }
1119        }
1120        unsafe {
1121            let f: Box_<F> = Box_::new(f);
1122            connect_raw(
1123                self.as_ptr() as *mut _,
1124                c"notify::always-show-arrow".as_ptr(),
1125                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1126                    notify_always_show_arrow_trampoline::<F> as *const (),
1127                )),
1128                Box_::into_raw(f),
1129            )
1130        }
1131    }
1132
1133    #[cfg(feature = "v4_12")]
1134    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1135    #[doc(alias = "can-shrink")]
1136    pub fn connect_can_shrink_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1137        unsafe extern "C" fn notify_can_shrink_trampoline<F: Fn(&MenuButton) + 'static>(
1138            this: *mut ffi::GtkMenuButton,
1139            _param_spec: glib::ffi::gpointer,
1140            f: glib::ffi::gpointer,
1141        ) {
1142            unsafe {
1143                let f: &F = &*(f as *const F);
1144                f(&from_glib_borrow(this))
1145            }
1146        }
1147        unsafe {
1148            let f: Box_<F> = Box_::new(f);
1149            connect_raw(
1150                self.as_ptr() as *mut _,
1151                c"notify::can-shrink".as_ptr(),
1152                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1153                    notify_can_shrink_trampoline::<F> as *const (),
1154                )),
1155                Box_::into_raw(f),
1156            )
1157        }
1158    }
1159
1160    #[cfg(feature = "v4_6")]
1161    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1162    #[doc(alias = "child")]
1163    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1164        unsafe extern "C" fn notify_child_trampoline<F: Fn(&MenuButton) + 'static>(
1165            this: *mut ffi::GtkMenuButton,
1166            _param_spec: glib::ffi::gpointer,
1167            f: glib::ffi::gpointer,
1168        ) {
1169            unsafe {
1170                let f: &F = &*(f as *const F);
1171                f(&from_glib_borrow(this))
1172            }
1173        }
1174        unsafe {
1175            let f: Box_<F> = Box_::new(f);
1176            connect_raw(
1177                self.as_ptr() as *mut _,
1178                c"notify::child".as_ptr(),
1179                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1180                    notify_child_trampoline::<F> as *const (),
1181                )),
1182                Box_::into_raw(f),
1183            )
1184        }
1185    }
1186
1187    #[doc(alias = "direction")]
1188    pub fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1189        unsafe extern "C" fn notify_direction_trampoline<F: Fn(&MenuButton) + 'static>(
1190            this: *mut ffi::GtkMenuButton,
1191            _param_spec: glib::ffi::gpointer,
1192            f: glib::ffi::gpointer,
1193        ) {
1194            unsafe {
1195                let f: &F = &*(f as *const F);
1196                f(&from_glib_borrow(this))
1197            }
1198        }
1199        unsafe {
1200            let f: Box_<F> = Box_::new(f);
1201            connect_raw(
1202                self.as_ptr() as *mut _,
1203                c"notify::direction".as_ptr(),
1204                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1205                    notify_direction_trampoline::<F> as *const (),
1206                )),
1207                Box_::into_raw(f),
1208            )
1209        }
1210    }
1211
1212    #[doc(alias = "has-frame")]
1213    pub fn connect_has_frame_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1214        unsafe extern "C" fn notify_has_frame_trampoline<F: Fn(&MenuButton) + 'static>(
1215            this: *mut ffi::GtkMenuButton,
1216            _param_spec: glib::ffi::gpointer,
1217            f: glib::ffi::gpointer,
1218        ) {
1219            unsafe {
1220                let f: &F = &*(f as *const F);
1221                f(&from_glib_borrow(this))
1222            }
1223        }
1224        unsafe {
1225            let f: Box_<F> = Box_::new(f);
1226            connect_raw(
1227                self.as_ptr() as *mut _,
1228                c"notify::has-frame".as_ptr(),
1229                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1230                    notify_has_frame_trampoline::<F> as *const (),
1231                )),
1232                Box_::into_raw(f),
1233            )
1234        }
1235    }
1236
1237    #[doc(alias = "icon-name")]
1238    pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1239        unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&MenuButton) + 'static>(
1240            this: *mut ffi::GtkMenuButton,
1241            _param_spec: glib::ffi::gpointer,
1242            f: glib::ffi::gpointer,
1243        ) {
1244            unsafe {
1245                let f: &F = &*(f as *const F);
1246                f(&from_glib_borrow(this))
1247            }
1248        }
1249        unsafe {
1250            let f: Box_<F> = Box_::new(f);
1251            connect_raw(
1252                self.as_ptr() as *mut _,
1253                c"notify::icon-name".as_ptr(),
1254                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1255                    notify_icon_name_trampoline::<F> as *const (),
1256                )),
1257                Box_::into_raw(f),
1258            )
1259        }
1260    }
1261
1262    #[doc(alias = "label")]
1263    pub fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1264        unsafe extern "C" fn notify_label_trampoline<F: Fn(&MenuButton) + 'static>(
1265            this: *mut ffi::GtkMenuButton,
1266            _param_spec: glib::ffi::gpointer,
1267            f: glib::ffi::gpointer,
1268        ) {
1269            unsafe {
1270                let f: &F = &*(f as *const F);
1271                f(&from_glib_borrow(this))
1272            }
1273        }
1274        unsafe {
1275            let f: Box_<F> = Box_::new(f);
1276            connect_raw(
1277                self.as_ptr() as *mut _,
1278                c"notify::label".as_ptr(),
1279                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1280                    notify_label_trampoline::<F> as *const (),
1281                )),
1282                Box_::into_raw(f),
1283            )
1284        }
1285    }
1286
1287    #[doc(alias = "menu-model")]
1288    pub fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1289        unsafe extern "C" fn notify_menu_model_trampoline<F: Fn(&MenuButton) + 'static>(
1290            this: *mut ffi::GtkMenuButton,
1291            _param_spec: glib::ffi::gpointer,
1292            f: glib::ffi::gpointer,
1293        ) {
1294            unsafe {
1295                let f: &F = &*(f as *const F);
1296                f(&from_glib_borrow(this))
1297            }
1298        }
1299        unsafe {
1300            let f: Box_<F> = Box_::new(f);
1301            connect_raw(
1302                self.as_ptr() as *mut _,
1303                c"notify::menu-model".as_ptr(),
1304                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1305                    notify_menu_model_trampoline::<F> as *const (),
1306                )),
1307                Box_::into_raw(f),
1308            )
1309        }
1310    }
1311
1312    #[doc(alias = "popover")]
1313    pub fn connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1314        unsafe extern "C" fn notify_popover_trampoline<F: Fn(&MenuButton) + 'static>(
1315            this: *mut ffi::GtkMenuButton,
1316            _param_spec: glib::ffi::gpointer,
1317            f: glib::ffi::gpointer,
1318        ) {
1319            unsafe {
1320                let f: &F = &*(f as *const F);
1321                f(&from_glib_borrow(this))
1322            }
1323        }
1324        unsafe {
1325            let f: Box_<F> = Box_::new(f);
1326            connect_raw(
1327                self.as_ptr() as *mut _,
1328                c"notify::popover".as_ptr(),
1329                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1330                    notify_popover_trampoline::<F> as *const (),
1331                )),
1332                Box_::into_raw(f),
1333            )
1334        }
1335    }
1336
1337    #[cfg(feature = "v4_4")]
1338    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
1339    #[doc(alias = "primary")]
1340    pub fn connect_primary_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1341        unsafe extern "C" fn notify_primary_trampoline<F: Fn(&MenuButton) + 'static>(
1342            this: *mut ffi::GtkMenuButton,
1343            _param_spec: glib::ffi::gpointer,
1344            f: glib::ffi::gpointer,
1345        ) {
1346            unsafe {
1347                let f: &F = &*(f as *const F);
1348                f(&from_glib_borrow(this))
1349            }
1350        }
1351        unsafe {
1352            let f: Box_<F> = Box_::new(f);
1353            connect_raw(
1354                self.as_ptr() as *mut _,
1355                c"notify::primary".as_ptr(),
1356                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1357                    notify_primary_trampoline::<F> as *const (),
1358                )),
1359                Box_::into_raw(f),
1360            )
1361        }
1362    }
1363
1364    #[doc(alias = "use-underline")]
1365    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1366        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&MenuButton) + 'static>(
1367            this: *mut ffi::GtkMenuButton,
1368            _param_spec: glib::ffi::gpointer,
1369            f: glib::ffi::gpointer,
1370        ) {
1371            unsafe {
1372                let f: &F = &*(f as *const F);
1373                f(&from_glib_borrow(this))
1374            }
1375        }
1376        unsafe {
1377            let f: Box_<F> = Box_::new(f);
1378            connect_raw(
1379                self.as_ptr() as *mut _,
1380                c"notify::use-underline".as_ptr(),
1381                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1382                    notify_use_underline_trampoline::<F> as *const (),
1383                )),
1384                Box_::into_raw(f),
1385            )
1386        }
1387    }
1388}
1389
1390impl Default for MenuButton {
1391    fn default() -> Self {
1392        Self::new()
1393    }
1394}
1395
1396// rustdoc-stripper-ignore-next
1397/// A [builder-pattern] type to construct [`MenuButton`] objects.
1398///
1399/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1400#[must_use = "The builder must be built to be used"]
1401pub struct MenuButtonBuilder {
1402    builder: glib::object::ObjectBuilder<'static, MenuButton>,
1403}
1404
1405impl MenuButtonBuilder {
1406    fn new() -> Self {
1407        Self {
1408            builder: glib::object::Object::builder(),
1409        }
1410    }
1411
1412    /// Whether the menu button is active.
1413    #[cfg(feature = "v4_10")]
1414    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
1415    pub fn active(self, active: bool) -> Self {
1416        Self {
1417            builder: self.builder.property("active", active),
1418        }
1419    }
1420
1421    /// Whether to show a dropdown arrow even when using an icon or a custom child.
1422    #[cfg(feature = "v4_4")]
1423    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
1424    pub fn always_show_arrow(self, always_show_arrow: bool) -> Self {
1425        Self {
1426            builder: self
1427                .builder
1428                .property("always-show-arrow", always_show_arrow),
1429        }
1430    }
1431
1432    /// Whether the size of the button can be made smaller than the natural
1433    /// size of its contents.
1434    #[cfg(feature = "v4_12")]
1435    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1436    pub fn can_shrink(self, can_shrink: bool) -> Self {
1437        Self {
1438            builder: self.builder.property("can-shrink", can_shrink),
1439        }
1440    }
1441
1442    /// The child widget.
1443    #[cfg(feature = "v4_6")]
1444    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1445    pub fn child(self, child: &impl IsA<Widget>) -> Self {
1446        Self {
1447            builder: self.builder.property("child", child.clone().upcast()),
1448        }
1449    }
1450
1451    /// The [`ArrowType`][crate::ArrowType] representing the direction in which the
1452    /// menu or popover will be popped out.
1453    pub fn direction(self, direction: ArrowType) -> Self {
1454        Self {
1455            builder: self.builder.property("direction", direction),
1456        }
1457    }
1458
1459    /// Whether the button has a frame.
1460    pub fn has_frame(self, has_frame: bool) -> Self {
1461        Self {
1462            builder: self.builder.property("has-frame", has_frame),
1463        }
1464    }
1465
1466    /// The name of the icon used to automatically populate the button.
1467    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1468        Self {
1469            builder: self.builder.property("icon-name", icon_name.into()),
1470        }
1471    }
1472
1473    /// The label for the button.
1474    pub fn label(self, label: impl Into<glib::GString>) -> Self {
1475        Self {
1476            builder: self.builder.property("label", label.into()),
1477        }
1478    }
1479
1480    /// The `GMenuModel` from which the popup will be created.
1481    ///
1482    /// See [`MenuButton::set_menu_model()`][crate::MenuButton::set_menu_model()] for the interaction
1483    /// with the [`popover`][struct@crate::MenuButton#popover] property.
1484    pub fn menu_model(self, menu_model: &impl IsA<gio::MenuModel>) -> Self {
1485        Self {
1486            builder: self
1487                .builder
1488                .property("menu-model", menu_model.clone().upcast()),
1489        }
1490    }
1491
1492    /// The [`Popover`][crate::Popover] that will be popped up when the button is clicked.
1493    pub fn popover(self, popover: &impl IsA<Popover>) -> Self {
1494        Self {
1495            builder: self.builder.property("popover", popover.clone().upcast()),
1496        }
1497    }
1498
1499    ///  key
1500    #[cfg(feature = "v4_4")]
1501    #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
1502    pub fn primary(self, primary: bool) -> Self {
1503        Self {
1504            builder: self.builder.property("primary", primary),
1505        }
1506    }
1507
1508    /// If set an underscore in the text indicates a mnemonic.
1509    pub fn use_underline(self, use_underline: bool) -> Self {
1510        Self {
1511            builder: self.builder.property("use-underline", use_underline),
1512        }
1513    }
1514
1515    /// Whether the widget or any of its descendents can accept
1516    /// the input focus.
1517    ///
1518    /// This property is meant to be set by widget implementations,
1519    /// typically in their instance init function.
1520    pub fn can_focus(self, can_focus: bool) -> Self {
1521        Self {
1522            builder: self.builder.property("can-focus", can_focus),
1523        }
1524    }
1525
1526    /// Whether the widget can receive pointer events.
1527    pub fn can_target(self, can_target: bool) -> Self {
1528        Self {
1529            builder: self.builder.property("can-target", can_target),
1530        }
1531    }
1532
1533    /// A list of css classes applied to this widget.
1534    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1535        Self {
1536            builder: self.builder.property("css-classes", css_classes.into()),
1537        }
1538    }
1539
1540    /// The name of this widget in the CSS tree.
1541    ///
1542    /// This property is meant to be set by widget implementations,
1543    /// typically in their instance init function.
1544    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1545        Self {
1546            builder: self.builder.property("css-name", css_name.into()),
1547        }
1548    }
1549
1550    /// The cursor used by @widget.
1551    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1552        Self {
1553            builder: self.builder.property("cursor", cursor.clone()),
1554        }
1555    }
1556
1557    /// Whether the widget should grab focus when it is clicked with the mouse.
1558    ///
1559    /// This property is only relevant for widgets that can take focus.
1560    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1561        Self {
1562            builder: self.builder.property("focus-on-click", focus_on_click),
1563        }
1564    }
1565
1566    /// Whether this widget itself will accept the input focus.
1567    pub fn focusable(self, focusable: bool) -> Self {
1568        Self {
1569            builder: self.builder.property("focusable", focusable),
1570        }
1571    }
1572
1573    /// How to distribute horizontal space if widget gets extra space.
1574    pub fn halign(self, halign: Align) -> Self {
1575        Self {
1576            builder: self.builder.property("halign", halign),
1577        }
1578    }
1579
1580    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1581    /// signal on @widget.
1582    ///
1583    /// A true value indicates that @widget can have a tooltip, in this case
1584    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1585    /// determine whether it will provide a tooltip or not.
1586    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1587        Self {
1588            builder: self.builder.property("has-tooltip", has_tooltip),
1589        }
1590    }
1591
1592    /// Overrides for height request of the widget.
1593    ///
1594    /// If this is -1, the natural request will be used.
1595    pub fn height_request(self, height_request: i32) -> Self {
1596        Self {
1597            builder: self.builder.property("height-request", height_request),
1598        }
1599    }
1600
1601    /// Whether to expand horizontally.
1602    pub fn hexpand(self, hexpand: bool) -> Self {
1603        Self {
1604            builder: self.builder.property("hexpand", hexpand),
1605        }
1606    }
1607
1608    /// Whether to use the `hexpand` property.
1609    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1610        Self {
1611            builder: self.builder.property("hexpand-set", hexpand_set),
1612        }
1613    }
1614
1615    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1616    /// the preferred size of the widget, and allocate its children.
1617    ///
1618    /// This property is meant to be set by widget implementations,
1619    /// typically in their instance init function.
1620    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1621        Self {
1622            builder: self
1623                .builder
1624                .property("layout-manager", layout_manager.clone().upcast()),
1625        }
1626    }
1627
1628    /// Makes this widget act like a modal dialog, with respect to
1629    /// event delivery.
1630    ///
1631    /// Global event controllers will not handle events with targets
1632    /// inside the widget, unless they are set up to ignore propagation
1633    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1634    #[cfg(feature = "v4_18")]
1635    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1636    pub fn limit_events(self, limit_events: bool) -> Self {
1637        Self {
1638            builder: self.builder.property("limit-events", limit_events),
1639        }
1640    }
1641
1642    /// Margin on bottom side of widget.
1643    ///
1644    /// This property adds margin outside of the widget's normal size
1645    /// request, the margin will be added in addition to the size from
1646    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1647    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1648        Self {
1649            builder: self.builder.property("margin-bottom", margin_bottom),
1650        }
1651    }
1652
1653    /// Margin on end of widget, horizontally.
1654    ///
1655    /// This property supports left-to-right and right-to-left text
1656    /// directions.
1657    ///
1658    /// This property adds margin outside of the widget's normal size
1659    /// request, the margin will be added in addition to the size from
1660    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1661    pub fn margin_end(self, margin_end: i32) -> Self {
1662        Self {
1663            builder: self.builder.property("margin-end", margin_end),
1664        }
1665    }
1666
1667    /// Margin on start of widget, horizontally.
1668    ///
1669    /// This property supports left-to-right and right-to-left text
1670    /// directions.
1671    ///
1672    /// This property adds margin outside of the widget's normal size
1673    /// request, the margin will be added in addition to the size from
1674    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1675    pub fn margin_start(self, margin_start: i32) -> Self {
1676        Self {
1677            builder: self.builder.property("margin-start", margin_start),
1678        }
1679    }
1680
1681    /// Margin on top side of widget.
1682    ///
1683    /// This property adds margin outside of the widget's normal size
1684    /// request, the margin will be added in addition to the size from
1685    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1686    pub fn margin_top(self, margin_top: i32) -> Self {
1687        Self {
1688            builder: self.builder.property("margin-top", margin_top),
1689        }
1690    }
1691
1692    /// The name of the widget.
1693    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1694        Self {
1695            builder: self.builder.property("name", name.into()),
1696        }
1697    }
1698
1699    /// The requested opacity of the widget.
1700    pub fn opacity(self, opacity: f64) -> Self {
1701        Self {
1702            builder: self.builder.property("opacity", opacity),
1703        }
1704    }
1705
1706    /// How content outside the widget's content area is treated.
1707    ///
1708    /// This property is meant to be set by widget implementations,
1709    /// typically in their instance init function.
1710    pub fn overflow(self, overflow: Overflow) -> Self {
1711        Self {
1712            builder: self.builder.property("overflow", overflow),
1713        }
1714    }
1715
1716    /// Whether the widget will receive the default action when it is focused.
1717    pub fn receives_default(self, receives_default: bool) -> Self {
1718        Self {
1719            builder: self.builder.property("receives-default", receives_default),
1720        }
1721    }
1722
1723    /// Whether the widget responds to input.
1724    pub fn sensitive(self, sensitive: bool) -> Self {
1725        Self {
1726            builder: self.builder.property("sensitive", sensitive),
1727        }
1728    }
1729
1730    /// Sets the text of tooltip to be the given string, which is marked up
1731    /// with Pango markup.
1732    ///
1733    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1734    ///
1735    /// This is a convenience property which will take care of getting the
1736    /// tooltip shown if the given string is not `NULL`:
1737    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1738    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1739    /// the default signal handler.
1740    ///
1741    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1742    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1743    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1744        Self {
1745            builder: self
1746                .builder
1747                .property("tooltip-markup", tooltip_markup.into()),
1748        }
1749    }
1750
1751    /// Sets the text of tooltip to be the given string.
1752    ///
1753    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1754    ///
1755    /// This is a convenience property which will take care of getting the
1756    /// tooltip shown if the given string is not `NULL`:
1757    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1758    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1759    /// the default signal handler.
1760    ///
1761    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1762    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1763    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1764        Self {
1765            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1766        }
1767    }
1768
1769    /// How to distribute vertical space if widget gets extra space.
1770    pub fn valign(self, valign: Align) -> Self {
1771        Self {
1772            builder: self.builder.property("valign", valign),
1773        }
1774    }
1775
1776    /// Whether to expand vertically.
1777    pub fn vexpand(self, vexpand: bool) -> Self {
1778        Self {
1779            builder: self.builder.property("vexpand", vexpand),
1780        }
1781    }
1782
1783    /// Whether to use the `vexpand` property.
1784    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1785        Self {
1786            builder: self.builder.property("vexpand-set", vexpand_set),
1787        }
1788    }
1789
1790    /// Whether the widget is visible.
1791    pub fn visible(self, visible: bool) -> Self {
1792        Self {
1793            builder: self.builder.property("visible", visible),
1794        }
1795    }
1796
1797    /// Overrides for width request of the widget.
1798    ///
1799    /// If this is -1, the natural request will be used.
1800    pub fn width_request(self, width_request: i32) -> Self {
1801        Self {
1802            builder: self.builder.property("width-request", width_request),
1803        }
1804    }
1805
1806    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1807    ///
1808    /// The accessible role cannot be changed once set.
1809    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1810        Self {
1811            builder: self.builder.property("accessible-role", accessible_role),
1812        }
1813    }
1814
1815    // rustdoc-stripper-ignore-next
1816    /// Build the [`MenuButton`].
1817    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1818    pub fn build(self) -> MenuButton {
1819        assert_initialized_main_thread!();
1820        self.builder.build()
1821    }
1822}