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