Skip to main content

gtk4/auto/
button.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9    AccessibleRole, Actionable, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
10    Widget, ffi,
11};
12use glib::{
13    object::ObjectType as _,
14    prelude::*,
15    signal::{SignalHandlerId, connect_raw},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20#[cfg(feature = "v4_10")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
22glib::wrapper! {
23    ///
24    ///
25    /// The [`Button`][crate::Button] widget can hold any valid child widget. That is, it can hold
26    /// almost any other standard [`Widget`][crate::Widget]. The most commonly used child is the
27    /// [`Label`][crate::Label].
28    ///
29    /// # Shortcuts and Gestures
30    ///
31    /// The following signals have default keybindings:
32    ///
33    /// - [`activate`][struct@crate::Button#activate]
34    ///
35    /// # CSS nodes
36    ///
37    /// [`Button`][crate::Button] has a single CSS node with name button. The node will get the
38    /// style classes .image-button or .text-button, if the content is just an
39    /// image or label, respectively. It may also receive the .flat style class.
40    /// When activating a button via the keyboard, the button will temporarily
41    /// gain the .keyboard-activating style class.
42    ///
43    /// Other style classes that are commonly used with [`Button`][crate::Button] include
44    /// .suggested-action and .destructive-action. In special cases, buttons
45    /// can be made round by adding the .circular style class.
46    ///
47    /// Button-like widgets like [`ToggleButton`][crate::ToggleButton], [`MenuButton`][crate::MenuButton],
48    /// [`VolumeButton`][crate::VolumeButton], [`LockButton`][crate::LockButton], [`ColorButton`][crate::ColorButton]
49    /// or [`FontButton`][crate::FontButton] use style classes such as .toggle, .popup, .scale,
50    /// .lock, .color on the button node to differentiate themselves from a plain
51    /// [`Button`][crate::Button].
52    ///
53    /// # Accessibility
54    ///
55    /// [`Button`][crate::Button] uses the [enum@Gtk.AccessibleRole.button] role.
56    ///
57    /// ## Properties
58    ///
59    ///
60    /// #### `can-shrink`
61    ///  Whether the size of the button can be made smaller than the natural
62    /// size of its contents.
63    ///
64    /// For text buttons, setting this property will allow ellipsizing the label.
65    ///
66    /// If the contents of a button are an icon or a custom widget, setting this
67    /// property has no effect.
68    ///
69    /// Readable | Writable
70    ///
71    ///
72    /// #### `child`
73    ///  The child widget.
74    ///
75    /// Readable | Writable
76    ///
77    ///
78    /// #### `has-frame`
79    ///  Whether the button has a frame.
80    ///
81    /// Readable | Writable
82    ///
83    ///
84    /// #### `icon-name`
85    ///  The name of the icon used to automatically populate the button.
86    ///
87    /// Readable | Writable
88    ///
89    ///
90    /// #### `label`
91    ///  Text of the label inside the button, if the button contains a label widget.
92    ///
93    /// Readable | Writable
94    ///
95    ///
96    /// #### `use-underline`
97    ///  If set, an underline in the text indicates that the following character is
98    /// to be used as mnemonic.
99    ///
100    /// Readable | Writable
101    /// <details><summary><h4>Widget</h4></summary>
102    ///
103    ///
104    /// #### `can-focus`
105    ///  Whether the widget or any of its descendents can accept
106    /// the input focus.
107    ///
108    /// This property is meant to be set by widget implementations,
109    /// typically in their instance init function.
110    ///
111    /// Readable | Writable
112    ///
113    ///
114    /// #### `can-target`
115    ///  Whether the widget can receive pointer events.
116    ///
117    /// Readable | Writable
118    ///
119    ///
120    /// #### `css-classes`
121    ///  A list of css classes applied to this widget.
122    ///
123    /// Readable | Writable
124    ///
125    ///
126    /// #### `css-name`
127    ///  The name of this widget in the CSS tree.
128    ///
129    /// This property is meant to be set by widget implementations,
130    /// typically in their instance init function.
131    ///
132    /// Readable | Writable | Construct Only
133    ///
134    ///
135    /// #### `cursor`
136    ///  The cursor used by @widget.
137    ///
138    /// Readable | Writable
139    ///
140    ///
141    /// #### `focus-on-click`
142    ///  Whether the widget should grab focus when it is clicked with the mouse.
143    ///
144    /// This property is only relevant for widgets that can take focus.
145    ///
146    /// Readable | Writable
147    ///
148    ///
149    /// #### `focusable`
150    ///  Whether this widget itself will accept the input focus.
151    ///
152    /// Readable | Writable
153    ///
154    ///
155    /// #### `halign`
156    ///  How to distribute horizontal space if widget gets extra space.
157    ///
158    /// Readable | Writable
159    ///
160    ///
161    /// #### `has-default`
162    ///  Whether the widget is the default widget.
163    ///
164    /// Readable
165    ///
166    ///
167    /// #### `has-focus`
168    ///  Whether the widget has the input focus.
169    ///
170    /// Readable
171    ///
172    ///
173    /// #### `has-tooltip`
174    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
175    /// signal on @widget.
176    ///
177    /// A true value indicates that @widget can have a tooltip, in this case
178    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
179    /// determine whether it will provide a tooltip or not.
180    ///
181    /// Readable | Writable
182    ///
183    ///
184    /// #### `height-request`
185    ///  Overrides for height request of the widget.
186    ///
187    /// If this is -1, the natural request will be used.
188    ///
189    /// Readable | Writable
190    ///
191    ///
192    /// #### `hexpand`
193    ///  Whether to expand horizontally.
194    ///
195    /// Readable | Writable
196    ///
197    ///
198    /// #### `hexpand-set`
199    ///  Whether to use the `hexpand` property.
200    ///
201    /// Readable | Writable
202    ///
203    ///
204    /// #### `layout-manager`
205    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
206    /// the preferred size of the widget, and allocate its children.
207    ///
208    /// This property is meant to be set by widget implementations,
209    /// typically in their instance init function.
210    ///
211    /// Readable | Writable
212    ///
213    ///
214    /// #### `limit-events`
215    ///  Makes this widget act like a modal dialog, with respect to
216    /// event delivery.
217    ///
218    /// Global event controllers will not handle events with targets
219    /// inside the widget, unless they are set up to ignore propagation
220    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
221    ///
222    /// Readable | Writable
223    ///
224    ///
225    /// #### `margin-bottom`
226    ///  Margin on bottom side of widget.
227    ///
228    /// This property adds margin outside of the widget's normal size
229    /// request, the margin will be added in addition to the size from
230    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
231    ///
232    /// Readable | Writable
233    ///
234    ///
235    /// #### `margin-end`
236    ///  Margin on end of widget, horizontally.
237    ///
238    /// This property supports left-to-right and right-to-left text
239    /// directions.
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    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
244    ///
245    /// Readable | Writable
246    ///
247    ///
248    /// #### `margin-start`
249    ///  Margin on start of widget, horizontally.
250    ///
251    /// This property supports left-to-right and right-to-left text
252    /// directions.
253    ///
254    /// This property adds margin outside of the widget's normal size
255    /// request, the margin will be added in addition to the size from
256    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
257    ///
258    /// Readable | Writable
259    ///
260    ///
261    /// #### `margin-top`
262    ///  Margin on top side of widget.
263    ///
264    /// This property adds margin outside of the widget's normal size
265    /// request, the margin will be added in addition to the size from
266    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
267    ///
268    /// Readable | Writable
269    ///
270    ///
271    /// #### `name`
272    ///  The name of the widget.
273    ///
274    /// Readable | Writable
275    ///
276    ///
277    /// #### `opacity`
278    ///  The requested opacity of the widget.
279    ///
280    /// Readable | Writable
281    ///
282    ///
283    /// #### `overflow`
284    ///  How content outside the widget's content area is treated.
285    ///
286    /// This property is meant to be set by widget implementations,
287    /// typically in their instance init function.
288    ///
289    /// Readable | Writable
290    ///
291    ///
292    /// #### `parent`
293    ///  The parent widget of this widget.
294    ///
295    /// Readable
296    ///
297    ///
298    /// #### `receives-default`
299    ///  Whether the widget will receive the default action when it is focused.
300    ///
301    /// Readable | Writable
302    ///
303    ///
304    /// #### `root`
305    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
306    ///
307    /// This will be `NULL` if the widget is not contained in a root widget.
308    ///
309    /// Readable
310    ///
311    ///
312    /// #### `scale-factor`
313    ///  The scale factor of the widget.
314    ///
315    /// Readable
316    ///
317    ///
318    /// #### `sensitive`
319    ///  Whether the widget responds to input.
320    ///
321    /// Readable | Writable
322    ///
323    ///
324    /// #### `tooltip-markup`
325    ///  Sets the text of tooltip to be the given string, which is marked up
326    /// with Pango markup.
327    ///
328    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
329    ///
330    /// This is a convenience property which will take care of getting the
331    /// tooltip shown if the given string is not `NULL`:
332    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
333    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
334    /// the default signal handler.
335    ///
336    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
337    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
338    ///
339    /// Readable | Writable
340    ///
341    ///
342    /// #### `tooltip-text`
343    ///  Sets the text of tooltip to be the given string.
344    ///
345    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
346    ///
347    /// This is a convenience property which will take care of getting the
348    /// tooltip shown if the given string is not `NULL`:
349    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
350    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
351    /// the default signal handler.
352    ///
353    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
354    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
355    ///
356    /// Readable | Writable
357    ///
358    ///
359    /// #### `valign`
360    ///  How to distribute vertical space if widget gets extra space.
361    ///
362    /// Readable | Writable
363    ///
364    ///
365    /// #### `vexpand`
366    ///  Whether to expand vertically.
367    ///
368    /// Readable | Writable
369    ///
370    ///
371    /// #### `vexpand-set`
372    ///  Whether to use the `vexpand` property.
373    ///
374    /// Readable | Writable
375    ///
376    ///
377    /// #### `visible`
378    ///  Whether the widget is visible.
379    ///
380    /// Readable | Writable
381    ///
382    ///
383    /// #### `width-request`
384    ///  Overrides for width request of the widget.
385    ///
386    /// If this is -1, the natural request will be used.
387    ///
388    /// Readable | Writable
389    /// </details>
390    /// <details><summary><h4>Accessible</h4></summary>
391    ///
392    ///
393    /// #### `accessible-role`
394    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
395    ///
396    /// The accessible role cannot be changed once set.
397    ///
398    /// Readable | Writable
399    /// </details>
400    /// <details><summary><h4>Actionable</h4></summary>
401    ///
402    ///
403    /// #### `action-name`
404    ///  The name of the action with which this widget should be associated.
405    ///
406    /// Readable | Writable
407    ///
408    ///
409    /// #### `action-target`
410    ///  The target value of the actionable widget's action.
411    ///
412    /// Readable | Writable
413    /// </details>
414    ///
415    /// ## Signals
416    ///
417    ///
418    /// #### `activate`
419    ///   keys.
420    ///
421    /// Action
422    ///
423    ///
424    /// #### `clicked`
425    ///  Emitted when the button has been activated (pressed and released).
426    ///
427    /// Action
428    /// <details><summary><h4>Widget</h4></summary>
429    ///
430    ///
431    /// #### `destroy`
432    ///  Signals that all holders of a reference to the widget should release
433    /// the reference that they hold.
434    ///
435    /// May result in finalization of the widget if all references are released.
436    ///
437    /// This signal is not suitable for saving widget state.
438    ///
439    ///
440    ///
441    ///
442    /// #### `direction-changed`
443    ///  Emitted when the text direction of a widget changes.
444    ///
445    ///
446    ///
447    ///
448    /// #### `hide`
449    ///  Emitted when @widget is hidden.
450    ///
451    ///
452    ///
453    ///
454    /// #### `keynav-failed`
455    ///  Emitted if keyboard navigation fails.
456    ///
457    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
458    ///
459    ///
460    ///
461    ///
462    /// #### `map`
463    ///  Emitted when @widget is going to be mapped.
464    ///
465    /// A widget is mapped when the widget is visible (which is controlled with
466    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
467    /// are also visible.
468    ///
469    /// The `::map` signal can be used to determine whether a widget will be drawn,
470    /// for instance it can resume an animation that was stopped during the
471    /// emission of [`unmap`][struct@crate::Widget#unmap].
472    ///
473    ///
474    ///
475    ///
476    /// #### `mnemonic-activate`
477    ///  Emitted when a widget is activated via a mnemonic.
478    ///
479    /// The default handler for this signal activates @widget if @group_cycling
480    /// is false, or just makes @widget grab focus if @group_cycling is true.
481    ///
482    ///
483    ///
484    ///
485    /// #### `move-focus`
486    ///   to move backward.
487    ///
488    /// Action
489    ///
490    ///
491    /// #### `query-tooltip`
492    ///  Emitted when the widget’s tooltip is about to be shown.
493    ///
494    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
495    /// is true and the hover timeout has expired with the cursor hovering
496    /// above @widget; or emitted when @widget got focus in keyboard mode.
497    ///
498    /// Using the given coordinates, the signal handler should determine
499    /// whether a tooltip should be shown for @widget. If this is the case
500    /// true should be returned, false otherwise. Note that if @keyboard_mode
501    /// is true, the values of @x and @y are undefined and should not be used.
502    ///
503    /// The signal handler is free to manipulate @tooltip with the therefore
504    /// destined function calls.
505    ///
506    ///
507    ///
508    ///
509    /// #### `realize`
510    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
511    ///
512    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
513    /// or the widget has been mapped (that is, it is going to be drawn).
514    ///
515    ///
516    ///
517    ///
518    /// #### `show`
519    ///  Emitted when @widget is shown.
520    ///
521    ///
522    ///
523    ///
524    /// #### `state-flags-changed`
525    ///  Emitted when the widget state changes.
526    ///
527    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
528    ///
529    ///
530    ///
531    ///
532    /// #### `unmap`
533    ///  Emitted when @widget is going to be unmapped.
534    ///
535    /// A widget is unmapped when either it or any of its parents up to the
536    /// toplevel widget have been set as hidden.
537    ///
538    /// As `::unmap` indicates that a widget will not be shown any longer,
539    /// it can be used to, for example, stop an animation on the widget.
540    ///
541    ///
542    ///
543    ///
544    /// #### `unrealize`
545    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
546    ///
547    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
548    /// or the widget has been unmapped (that is, it is going to be hidden).
549    ///
550    ///
551    /// </details>
552    ///
553    /// # Implements
554    ///
555    /// [`ButtonExt`][trait@crate::prelude::ButtonExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`ActionableExtManual`][trait@crate::prelude::ActionableExtManual]
556    #[doc(alias = "GtkButton")]
557    pub struct Button(Object<ffi::GtkButton, ffi::GtkButtonClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Actionable;
558
559    match fn {
560        type_ => || ffi::gtk_button_get_type(),
561    }
562}
563
564#[cfg(not(feature = "v4_10"))]
565glib::wrapper! {
566    #[doc(alias = "GtkButton")]
567    pub struct Button(Object<ffi::GtkButton, ffi::GtkButtonClass>) @extends Widget, @implements Buildable, ConstraintTarget, Actionable;
568
569    match fn {
570        type_ => || ffi::gtk_button_get_type(),
571    }
572}
573
574impl Button {
575    pub const NONE: Option<&'static Button> = None;
576
577    /// Creates a new [`Button`][crate::Button] widget.
578    ///
579    /// To add a child widget to the button, use [`ButtonExt::set_child()`][crate::prelude::ButtonExt::set_child()].
580    ///
581    /// # Returns
582    ///
583    /// The newly created [`Button`][crate::Button] widget.
584    #[doc(alias = "gtk_button_new")]
585    pub fn new() -> Button {
586        assert_initialized_main_thread!();
587        unsafe { Widget::from_glib_none(ffi::gtk_button_new()).unsafe_cast() }
588    }
589
590    /// Creates a new button containing an icon from the current icon theme.
591    ///
592    /// If the icon name isn’t known, a “broken image” icon will be
593    /// displayed instead. If the current icon theme is changed, the icon
594    /// will be updated appropriately.
595    /// ## `icon_name`
596    /// an icon name
597    ///
598    /// # Returns
599    ///
600    /// a new [`Button`][crate::Button] displaying the themed icon
601    #[doc(alias = "gtk_button_new_from_icon_name")]
602    #[doc(alias = "new_from_icon_name")]
603    pub fn from_icon_name(icon_name: &str) -> Button {
604        assert_initialized_main_thread!();
605        unsafe {
606            Widget::from_glib_none(ffi::gtk_button_new_from_icon_name(
607                icon_name.to_glib_none().0,
608            ))
609            .unsafe_cast()
610        }
611    }
612
613    /// Creates a [`Button`][crate::Button] widget with a [`Label`][crate::Label] child.
614    /// ## `label`
615    /// The text you want the [`Label`][crate::Label] to hold
616    ///
617    /// # Returns
618    ///
619    /// The newly created [`Button`][crate::Button] widget
620    #[doc(alias = "gtk_button_new_with_label")]
621    #[doc(alias = "new_with_label")]
622    pub fn with_label(label: &str) -> Button {
623        assert_initialized_main_thread!();
624        unsafe {
625            Widget::from_glib_none(ffi::gtk_button_new_with_label(label.to_glib_none().0))
626                .unsafe_cast()
627        }
628    }
629
630    ///  and that key
631    /// activates the button.
632    /// ## `label`
633    /// The text of the button, with an underscore in front of the
634    ///   mnemonic character
635    ///
636    /// # Returns
637    ///
638    /// a new [`Button`][crate::Button]
639    #[doc(alias = "gtk_button_new_with_mnemonic")]
640    #[doc(alias = "new_with_mnemonic")]
641    pub fn with_mnemonic(label: &str) -> Button {
642        assert_initialized_main_thread!();
643        unsafe {
644            Widget::from_glib_none(ffi::gtk_button_new_with_mnemonic(label.to_glib_none().0))
645                .unsafe_cast()
646        }
647    }
648
649    // rustdoc-stripper-ignore-next
650    /// Creates a new builder-pattern struct instance to construct [`Button`] objects.
651    ///
652    /// This method returns an instance of [`ButtonBuilder`](crate::builders::ButtonBuilder) which can be used to create [`Button`] objects.
653    pub fn builder() -> ButtonBuilder {
654        ButtonBuilder::new()
655    }
656}
657
658impl Default for Button {
659    fn default() -> Self {
660        Self::new()
661    }
662}
663
664// rustdoc-stripper-ignore-next
665/// A [builder-pattern] type to construct [`Button`] objects.
666///
667/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
668#[must_use = "The builder must be built to be used"]
669pub struct ButtonBuilder {
670    builder: glib::object::ObjectBuilder<'static, Button>,
671}
672
673impl ButtonBuilder {
674    fn new() -> Self {
675        Self {
676            builder: glib::object::Object::builder(),
677        }
678    }
679
680    /// Whether the size of the button can be made smaller than the natural
681    /// size of its contents.
682    ///
683    /// For text buttons, setting this property will allow ellipsizing the label.
684    ///
685    /// If the contents of a button are an icon or a custom widget, setting this
686    /// property has no effect.
687    #[cfg(feature = "v4_12")]
688    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
689    pub fn can_shrink(self, can_shrink: bool) -> Self {
690        Self {
691            builder: self.builder.property("can-shrink", can_shrink),
692        }
693    }
694
695    /// The child widget.
696    pub fn child(self, child: &impl IsA<Widget>) -> Self {
697        Self {
698            builder: self.builder.property("child", child.clone().upcast()),
699        }
700    }
701
702    /// Whether the button has a frame.
703    pub fn has_frame(self, has_frame: bool) -> Self {
704        Self {
705            builder: self.builder.property("has-frame", has_frame),
706        }
707    }
708
709    /// The name of the icon used to automatically populate the button.
710    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
711        Self {
712            builder: self.builder.property("icon-name", icon_name.into()),
713        }
714    }
715
716    /// Text of the label inside the button, if the button contains a label widget.
717    pub fn label(self, label: impl Into<glib::GString>) -> Self {
718        Self {
719            builder: self.builder.property("label", label.into()),
720        }
721    }
722
723    /// If set, an underline in the text indicates that the following character is
724    /// to be used as mnemonic.
725    pub fn use_underline(self, use_underline: bool) -> Self {
726        Self {
727            builder: self.builder.property("use-underline", use_underline),
728        }
729    }
730
731    /// Whether the widget or any of its descendents can accept
732    /// the input focus.
733    ///
734    /// This property is meant to be set by widget implementations,
735    /// typically in their instance init function.
736    pub fn can_focus(self, can_focus: bool) -> Self {
737        Self {
738            builder: self.builder.property("can-focus", can_focus),
739        }
740    }
741
742    /// Whether the widget can receive pointer events.
743    pub fn can_target(self, can_target: bool) -> Self {
744        Self {
745            builder: self.builder.property("can-target", can_target),
746        }
747    }
748
749    /// A list of css classes applied to this widget.
750    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
751        Self {
752            builder: self.builder.property("css-classes", css_classes.into()),
753        }
754    }
755
756    /// The name of this widget in the CSS tree.
757    ///
758    /// This property is meant to be set by widget implementations,
759    /// typically in their instance init function.
760    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
761        Self {
762            builder: self.builder.property("css-name", css_name.into()),
763        }
764    }
765
766    /// The cursor used by @widget.
767    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
768        Self {
769            builder: self.builder.property("cursor", cursor.clone()),
770        }
771    }
772
773    /// Whether the widget should grab focus when it is clicked with the mouse.
774    ///
775    /// This property is only relevant for widgets that can take focus.
776    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
777        Self {
778            builder: self.builder.property("focus-on-click", focus_on_click),
779        }
780    }
781
782    /// Whether this widget itself will accept the input focus.
783    pub fn focusable(self, focusable: bool) -> Self {
784        Self {
785            builder: self.builder.property("focusable", focusable),
786        }
787    }
788
789    /// How to distribute horizontal space if widget gets extra space.
790    pub fn halign(self, halign: Align) -> Self {
791        Self {
792            builder: self.builder.property("halign", halign),
793        }
794    }
795
796    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
797    /// signal on @widget.
798    ///
799    /// A true value indicates that @widget can have a tooltip, in this case
800    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
801    /// determine whether it will provide a tooltip or not.
802    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
803        Self {
804            builder: self.builder.property("has-tooltip", has_tooltip),
805        }
806    }
807
808    /// Overrides for height request of the widget.
809    ///
810    /// If this is -1, the natural request will be used.
811    pub fn height_request(self, height_request: i32) -> Self {
812        Self {
813            builder: self.builder.property("height-request", height_request),
814        }
815    }
816
817    /// Whether to expand horizontally.
818    pub fn hexpand(self, hexpand: bool) -> Self {
819        Self {
820            builder: self.builder.property("hexpand", hexpand),
821        }
822    }
823
824    /// Whether to use the `hexpand` property.
825    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
826        Self {
827            builder: self.builder.property("hexpand-set", hexpand_set),
828        }
829    }
830
831    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
832    /// the preferred size of the widget, and allocate its children.
833    ///
834    /// This property is meant to be set by widget implementations,
835    /// typically in their instance init function.
836    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
837        Self {
838            builder: self
839                .builder
840                .property("layout-manager", layout_manager.clone().upcast()),
841        }
842    }
843
844    /// Makes this widget act like a modal dialog, with respect to
845    /// event delivery.
846    ///
847    /// Global event controllers will not handle events with targets
848    /// inside the widget, unless they are set up to ignore propagation
849    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
850    #[cfg(feature = "v4_18")]
851    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
852    pub fn limit_events(self, limit_events: bool) -> Self {
853        Self {
854            builder: self.builder.property("limit-events", limit_events),
855        }
856    }
857
858    /// Margin on bottom side of widget.
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    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
863    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
864        Self {
865            builder: self.builder.property("margin-bottom", margin_bottom),
866        }
867    }
868
869    /// Margin on end of widget, horizontally.
870    ///
871    /// This property supports left-to-right and right-to-left text
872    /// directions.
873    ///
874    /// This property adds margin outside of the widget's normal size
875    /// request, the margin will be added in addition to the size from
876    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
877    pub fn margin_end(self, margin_end: i32) -> Self {
878        Self {
879            builder: self.builder.property("margin-end", margin_end),
880        }
881    }
882
883    /// Margin on start of widget, horizontally.
884    ///
885    /// This property supports left-to-right and right-to-left text
886    /// directions.
887    ///
888    /// This property adds margin outside of the widget's normal size
889    /// request, the margin will be added in addition to the size from
890    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
891    pub fn margin_start(self, margin_start: i32) -> Self {
892        Self {
893            builder: self.builder.property("margin-start", margin_start),
894        }
895    }
896
897    /// Margin on top side of widget.
898    ///
899    /// This property adds margin outside of the widget's normal size
900    /// request, the margin will be added in addition to the size from
901    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
902    pub fn margin_top(self, margin_top: i32) -> Self {
903        Self {
904            builder: self.builder.property("margin-top", margin_top),
905        }
906    }
907
908    /// The name of the widget.
909    pub fn name(self, name: impl Into<glib::GString>) -> Self {
910        Self {
911            builder: self.builder.property("name", name.into()),
912        }
913    }
914
915    /// The requested opacity of the widget.
916    pub fn opacity(self, opacity: f64) -> Self {
917        Self {
918            builder: self.builder.property("opacity", opacity),
919        }
920    }
921
922    /// How content outside the widget's content area is treated.
923    ///
924    /// This property is meant to be set by widget implementations,
925    /// typically in their instance init function.
926    pub fn overflow(self, overflow: Overflow) -> Self {
927        Self {
928            builder: self.builder.property("overflow", overflow),
929        }
930    }
931
932    /// Whether the widget will receive the default action when it is focused.
933    pub fn receives_default(self, receives_default: bool) -> Self {
934        Self {
935            builder: self.builder.property("receives-default", receives_default),
936        }
937    }
938
939    /// Whether the widget responds to input.
940    pub fn sensitive(self, sensitive: bool) -> Self {
941        Self {
942            builder: self.builder.property("sensitive", sensitive),
943        }
944    }
945
946    /// Sets the text of tooltip to be the given string, which is marked up
947    /// with Pango markup.
948    ///
949    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
950    ///
951    /// This is a convenience property which will take care of getting the
952    /// tooltip shown if the given string is not `NULL`:
953    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
954    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
955    /// the default signal handler.
956    ///
957    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
958    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
959    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
960        Self {
961            builder: self
962                .builder
963                .property("tooltip-markup", tooltip_markup.into()),
964        }
965    }
966
967    /// Sets the text of tooltip to be the given string.
968    ///
969    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
970    ///
971    /// This is a convenience property which will take care of getting the
972    /// tooltip shown if the given string is not `NULL`:
973    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
974    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
975    /// the default signal handler.
976    ///
977    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
978    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
979    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
980        Self {
981            builder: self.builder.property("tooltip-text", tooltip_text.into()),
982        }
983    }
984
985    /// How to distribute vertical space if widget gets extra space.
986    pub fn valign(self, valign: Align) -> Self {
987        Self {
988            builder: self.builder.property("valign", valign),
989        }
990    }
991
992    /// Whether to expand vertically.
993    pub fn vexpand(self, vexpand: bool) -> Self {
994        Self {
995            builder: self.builder.property("vexpand", vexpand),
996        }
997    }
998
999    /// Whether to use the `vexpand` property.
1000    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1001        Self {
1002            builder: self.builder.property("vexpand-set", vexpand_set),
1003        }
1004    }
1005
1006    /// Whether the widget is visible.
1007    pub fn visible(self, visible: bool) -> Self {
1008        Self {
1009            builder: self.builder.property("visible", visible),
1010        }
1011    }
1012
1013    /// Overrides for width request of the widget.
1014    ///
1015    /// If this is -1, the natural request will be used.
1016    pub fn width_request(self, width_request: i32) -> Self {
1017        Self {
1018            builder: self.builder.property("width-request", width_request),
1019        }
1020    }
1021
1022    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1023    ///
1024    /// The accessible role cannot be changed once set.
1025    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1026        Self {
1027            builder: self.builder.property("accessible-role", accessible_role),
1028        }
1029    }
1030
1031    /// The name of the action with which this widget should be associated.
1032    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1033        Self {
1034            builder: self.builder.property("action-name", action_name.into()),
1035        }
1036    }
1037
1038    /// The target value of the actionable widget's action.
1039    pub fn action_target(self, action_target: &glib::Variant) -> Self {
1040        Self {
1041            builder: self
1042                .builder
1043                .property("action-target", action_target.clone()),
1044        }
1045    }
1046
1047    // rustdoc-stripper-ignore-next
1048    /// Build the [`Button`].
1049    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1050    pub fn build(self) -> Button {
1051        assert_initialized_main_thread!();
1052        self.builder.build()
1053    }
1054}
1055
1056/// Trait containing all [`struct@Button`] methods.
1057///
1058/// # Implementors
1059///
1060/// [`Button`][struct@crate::Button], [`LinkButton`][struct@crate::LinkButton], [`LockButton`][struct@crate::LockButton], [`ToggleButton`][struct@crate::ToggleButton]
1061pub trait ButtonExt: IsA<Button> + 'static {
1062    /// Retrieves whether the button can be smaller than the natural
1063    /// size of its contents.
1064    ///
1065    /// # Returns
1066    ///
1067    /// true if the button can shrink, and false otherwise
1068    #[cfg(feature = "v4_12")]
1069    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1070    #[doc(alias = "gtk_button_get_can_shrink")]
1071    #[doc(alias = "get_can_shrink")]
1072    #[doc(alias = "can-shrink")]
1073    fn can_shrink(&self) -> bool {
1074        unsafe {
1075            from_glib(ffi::gtk_button_get_can_shrink(
1076                self.as_ref().to_glib_none().0,
1077            ))
1078        }
1079    }
1080
1081    /// Gets the child widget of @self.
1082    ///
1083    /// # Returns
1084    ///
1085    /// the child widget of @self
1086    #[doc(alias = "gtk_button_get_child")]
1087    #[doc(alias = "get_child")]
1088    fn child(&self) -> Option<Widget> {
1089        unsafe { from_glib_none(ffi::gtk_button_get_child(self.as_ref().to_glib_none().0)) }
1090    }
1091
1092    /// Returns whether the button has a frame.
1093    ///
1094    /// # Returns
1095    ///
1096    /// [`true`] if the button has a frame
1097    #[doc(alias = "gtk_button_get_has_frame")]
1098    #[doc(alias = "get_has_frame")]
1099    #[doc(alias = "has-frame")]
1100    fn has_frame(&self) -> bool {
1101        unsafe {
1102            from_glib(ffi::gtk_button_get_has_frame(
1103                self.as_ref().to_glib_none().0,
1104            ))
1105        }
1106    }
1107
1108    /// Returns the icon name of the button.
1109    ///
1110    /// If the icon name has not been set with [`set_icon_name()`][Self::set_icon_name()]
1111    /// the return value will be [`None`]. This will be the case if you create
1112    /// an empty button with [`Button::new()`][crate::Button::new()] to use as a container.
1113    ///
1114    /// # Returns
1115    ///
1116    /// The icon name set via [`set_icon_name()`][Self::set_icon_name()]
1117    #[doc(alias = "gtk_button_get_icon_name")]
1118    #[doc(alias = "get_icon_name")]
1119    #[doc(alias = "icon-name")]
1120    fn icon_name(&self) -> Option<glib::GString> {
1121        unsafe {
1122            from_glib_none(ffi::gtk_button_get_icon_name(
1123                self.as_ref().to_glib_none().0,
1124            ))
1125        }
1126    }
1127
1128    /// Fetches the text from the label of the button.
1129    ///
1130    /// If the label text has not been set with [`set_label()`][Self::set_label()]
1131    /// the return value will be [`None`]. This will be the case if you create
1132    /// an empty button with [`Button::new()`][crate::Button::new()] to use as a container.
1133    ///
1134    /// # Returns
1135    ///
1136    /// The text of the label widget. This string is owned
1137    /// by the widget and must not be modified or freed.
1138    #[doc(alias = "gtk_button_get_label")]
1139    #[doc(alias = "get_label")]
1140    fn label(&self) -> Option<glib::GString> {
1141        unsafe { from_glib_none(ffi::gtk_button_get_label(self.as_ref().to_glib_none().0)) }
1142    }
1143
1144    /// gets whether underlines are interpreted as mnemonics.
1145    ///
1146    /// See [`set_use_underline()`][Self::set_use_underline()].
1147    ///
1148    /// # Returns
1149    ///
1150    /// [`true`] if an embedded underline in the button label
1151    ///   indicates the mnemonic accelerator keys.
1152    #[doc(alias = "gtk_button_get_use_underline")]
1153    #[doc(alias = "get_use_underline")]
1154    #[doc(alias = "use-underline")]
1155    fn uses_underline(&self) -> bool {
1156        unsafe {
1157            from_glib(ffi::gtk_button_get_use_underline(
1158                self.as_ref().to_glib_none().0,
1159            ))
1160        }
1161    }
1162
1163    /// Sets whether the button size can be smaller than the natural size of
1164    /// its contents.
1165    ///
1166    /// For text buttons, setting @can_shrink to true will ellipsize the label.
1167    ///
1168    /// For icons and custom children, this function has no effect.
1169    /// ## `can_shrink`
1170    /// whether the button can shrink
1171    #[cfg(feature = "v4_12")]
1172    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1173    #[doc(alias = "gtk_button_set_can_shrink")]
1174    #[doc(alias = "can-shrink")]
1175    fn set_can_shrink(&self, can_shrink: bool) {
1176        unsafe {
1177            ffi::gtk_button_set_can_shrink(self.as_ref().to_glib_none().0, can_shrink.into_glib());
1178        }
1179    }
1180
1181    /// Sets the child widget of @self.
1182    ///
1183    /// Note that by using this API, you take full responsibility for setting
1184    /// up the proper accessibility label and description information for @self.
1185    /// Most likely, you'll either set the accessibility label or description
1186    /// for @self explicitly, or you'll set a labelled-by or described-by
1187    /// relations from @child to @self.
1188    /// ## `child`
1189    /// the child widget
1190    #[doc(alias = "gtk_button_set_child")]
1191    #[doc(alias = "child")]
1192    fn set_child(&self, child: Option<&impl IsA<Widget>>) {
1193        unsafe {
1194            ffi::gtk_button_set_child(
1195                self.as_ref().to_glib_none().0,
1196                child.map(|p| p.as_ref()).to_glib_none().0,
1197            );
1198        }
1199    }
1200
1201    /// Sets the style of the button.
1202    ///
1203    /// Buttons can have a flat appearance or have a frame drawn around them.
1204    /// ## `has_frame`
1205    /// whether the button should have a visible frame
1206    #[doc(alias = "gtk_button_set_has_frame")]
1207    #[doc(alias = "has-frame")]
1208    fn set_has_frame(&self, has_frame: bool) {
1209        unsafe {
1210            ffi::gtk_button_set_has_frame(self.as_ref().to_glib_none().0, has_frame.into_glib());
1211        }
1212    }
1213
1214    /// Adds a [`Image`][crate::Image] with the given icon name as a child.
1215    ///
1216    /// If @self already contains a child widget, that child widget will
1217    /// be removed and replaced with the image.
1218    /// ## `icon_name`
1219    /// An icon name
1220    #[doc(alias = "gtk_button_set_icon_name")]
1221    #[doc(alias = "icon-name")]
1222    fn set_icon_name(&self, icon_name: &str) {
1223        unsafe {
1224            ffi::gtk_button_set_icon_name(
1225                self.as_ref().to_glib_none().0,
1226                icon_name.to_glib_none().0,
1227            );
1228        }
1229    }
1230
1231    /// Sets the text of the label of the button to @label.
1232    ///
1233    /// This will also clear any previously set labels.
1234    /// ## `label`
1235    /// a string
1236    #[doc(alias = "gtk_button_set_label")]
1237    #[doc(alias = "label")]
1238    fn set_label(&self, label: &str) {
1239        unsafe {
1240            ffi::gtk_button_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0);
1241        }
1242    }
1243
1244    /// Sets whether to use underlines as mnemonics.
1245    ///
1246    /// If true, an underline in the text of the button label indicates
1247    /// the next character should be used for the mnemonic accelerator key.
1248    /// ## `use_underline`
1249    /// [`true`] if underlines in the text indicate mnemonics
1250    #[doc(alias = "gtk_button_set_use_underline")]
1251    #[doc(alias = "use-underline")]
1252    fn set_use_underline(&self, use_underline: bool) {
1253        unsafe {
1254            ffi::gtk_button_set_use_underline(
1255                self.as_ref().to_glib_none().0,
1256                use_underline.into_glib(),
1257            );
1258        }
1259    }
1260
1261    ///  keys.
1262    #[doc(alias = "activate")]
1263    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1264        unsafe extern "C" fn activate_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1265            this: *mut ffi::GtkButton,
1266            f: glib::ffi::gpointer,
1267        ) {
1268            unsafe {
1269                let f: &F = &*(f as *const F);
1270                f(Button::from_glib_borrow(this).unsafe_cast_ref())
1271            }
1272        }
1273        unsafe {
1274            let f: Box_<F> = Box_::new(f);
1275            connect_raw(
1276                self.as_ptr() as *mut _,
1277                c"activate".as_ptr(),
1278                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1279                    activate_trampoline::<Self, F> as *const (),
1280                )),
1281                Box_::into_raw(f),
1282            )
1283        }
1284    }
1285
1286    fn emit_activate(&self) {
1287        self.emit_by_name::<()>("activate", &[]);
1288    }
1289
1290    /// Emitted when the button has been activated (pressed and released).
1291    #[doc(alias = "clicked")]
1292    fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1293        unsafe extern "C" fn clicked_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1294            this: *mut ffi::GtkButton,
1295            f: glib::ffi::gpointer,
1296        ) {
1297            unsafe {
1298                let f: &F = &*(f as *const F);
1299                f(Button::from_glib_borrow(this).unsafe_cast_ref())
1300            }
1301        }
1302        unsafe {
1303            let f: Box_<F> = Box_::new(f);
1304            connect_raw(
1305                self.as_ptr() as *mut _,
1306                c"clicked".as_ptr(),
1307                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1308                    clicked_trampoline::<Self, F> as *const (),
1309                )),
1310                Box_::into_raw(f),
1311            )
1312        }
1313    }
1314
1315    fn emit_clicked(&self) {
1316        self.emit_by_name::<()>("clicked", &[]);
1317    }
1318
1319    #[cfg(feature = "v4_12")]
1320    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1321    #[doc(alias = "can-shrink")]
1322    fn connect_can_shrink_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1323        unsafe extern "C" fn notify_can_shrink_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1324            this: *mut ffi::GtkButton,
1325            _param_spec: glib::ffi::gpointer,
1326            f: glib::ffi::gpointer,
1327        ) {
1328            unsafe {
1329                let f: &F = &*(f as *const F);
1330                f(Button::from_glib_borrow(this).unsafe_cast_ref())
1331            }
1332        }
1333        unsafe {
1334            let f: Box_<F> = Box_::new(f);
1335            connect_raw(
1336                self.as_ptr() as *mut _,
1337                c"notify::can-shrink".as_ptr(),
1338                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1339                    notify_can_shrink_trampoline::<Self, F> as *const (),
1340                )),
1341                Box_::into_raw(f),
1342            )
1343        }
1344    }
1345
1346    #[doc(alias = "child")]
1347    fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1348        unsafe extern "C" fn notify_child_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1349            this: *mut ffi::GtkButton,
1350            _param_spec: glib::ffi::gpointer,
1351            f: glib::ffi::gpointer,
1352        ) {
1353            unsafe {
1354                let f: &F = &*(f as *const F);
1355                f(Button::from_glib_borrow(this).unsafe_cast_ref())
1356            }
1357        }
1358        unsafe {
1359            let f: Box_<F> = Box_::new(f);
1360            connect_raw(
1361                self.as_ptr() as *mut _,
1362                c"notify::child".as_ptr(),
1363                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1364                    notify_child_trampoline::<Self, F> as *const (),
1365                )),
1366                Box_::into_raw(f),
1367            )
1368        }
1369    }
1370
1371    #[doc(alias = "has-frame")]
1372    fn connect_has_frame_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1373        unsafe extern "C" fn notify_has_frame_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1374            this: *mut ffi::GtkButton,
1375            _param_spec: glib::ffi::gpointer,
1376            f: glib::ffi::gpointer,
1377        ) {
1378            unsafe {
1379                let f: &F = &*(f as *const F);
1380                f(Button::from_glib_borrow(this).unsafe_cast_ref())
1381            }
1382        }
1383        unsafe {
1384            let f: Box_<F> = Box_::new(f);
1385            connect_raw(
1386                self.as_ptr() as *mut _,
1387                c"notify::has-frame".as_ptr(),
1388                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1389                    notify_has_frame_trampoline::<Self, F> as *const (),
1390                )),
1391                Box_::into_raw(f),
1392            )
1393        }
1394    }
1395
1396    #[doc(alias = "icon-name")]
1397    fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1398        unsafe extern "C" fn notify_icon_name_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1399            this: *mut ffi::GtkButton,
1400            _param_spec: glib::ffi::gpointer,
1401            f: glib::ffi::gpointer,
1402        ) {
1403            unsafe {
1404                let f: &F = &*(f as *const F);
1405                f(Button::from_glib_borrow(this).unsafe_cast_ref())
1406            }
1407        }
1408        unsafe {
1409            let f: Box_<F> = Box_::new(f);
1410            connect_raw(
1411                self.as_ptr() as *mut _,
1412                c"notify::icon-name".as_ptr(),
1413                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1414                    notify_icon_name_trampoline::<Self, F> as *const (),
1415                )),
1416                Box_::into_raw(f),
1417            )
1418        }
1419    }
1420
1421    #[doc(alias = "label")]
1422    fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1423        unsafe extern "C" fn notify_label_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1424            this: *mut ffi::GtkButton,
1425            _param_spec: glib::ffi::gpointer,
1426            f: glib::ffi::gpointer,
1427        ) {
1428            unsafe {
1429                let f: &F = &*(f as *const F);
1430                f(Button::from_glib_borrow(this).unsafe_cast_ref())
1431            }
1432        }
1433        unsafe {
1434            let f: Box_<F> = Box_::new(f);
1435            connect_raw(
1436                self.as_ptr() as *mut _,
1437                c"notify::label".as_ptr(),
1438                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1439                    notify_label_trampoline::<Self, F> as *const (),
1440                )),
1441                Box_::into_raw(f),
1442            )
1443        }
1444    }
1445
1446    #[doc(alias = "use-underline")]
1447    fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1448        unsafe extern "C" fn notify_use_underline_trampoline<
1449            P: IsA<Button>,
1450            F: Fn(&P) + 'static,
1451        >(
1452            this: *mut ffi::GtkButton,
1453            _param_spec: glib::ffi::gpointer,
1454            f: glib::ffi::gpointer,
1455        ) {
1456            unsafe {
1457                let f: &F = &*(f as *const F);
1458                f(Button::from_glib_borrow(this).unsafe_cast_ref())
1459            }
1460        }
1461        unsafe {
1462            let f: Box_<F> = Box_::new(f);
1463            connect_raw(
1464                self.as_ptr() as *mut _,
1465                c"notify::use-underline".as_ptr(),
1466                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1467                    notify_use_underline_trampoline::<Self, F> as *const (),
1468                )),
1469                Box_::into_raw(f),
1470            )
1471        }
1472    }
1473}
1474
1475impl<O: IsA<Button>> ButtonExt for O {}