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