Skip to main content

gtk/auto/
model_button.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    Actionable, Align, Bin, Buildable, Button, ButtonRole, Container, PositionType, ReliefStyle,
7    ResizeMode, Widget, ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    ///
18    /// ╰── check
19    /// ]|
20    ///
21    /// Iconic model buttons (see [`iconic`][struct@crate::ModelButton#iconic]) change the name of
22    /// their main node to button and add a .model style class to it. The indicator
23    /// subnode is invisible in this case.
24    ///
25    /// ## Properties
26    ///
27    ///
28    /// #### `active`
29    ///  The state of the button. This is reflecting the state of the associated
30    /// `GAction`.
31    ///
32    /// Readable | Writable
33    ///
34    ///
35    /// #### `centered`
36    ///  Whether to render the button contents centered instead of left-aligned.
37    /// This property should be set for title-like items.
38    ///
39    /// Readable | Writable
40    ///
41    ///
42    /// #### `icon`
43    ///  A [`gio::Icon`][crate::gio::Icon] that will be used if iconic appearance for the button is
44    /// desired.
45    ///
46    /// Readable | Writable
47    ///
48    ///
49    /// #### `iconic`
50    ///  If this property is set, the button will show an icon if one is set.
51    /// If no icon is set, the text will be used. This is typically used for
52    /// horizontal sections of linked buttons.
53    ///
54    /// Readable | Writable
55    ///
56    ///
57    /// #### `inverted`
58    ///  Whether to show the submenu indicator at the opposite side than normal.
59    /// This property should be set for model buttons that 'go back' to a parent
60    /// menu.
61    ///
62    /// Readable | Writable
63    ///
64    ///
65    /// #### `menu-name`
66    ///  The name of a submenu to open when the button is activated.
67    /// If this is set, the button should not have an action associated with it.
68    ///
69    /// Readable | Writable
70    ///
71    ///
72    /// #### `role`
73    ///  Specifies whether the button is a plain, check or radio button.
74    /// When [`action-name`][struct@crate::Actionable#action-name] is set, the role will be determined
75    /// from the action and does not have to be set explicitly.
76    ///
77    /// Readable | Writable
78    ///
79    ///
80    /// #### `text`
81    ///  The label for the button.
82    ///
83    /// Readable | Writable
84    ///
85    ///
86    /// #### `use-markup`
87    ///  If [`true`], XML tags in the text of the button are interpreted as by
88    /// `pango_parse_markup()` to format the enclosed spans of text. If [`false`], the
89    /// text will be displayed verbatim.
90    ///
91    /// Readable | Writable
92    /// <details><summary><h4>Button</h4></summary>
93    ///
94    ///
95    /// #### `always-show-image`
96    ///  If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
97    /// setting and always show the image, if available.
98    ///
99    /// Use this property if the button would be useless or hard to use
100    /// without the image.
101    ///
102    /// Readable | Writable | Construct
103    ///
104    ///
105    /// #### `image`
106    ///  The child widget to appear next to the button text.
107    ///
108    /// Readable | Writable
109    ///
110    ///
111    /// #### `image-position`
112    ///  The position of the image relative to the text inside the button.
113    ///
114    /// Readable | Writable
115    ///
116    ///
117    /// #### `label`
118    ///  Readable | Writable | Construct
119    ///
120    ///
121    /// #### `relief`
122    ///  Readable | Writable
123    ///
124    ///
125    /// #### `use-stock`
126    ///  Readable | Writable | Construct
127    ///
128    ///
129    /// #### `use-underline`
130    ///  Readable | Writable | Construct
131    ///
132    ///
133    /// #### `xalign`
134    ///  If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
135    /// can be used to control its horizontal alignment. 0.0 is left aligned,
136    /// 1.0 is right aligned.
137    ///
138    /// Readable | Writable
139    ///
140    ///
141    /// #### `yalign`
142    ///  If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
143    /// can be used to control its vertical alignment. 0.0 is top aligned,
144    /// 1.0 is bottom aligned.
145    ///
146    /// Readable | Writable
147    /// </details>
148    /// <details><summary><h4>Container</h4></summary>
149    ///
150    ///
151    /// #### `border-width`
152    ///  Readable | Writable
153    ///
154    ///
155    /// #### `child`
156    ///  Writable
157    ///
158    ///
159    /// #### `resize-mode`
160    ///  Readable | Writable
161    /// </details>
162    /// <details><summary><h4>Widget</h4></summary>
163    ///
164    ///
165    /// #### `app-paintable`
166    ///  Readable | Writable
167    ///
168    ///
169    /// #### `can-default`
170    ///  Readable | Writable
171    ///
172    ///
173    /// #### `can-focus`
174    ///  Readable | Writable
175    ///
176    ///
177    /// #### `composite-child`
178    ///  Readable
179    ///
180    ///
181    /// #### `double-buffered`
182    ///  Whether the widget is double buffered.
183    ///
184    /// Readable | Writable
185    ///
186    ///
187    /// #### `events`
188    ///  Readable | Writable
189    ///
190    ///
191    /// #### `expand`
192    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
193    ///
194    /// Readable | Writable
195    ///
196    ///
197    /// #### `focus-on-click`
198    ///  Whether the widget should grab focus when it is clicked with the mouse.
199    ///
200    /// This property is only relevant for widgets that can take focus.
201    ///
202    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
203    /// GtkComboBox) implemented this property individually.
204    ///
205    /// Readable | Writable
206    ///
207    ///
208    /// #### `halign`
209    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
210    ///
211    /// Readable | Writable
212    ///
213    ///
214    /// #### `has-default`
215    ///  Readable | Writable
216    ///
217    ///
218    /// #### `has-focus`
219    ///  Readable | Writable
220    ///
221    ///
222    /// #### `has-tooltip`
223    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
224    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
225    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
226    /// whether it will provide a tooltip or not.
227    ///
228    /// Note that setting this property to [`true`] for the first time will change
229    /// the event masks of the GdkWindows of this widget to include leave-notify
230    /// and motion-notify events. This cannot and will not be undone when the
231    /// property is set to [`false`] again.
232    ///
233    /// Readable | Writable
234    ///
235    ///
236    /// #### `height-request`
237    ///  Readable | Writable
238    ///
239    ///
240    /// #### `hexpand`
241    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
242    ///
243    /// Readable | Writable
244    ///
245    ///
246    /// #### `hexpand-set`
247    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
248    ///
249    /// Readable | Writable
250    ///
251    ///
252    /// #### `is-focus`
253    ///  Readable | Writable
254    ///
255    ///
256    /// #### `margin`
257    ///  Sets all four sides' margin at once. If read, returns max
258    /// margin on any side.
259    ///
260    /// Readable | Writable
261    ///
262    ///
263    /// #### `margin-bottom`
264    ///  Margin on bottom side of widget.
265    ///
266    /// This property adds margin outside of the widget's normal size
267    /// request, the margin will be added in addition to the size from
268    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
269    ///
270    /// Readable | Writable
271    ///
272    ///
273    /// #### `margin-end`
274    ///  Margin on end of widget, horizontally. This property supports
275    /// left-to-right and right-to-left text directions.
276    ///
277    /// This property adds margin outside of the widget's normal size
278    /// request, the margin will be added in addition to the size from
279    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
280    ///
281    /// Readable | Writable
282    ///
283    ///
284    /// #### `margin-left`
285    ///  Margin on left side of widget.
286    ///
287    /// This property adds margin outside of the widget's normal size
288    /// request, the margin will be added in addition to the size from
289    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
290    ///
291    /// Readable | Writable
292    ///
293    ///
294    /// #### `margin-right`
295    ///  Margin on right side of widget.
296    ///
297    /// This property adds margin outside of the widget's normal size
298    /// request, the margin will be added in addition to the size from
299    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
300    ///
301    /// Readable | Writable
302    ///
303    ///
304    /// #### `margin-start`
305    ///  Margin on start of widget, horizontally. This property supports
306    /// left-to-right and right-to-left text directions.
307    ///
308    /// This property adds margin outside of the widget's normal size
309    /// request, the margin will be added in addition to the size from
310    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
311    ///
312    /// Readable | Writable
313    ///
314    ///
315    /// #### `margin-top`
316    ///  Margin on top side of widget.
317    ///
318    /// This property adds margin outside of the widget's normal size
319    /// request, the margin will be added in addition to the size from
320    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
321    ///
322    /// Readable | Writable
323    ///
324    ///
325    /// #### `name`
326    ///  Readable | Writable
327    ///
328    ///
329    /// #### `no-show-all`
330    ///  Readable | Writable
331    ///
332    ///
333    /// #### `opacity`
334    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
335    /// more details about window opacity.
336    ///
337    /// Before 3.8 this was only available in GtkWindow
338    ///
339    /// Readable | Writable
340    ///
341    ///
342    /// #### `parent`
343    ///  Readable | Writable
344    ///
345    ///
346    /// #### `receives-default`
347    ///  Readable | Writable
348    ///
349    ///
350    /// #### `scale-factor`
351    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
352    /// more details about widget scaling.
353    ///
354    /// Readable
355    ///
356    ///
357    /// #### `sensitive`
358    ///  Readable | Writable
359    ///
360    ///
361    /// #### `style`
362    ///  The style of the widget, which contains information about how it will look (colors, etc).
363    ///
364    /// Readable | Writable
365    ///
366    ///
367    /// #### `tooltip-markup`
368    ///  Sets the text of tooltip to be the given string, which is marked up
369    /// with the [Pango text markup language][PangoMarkupFormat].
370    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
371    ///
372    /// This is a convenience property which will take care of getting the
373    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
374    /// will automatically be set to [`true`] and there will be taken care of
375    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
376    ///
377    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
378    /// are set, the last one wins.
379    ///
380    /// Readable | Writable
381    ///
382    ///
383    /// #### `tooltip-text`
384    ///  Sets the text of tooltip to be the given string.
385    ///
386    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
387    ///
388    /// This is a convenience property which will take care of getting the
389    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
390    /// will automatically be set to [`true`] and there will be taken care of
391    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
392    ///
393    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
394    /// are set, the last one wins.
395    ///
396    /// Readable | Writable
397    ///
398    ///
399    /// #### `valign`
400    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
401    ///
402    /// Readable | Writable
403    ///
404    ///
405    /// #### `vexpand`
406    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
407    ///
408    /// Readable | Writable
409    ///
410    ///
411    /// #### `vexpand-set`
412    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
413    ///
414    /// Readable | Writable
415    ///
416    ///
417    /// #### `visible`
418    ///  Readable | Writable
419    ///
420    ///
421    /// #### `width-request`
422    ///  Readable | Writable
423    ///
424    ///
425    /// #### `window`
426    ///  The widget's window if it is realized, [`None`] otherwise.
427    ///
428    /// Readable
429    /// </details>
430    /// <details><summary><h4>Actionable</h4></summary>
431    ///
432    ///
433    /// #### `action-name`
434    ///  Readable | Writable
435    ///
436    ///
437    /// #### `action-target`
438    ///  Readable | Writable
439    /// </details>
440    /// <details><summary><h4>Activatable</h4></summary>
441    ///
442    ///
443    /// #### `related-action`
444    ///   call `gtk_activatable_do_set_related_action()` when it changes.
445    ///
446    /// Readable | Writable
447    ///
448    ///
449    /// #### `use-action-appearance`
450    ///   widget when it changes.
451    ///
452    /// Readable | Writable
453    /// </details>
454    ///
455    /// # Implements
456    ///
457    /// [`ButtonExt`][trait@crate::prelude::ButtonExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
458    #[doc(alias = "GtkModelButton")]
459    pub struct ModelButton(Object<ffi::GtkModelButton>) @extends Button, Bin, Container, Widget, @implements Buildable, Actionable;
460
461    match fn {
462        type_ => || ffi::gtk_model_button_get_type(),
463    }
464}
465
466impl ModelButton {
467    /// Creates a new GtkModelButton.
468    ///
469    /// # Returns
470    ///
471    /// the newly created [`ModelButton`][crate::ModelButton] widget
472    #[doc(alias = "gtk_model_button_new")]
473    pub fn new() -> ModelButton {
474        assert_initialized_main_thread!();
475        unsafe { Widget::from_glib_none(ffi::gtk_model_button_new()).unsafe_cast() }
476    }
477
478    // rustdoc-stripper-ignore-next
479    /// Creates a new builder-pattern struct instance to construct [`ModelButton`] objects.
480    ///
481    /// This method returns an instance of [`ModelButtonBuilder`](crate::builders::ModelButtonBuilder) which can be used to create [`ModelButton`] objects.
482    pub fn builder() -> ModelButtonBuilder {
483        ModelButtonBuilder::new()
484    }
485
486    /// The state of the button. This is reflecting the state of the associated
487    /// `GAction`.
488    pub fn is_active(&self) -> bool {
489        ObjectExt::property(self, "active")
490    }
491
492    /// The state of the button. This is reflecting the state of the associated
493    /// `GAction`.
494    pub fn set_active(&self, active: bool) {
495        ObjectExt::set_property(self, "active", active)
496    }
497
498    /// Whether to render the button contents centered instead of left-aligned.
499    /// This property should be set for title-like items.
500    pub fn is_centered(&self) -> bool {
501        ObjectExt::property(self, "centered")
502    }
503
504    /// Whether to render the button contents centered instead of left-aligned.
505    /// This property should be set for title-like items.
506    pub fn set_centered(&self, centered: bool) {
507        ObjectExt::set_property(self, "centered", centered)
508    }
509
510    /// A [`gio::Icon`][crate::gio::Icon] that will be used if iconic appearance for the button is
511    /// desired.
512    pub fn icon(&self) -> Option<gio::Icon> {
513        ObjectExt::property(self, "icon")
514    }
515
516    /// A [`gio::Icon`][crate::gio::Icon] that will be used if iconic appearance for the button is
517    /// desired.
518    pub fn set_icon<P: IsA<gio::Icon>>(&self, icon: Option<&P>) {
519        ObjectExt::set_property(self, "icon", icon)
520    }
521
522    /// If this property is set, the button will show an icon if one is set.
523    /// If no icon is set, the text will be used. This is typically used for
524    /// horizontal sections of linked buttons.
525    pub fn is_iconic(&self) -> bool {
526        ObjectExt::property(self, "iconic")
527    }
528
529    /// If this property is set, the button will show an icon if one is set.
530    /// If no icon is set, the text will be used. This is typically used for
531    /// horizontal sections of linked buttons.
532    pub fn set_iconic(&self, iconic: bool) {
533        ObjectExt::set_property(self, "iconic", iconic)
534    }
535
536    /// Whether to show the submenu indicator at the opposite side than normal.
537    /// This property should be set for model buttons that 'go back' to a parent
538    /// menu.
539    pub fn is_inverted(&self) -> bool {
540        ObjectExt::property(self, "inverted")
541    }
542
543    /// Whether to show the submenu indicator at the opposite side than normal.
544    /// This property should be set for model buttons that 'go back' to a parent
545    /// menu.
546    pub fn set_inverted(&self, inverted: bool) {
547        ObjectExt::set_property(self, "inverted", inverted)
548    }
549
550    /// The name of a submenu to open when the button is activated.
551    /// If this is set, the button should not have an action associated with it.
552    #[doc(alias = "menu-name")]
553    pub fn menu_name(&self) -> Option<glib::GString> {
554        ObjectExt::property(self, "menu-name")
555    }
556
557    /// The name of a submenu to open when the button is activated.
558    /// If this is set, the button should not have an action associated with it.
559    #[doc(alias = "menu-name")]
560    pub fn set_menu_name(&self, menu_name: Option<&str>) {
561        ObjectExt::set_property(self, "menu-name", menu_name)
562    }
563
564    /// Specifies whether the button is a plain, check or radio button.
565    /// When [`action-name`][struct@crate::Actionable#action-name] is set, the role will be determined
566    /// from the action and does not have to be set explicitly.
567    pub fn role(&self) -> ButtonRole {
568        ObjectExt::property(self, "role")
569    }
570
571    /// Specifies whether the button is a plain, check or radio button.
572    /// When [`action-name`][struct@crate::Actionable#action-name] is set, the role will be determined
573    /// from the action and does not have to be set explicitly.
574    pub fn set_role(&self, role: ButtonRole) {
575        ObjectExt::set_property(self, "role", role)
576    }
577
578    /// The label for the button.
579    pub fn text(&self) -> Option<glib::GString> {
580        ObjectExt::property(self, "text")
581    }
582
583    /// The label for the button.
584    pub fn set_text(&self, text: Option<&str>) {
585        ObjectExt::set_property(self, "text", text)
586    }
587
588    /// If [`true`], XML tags in the text of the button are interpreted as by
589    /// `pango_parse_markup()` to format the enclosed spans of text. If [`false`], the
590    /// text will be displayed verbatim.
591    #[cfg(feature = "v3_24")]
592    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
593    #[doc(alias = "use-markup")]
594    pub fn uses_markup(&self) -> bool {
595        ObjectExt::property(self, "use-markup")
596    }
597
598    /// If [`true`], XML tags in the text of the button are interpreted as by
599    /// `pango_parse_markup()` to format the enclosed spans of text. If [`false`], the
600    /// text will be displayed verbatim.
601    #[cfg(feature = "v3_24")]
602    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
603    #[doc(alias = "use-markup")]
604    pub fn set_use_markup(&self, use_markup: bool) {
605        ObjectExt::set_property(self, "use-markup", use_markup)
606    }
607
608    #[doc(alias = "active")]
609    pub fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
610        unsafe extern "C" fn notify_active_trampoline<F: Fn(&ModelButton) + 'static>(
611            this: *mut ffi::GtkModelButton,
612            _param_spec: glib::ffi::gpointer,
613            f: glib::ffi::gpointer,
614        ) {
615            unsafe {
616                let f: &F = &*(f as *const F);
617                f(&from_glib_borrow(this))
618            }
619        }
620        unsafe {
621            let f: Box_<F> = Box_::new(f);
622            connect_raw(
623                self.as_ptr() as *mut _,
624                c"notify::active".as_ptr(),
625                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
626                    notify_active_trampoline::<F> as *const (),
627                )),
628                Box_::into_raw(f),
629            )
630        }
631    }
632
633    #[doc(alias = "centered")]
634    pub fn connect_centered_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
635        unsafe extern "C" fn notify_centered_trampoline<F: Fn(&ModelButton) + 'static>(
636            this: *mut ffi::GtkModelButton,
637            _param_spec: glib::ffi::gpointer,
638            f: glib::ffi::gpointer,
639        ) {
640            unsafe {
641                let f: &F = &*(f as *const F);
642                f(&from_glib_borrow(this))
643            }
644        }
645        unsafe {
646            let f: Box_<F> = Box_::new(f);
647            connect_raw(
648                self.as_ptr() as *mut _,
649                c"notify::centered".as_ptr(),
650                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
651                    notify_centered_trampoline::<F> as *const (),
652                )),
653                Box_::into_raw(f),
654            )
655        }
656    }
657
658    #[doc(alias = "icon")]
659    pub fn connect_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
660        unsafe extern "C" fn notify_icon_trampoline<F: Fn(&ModelButton) + 'static>(
661            this: *mut ffi::GtkModelButton,
662            _param_spec: glib::ffi::gpointer,
663            f: glib::ffi::gpointer,
664        ) {
665            unsafe {
666                let f: &F = &*(f as *const F);
667                f(&from_glib_borrow(this))
668            }
669        }
670        unsafe {
671            let f: Box_<F> = Box_::new(f);
672            connect_raw(
673                self.as_ptr() as *mut _,
674                c"notify::icon".as_ptr(),
675                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
676                    notify_icon_trampoline::<F> as *const (),
677                )),
678                Box_::into_raw(f),
679            )
680        }
681    }
682
683    #[doc(alias = "iconic")]
684    pub fn connect_iconic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
685        unsafe extern "C" fn notify_iconic_trampoline<F: Fn(&ModelButton) + 'static>(
686            this: *mut ffi::GtkModelButton,
687            _param_spec: glib::ffi::gpointer,
688            f: glib::ffi::gpointer,
689        ) {
690            unsafe {
691                let f: &F = &*(f as *const F);
692                f(&from_glib_borrow(this))
693            }
694        }
695        unsafe {
696            let f: Box_<F> = Box_::new(f);
697            connect_raw(
698                self.as_ptr() as *mut _,
699                c"notify::iconic".as_ptr(),
700                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
701                    notify_iconic_trampoline::<F> as *const (),
702                )),
703                Box_::into_raw(f),
704            )
705        }
706    }
707
708    #[doc(alias = "inverted")]
709    pub fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
710        unsafe extern "C" fn notify_inverted_trampoline<F: Fn(&ModelButton) + 'static>(
711            this: *mut ffi::GtkModelButton,
712            _param_spec: glib::ffi::gpointer,
713            f: glib::ffi::gpointer,
714        ) {
715            unsafe {
716                let f: &F = &*(f as *const F);
717                f(&from_glib_borrow(this))
718            }
719        }
720        unsafe {
721            let f: Box_<F> = Box_::new(f);
722            connect_raw(
723                self.as_ptr() as *mut _,
724                c"notify::inverted".as_ptr(),
725                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
726                    notify_inverted_trampoline::<F> as *const (),
727                )),
728                Box_::into_raw(f),
729            )
730        }
731    }
732
733    #[doc(alias = "menu-name")]
734    pub fn connect_menu_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
735        unsafe extern "C" fn notify_menu_name_trampoline<F: Fn(&ModelButton) + 'static>(
736            this: *mut ffi::GtkModelButton,
737            _param_spec: glib::ffi::gpointer,
738            f: glib::ffi::gpointer,
739        ) {
740            unsafe {
741                let f: &F = &*(f as *const F);
742                f(&from_glib_borrow(this))
743            }
744        }
745        unsafe {
746            let f: Box_<F> = Box_::new(f);
747            connect_raw(
748                self.as_ptr() as *mut _,
749                c"notify::menu-name".as_ptr(),
750                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
751                    notify_menu_name_trampoline::<F> as *const (),
752                )),
753                Box_::into_raw(f),
754            )
755        }
756    }
757
758    #[doc(alias = "role")]
759    pub fn connect_role_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
760        unsafe extern "C" fn notify_role_trampoline<F: Fn(&ModelButton) + 'static>(
761            this: *mut ffi::GtkModelButton,
762            _param_spec: glib::ffi::gpointer,
763            f: glib::ffi::gpointer,
764        ) {
765            unsafe {
766                let f: &F = &*(f as *const F);
767                f(&from_glib_borrow(this))
768            }
769        }
770        unsafe {
771            let f: Box_<F> = Box_::new(f);
772            connect_raw(
773                self.as_ptr() as *mut _,
774                c"notify::role".as_ptr(),
775                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
776                    notify_role_trampoline::<F> as *const (),
777                )),
778                Box_::into_raw(f),
779            )
780        }
781    }
782
783    #[doc(alias = "text")]
784    pub fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
785        unsafe extern "C" fn notify_text_trampoline<F: Fn(&ModelButton) + 'static>(
786            this: *mut ffi::GtkModelButton,
787            _param_spec: glib::ffi::gpointer,
788            f: glib::ffi::gpointer,
789        ) {
790            unsafe {
791                let f: &F = &*(f as *const F);
792                f(&from_glib_borrow(this))
793            }
794        }
795        unsafe {
796            let f: Box_<F> = Box_::new(f);
797            connect_raw(
798                self.as_ptr() as *mut _,
799                c"notify::text".as_ptr(),
800                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
801                    notify_text_trampoline::<F> as *const (),
802                )),
803                Box_::into_raw(f),
804            )
805        }
806    }
807
808    #[cfg(feature = "v3_24")]
809    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
810    #[doc(alias = "use-markup")]
811    pub fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
812        unsafe extern "C" fn notify_use_markup_trampoline<F: Fn(&ModelButton) + 'static>(
813            this: *mut ffi::GtkModelButton,
814            _param_spec: glib::ffi::gpointer,
815            f: glib::ffi::gpointer,
816        ) {
817            unsafe {
818                let f: &F = &*(f as *const F);
819                f(&from_glib_borrow(this))
820            }
821        }
822        unsafe {
823            let f: Box_<F> = Box_::new(f);
824            connect_raw(
825                self.as_ptr() as *mut _,
826                c"notify::use-markup".as_ptr(),
827                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
828                    notify_use_markup_trampoline::<F> as *const (),
829                )),
830                Box_::into_raw(f),
831            )
832        }
833    }
834}
835
836impl Default for ModelButton {
837    fn default() -> Self {
838        Self::new()
839    }
840}
841
842// rustdoc-stripper-ignore-next
843/// A [builder-pattern] type to construct [`ModelButton`] objects.
844///
845/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
846#[must_use = "The builder must be built to be used"]
847pub struct ModelButtonBuilder {
848    builder: glib::object::ObjectBuilder<'static, ModelButton>,
849}
850
851impl ModelButtonBuilder {
852    fn new() -> Self {
853        Self {
854            builder: glib::object::Object::builder(),
855        }
856    }
857
858    /// The state of the button. This is reflecting the state of the associated
859    /// `GAction`.
860    pub fn active(self, active: bool) -> Self {
861        Self {
862            builder: self.builder.property("active", active),
863        }
864    }
865
866    /// Whether to render the button contents centered instead of left-aligned.
867    /// This property should be set for title-like items.
868    pub fn centered(self, centered: bool) -> Self {
869        Self {
870            builder: self.builder.property("centered", centered),
871        }
872    }
873
874    /// A [`gio::Icon`][crate::gio::Icon] that will be used if iconic appearance for the button is
875    /// desired.
876    pub fn icon(self, icon: &impl IsA<gio::Icon>) -> Self {
877        Self {
878            builder: self.builder.property("icon", icon.clone().upcast()),
879        }
880    }
881
882    /// If this property is set, the button will show an icon if one is set.
883    /// If no icon is set, the text will be used. This is typically used for
884    /// horizontal sections of linked buttons.
885    pub fn iconic(self, iconic: bool) -> Self {
886        Self {
887            builder: self.builder.property("iconic", iconic),
888        }
889    }
890
891    /// Whether to show the submenu indicator at the opposite side than normal.
892    /// This property should be set for model buttons that 'go back' to a parent
893    /// menu.
894    pub fn inverted(self, inverted: bool) -> Self {
895        Self {
896            builder: self.builder.property("inverted", inverted),
897        }
898    }
899
900    /// The name of a submenu to open when the button is activated.
901    /// If this is set, the button should not have an action associated with it.
902    pub fn menu_name(self, menu_name: impl Into<glib::GString>) -> Self {
903        Self {
904            builder: self.builder.property("menu-name", menu_name.into()),
905        }
906    }
907
908    /// Specifies whether the button is a plain, check or radio button.
909    /// When [`action-name`][struct@crate::Actionable#action-name] is set, the role will be determined
910    /// from the action and does not have to be set explicitly.
911    pub fn role(self, role: ButtonRole) -> Self {
912        Self {
913            builder: self.builder.property("role", role),
914        }
915    }
916
917    /// The label for the button.
918    pub fn text(self, text: impl Into<glib::GString>) -> Self {
919        Self {
920            builder: self.builder.property("text", text.into()),
921        }
922    }
923
924    /// If [`true`], XML tags in the text of the button are interpreted as by
925    /// `pango_parse_markup()` to format the enclosed spans of text. If [`false`], the
926    /// text will be displayed verbatim.
927    #[cfg(feature = "v3_24")]
928    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
929    pub fn use_markup(self, use_markup: bool) -> Self {
930        Self {
931            builder: self.builder.property("use-markup", use_markup),
932        }
933    }
934
935    /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
936    /// setting and always show the image, if available.
937    ///
938    /// Use this property if the button would be useless or hard to use
939    /// without the image.
940    pub fn always_show_image(self, always_show_image: bool) -> Self {
941        Self {
942            builder: self
943                .builder
944                .property("always-show-image", always_show_image),
945        }
946    }
947
948    /// The child widget to appear next to the button text.
949    pub fn image(self, image: &impl IsA<Widget>) -> Self {
950        Self {
951            builder: self.builder.property("image", image.clone().upcast()),
952        }
953    }
954
955    /// The position of the image relative to the text inside the button.
956    pub fn image_position(self, image_position: PositionType) -> Self {
957        Self {
958            builder: self.builder.property("image-position", image_position),
959        }
960    }
961
962    pub fn label(self, label: impl Into<glib::GString>) -> Self {
963        Self {
964            builder: self.builder.property("label", label.into()),
965        }
966    }
967
968    pub fn relief(self, relief: ReliefStyle) -> Self {
969        Self {
970            builder: self.builder.property("relief", relief),
971        }
972    }
973
974    pub fn use_underline(self, use_underline: bool) -> Self {
975        Self {
976            builder: self.builder.property("use-underline", use_underline),
977        }
978    }
979
980    pub fn border_width(self, border_width: u32) -> Self {
981        Self {
982            builder: self.builder.property("border-width", border_width),
983        }
984    }
985
986    pub fn child(self, child: &impl IsA<Widget>) -> Self {
987        Self {
988            builder: self.builder.property("child", child.clone().upcast()),
989        }
990    }
991
992    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
993        Self {
994            builder: self.builder.property("resize-mode", resize_mode),
995        }
996    }
997
998    pub fn app_paintable(self, app_paintable: bool) -> Self {
999        Self {
1000            builder: self.builder.property("app-paintable", app_paintable),
1001        }
1002    }
1003
1004    pub fn can_default(self, can_default: bool) -> Self {
1005        Self {
1006            builder: self.builder.property("can-default", can_default),
1007        }
1008    }
1009
1010    pub fn can_focus(self, can_focus: bool) -> Self {
1011        Self {
1012            builder: self.builder.property("can-focus", can_focus),
1013        }
1014    }
1015
1016    pub fn events(self, events: gdk::EventMask) -> Self {
1017        Self {
1018            builder: self.builder.property("events", events),
1019        }
1020    }
1021
1022    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1023    pub fn expand(self, expand: bool) -> Self {
1024        Self {
1025            builder: self.builder.property("expand", expand),
1026        }
1027    }
1028
1029    /// Whether the widget should grab focus when it is clicked with the mouse.
1030    ///
1031    /// This property is only relevant for widgets that can take focus.
1032    ///
1033    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1034    /// GtkComboBox) implemented this property individually.
1035    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1036        Self {
1037            builder: self.builder.property("focus-on-click", focus_on_click),
1038        }
1039    }
1040
1041    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1042    pub fn halign(self, halign: Align) -> Self {
1043        Self {
1044            builder: self.builder.property("halign", halign),
1045        }
1046    }
1047
1048    pub fn has_default(self, has_default: bool) -> Self {
1049        Self {
1050            builder: self.builder.property("has-default", has_default),
1051        }
1052    }
1053
1054    pub fn has_focus(self, has_focus: bool) -> Self {
1055        Self {
1056            builder: self.builder.property("has-focus", has_focus),
1057        }
1058    }
1059
1060    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1061    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1062    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1063    /// whether it will provide a tooltip or not.
1064    ///
1065    /// Note that setting this property to [`true`] for the first time will change
1066    /// the event masks of the GdkWindows of this widget to include leave-notify
1067    /// and motion-notify events. This cannot and will not be undone when the
1068    /// property is set to [`false`] again.
1069    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1070        Self {
1071            builder: self.builder.property("has-tooltip", has_tooltip),
1072        }
1073    }
1074
1075    pub fn height_request(self, height_request: i32) -> Self {
1076        Self {
1077            builder: self.builder.property("height-request", height_request),
1078        }
1079    }
1080
1081    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1082    pub fn hexpand(self, hexpand: bool) -> Self {
1083        Self {
1084            builder: self.builder.property("hexpand", hexpand),
1085        }
1086    }
1087
1088    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1089    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1090        Self {
1091            builder: self.builder.property("hexpand-set", hexpand_set),
1092        }
1093    }
1094
1095    pub fn is_focus(self, is_focus: bool) -> Self {
1096        Self {
1097            builder: self.builder.property("is-focus", is_focus),
1098        }
1099    }
1100
1101    /// Sets all four sides' margin at once. If read, returns max
1102    /// margin on any side.
1103    pub fn margin(self, margin: i32) -> Self {
1104        Self {
1105            builder: self.builder.property("margin", margin),
1106        }
1107    }
1108
1109    /// Margin on bottom side of widget.
1110    ///
1111    /// This property adds margin outside of the widget's normal size
1112    /// request, the margin will be added in addition to the size from
1113    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1114    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1115        Self {
1116            builder: self.builder.property("margin-bottom", margin_bottom),
1117        }
1118    }
1119
1120    /// Margin on end of widget, horizontally. This property supports
1121    /// left-to-right and right-to-left text directions.
1122    ///
1123    /// This property adds margin outside of the widget's normal size
1124    /// request, the margin will be added in addition to the size from
1125    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1126    pub fn margin_end(self, margin_end: i32) -> Self {
1127        Self {
1128            builder: self.builder.property("margin-end", margin_end),
1129        }
1130    }
1131
1132    /// Margin on start of widget, horizontally. This property supports
1133    /// left-to-right and right-to-left text directions.
1134    ///
1135    /// This property adds margin outside of the widget's normal size
1136    /// request, the margin will be added in addition to the size from
1137    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1138    pub fn margin_start(self, margin_start: i32) -> Self {
1139        Self {
1140            builder: self.builder.property("margin-start", margin_start),
1141        }
1142    }
1143
1144    /// Margin on top side of widget.
1145    ///
1146    /// This property adds margin outside of the widget's normal size
1147    /// request, the margin will be added in addition to the size from
1148    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1149    pub fn margin_top(self, margin_top: i32) -> Self {
1150        Self {
1151            builder: self.builder.property("margin-top", margin_top),
1152        }
1153    }
1154
1155    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1156        Self {
1157            builder: self.builder.property("name", name.into()),
1158        }
1159    }
1160
1161    pub fn no_show_all(self, no_show_all: bool) -> Self {
1162        Self {
1163            builder: self.builder.property("no-show-all", no_show_all),
1164        }
1165    }
1166
1167    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1168    /// more details about window opacity.
1169    ///
1170    /// Before 3.8 this was only available in GtkWindow
1171    pub fn opacity(self, opacity: f64) -> Self {
1172        Self {
1173            builder: self.builder.property("opacity", opacity),
1174        }
1175    }
1176
1177    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1178        Self {
1179            builder: self.builder.property("parent", parent.clone().upcast()),
1180        }
1181    }
1182
1183    pub fn receives_default(self, receives_default: bool) -> Self {
1184        Self {
1185            builder: self.builder.property("receives-default", receives_default),
1186        }
1187    }
1188
1189    pub fn sensitive(self, sensitive: bool) -> Self {
1190        Self {
1191            builder: self.builder.property("sensitive", sensitive),
1192        }
1193    }
1194
1195    /// Sets the text of tooltip to be the given string, which is marked up
1196    /// with the [Pango text markup language][PangoMarkupFormat].
1197    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1198    ///
1199    /// This is a convenience property which will take care of getting the
1200    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1201    /// will automatically be set to [`true`] and there will be taken care of
1202    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1203    ///
1204    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1205    /// are set, the last one wins.
1206    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1207        Self {
1208            builder: self
1209                .builder
1210                .property("tooltip-markup", tooltip_markup.into()),
1211        }
1212    }
1213
1214    /// Sets the text of tooltip to be the given string.
1215    ///
1216    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1217    ///
1218    /// This is a convenience property which will take care of getting the
1219    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1220    /// will automatically be set to [`true`] and there will be taken care of
1221    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1222    ///
1223    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1224    /// are set, the last one wins.
1225    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1226        Self {
1227            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1228        }
1229    }
1230
1231    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1232    pub fn valign(self, valign: Align) -> Self {
1233        Self {
1234            builder: self.builder.property("valign", valign),
1235        }
1236    }
1237
1238    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1239    pub fn vexpand(self, vexpand: bool) -> Self {
1240        Self {
1241            builder: self.builder.property("vexpand", vexpand),
1242        }
1243    }
1244
1245    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1246    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1247        Self {
1248            builder: self.builder.property("vexpand-set", vexpand_set),
1249        }
1250    }
1251
1252    pub fn visible(self, visible: bool) -> Self {
1253        Self {
1254            builder: self.builder.property("visible", visible),
1255        }
1256    }
1257
1258    pub fn width_request(self, width_request: i32) -> Self {
1259        Self {
1260            builder: self.builder.property("width-request", width_request),
1261        }
1262    }
1263
1264    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1265        Self {
1266            builder: self.builder.property("action-name", action_name.into()),
1267        }
1268    }
1269
1270    pub fn action_target(self, action_target: &glib::Variant) -> Self {
1271        Self {
1272            builder: self
1273                .builder
1274                .property("action-target", action_target.clone()),
1275        }
1276    }
1277
1278    // rustdoc-stripper-ignore-next
1279    /// Build the [`ModelButton`].
1280    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1281    pub fn build(self) -> ModelButton {
1282        assert_initialized_main_thread!();
1283        self.builder.build()
1284    }
1285}