Skip to main content

libadwaita/auto/
button_content.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14#[cfg(feature = "gtk_v4_10")]
15#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_10")))]
16glib::wrapper! {
17    ///
18    /// ```text
19    ///
20    /// `AdwButtonContent` handles style classes and connecting the mnemonic to the
21    /// button automatically.
22    ///
23    /// ## CSS nodes
24    ///
25    /// ```
26    /// buttoncontent
27    /// ╰── box
28    ///     ├── image
29    ///     ╰── label
30    /// ```text
31    ///
32    /// [`ButtonContent`][crate::ButtonContent]'s CSS node is called `buttoncontent`. It contains a `box`
33    /// subnode that serves as a container for the  `image` and `label` nodes.
34    ///
35    /// When inside a `GtkButton` or [`SplitButton`][crate::SplitButton], the button will receive the
36    /// `.image-text-button` style class. When inside a `GtkMenuButton`, the
37    /// internal `GtkButton` will receive it instead.
38    ///
39    /// ## Accessibility
40    ///
41    /// [`ButtonContent`][crate::ButtonContent] uses the [enum@Gtk.AccessibleRole.group] role.
42    ///
43    /// ## Properties
44    ///
45    ///
46    /// #### `can-shrink`
47    ///  Whether the button can be smaller than the natural size of its contents.
48    ///
49    /// If set to `TRUE`, the label will ellipsize.
50    ///
51    /// See [`can-shrink`][struct@crate::Gtk::Button#can-shrink].
52    ///
53    /// Readable | Writable
54    ///
55    ///
56    /// #### `icon-name`
57    ///  The name of the displayed icon.
58    ///
59    /// If empty, the icon is not shown.
60    ///
61    /// Readable | Writable
62    ///
63    ///
64    /// #### `label`
65    ///  The displayed label.
66    ///
67    /// Readable | Writable
68    ///
69    ///
70    /// #### `use-underline`
71    ///  Whether an underline in the text indicates a mnemonic.
72    ///
73    /// The mnemonic can be used to activate the parent button.
74    ///
75    /// See [`label`][struct@crate::ButtonContent#label].
76    ///
77    /// Readable | Writable
78    /// <details><summary><h4>Widget</h4></summary>
79    ///
80    ///
81    /// #### `can-focus`
82    ///  Whether the widget or any of its descendents can accept
83    /// the input focus.
84    ///
85    /// This property is meant to be set by widget implementations,
86    /// typically in their instance init function.
87    ///
88    /// Readable | Writable
89    ///
90    ///
91    /// #### `can-target`
92    ///  Whether the widget can receive pointer events.
93    ///
94    /// Readable | Writable
95    ///
96    ///
97    /// #### `css-classes`
98    ///  A list of css classes applied to this widget.
99    ///
100    /// Readable | Writable
101    ///
102    ///
103    /// #### `css-name`
104    ///  The name of this widget in the CSS tree.
105    ///
106    /// This property is meant to be set by widget implementations,
107    /// typically in their instance init function.
108    ///
109    /// Readable | Writable | Construct Only
110    ///
111    ///
112    /// #### `cursor`
113    ///  The cursor used by @widget.
114    ///
115    /// Readable | Writable
116    ///
117    ///
118    /// #### `focus-on-click`
119    ///  Whether the widget should grab focus when it is clicked with the mouse.
120    ///
121    /// This property is only relevant for widgets that can take focus.
122    ///
123    /// Readable | Writable
124    ///
125    ///
126    /// #### `focusable`
127    ///  Whether this widget itself will accept the input focus.
128    ///
129    /// Readable | Writable
130    ///
131    ///
132    /// #### `halign`
133    ///  How to distribute horizontal space if widget gets extra space.
134    ///
135    /// Readable | Writable
136    ///
137    ///
138    /// #### `has-default`
139    ///  Whether the widget is the default widget.
140    ///
141    /// Readable
142    ///
143    ///
144    /// #### `has-focus`
145    ///  Whether the widget has the input focus.
146    ///
147    /// Readable
148    ///
149    ///
150    /// #### `has-tooltip`
151    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
152    /// signal on @widget.
153    ///
154    /// A true value indicates that @widget can have a tooltip, in this case
155    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
156    /// determine whether it will provide a tooltip or not.
157    ///
158    /// Readable | Writable
159    ///
160    ///
161    /// #### `height-request`
162    ///  Overrides for height request of the widget.
163    ///
164    /// If this is -1, the natural request will be used.
165    ///
166    /// Readable | Writable
167    ///
168    ///
169    /// #### `hexpand`
170    ///  Whether to expand horizontally.
171    ///
172    /// Readable | Writable
173    ///
174    ///
175    /// #### `hexpand-set`
176    ///  Whether to use the `hexpand` property.
177    ///
178    /// Readable | Writable
179    ///
180    ///
181    /// #### `layout-manager`
182    ///  The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
183    /// the preferred size of the widget, and allocate its children.
184    ///
185    /// This property is meant to be set by widget implementations,
186    /// typically in their instance init function.
187    ///
188    /// Readable | Writable
189    ///
190    ///
191    /// #### `limit-events`
192    ///  Makes this widget act like a modal dialog, with respect to
193    /// event delivery.
194    ///
195    /// Global event controllers will not handle events with targets
196    /// inside the widget, unless they are set up to ignore propagation
197    /// limits. See `Gtk::EventController::set_propagation_limit()`.
198    ///
199    /// Readable | Writable
200    ///
201    ///
202    /// #### `margin-bottom`
203    ///  Margin on bottom side of widget.
204    ///
205    /// This property adds margin outside of the widget's normal size
206    /// request, the margin will be added in addition to the size from
207    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
208    ///
209    /// Readable | Writable
210    ///
211    ///
212    /// #### `margin-end`
213    ///  Margin on end of widget, horizontally.
214    ///
215    /// This property supports left-to-right and right-to-left text
216    /// directions.
217    ///
218    /// This property adds margin outside of the widget's normal size
219    /// request, the margin will be added in addition to the size from
220    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
221    ///
222    /// Readable | Writable
223    ///
224    ///
225    /// #### `margin-start`
226    ///  Margin on start of widget, horizontally.
227    ///
228    /// This property supports left-to-right and right-to-left text
229    /// directions.
230    ///
231    /// This property adds margin outside of the widget's normal size
232    /// request, the margin will be added in addition to the size from
233    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
234    ///
235    /// Readable | Writable
236    ///
237    ///
238    /// #### `margin-top`
239    ///  Margin on top side of widget.
240    ///
241    /// This property adds margin outside of the widget's normal size
242    /// request, the margin will be added in addition to the size from
243    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
244    ///
245    /// Readable | Writable
246    ///
247    ///
248    /// #### `name`
249    ///  The name of the widget.
250    ///
251    /// Readable | Writable
252    ///
253    ///
254    /// #### `opacity`
255    ///  The requested opacity of the widget.
256    ///
257    /// Readable | Writable
258    ///
259    ///
260    /// #### `overflow`
261    ///  How content outside the widget's content area is treated.
262    ///
263    /// This property is meant to be set by widget implementations,
264    /// typically in their instance init function.
265    ///
266    /// Readable | Writable
267    ///
268    ///
269    /// #### `parent`
270    ///  The parent widget of this widget.
271    ///
272    /// Readable
273    ///
274    ///
275    /// #### `receives-default`
276    ///  Whether the widget will receive the default action when it is focused.
277    ///
278    /// Readable | Writable
279    ///
280    ///
281    /// #### `root`
282    ///  The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
283    ///
284    /// This will be `NULL` if the widget is not contained in a root widget.
285    ///
286    /// Readable
287    ///
288    ///
289    /// #### `scale-factor`
290    ///  The scale factor of the widget.
291    ///
292    /// Readable
293    ///
294    ///
295    /// #### `sensitive`
296    ///  Whether the widget responds to input.
297    ///
298    /// Readable | Writable
299    ///
300    ///
301    /// #### `tooltip-markup`
302    ///  Sets the text of tooltip to be the given string, which is marked up
303    /// with Pango markup.
304    ///
305    /// Also see `Gtk::Tooltip::set_markup()`.
306    ///
307    /// This is a convenience property which will take care of getting the
308    /// tooltip shown if the given string is not `NULL`:
309    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
310    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
311    /// the default signal handler.
312    ///
313    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
314    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
315    ///
316    /// Readable | Writable
317    ///
318    ///
319    /// #### `tooltip-text`
320    ///  Sets the text of tooltip to be the given string.
321    ///
322    /// Also see `Gtk::Tooltip::set_text()`.
323    ///
324    /// This is a convenience property which will take care of getting the
325    /// tooltip shown if the given string is not `NULL`:
326    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
327    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
328    /// the default signal handler.
329    ///
330    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
331    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
332    ///
333    /// Readable | Writable
334    ///
335    ///
336    /// #### `valign`
337    ///  How to distribute vertical space if widget gets extra space.
338    ///
339    /// Readable | Writable
340    ///
341    ///
342    /// #### `vexpand`
343    ///  Whether to expand vertically.
344    ///
345    /// Readable | Writable
346    ///
347    ///
348    /// #### `vexpand-set`
349    ///  Whether to use the `vexpand` property.
350    ///
351    /// Readable | Writable
352    ///
353    ///
354    /// #### `visible`
355    ///  Whether the widget is visible.
356    ///
357    /// Readable | Writable
358    ///
359    ///
360    /// #### `width-request`
361    ///  Overrides for width request of the widget.
362    ///
363    /// If this is -1, the natural request will be used.
364    ///
365    /// Readable | Writable
366    /// </details>
367    /// <details><summary><h4>Accessible</h4></summary>
368    ///
369    ///
370    /// #### `accessible-role`
371    ///  The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
372    ///
373    /// The accessible role cannot be changed once set.
374    ///
375    /// Readable | Writable
376    /// </details>
377    ///
378    /// # Implements
379    ///
380    /// [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`]
381    #[doc(alias = "AdwButtonContent")]
382    pub struct ButtonContent(Object<ffi::AdwButtonContent, ffi::AdwButtonContentClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
383
384    match fn {
385        type_ => || ffi::adw_button_content_get_type(),
386    }
387}
388
389#[cfg(not(feature = "gtk_v4_10"))]
390glib::wrapper! {
391    #[doc(alias = "AdwButtonContent")]
392    pub struct ButtonContent(Object<ffi::AdwButtonContent, ffi::AdwButtonContentClass>) @extends gtk::Widget, @implements gtk::Buildable, gtk::ConstraintTarget;
393
394    match fn {
395        type_ => || ffi::adw_button_content_get_type(),
396    }
397}
398
399impl ButtonContent {
400    /// Creates a new [`ButtonContent`][crate::ButtonContent].
401    ///
402    /// # Returns
403    ///
404    /// the new created [`ButtonContent`][crate::ButtonContent]
405    #[doc(alias = "adw_button_content_new")]
406    pub fn new() -> ButtonContent {
407        assert_initialized_main_thread!();
408        unsafe { gtk::Widget::from_glib_none(ffi::adw_button_content_new()).unsafe_cast() }
409    }
410
411    // rustdoc-stripper-ignore-next
412    /// Creates a new builder-pattern struct instance to construct [`ButtonContent`] objects.
413    ///
414    /// This method returns an instance of [`ButtonContentBuilder`](crate::builders::ButtonContentBuilder) which can be used to create [`ButtonContent`] objects.
415    pub fn builder() -> ButtonContentBuilder {
416        ButtonContentBuilder::new()
417    }
418
419    /// gets whether the button can be smaller than the natural size of its contents.
420    ///
421    /// # Returns
422    ///
423    /// whether the button can shrink
424    #[cfg(feature = "v1_4")]
425    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
426    #[doc(alias = "adw_button_content_get_can_shrink")]
427    #[doc(alias = "get_can_shrink")]
428    #[doc(alias = "can-shrink")]
429    pub fn can_shrink(&self) -> bool {
430        unsafe {
431            from_glib(ffi::adw_button_content_get_can_shrink(
432                self.to_glib_none().0,
433            ))
434        }
435    }
436
437    /// Gets the name of the displayed icon.
438    ///
439    /// # Returns
440    ///
441    /// the icon name
442    #[doc(alias = "adw_button_content_get_icon_name")]
443    #[doc(alias = "get_icon_name")]
444    #[doc(alias = "icon-name")]
445    pub fn icon_name(&self) -> glib::GString {
446        unsafe { from_glib_none(ffi::adw_button_content_get_icon_name(self.to_glib_none().0)) }
447    }
448
449    /// Gets the displayed label.
450    ///
451    /// # Returns
452    ///
453    /// the label
454    #[doc(alias = "adw_button_content_get_label")]
455    #[doc(alias = "get_label")]
456    pub fn label(&self) -> glib::GString {
457        unsafe { from_glib_none(ffi::adw_button_content_get_label(self.to_glib_none().0)) }
458    }
459
460    /// Gets whether an underline in the text indicates a mnemonic.
461    ///
462    /// # Returns
463    ///
464    /// whether an underline in the text indicates a mnemonic
465    #[doc(alias = "adw_button_content_get_use_underline")]
466    #[doc(alias = "get_use_underline")]
467    #[doc(alias = "use-underline")]
468    pub fn uses_underline(&self) -> bool {
469        unsafe {
470            from_glib(ffi::adw_button_content_get_use_underline(
471                self.to_glib_none().0,
472            ))
473        }
474    }
475
476    /// Sets whether the button can be smaller than the natural size of its contents.
477    ///
478    /// If set to `TRUE`, the label will ellipsize.
479    ///
480    /// See `Gtk::Button::set_can_shrink()`.
481    /// ## `can_shrink`
482    /// whether the button can shrink
483    #[cfg(feature = "v1_4")]
484    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
485    #[doc(alias = "adw_button_content_set_can_shrink")]
486    #[doc(alias = "can-shrink")]
487    pub fn set_can_shrink(&self, can_shrink: bool) {
488        unsafe {
489            ffi::adw_button_content_set_can_shrink(self.to_glib_none().0, can_shrink.into_glib());
490        }
491    }
492
493    /// Sets the name of the displayed icon.
494    ///
495    /// If empty, the icon is not shown.
496    /// ## `icon_name`
497    /// the new icon name
498    #[doc(alias = "adw_button_content_set_icon_name")]
499    #[doc(alias = "icon-name")]
500    pub fn set_icon_name(&self, icon_name: &str) {
501        unsafe {
502            ffi::adw_button_content_set_icon_name(
503                self.to_glib_none().0,
504                icon_name.to_glib_none().0,
505            );
506        }
507    }
508
509    /// Sets the displayed label.
510    /// ## `label`
511    /// the new label
512    #[doc(alias = "adw_button_content_set_label")]
513    #[doc(alias = "label")]
514    pub fn set_label(&self, label: &str) {
515        unsafe {
516            ffi::adw_button_content_set_label(self.to_glib_none().0, label.to_glib_none().0);
517        }
518    }
519
520    /// Sets whether an underline in the text indicates a mnemonic.
521    ///
522    /// The mnemonic can be used to activate the parent button.
523    ///
524    /// See [`label`][struct@crate::ButtonContent#label].
525    /// ## `use_underline`
526    /// whether an underline in the text indicates a mnemonic
527    #[doc(alias = "adw_button_content_set_use_underline")]
528    #[doc(alias = "use-underline")]
529    pub fn set_use_underline(&self, use_underline: bool) {
530        unsafe {
531            ffi::adw_button_content_set_use_underline(
532                self.to_glib_none().0,
533                use_underline.into_glib(),
534            );
535        }
536    }
537
538    #[cfg(feature = "v1_4")]
539    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
540    #[doc(alias = "can-shrink")]
541    pub fn connect_can_shrink_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
542        unsafe extern "C" fn notify_can_shrink_trampoline<F: Fn(&ButtonContent) + 'static>(
543            this: *mut ffi::AdwButtonContent,
544            _param_spec: glib::ffi::gpointer,
545            f: glib::ffi::gpointer,
546        ) {
547            unsafe {
548                let f: &F = &*(f as *const F);
549                f(&from_glib_borrow(this))
550            }
551        }
552        unsafe {
553            let f: Box_<F> = Box_::new(f);
554            connect_raw(
555                self.as_ptr() as *mut _,
556                c"notify::can-shrink".as_ptr(),
557                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
558                    notify_can_shrink_trampoline::<F> as *const (),
559                )),
560                Box_::into_raw(f),
561            )
562        }
563    }
564
565    #[doc(alias = "icon-name")]
566    pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
567        unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&ButtonContent) + 'static>(
568            this: *mut ffi::AdwButtonContent,
569            _param_spec: glib::ffi::gpointer,
570            f: glib::ffi::gpointer,
571        ) {
572            unsafe {
573                let f: &F = &*(f as *const F);
574                f(&from_glib_borrow(this))
575            }
576        }
577        unsafe {
578            let f: Box_<F> = Box_::new(f);
579            connect_raw(
580                self.as_ptr() as *mut _,
581                c"notify::icon-name".as_ptr(),
582                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
583                    notify_icon_name_trampoline::<F> as *const (),
584                )),
585                Box_::into_raw(f),
586            )
587        }
588    }
589
590    #[doc(alias = "label")]
591    pub fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
592        unsafe extern "C" fn notify_label_trampoline<F: Fn(&ButtonContent) + 'static>(
593            this: *mut ffi::AdwButtonContent,
594            _param_spec: glib::ffi::gpointer,
595            f: glib::ffi::gpointer,
596        ) {
597            unsafe {
598                let f: &F = &*(f as *const F);
599                f(&from_glib_borrow(this))
600            }
601        }
602        unsafe {
603            let f: Box_<F> = Box_::new(f);
604            connect_raw(
605                self.as_ptr() as *mut _,
606                c"notify::label".as_ptr(),
607                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
608                    notify_label_trampoline::<F> as *const (),
609                )),
610                Box_::into_raw(f),
611            )
612        }
613    }
614
615    #[doc(alias = "use-underline")]
616    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
617        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&ButtonContent) + 'static>(
618            this: *mut ffi::AdwButtonContent,
619            _param_spec: glib::ffi::gpointer,
620            f: glib::ffi::gpointer,
621        ) {
622            unsafe {
623                let f: &F = &*(f as *const F);
624                f(&from_glib_borrow(this))
625            }
626        }
627        unsafe {
628            let f: Box_<F> = Box_::new(f);
629            connect_raw(
630                self.as_ptr() as *mut _,
631                c"notify::use-underline".as_ptr(),
632                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
633                    notify_use_underline_trampoline::<F> as *const (),
634                )),
635                Box_::into_raw(f),
636            )
637        }
638    }
639}
640
641impl Default for ButtonContent {
642    fn default() -> Self {
643        Self::new()
644    }
645}
646
647// rustdoc-stripper-ignore-next
648/// A [builder-pattern] type to construct [`ButtonContent`] objects.
649///
650/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
651#[must_use = "The builder must be built to be used"]
652pub struct ButtonContentBuilder {
653    builder: glib::object::ObjectBuilder<'static, ButtonContent>,
654}
655
656impl ButtonContentBuilder {
657    fn new() -> Self {
658        Self {
659            builder: glib::object::Object::builder(),
660        }
661    }
662
663    /// Whether the button can be smaller than the natural size of its contents.
664    ///
665    /// If set to `TRUE`, the label will ellipsize.
666    ///
667    /// See [`can-shrink`][struct@crate::Gtk::Button#can-shrink].
668    #[cfg(feature = "v1_4")]
669    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
670    pub fn can_shrink(self, can_shrink: bool) -> Self {
671        Self {
672            builder: self.builder.property("can-shrink", can_shrink),
673        }
674    }
675
676    /// The name of the displayed icon.
677    ///
678    /// If empty, the icon is not shown.
679    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
680        Self {
681            builder: self.builder.property("icon-name", icon_name.into()),
682        }
683    }
684
685    /// The displayed label.
686    pub fn label(self, label: impl Into<glib::GString>) -> Self {
687        Self {
688            builder: self.builder.property("label", label.into()),
689        }
690    }
691
692    /// Whether an underline in the text indicates a mnemonic.
693    ///
694    /// The mnemonic can be used to activate the parent button.
695    ///
696    /// See [`label`][struct@crate::ButtonContent#label].
697    pub fn use_underline(self, use_underline: bool) -> Self {
698        Self {
699            builder: self.builder.property("use-underline", use_underline),
700        }
701    }
702
703    /// Whether the widget or any of its descendents can accept
704    /// the input focus.
705    ///
706    /// This property is meant to be set by widget implementations,
707    /// typically in their instance init function.
708    pub fn can_focus(self, can_focus: bool) -> Self {
709        Self {
710            builder: self.builder.property("can-focus", can_focus),
711        }
712    }
713
714    /// Whether the widget can receive pointer events.
715    pub fn can_target(self, can_target: bool) -> Self {
716        Self {
717            builder: self.builder.property("can-target", can_target),
718        }
719    }
720
721    /// A list of css classes applied to this widget.
722    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
723        Self {
724            builder: self.builder.property("css-classes", css_classes.into()),
725        }
726    }
727
728    /// The name of this widget in the CSS tree.
729    ///
730    /// This property is meant to be set by widget implementations,
731    /// typically in their instance init function.
732    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
733        Self {
734            builder: self.builder.property("css-name", css_name.into()),
735        }
736    }
737
738    /// The cursor used by @widget.
739    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
740        Self {
741            builder: self.builder.property("cursor", cursor.clone()),
742        }
743    }
744
745    /// Whether the widget should grab focus when it is clicked with the mouse.
746    ///
747    /// This property is only relevant for widgets that can take focus.
748    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
749        Self {
750            builder: self.builder.property("focus-on-click", focus_on_click),
751        }
752    }
753
754    /// Whether this widget itself will accept the input focus.
755    pub fn focusable(self, focusable: bool) -> Self {
756        Self {
757            builder: self.builder.property("focusable", focusable),
758        }
759    }
760
761    /// How to distribute horizontal space if widget gets extra space.
762    pub fn halign(self, halign: gtk::Align) -> Self {
763        Self {
764            builder: self.builder.property("halign", halign),
765        }
766    }
767
768    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
769    /// signal on @widget.
770    ///
771    /// A true value indicates that @widget can have a tooltip, in this case
772    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
773    /// determine whether it will provide a tooltip or not.
774    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
775        Self {
776            builder: self.builder.property("has-tooltip", has_tooltip),
777        }
778    }
779
780    /// Overrides for height request of the widget.
781    ///
782    /// If this is -1, the natural request will be used.
783    pub fn height_request(self, height_request: i32) -> Self {
784        Self {
785            builder: self.builder.property("height-request", height_request),
786        }
787    }
788
789    /// Whether to expand horizontally.
790    pub fn hexpand(self, hexpand: bool) -> Self {
791        Self {
792            builder: self.builder.property("hexpand", hexpand),
793        }
794    }
795
796    /// Whether to use the `hexpand` property.
797    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
798        Self {
799            builder: self.builder.property("hexpand-set", hexpand_set),
800        }
801    }
802
803    /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
804    /// the preferred size of the widget, and allocate its children.
805    ///
806    /// This property is meant to be set by widget implementations,
807    /// typically in their instance init function.
808    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
809        Self {
810            builder: self
811                .builder
812                .property("layout-manager", layout_manager.clone().upcast()),
813        }
814    }
815
816    /// Makes this widget act like a modal dialog, with respect to
817    /// event delivery.
818    ///
819    /// Global event controllers will not handle events with targets
820    /// inside the widget, unless they are set up to ignore propagation
821    /// limits. See `Gtk::EventController::set_propagation_limit()`.
822    #[cfg(feature = "gtk_v4_18")]
823    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
824    pub fn limit_events(self, limit_events: bool) -> Self {
825        Self {
826            builder: self.builder.property("limit-events", limit_events),
827        }
828    }
829
830    /// Margin on bottom side of widget.
831    ///
832    /// This property adds margin outside of the widget's normal size
833    /// request, the margin will be added in addition to the size from
834    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
835    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
836        Self {
837            builder: self.builder.property("margin-bottom", margin_bottom),
838        }
839    }
840
841    /// Margin on end of widget, horizontally.
842    ///
843    /// This property supports left-to-right and right-to-left text
844    /// directions.
845    ///
846    /// This property adds margin outside of the widget's normal size
847    /// request, the margin will be added in addition to the size from
848    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
849    pub fn margin_end(self, margin_end: i32) -> Self {
850        Self {
851            builder: self.builder.property("margin-end", margin_end),
852        }
853    }
854
855    /// Margin on start of widget, horizontally.
856    ///
857    /// This property supports left-to-right and right-to-left text
858    /// directions.
859    ///
860    /// This property adds margin outside of the widget's normal size
861    /// request, the margin will be added in addition to the size from
862    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
863    pub fn margin_start(self, margin_start: i32) -> Self {
864        Self {
865            builder: self.builder.property("margin-start", margin_start),
866        }
867    }
868
869    /// Margin on top side of widget.
870    ///
871    /// This property adds margin outside of the widget's normal size
872    /// request, the margin will be added in addition to the size from
873    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
874    pub fn margin_top(self, margin_top: i32) -> Self {
875        Self {
876            builder: self.builder.property("margin-top", margin_top),
877        }
878    }
879
880    /// The name of the widget.
881    pub fn name(self, name: impl Into<glib::GString>) -> Self {
882        Self {
883            builder: self.builder.property("name", name.into()),
884        }
885    }
886
887    /// The requested opacity of the widget.
888    pub fn opacity(self, opacity: f64) -> Self {
889        Self {
890            builder: self.builder.property("opacity", opacity),
891        }
892    }
893
894    /// How content outside the widget's content area is treated.
895    ///
896    /// This property is meant to be set by widget implementations,
897    /// typically in their instance init function.
898    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
899        Self {
900            builder: self.builder.property("overflow", overflow),
901        }
902    }
903
904    /// Whether the widget will receive the default action when it is focused.
905    pub fn receives_default(self, receives_default: bool) -> Self {
906        Self {
907            builder: self.builder.property("receives-default", receives_default),
908        }
909    }
910
911    /// Whether the widget responds to input.
912    pub fn sensitive(self, sensitive: bool) -> Self {
913        Self {
914            builder: self.builder.property("sensitive", sensitive),
915        }
916    }
917
918    /// Sets the text of tooltip to be the given string, which is marked up
919    /// with Pango markup.
920    ///
921    /// Also see `Gtk::Tooltip::set_markup()`.
922    ///
923    /// This is a convenience property which will take care of getting the
924    /// tooltip shown if the given string is not `NULL`:
925    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
926    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
927    /// the default signal handler.
928    ///
929    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
930    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
931    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
932        Self {
933            builder: self
934                .builder
935                .property("tooltip-markup", tooltip_markup.into()),
936        }
937    }
938
939    /// Sets the text of tooltip to be the given string.
940    ///
941    /// Also see `Gtk::Tooltip::set_text()`.
942    ///
943    /// This is a convenience property which will take care of getting the
944    /// tooltip shown if the given string is not `NULL`:
945    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
946    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
947    /// the default signal handler.
948    ///
949    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
950    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
951    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
952        Self {
953            builder: self.builder.property("tooltip-text", tooltip_text.into()),
954        }
955    }
956
957    /// How to distribute vertical space if widget gets extra space.
958    pub fn valign(self, valign: gtk::Align) -> Self {
959        Self {
960            builder: self.builder.property("valign", valign),
961        }
962    }
963
964    /// Whether to expand vertically.
965    pub fn vexpand(self, vexpand: bool) -> Self {
966        Self {
967            builder: self.builder.property("vexpand", vexpand),
968        }
969    }
970
971    /// Whether to use the `vexpand` property.
972    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
973        Self {
974            builder: self.builder.property("vexpand-set", vexpand_set),
975        }
976    }
977
978    /// Whether the widget is visible.
979    pub fn visible(self, visible: bool) -> Self {
980        Self {
981            builder: self.builder.property("visible", visible),
982        }
983    }
984
985    /// Overrides for width request of the widget.
986    ///
987    /// If this is -1, the natural request will be used.
988    pub fn width_request(self, width_request: i32) -> Self {
989        Self {
990            builder: self.builder.property("width-request", width_request),
991        }
992    }
993
994    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
995    ///
996    /// The accessible role cannot be changed once set.
997    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
998        Self {
999            builder: self.builder.property("accessible-role", accessible_role),
1000        }
1001    }
1002
1003    // rustdoc-stripper-ignore-next
1004    /// Build the [`ButtonContent`].
1005    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1006    pub fn build(self) -> ButtonContent {
1007        assert_initialized_main_thread!();
1008        self.builder.build()
1009    }
1010}