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,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute};
15
16glib::wrapper! {
17    #[doc(alias = "GtkModelButton")]
18    pub struct ModelButton(Object<ffi::GtkModelButton>) @extends Button, Bin, Container, Widget, @implements Buildable, Actionable;
19
20    match fn {
21        type_ => || ffi::gtk_model_button_get_type(),
22    }
23}
24
25impl ModelButton {
26    #[doc(alias = "gtk_model_button_new")]
27    pub fn new() -> ModelButton {
28        assert_initialized_main_thread!();
29        unsafe { Widget::from_glib_none(ffi::gtk_model_button_new()).unsafe_cast() }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`ModelButton`] objects.
34    ///
35    /// This method returns an instance of [`ModelButtonBuilder`](crate::builders::ModelButtonBuilder) which can be used to create [`ModelButton`] objects.
36    pub fn builder() -> ModelButtonBuilder {
37        ModelButtonBuilder::new()
38    }
39
40    pub fn is_active(&self) -> bool {
41        ObjectExt::property(self, "active")
42    }
43
44    pub fn set_active(&self, active: bool) {
45        ObjectExt::set_property(self, "active", active)
46    }
47
48    pub fn is_centered(&self) -> bool {
49        ObjectExt::property(self, "centered")
50    }
51
52    pub fn set_centered(&self, centered: bool) {
53        ObjectExt::set_property(self, "centered", centered)
54    }
55
56    pub fn icon(&self) -> Option<gio::Icon> {
57        ObjectExt::property(self, "icon")
58    }
59
60    pub fn set_icon<P: IsA<gio::Icon>>(&self, icon: Option<&P>) {
61        ObjectExt::set_property(self, "icon", icon)
62    }
63
64    pub fn is_iconic(&self) -> bool {
65        ObjectExt::property(self, "iconic")
66    }
67
68    pub fn set_iconic(&self, iconic: bool) {
69        ObjectExt::set_property(self, "iconic", iconic)
70    }
71
72    pub fn is_inverted(&self) -> bool {
73        ObjectExt::property(self, "inverted")
74    }
75
76    pub fn set_inverted(&self, inverted: bool) {
77        ObjectExt::set_property(self, "inverted", inverted)
78    }
79
80    #[doc(alias = "menu-name")]
81    pub fn menu_name(&self) -> Option<glib::GString> {
82        ObjectExt::property(self, "menu-name")
83    }
84
85    #[doc(alias = "menu-name")]
86    pub fn set_menu_name(&self, menu_name: Option<&str>) {
87        ObjectExt::set_property(self, "menu-name", menu_name)
88    }
89
90    pub fn role(&self) -> ButtonRole {
91        ObjectExt::property(self, "role")
92    }
93
94    pub fn set_role(&self, role: ButtonRole) {
95        ObjectExt::set_property(self, "role", role)
96    }
97
98    pub fn text(&self) -> Option<glib::GString> {
99        ObjectExt::property(self, "text")
100    }
101
102    pub fn set_text(&self, text: Option<&str>) {
103        ObjectExt::set_property(self, "text", text)
104    }
105
106    #[cfg(feature = "v3_24")]
107    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
108    #[doc(alias = "use-markup")]
109    pub fn uses_markup(&self) -> bool {
110        ObjectExt::property(self, "use-markup")
111    }
112
113    #[cfg(feature = "v3_24")]
114    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
115    #[doc(alias = "use-markup")]
116    pub fn set_use_markup(&self, use_markup: bool) {
117        ObjectExt::set_property(self, "use-markup", use_markup)
118    }
119
120    #[doc(alias = "active")]
121    pub fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
122        unsafe extern "C" fn notify_active_trampoline<F: Fn(&ModelButton) + 'static>(
123            this: *mut ffi::GtkModelButton,
124            _param_spec: glib::ffi::gpointer,
125            f: glib::ffi::gpointer,
126        ) {
127            let f: &F = &*(f as *const F);
128            f(&from_glib_borrow(this))
129        }
130        unsafe {
131            let f: Box_<F> = Box_::new(f);
132            connect_raw(
133                self.as_ptr() as *mut _,
134                b"notify::active\0".as_ptr() as *const _,
135                Some(transmute::<_, unsafe extern "C" fn()>(
136                    notify_active_trampoline::<F> as *const (),
137                )),
138                Box_::into_raw(f),
139            )
140        }
141    }
142
143    #[doc(alias = "centered")]
144    pub fn connect_centered_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
145        unsafe extern "C" fn notify_centered_trampoline<F: Fn(&ModelButton) + 'static>(
146            this: *mut ffi::GtkModelButton,
147            _param_spec: glib::ffi::gpointer,
148            f: glib::ffi::gpointer,
149        ) {
150            let f: &F = &*(f as *const F);
151            f(&from_glib_borrow(this))
152        }
153        unsafe {
154            let f: Box_<F> = Box_::new(f);
155            connect_raw(
156                self.as_ptr() as *mut _,
157                b"notify::centered\0".as_ptr() as *const _,
158                Some(transmute::<_, unsafe extern "C" fn()>(
159                    notify_centered_trampoline::<F> as *const (),
160                )),
161                Box_::into_raw(f),
162            )
163        }
164    }
165
166    #[doc(alias = "icon")]
167    pub fn connect_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
168        unsafe extern "C" fn notify_icon_trampoline<F: Fn(&ModelButton) + 'static>(
169            this: *mut ffi::GtkModelButton,
170            _param_spec: glib::ffi::gpointer,
171            f: glib::ffi::gpointer,
172        ) {
173            let f: &F = &*(f as *const F);
174            f(&from_glib_borrow(this))
175        }
176        unsafe {
177            let f: Box_<F> = Box_::new(f);
178            connect_raw(
179                self.as_ptr() as *mut _,
180                b"notify::icon\0".as_ptr() as *const _,
181                Some(transmute::<_, unsafe extern "C" fn()>(
182                    notify_icon_trampoline::<F> as *const (),
183                )),
184                Box_::into_raw(f),
185            )
186        }
187    }
188
189    #[doc(alias = "iconic")]
190    pub fn connect_iconic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
191        unsafe extern "C" fn notify_iconic_trampoline<F: Fn(&ModelButton) + 'static>(
192            this: *mut ffi::GtkModelButton,
193            _param_spec: glib::ffi::gpointer,
194            f: glib::ffi::gpointer,
195        ) {
196            let f: &F = &*(f as *const F);
197            f(&from_glib_borrow(this))
198        }
199        unsafe {
200            let f: Box_<F> = Box_::new(f);
201            connect_raw(
202                self.as_ptr() as *mut _,
203                b"notify::iconic\0".as_ptr() as *const _,
204                Some(transmute::<_, unsafe extern "C" fn()>(
205                    notify_iconic_trampoline::<F> as *const (),
206                )),
207                Box_::into_raw(f),
208            )
209        }
210    }
211
212    #[doc(alias = "inverted")]
213    pub fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
214        unsafe extern "C" fn notify_inverted_trampoline<F: Fn(&ModelButton) + 'static>(
215            this: *mut ffi::GtkModelButton,
216            _param_spec: glib::ffi::gpointer,
217            f: glib::ffi::gpointer,
218        ) {
219            let f: &F = &*(f as *const F);
220            f(&from_glib_borrow(this))
221        }
222        unsafe {
223            let f: Box_<F> = Box_::new(f);
224            connect_raw(
225                self.as_ptr() as *mut _,
226                b"notify::inverted\0".as_ptr() as *const _,
227                Some(transmute::<_, unsafe extern "C" fn()>(
228                    notify_inverted_trampoline::<F> as *const (),
229                )),
230                Box_::into_raw(f),
231            )
232        }
233    }
234
235    #[doc(alias = "menu-name")]
236    pub fn connect_menu_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
237        unsafe extern "C" fn notify_menu_name_trampoline<F: Fn(&ModelButton) + 'static>(
238            this: *mut ffi::GtkModelButton,
239            _param_spec: glib::ffi::gpointer,
240            f: glib::ffi::gpointer,
241        ) {
242            let f: &F = &*(f as *const F);
243            f(&from_glib_borrow(this))
244        }
245        unsafe {
246            let f: Box_<F> = Box_::new(f);
247            connect_raw(
248                self.as_ptr() as *mut _,
249                b"notify::menu-name\0".as_ptr() as *const _,
250                Some(transmute::<_, unsafe extern "C" fn()>(
251                    notify_menu_name_trampoline::<F> as *const (),
252                )),
253                Box_::into_raw(f),
254            )
255        }
256    }
257
258    #[doc(alias = "role")]
259    pub fn connect_role_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
260        unsafe extern "C" fn notify_role_trampoline<F: Fn(&ModelButton) + 'static>(
261            this: *mut ffi::GtkModelButton,
262            _param_spec: glib::ffi::gpointer,
263            f: glib::ffi::gpointer,
264        ) {
265            let f: &F = &*(f as *const F);
266            f(&from_glib_borrow(this))
267        }
268        unsafe {
269            let f: Box_<F> = Box_::new(f);
270            connect_raw(
271                self.as_ptr() as *mut _,
272                b"notify::role\0".as_ptr() as *const _,
273                Some(transmute::<_, unsafe extern "C" fn()>(
274                    notify_role_trampoline::<F> as *const (),
275                )),
276                Box_::into_raw(f),
277            )
278        }
279    }
280
281    #[doc(alias = "text")]
282    pub fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
283        unsafe extern "C" fn notify_text_trampoline<F: Fn(&ModelButton) + 'static>(
284            this: *mut ffi::GtkModelButton,
285            _param_spec: glib::ffi::gpointer,
286            f: glib::ffi::gpointer,
287        ) {
288            let f: &F = &*(f as *const F);
289            f(&from_glib_borrow(this))
290        }
291        unsafe {
292            let f: Box_<F> = Box_::new(f);
293            connect_raw(
294                self.as_ptr() as *mut _,
295                b"notify::text\0".as_ptr() as *const _,
296                Some(transmute::<_, unsafe extern "C" fn()>(
297                    notify_text_trampoline::<F> as *const (),
298                )),
299                Box_::into_raw(f),
300            )
301        }
302    }
303
304    #[cfg(feature = "v3_24")]
305    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
306    #[doc(alias = "use-markup")]
307    pub fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
308        unsafe extern "C" fn notify_use_markup_trampoline<F: Fn(&ModelButton) + 'static>(
309            this: *mut ffi::GtkModelButton,
310            _param_spec: glib::ffi::gpointer,
311            f: glib::ffi::gpointer,
312        ) {
313            let f: &F = &*(f as *const F);
314            f(&from_glib_borrow(this))
315        }
316        unsafe {
317            let f: Box_<F> = Box_::new(f);
318            connect_raw(
319                self.as_ptr() as *mut _,
320                b"notify::use-markup\0".as_ptr() as *const _,
321                Some(transmute::<_, unsafe extern "C" fn()>(
322                    notify_use_markup_trampoline::<F> as *const (),
323                )),
324                Box_::into_raw(f),
325            )
326        }
327    }
328}
329
330impl Default for ModelButton {
331    fn default() -> Self {
332        Self::new()
333    }
334}
335
336// rustdoc-stripper-ignore-next
337/// A [builder-pattern] type to construct [`ModelButton`] objects.
338///
339/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
340#[must_use = "The builder must be built to be used"]
341pub struct ModelButtonBuilder {
342    builder: glib::object::ObjectBuilder<'static, ModelButton>,
343}
344
345impl ModelButtonBuilder {
346    fn new() -> Self {
347        Self {
348            builder: glib::object::Object::builder(),
349        }
350    }
351
352    pub fn active(self, active: bool) -> Self {
353        Self {
354            builder: self.builder.property("active", active),
355        }
356    }
357
358    pub fn centered(self, centered: bool) -> Self {
359        Self {
360            builder: self.builder.property("centered", centered),
361        }
362    }
363
364    pub fn icon(self, icon: &impl IsA<gio::Icon>) -> Self {
365        Self {
366            builder: self.builder.property("icon", icon.clone().upcast()),
367        }
368    }
369
370    pub fn iconic(self, iconic: bool) -> Self {
371        Self {
372            builder: self.builder.property("iconic", iconic),
373        }
374    }
375
376    pub fn inverted(self, inverted: bool) -> Self {
377        Self {
378            builder: self.builder.property("inverted", inverted),
379        }
380    }
381
382    pub fn menu_name(self, menu_name: impl Into<glib::GString>) -> Self {
383        Self {
384            builder: self.builder.property("menu-name", menu_name.into()),
385        }
386    }
387
388    pub fn role(self, role: ButtonRole) -> Self {
389        Self {
390            builder: self.builder.property("role", role),
391        }
392    }
393
394    pub fn text(self, text: impl Into<glib::GString>) -> Self {
395        Self {
396            builder: self.builder.property("text", text.into()),
397        }
398    }
399
400    #[cfg(feature = "v3_24")]
401    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
402    pub fn use_markup(self, use_markup: bool) -> Self {
403        Self {
404            builder: self.builder.property("use-markup", use_markup),
405        }
406    }
407
408    pub fn always_show_image(self, always_show_image: bool) -> Self {
409        Self {
410            builder: self
411                .builder
412                .property("always-show-image", always_show_image),
413        }
414    }
415
416    pub fn image(self, image: &impl IsA<Widget>) -> Self {
417        Self {
418            builder: self.builder.property("image", image.clone().upcast()),
419        }
420    }
421
422    pub fn image_position(self, image_position: PositionType) -> Self {
423        Self {
424            builder: self.builder.property("image-position", image_position),
425        }
426    }
427
428    pub fn label(self, label: impl Into<glib::GString>) -> Self {
429        Self {
430            builder: self.builder.property("label", label.into()),
431        }
432    }
433
434    pub fn relief(self, relief: ReliefStyle) -> Self {
435        Self {
436            builder: self.builder.property("relief", relief),
437        }
438    }
439
440    pub fn use_underline(self, use_underline: bool) -> Self {
441        Self {
442            builder: self.builder.property("use-underline", use_underline),
443        }
444    }
445
446    pub fn border_width(self, border_width: u32) -> Self {
447        Self {
448            builder: self.builder.property("border-width", border_width),
449        }
450    }
451
452    pub fn child(self, child: &impl IsA<Widget>) -> Self {
453        Self {
454            builder: self.builder.property("child", child.clone().upcast()),
455        }
456    }
457
458    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
459        Self {
460            builder: self.builder.property("resize-mode", resize_mode),
461        }
462    }
463
464    pub fn app_paintable(self, app_paintable: bool) -> Self {
465        Self {
466            builder: self.builder.property("app-paintable", app_paintable),
467        }
468    }
469
470    pub fn can_default(self, can_default: bool) -> Self {
471        Self {
472            builder: self.builder.property("can-default", can_default),
473        }
474    }
475
476    pub fn can_focus(self, can_focus: bool) -> Self {
477        Self {
478            builder: self.builder.property("can-focus", can_focus),
479        }
480    }
481
482    pub fn events(self, events: gdk::EventMask) -> Self {
483        Self {
484            builder: self.builder.property("events", events),
485        }
486    }
487
488    pub fn expand(self, expand: bool) -> Self {
489        Self {
490            builder: self.builder.property("expand", expand),
491        }
492    }
493
494    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
495        Self {
496            builder: self.builder.property("focus-on-click", focus_on_click),
497        }
498    }
499
500    pub fn halign(self, halign: Align) -> Self {
501        Self {
502            builder: self.builder.property("halign", halign),
503        }
504    }
505
506    pub fn has_default(self, has_default: bool) -> Self {
507        Self {
508            builder: self.builder.property("has-default", has_default),
509        }
510    }
511
512    pub fn has_focus(self, has_focus: bool) -> Self {
513        Self {
514            builder: self.builder.property("has-focus", has_focus),
515        }
516    }
517
518    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
519        Self {
520            builder: self.builder.property("has-tooltip", has_tooltip),
521        }
522    }
523
524    pub fn height_request(self, height_request: i32) -> Self {
525        Self {
526            builder: self.builder.property("height-request", height_request),
527        }
528    }
529
530    pub fn hexpand(self, hexpand: bool) -> Self {
531        Self {
532            builder: self.builder.property("hexpand", hexpand),
533        }
534    }
535
536    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
537        Self {
538            builder: self.builder.property("hexpand-set", hexpand_set),
539        }
540    }
541
542    pub fn is_focus(self, is_focus: bool) -> Self {
543        Self {
544            builder: self.builder.property("is-focus", is_focus),
545        }
546    }
547
548    pub fn margin(self, margin: i32) -> Self {
549        Self {
550            builder: self.builder.property("margin", margin),
551        }
552    }
553
554    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
555        Self {
556            builder: self.builder.property("margin-bottom", margin_bottom),
557        }
558    }
559
560    pub fn margin_end(self, margin_end: i32) -> Self {
561        Self {
562            builder: self.builder.property("margin-end", margin_end),
563        }
564    }
565
566    pub fn margin_start(self, margin_start: i32) -> Self {
567        Self {
568            builder: self.builder.property("margin-start", margin_start),
569        }
570    }
571
572    pub fn margin_top(self, margin_top: i32) -> Self {
573        Self {
574            builder: self.builder.property("margin-top", margin_top),
575        }
576    }
577
578    pub fn name(self, name: impl Into<glib::GString>) -> Self {
579        Self {
580            builder: self.builder.property("name", name.into()),
581        }
582    }
583
584    pub fn no_show_all(self, no_show_all: bool) -> Self {
585        Self {
586            builder: self.builder.property("no-show-all", no_show_all),
587        }
588    }
589
590    pub fn opacity(self, opacity: f64) -> Self {
591        Self {
592            builder: self.builder.property("opacity", opacity),
593        }
594    }
595
596    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
597        Self {
598            builder: self.builder.property("parent", parent.clone().upcast()),
599        }
600    }
601
602    pub fn receives_default(self, receives_default: bool) -> Self {
603        Self {
604            builder: self.builder.property("receives-default", receives_default),
605        }
606    }
607
608    pub fn sensitive(self, sensitive: bool) -> Self {
609        Self {
610            builder: self.builder.property("sensitive", sensitive),
611        }
612    }
613
614    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
615        Self {
616            builder: self
617                .builder
618                .property("tooltip-markup", tooltip_markup.into()),
619        }
620    }
621
622    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
623        Self {
624            builder: self.builder.property("tooltip-text", tooltip_text.into()),
625        }
626    }
627
628    pub fn valign(self, valign: Align) -> Self {
629        Self {
630            builder: self.builder.property("valign", valign),
631        }
632    }
633
634    pub fn vexpand(self, vexpand: bool) -> Self {
635        Self {
636            builder: self.builder.property("vexpand", vexpand),
637        }
638    }
639
640    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
641        Self {
642            builder: self.builder.property("vexpand-set", vexpand_set),
643        }
644    }
645
646    pub fn visible(self, visible: bool) -> Self {
647        Self {
648            builder: self.builder.property("visible", visible),
649        }
650    }
651
652    pub fn width_request(self, width_request: i32) -> Self {
653        Self {
654            builder: self.builder.property("width-request", width_request),
655        }
656    }
657
658    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
659        Self {
660            builder: self.builder.property("action-name", action_name.into()),
661        }
662    }
663
664    pub fn action_target(self, action_target: &glib::Variant) -> Self {
665        Self {
666            builder: self
667                .builder
668                .property("action-target", action_target.clone()),
669        }
670    }
671
672    // rustdoc-stripper-ignore-next
673    /// Build the [`ModelButton`].
674    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
675    pub fn build(self) -> ModelButton {
676        self.builder.build()
677    }
678}
679
680impl fmt::Display for ModelButton {
681    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
682        f.write_str("ModelButton")
683    }
684}