gtk/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 Actionable, Align, Bin, Buildable, Container, IconSize, PositionType, ReliefStyle, ResizeMode,
7 Widget, ffi,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
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. The various signals and how to use them
20 /// are outlined below.
21 ///
22 /// The [`Button`][crate::Button] widget can hold any valid child widget. That is, it can hold
23 /// almost any other standard [`Widget`][crate::Widget]. The most commonly used child is the
24 /// [`Label`][crate::Label].
25 ///
26 /// # CSS nodes
27 ///
28 /// GtkButton has a single CSS node with name button. The node will get the
29 /// style classes .image-button or .text-button, if the content is just an
30 /// image or label, respectively. It may also receive the .flat style class.
31 ///
32 /// Other style classes that are commonly used with GtkButton include
33 /// .suggested-action and .destructive-action. In special cases, buttons
34 /// can be made round by adding the .circular style class.
35 ///
36 /// Button-like widgets like [`ToggleButton`][crate::ToggleButton], [`MenuButton`][crate::MenuButton], [`VolumeButton`][crate::VolumeButton],
37 /// [`LockButton`][crate::LockButton], [`ColorButton`][crate::ColorButton], [`FontButton`][crate::FontButton] or [`FileChooserButton`][crate::FileChooserButton] use
38 /// style classes such as .toggle, .popup, .scale, .lock, .color, .font, .file
39 /// to differentiate themselves from a plain GtkButton.
40 ///
41 /// ## Properties
42 ///
43 ///
44 /// #### `always-show-image`
45 /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
46 /// setting and always show the image, if available.
47 ///
48 /// Use this property if the button would be useless or hard to use
49 /// without the image.
50 ///
51 /// Readable | Writable | Construct
52 ///
53 ///
54 /// #### `image`
55 /// The child widget to appear next to the button text.
56 ///
57 /// Readable | Writable
58 ///
59 ///
60 /// #### `image-position`
61 /// The position of the image relative to the text inside the button.
62 ///
63 /// Readable | Writable
64 ///
65 ///
66 /// #### `label`
67 /// Readable | Writable | Construct
68 ///
69 ///
70 /// #### `relief`
71 /// Readable | Writable
72 ///
73 ///
74 /// #### `use-stock`
75 /// Readable | Writable | Construct
76 ///
77 ///
78 /// #### `use-underline`
79 /// Readable | Writable | Construct
80 ///
81 ///
82 /// #### `xalign`
83 /// If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
84 /// can be used to control its horizontal alignment. 0.0 is left aligned,
85 /// 1.0 is right aligned.
86 ///
87 /// Readable | Writable
88 ///
89 ///
90 /// #### `yalign`
91 /// If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
92 /// can be used to control its vertical alignment. 0.0 is top aligned,
93 /// 1.0 is bottom aligned.
94 ///
95 /// Readable | Writable
96 /// <details><summary><h4>Container</h4></summary>
97 ///
98 ///
99 /// #### `border-width`
100 /// Readable | Writable
101 ///
102 ///
103 /// #### `child`
104 /// Writable
105 ///
106 ///
107 /// #### `resize-mode`
108 /// Readable | Writable
109 /// </details>
110 /// <details><summary><h4>Widget</h4></summary>
111 ///
112 ///
113 /// #### `app-paintable`
114 /// Readable | Writable
115 ///
116 ///
117 /// #### `can-default`
118 /// Readable | Writable
119 ///
120 ///
121 /// #### `can-focus`
122 /// Readable | Writable
123 ///
124 ///
125 /// #### `composite-child`
126 /// Readable
127 ///
128 ///
129 /// #### `double-buffered`
130 /// Whether the widget is double buffered.
131 ///
132 /// Readable | Writable
133 ///
134 ///
135 /// #### `events`
136 /// Readable | Writable
137 ///
138 ///
139 /// #### `expand`
140 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
141 ///
142 /// Readable | Writable
143 ///
144 ///
145 /// #### `focus-on-click`
146 /// Whether the widget should grab focus when it is clicked with the mouse.
147 ///
148 /// This property is only relevant for widgets that can take focus.
149 ///
150 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
151 /// GtkComboBox) implemented this property individually.
152 ///
153 /// Readable | Writable
154 ///
155 ///
156 /// #### `halign`
157 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
158 ///
159 /// Readable | Writable
160 ///
161 ///
162 /// #### `has-default`
163 /// Readable | Writable
164 ///
165 ///
166 /// #### `has-focus`
167 /// Readable | Writable
168 ///
169 ///
170 /// #### `has-tooltip`
171 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
172 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
173 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
174 /// whether it will provide a tooltip or not.
175 ///
176 /// Note that setting this property to [`true`] for the first time will change
177 /// the event masks of the GdkWindows of this widget to include leave-notify
178 /// and motion-notify events. This cannot and will not be undone when the
179 /// property is set to [`false`] again.
180 ///
181 /// Readable | Writable
182 ///
183 ///
184 /// #### `height-request`
185 /// Readable | Writable
186 ///
187 ///
188 /// #### `hexpand`
189 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
190 ///
191 /// Readable | Writable
192 ///
193 ///
194 /// #### `hexpand-set`
195 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
196 ///
197 /// Readable | Writable
198 ///
199 ///
200 /// #### `is-focus`
201 /// Readable | Writable
202 ///
203 ///
204 /// #### `margin`
205 /// Sets all four sides' margin at once. If read, returns max
206 /// margin on any side.
207 ///
208 /// Readable | Writable
209 ///
210 ///
211 /// #### `margin-bottom`
212 /// Margin on bottom side of widget.
213 ///
214 /// This property adds margin outside of the widget's normal size
215 /// request, the margin will be added in addition to the size from
216 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
217 ///
218 /// Readable | Writable
219 ///
220 ///
221 /// #### `margin-end`
222 /// Margin on end of widget, horizontally. This property supports
223 /// left-to-right and right-to-left text directions.
224 ///
225 /// This property adds margin outside of the widget's normal size
226 /// request, the margin will be added in addition to the size from
227 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
228 ///
229 /// Readable | Writable
230 ///
231 ///
232 /// #### `margin-left`
233 /// Margin on left side of widget.
234 ///
235 /// This property adds margin outside of the widget's normal size
236 /// request, the margin will be added in addition to the size from
237 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
238 ///
239 /// Readable | Writable
240 ///
241 ///
242 /// #### `margin-right`
243 /// Margin on right side of widget.
244 ///
245 /// This property adds margin outside of the widget's normal size
246 /// request, the margin will be added in addition to the size from
247 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
248 ///
249 /// Readable | Writable
250 ///
251 ///
252 /// #### `margin-start`
253 /// Margin on start of widget, horizontally. This property supports
254 /// left-to-right and right-to-left text directions.
255 ///
256 /// This property adds margin outside of the widget's normal size
257 /// request, the margin will be added in addition to the size from
258 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
259 ///
260 /// Readable | Writable
261 ///
262 ///
263 /// #### `margin-top`
264 /// Margin on top side of widget.
265 ///
266 /// This property adds margin outside of the widget's normal size
267 /// request, the margin will be added in addition to the size from
268 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
269 ///
270 /// Readable | Writable
271 ///
272 ///
273 /// #### `name`
274 /// Readable | Writable
275 ///
276 ///
277 /// #### `no-show-all`
278 /// Readable | Writable
279 ///
280 ///
281 /// #### `opacity`
282 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
283 /// more details about window opacity.
284 ///
285 /// Before 3.8 this was only available in GtkWindow
286 ///
287 /// Readable | Writable
288 ///
289 ///
290 /// #### `parent`
291 /// Readable | Writable
292 ///
293 ///
294 /// #### `receives-default`
295 /// Readable | Writable
296 ///
297 ///
298 /// #### `scale-factor`
299 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
300 /// more details about widget scaling.
301 ///
302 /// Readable
303 ///
304 ///
305 /// #### `sensitive`
306 /// Readable | Writable
307 ///
308 ///
309 /// #### `style`
310 /// The style of the widget, which contains information about how it will look (colors, etc).
311 ///
312 /// Readable | Writable
313 ///
314 ///
315 /// #### `tooltip-markup`
316 /// Sets the text of tooltip to be the given string, which is marked up
317 /// with the [Pango text markup language][PangoMarkupFormat].
318 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
319 ///
320 /// This is a convenience property which will take care of getting the
321 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
322 /// will automatically be set to [`true`] and there will be taken care of
323 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
324 ///
325 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
326 /// are set, the last one wins.
327 ///
328 /// Readable | Writable
329 ///
330 ///
331 /// #### `tooltip-text`
332 /// Sets the text of tooltip to be the given string.
333 ///
334 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
335 ///
336 /// This is a convenience property which will take care of getting the
337 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
338 /// will automatically be set to [`true`] and there will be taken care of
339 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
340 ///
341 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
342 /// are set, the last one wins.
343 ///
344 /// Readable | Writable
345 ///
346 ///
347 /// #### `valign`
348 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
349 ///
350 /// Readable | Writable
351 ///
352 ///
353 /// #### `vexpand`
354 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
355 ///
356 /// Readable | Writable
357 ///
358 ///
359 /// #### `vexpand-set`
360 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
361 ///
362 /// Readable | Writable
363 ///
364 ///
365 /// #### `visible`
366 /// Readable | Writable
367 ///
368 ///
369 /// #### `width-request`
370 /// Readable | Writable
371 ///
372 ///
373 /// #### `window`
374 /// The widget's window if it is realized, [`None`] otherwise.
375 ///
376 /// Readable
377 /// </details>
378 /// <details><summary><h4>Actionable</h4></summary>
379 ///
380 ///
381 /// #### `action-name`
382 /// Readable | Writable
383 ///
384 ///
385 /// #### `action-target`
386 /// Readable | Writable
387 /// </details>
388 /// <details><summary><h4>Activatable</h4></summary>
389 ///
390 ///
391 /// #### `related-action`
392 /// call `gtk_activatable_do_set_related_action()` when it changes.
393 ///
394 /// Readable | Writable
395 ///
396 ///
397 /// #### `use-action-appearance`
398 /// widget when it changes.
399 ///
400 /// Readable | Writable
401 /// </details>
402 ///
403 /// ## Signals
404 ///
405 ///
406 /// #### `activate`
407 /// The ::activate signal on GtkButton is an action signal and
408 /// emitting it causes the button to animate press then release.
409 /// Applications should never connect to this signal, but use the
410 /// [`clicked`][struct@crate::Button#clicked] signal.
411 ///
412 /// Action
413 ///
414 ///
415 /// #### `clicked`
416 /// Emitted when the button has been activated (pressed and released).
417 ///
418 /// Action
419 ///
420 ///
421 /// #### `enter`
422 /// Emitted when the pointer enters the button.
423 ///
424 ///
425 ///
426 ///
427 /// #### `leave`
428 /// Emitted when the pointer leaves the button.
429 ///
430 ///
431 ///
432 ///
433 /// #### `pressed`
434 /// Emitted when the button is pressed.
435 ///
436 ///
437 ///
438 ///
439 /// #### `released`
440 /// Emitted when the button is released.
441 ///
442 ///
443 /// <details><summary><h4>Container</h4></summary>
444 ///
445 ///
446 /// #### `add`
447 ///
448 ///
449 ///
450 /// #### `check-resize`
451 ///
452 ///
453 ///
454 /// #### `remove`
455 ///
456 ///
457 ///
458 /// #### `set-focus-child`
459 ///
460 /// </details>
461 /// <details><summary><h4>Widget</h4></summary>
462 ///
463 ///
464 /// #### `accel-closures-changed`
465 ///
466 ///
467 ///
468 /// #### `button-press-event`
469 /// The ::button-press-event signal will be emitted when a button
470 /// (typically from a mouse) is pressed.
471 ///
472 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
473 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
474 ///
475 /// This signal will be sent to the grab widget if there is one.
476 ///
477 ///
478 ///
479 ///
480 /// #### `button-release-event`
481 /// The ::button-release-event signal will be emitted when a button
482 /// (typically from a mouse) is released.
483 ///
484 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
485 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
486 ///
487 /// This signal will be sent to the grab widget if there is one.
488 ///
489 ///
490 ///
491 ///
492 /// #### `can-activate-accel`
493 /// Determines whether an accelerator that activates the signal
494 /// identified by `signal_id` can currently be activated.
495 /// This signal is present to allow applications and derived
496 /// widgets to override the default [`Widget`][crate::Widget] handling
497 /// for determining whether an accelerator can be activated.
498 ///
499 ///
500 ///
501 ///
502 /// #### `child-notify`
503 /// The ::child-notify signal is emitted for each
504 /// [child property][child-properties] that has
505 /// changed on an object. The signal's detail holds the property name.
506 ///
507 /// Detailed
508 ///
509 ///
510 /// #### `composited-changed`
511 /// The ::composited-changed signal is emitted when the composited
512 /// status of `widgets` screen changes.
513 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
514 ///
515 /// Action
516 ///
517 ///
518 /// #### `configure-event`
519 /// The ::configure-event signal will be emitted when the size, position or
520 /// stacking of the `widget`'s window has changed.
521 ///
522 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
523 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
524 /// automatically for all new windows.
525 ///
526 ///
527 ///
528 ///
529 /// #### `damage-event`
530 /// Emitted when a redirected window belonging to `widget` gets drawn into.
531 /// The region/area members of the event shows what area of the redirected
532 /// drawable was drawn into.
533 ///
534 ///
535 ///
536 ///
537 /// #### `delete-event`
538 /// The ::delete-event signal is emitted if a user requests that
539 /// a toplevel window is closed. The default handler for this signal
540 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
541 /// this signal will cause the window to be hidden instead, so that
542 /// it can later be shown again without reconstructing it.
543 ///
544 ///
545 ///
546 ///
547 /// #### `destroy`
548 /// Signals that all holders of a reference to the widget should release
549 /// the reference that they hold. May result in finalization of the widget
550 /// if all references are released.
551 ///
552 /// This signal is not suitable for saving widget state.
553 ///
554 ///
555 ///
556 ///
557 /// #### `destroy-event`
558 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
559 /// You rarely get this signal, because most widgets disconnect themselves
560 /// from their window before they destroy it, so no widget owns the
561 /// window at destroy time.
562 ///
563 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
564 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
565 /// automatically for all new windows.
566 ///
567 ///
568 ///
569 ///
570 /// #### `direction-changed`
571 /// The ::direction-changed signal is emitted when the text direction
572 /// of a widget changes.
573 ///
574 ///
575 ///
576 ///
577 /// #### `drag-begin`
578 /// The ::drag-begin signal is emitted on the drag source when a drag is
579 /// started. A typical reason to connect to this signal is to set up a
580 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
581 ///
582 /// Note that some widgets set up a drag icon in the default handler of
583 /// this signal, so you may have to use `g_signal_connect_after()` to
584 /// override what the default handler did.
585 ///
586 ///
587 ///
588 ///
589 /// #### `drag-data-delete`
590 /// The ::drag-data-delete signal is emitted on the drag source when a drag
591 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
592 /// handler is responsible for deleting the data that has been dropped. What
593 /// "delete" means depends on the context of the drag operation.
594 ///
595 ///
596 ///
597 ///
598 /// #### `drag-data-get`
599 /// The ::drag-data-get signal is emitted on the drag source when the drop
600 /// site requests the data which is dragged. It is the responsibility of
601 /// the signal handler to fill `data` with the data in the format which
602 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
603 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
604 ///
605 ///
606 ///
607 ///
608 /// #### `drag-data-received`
609 /// format == 8))
610 /// {
611 /// GdkDragAction action;
612 ///
613 /// // handle data here
614 ///
615 /// action = gdk_drag_context_get_selected_action (context);
616 /// if (action == GDK_ACTION_ASK)
617 /// {
618 /// GtkWidget *dialog;
619 /// gint response;
620 ///
621 /// dialog = gtk_message_dialog_new (NULL,
622 /// GTK_DIALOG_MODAL |
623 /// GTK_DIALOG_DESTROY_WITH_PARENT,
624 /// GTK_MESSAGE_INFO,
625 /// GTK_BUTTONS_YES_NO,
626 /// "Move the data ?\n");
627 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
628 /// gtk_widget_destroy (dialog);
629 ///
630 /// if (response == GTK_RESPONSE_YES)
631 /// action = GDK_ACTION_MOVE;
632 /// else
633 /// action = GDK_ACTION_COPY;
634 /// }
635 ///
636 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
637 /// }
638 /// else
639 /// gtk_drag_finish (context, FALSE, FALSE, time);
640 /// }
641 /// ]|
642 ///
643 ///
644 ///
645 ///
646 /// #### `drag-drop`
647 /// The ::drag-drop signal is emitted on the drop site when the user drops
648 /// the data onto the widget. The signal handler must determine whether
649 /// the cursor position is in a drop zone or not. If it is not in a drop
650 /// zone, it returns [`false`] and no further processing is necessary.
651 /// Otherwise, the handler returns [`true`]. In this case, the handler must
652 /// ensure that `gtk_drag_finish()` is called to let the source know that
653 /// the drop is done. The call to `gtk_drag_finish()` can be done either
654 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
655 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
656 /// or more of the supported targets.
657 ///
658 ///
659 ///
660 ///
661 /// #### `drag-end`
662 /// The ::drag-end signal is emitted on the drag source when a drag is
663 /// finished. A typical reason to connect to this signal is to undo
664 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
665 ///
666 ///
667 ///
668 ///
669 /// #### `drag-failed`
670 /// The ::drag-failed signal is emitted on the drag source when a drag has
671 /// failed. The signal handler may hook custom code to handle a failed DnD
672 /// operation based on the type of error, it returns [`true`] is the failure has
673 /// been already handled (not showing the default "drag operation failed"
674 /// animation), otherwise it returns [`false`].
675 ///
676 ///
677 ///
678 ///
679 /// #### `drag-leave`
680 /// The ::drag-leave signal is emitted on the drop site when the cursor
681 /// leaves the widget. A typical reason to connect to this signal is to
682 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
683 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
684 ///
685 ///
686 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
687 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
688 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
689 ///
690 ///
691 ///
692 ///
693 /// #### `drag-motion`
694 /// suggested_action,
695 /// time);
696 /// }
697 /// else
698 /// {
699 /// // accept the drop
700 /// }
701 /// }
702 /// ]|
703 ///
704 ///
705 ///
706 ///
707 /// #### `draw`
708 /// This signal is emitted when a widget is supposed to render itself.
709 /// The `widget`'s top left corner must be painted at the origin of
710 /// the passed in context and be sized to the values returned by
711 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
712 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
713 ///
714 /// Signal handlers connected to this signal can modify the cairo
715 /// context passed as `cr` in any way they like and don't need to
716 /// restore it. The signal emission takes care of calling `cairo_save()`
717 /// before and `cairo_restore()` after invoking the handler.
718 ///
719 /// The signal handler will get a `cr` with a clip region already set to the
720 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
721 /// widgets that want to avoid redrawing themselves completely can get the full
722 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
723 /// get a finer-grained representation of the dirty region with
724 /// `cairo_copy_clip_rectangle_list()`.
725 ///
726 ///
727 ///
728 ///
729 /// #### `enter-notify-event`
730 /// The ::enter-notify-event will be emitted when the pointer enters
731 /// the `widget`'s window.
732 ///
733 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
734 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
735 ///
736 /// This signal will be sent to the grab widget if there is one.
737 ///
738 ///
739 ///
740 ///
741 /// #### `event`
742 /// The GTK+ main loop will emit three signals for each GDK event delivered
743 /// to a widget: one generic ::event signal, another, more specific,
744 /// signal that matches the type of event delivered (e.g.
745 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
746 /// [`event-after`][struct@crate::Widget#event-after] signal.
747 ///
748 ///
749 ///
750 ///
751 /// #### `event-after`
752 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
753 /// the second more specific signal, ::event-after will be emitted
754 /// regardless of the previous two signals handlers return values.
755 ///
756 ///
757 ///
758 ///
759 /// #### `focus`
760 ///
761 ///
762 ///
763 /// #### `focus-in-event`
764 /// The ::focus-in-event signal will be emitted when the keyboard focus
765 /// enters the `widget`'s window.
766 ///
767 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
768 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
769 ///
770 ///
771 ///
772 ///
773 /// #### `focus-out-event`
774 /// The ::focus-out-event signal will be emitted when the keyboard focus
775 /// leaves the `widget`'s window.
776 ///
777 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
778 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
779 ///
780 ///
781 ///
782 ///
783 /// #### `grab-broken-event`
784 /// Emitted when a pointer or keyboard grab on a window belonging
785 /// to `widget` gets broken.
786 ///
787 /// On X11, this happens when the grab window becomes unviewable
788 /// (i.e. it or one of its ancestors is unmapped), or if the same
789 /// application grabs the pointer or keyboard again.
790 ///
791 ///
792 ///
793 ///
794 /// #### `grab-focus`
795 /// Action
796 ///
797 ///
798 /// #### `grab-notify`
799 /// The ::grab-notify signal is emitted when a widget becomes
800 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
801 /// another widget, or when it becomes unshadowed due to a grab
802 /// being removed.
803 ///
804 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
805 /// grab widget in the grab stack of its window group is not
806 /// its ancestor.
807 ///
808 ///
809 ///
810 ///
811 /// #### `hide`
812 /// The ::hide signal is emitted when `widget` is hidden, for example with
813 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
814 ///
815 ///
816 ///
817 ///
818 /// #### `hierarchy-changed`
819 /// The ::hierarchy-changed signal is emitted when the
820 /// anchored state of a widget changes. A widget is
821 /// “anchored” when its toplevel
822 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
823 /// a widget changes from un-anchored to anchored or vice-versa.
824 ///
825 ///
826 ///
827 ///
828 /// #### `key-press-event`
829 /// The ::key-press-event signal is emitted when a key is pressed. The signal
830 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
831 ///
832 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
833 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
834 ///
835 /// This signal will be sent to the grab widget if there is one.
836 ///
837 ///
838 ///
839 ///
840 /// #### `key-release-event`
841 /// The ::key-release-event signal is emitted when a key is released.
842 ///
843 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
844 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
845 ///
846 /// This signal will be sent to the grab widget if there is one.
847 ///
848 ///
849 ///
850 ///
851 /// #### `keynav-failed`
852 /// Gets emitted if keyboard navigation fails.
853 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
854 ///
855 ///
856 ///
857 ///
858 /// #### `leave-notify-event`
859 /// The ::leave-notify-event will be emitted when the pointer leaves
860 /// the `widget`'s window.
861 ///
862 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
863 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
864 ///
865 /// This signal will be sent to the grab widget if there is one.
866 ///
867 ///
868 ///
869 ///
870 /// #### `map`
871 /// The ::map signal is emitted when `widget` is going to be mapped, that is
872 /// when the widget is visible (which is controlled with
873 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
874 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
875 /// be emitted.
876 ///
877 /// The ::map signal can be used to determine whether a widget will be drawn,
878 /// for instance it can resume an animation that was stopped during the
879 /// emission of [`unmap`][struct@crate::Widget#unmap].
880 ///
881 ///
882 ///
883 ///
884 /// #### `map-event`
885 /// The ::map-event signal will be emitted when the `widget`'s window is
886 /// mapped. A window is mapped when it becomes visible on the screen.
887 ///
888 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
889 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
890 /// automatically for all new windows.
891 ///
892 ///
893 ///
894 ///
895 /// #### `mnemonic-activate`
896 /// The default handler for this signal activates `widget` if `group_cycling`
897 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
898 ///
899 ///
900 ///
901 ///
902 /// #### `motion-notify-event`
903 /// The ::motion-notify-event signal is emitted when the pointer moves
904 /// over the widget's [`gdk::Window`][crate::gdk::Window].
905 ///
906 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
907 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
908 ///
909 /// This signal will be sent to the grab widget if there is one.
910 ///
911 ///
912 ///
913 ///
914 /// #### `move-focus`
915 /// Action
916 ///
917 ///
918 /// #### `parent-set`
919 /// The ::parent-set signal is emitted when a new parent
920 /// has been set on a widget.
921 ///
922 ///
923 ///
924 ///
925 /// #### `popup-menu`
926 /// This signal gets emitted whenever a widget should pop up a context
927 /// menu. This usually happens through the standard key binding mechanism;
928 /// by pressing a certain key while a widget is focused, the user can cause
929 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
930 /// a menu with clipboard commands. See the
931 /// [Popup Menu Migration Checklist][checklist-popup-menu]
932 /// for an example of how to use this signal.
933 ///
934 /// Action
935 ///
936 ///
937 /// #### `property-notify-event`
938 /// The ::property-notify-event signal will be emitted when a property on
939 /// the `widget`'s window has been changed or deleted.
940 ///
941 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
942 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
943 ///
944 ///
945 ///
946 ///
947 /// #### `proximity-in-event`
948 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
949 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
950 ///
951 /// This signal will be sent to the grab widget if there is one.
952 ///
953 ///
954 ///
955 ///
956 /// #### `proximity-out-event`
957 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
958 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
959 ///
960 /// This signal will be sent to the grab widget if there is one.
961 ///
962 ///
963 ///
964 ///
965 /// #### `query-tooltip`
966 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
967 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
968 /// focus in keyboard mode.
969 ///
970 /// Using the given coordinates, the signal handler should determine
971 /// whether a tooltip should be shown for `widget`. If this is the case
972 /// [`true`] should be returned, [`false`] otherwise. Note that if
973 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
974 /// should not be used.
975 ///
976 /// The signal handler is free to manipulate `tooltip` with the therefore
977 /// destined function calls.
978 ///
979 ///
980 ///
981 ///
982 /// #### `realize`
983 /// The ::realize signal is emitted when `widget` is associated with a
984 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
985 /// widget has been mapped (that is, it is going to be drawn).
986 ///
987 ///
988 ///
989 ///
990 /// #### `screen-changed`
991 /// The ::screen-changed signal gets emitted when the
992 /// screen of a widget has changed.
993 ///
994 ///
995 ///
996 ///
997 /// #### `scroll-event`
998 /// The ::scroll-event signal is emitted when a button in the 4 to 7
999 /// range is pressed. Wheel mice are usually configured to generate
1000 /// button press events for buttons 4 and 5 when the wheel is turned.
1001 ///
1002 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1003 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1004 ///
1005 /// This signal will be sent to the grab widget if there is one.
1006 ///
1007 ///
1008 ///
1009 ///
1010 /// #### `selection-clear-event`
1011 /// The ::selection-clear-event signal will be emitted when the
1012 /// the `widget`'s window has lost ownership of a selection.
1013 ///
1014 ///
1015 ///
1016 ///
1017 /// #### `selection-get`
1018 ///
1019 ///
1020 ///
1021 /// #### `selection-notify-event`
1022 ///
1023 ///
1024 ///
1025 /// #### `selection-received`
1026 ///
1027 ///
1028 ///
1029 /// #### `selection-request-event`
1030 /// The ::selection-request-event signal will be emitted when
1031 /// another client requests ownership of the selection owned by
1032 /// the `widget`'s window.
1033 ///
1034 ///
1035 ///
1036 ///
1037 /// #### `show`
1038 /// The ::show signal is emitted when `widget` is shown, for example with
1039 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1040 ///
1041 ///
1042 ///
1043 ///
1044 /// #### `show-help`
1045 /// Action
1046 ///
1047 ///
1048 /// #### `size-allocate`
1049 ///
1050 ///
1051 ///
1052 /// #### `state-changed`
1053 /// The ::state-changed signal is emitted when the widget state changes.
1054 /// See `gtk_widget_get_state()`.
1055 ///
1056 ///
1057 ///
1058 ///
1059 /// #### `state-flags-changed`
1060 /// The ::state-flags-changed signal is emitted when the widget state
1061 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1062 ///
1063 ///
1064 ///
1065 ///
1066 /// #### `style-set`
1067 /// The ::style-set signal is emitted when a new style has been set
1068 /// on a widget. Note that style-modifying functions like
1069 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1070 ///
1071 /// Note that this signal is emitted for changes to the deprecated
1072 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1073 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1074 ///
1075 ///
1076 ///
1077 ///
1078 /// #### `style-updated`
1079 /// The ::style-updated signal is a convenience signal that is emitted when the
1080 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1081 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1082 ///
1083 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1084 /// cause this signal to be emitted.
1085 ///
1086 ///
1087 ///
1088 ///
1089 /// #### `touch-event`
1090 ///
1091 ///
1092 ///
1093 /// #### `unmap`
1094 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1095 /// means that either it or any of its parents up to the toplevel widget have
1096 /// been set as hidden.
1097 ///
1098 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1099 /// used to, for example, stop an animation on the widget.
1100 ///
1101 ///
1102 ///
1103 ///
1104 /// #### `unmap-event`
1105 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1106 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1107 ///
1108 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1109 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1110 /// automatically for all new windows.
1111 ///
1112 ///
1113 ///
1114 ///
1115 /// #### `unrealize`
1116 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1117 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1118 /// called or the widget has been unmapped (that is, it is going to be
1119 /// hidden).
1120 ///
1121 ///
1122 ///
1123 ///
1124 /// #### `visibility-notify-event`
1125 /// The ::visibility-notify-event will be emitted when the `widget`'s
1126 /// window is obscured or unobscured.
1127 ///
1128 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1129 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1130 ///
1131 ///
1132 ///
1133 ///
1134 /// #### `window-state-event`
1135 /// The ::window-state-event will be emitted when the state of the
1136 /// toplevel window associated to the `widget` changes.
1137 ///
1138 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1139 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1140 /// this mask automatically for all new windows.
1141 ///
1142 ///
1143 /// </details>
1144 ///
1145 /// # Implements
1146 ///
1147 /// [`ButtonExt`][trait@crate::prelude::ButtonExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1148 #[doc(alias = "GtkButton")]
1149 pub struct Button(Object<ffi::GtkButton, ffi::GtkButtonClass>) @extends Bin, Container, Widget, @implements Buildable, Actionable;
1150
1151 match fn {
1152 type_ => || ffi::gtk_button_get_type(),
1153 }
1154}
1155
1156impl Button {
1157 pub const NONE: Option<&'static Button> = None;
1158
1159 /// Creates a new [`Button`][crate::Button] widget. To add a child widget to the button,
1160 /// use [`ContainerExt::add()`][crate::prelude::ContainerExt::add()].
1161 ///
1162 /// # Returns
1163 ///
1164 /// The newly created [`Button`][crate::Button] widget.
1165 #[doc(alias = "gtk_button_new")]
1166 pub fn new() -> Button {
1167 assert_initialized_main_thread!();
1168 unsafe { Widget::from_glib_none(ffi::gtk_button_new()).unsafe_cast() }
1169 }
1170
1171 /// Creates a new button containing an icon from the current icon theme.
1172 ///
1173 /// If the icon name isn’t known, a “broken image” icon will be
1174 /// displayed instead. If the current icon theme is changed, the icon
1175 /// will be updated appropriately.
1176 ///
1177 /// This function is a convenience wrapper around [`new()`][Self::new()] and
1178 /// [`ButtonExt::set_image()`][crate::prelude::ButtonExt::set_image()].
1179 /// ## `icon_name`
1180 /// an icon name or [`None`]
1181 /// ## `size`
1182 /// an icon size ([`IconSize`][crate::IconSize])
1183 ///
1184 /// # Returns
1185 ///
1186 /// a new [`Button`][crate::Button] displaying the themed icon
1187 #[doc(alias = "gtk_button_new_from_icon_name")]
1188 #[doc(alias = "new_from_icon_name")]
1189 pub fn from_icon_name(icon_name: Option<&str>, size: IconSize) -> Button {
1190 assert_initialized_main_thread!();
1191 unsafe {
1192 Widget::from_glib_none(ffi::gtk_button_new_from_icon_name(
1193 icon_name.to_glib_none().0,
1194 size.into_glib(),
1195 ))
1196 .unsafe_cast()
1197 }
1198 }
1199
1200 /// Creates a [`Button`][crate::Button] widget with a [`Label`][crate::Label] child containing the given
1201 /// text.
1202 /// ## `label`
1203 /// The text you want the [`Label`][crate::Label] to hold.
1204 ///
1205 /// # Returns
1206 ///
1207 /// The newly created [`Button`][crate::Button] widget.
1208 #[doc(alias = "gtk_button_new_with_label")]
1209 #[doc(alias = "new_with_label")]
1210 pub fn with_label(label: &str) -> Button {
1211 assert_initialized_main_thread!();
1212 unsafe {
1213 Widget::from_glib_none(ffi::gtk_button_new_with_label(label.to_glib_none().0))
1214 .unsafe_cast()
1215 }
1216 }
1217
1218 /// Creates a new [`Button`][crate::Button] containing a label.
1219 /// If characters in `label` are preceded by an underscore, they are underlined.
1220 /// If you need a literal underscore character in a label, use “__” (two
1221 /// underscores). The first underlined character represents a keyboard
1222 /// accelerator called a mnemonic.
1223 /// Pressing Alt and that key activates the button.
1224 /// ## `label`
1225 /// The text of the button, with an underscore in front of the
1226 /// mnemonic character
1227 ///
1228 /// # Returns
1229 ///
1230 /// a new [`Button`][crate::Button]
1231 #[doc(alias = "gtk_button_new_with_mnemonic")]
1232 #[doc(alias = "new_with_mnemonic")]
1233 pub fn with_mnemonic(label: &str) -> Button {
1234 assert_initialized_main_thread!();
1235 unsafe {
1236 Widget::from_glib_none(ffi::gtk_button_new_with_mnemonic(label.to_glib_none().0))
1237 .unsafe_cast()
1238 }
1239 }
1240
1241 // rustdoc-stripper-ignore-next
1242 /// Creates a new builder-pattern struct instance to construct [`Button`] objects.
1243 ///
1244 /// This method returns an instance of [`ButtonBuilder`](crate::builders::ButtonBuilder) which can be used to create [`Button`] objects.
1245 pub fn builder() -> ButtonBuilder {
1246 ButtonBuilder::new()
1247 }
1248}
1249
1250impl Default for Button {
1251 fn default() -> Self {
1252 Self::new()
1253 }
1254}
1255
1256// rustdoc-stripper-ignore-next
1257/// A [builder-pattern] type to construct [`Button`] objects.
1258///
1259/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1260#[must_use = "The builder must be built to be used"]
1261pub struct ButtonBuilder {
1262 builder: glib::object::ObjectBuilder<'static, Button>,
1263}
1264
1265impl ButtonBuilder {
1266 fn new() -> Self {
1267 Self {
1268 builder: glib::object::Object::builder(),
1269 }
1270 }
1271
1272 /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
1273 /// setting and always show the image, if available.
1274 ///
1275 /// Use this property if the button would be useless or hard to use
1276 /// without the image.
1277 pub fn always_show_image(self, always_show_image: bool) -> Self {
1278 Self {
1279 builder: self
1280 .builder
1281 .property("always-show-image", always_show_image),
1282 }
1283 }
1284
1285 /// The child widget to appear next to the button text.
1286 pub fn image(self, image: &impl IsA<Widget>) -> Self {
1287 Self {
1288 builder: self.builder.property("image", image.clone().upcast()),
1289 }
1290 }
1291
1292 /// The position of the image relative to the text inside the button.
1293 pub fn image_position(self, image_position: PositionType) -> Self {
1294 Self {
1295 builder: self.builder.property("image-position", image_position),
1296 }
1297 }
1298
1299 pub fn label(self, label: impl Into<glib::GString>) -> Self {
1300 Self {
1301 builder: self.builder.property("label", label.into()),
1302 }
1303 }
1304
1305 pub fn relief(self, relief: ReliefStyle) -> Self {
1306 Self {
1307 builder: self.builder.property("relief", relief),
1308 }
1309 }
1310
1311 pub fn use_underline(self, use_underline: bool) -> Self {
1312 Self {
1313 builder: self.builder.property("use-underline", use_underline),
1314 }
1315 }
1316
1317 pub fn border_width(self, border_width: u32) -> Self {
1318 Self {
1319 builder: self.builder.property("border-width", border_width),
1320 }
1321 }
1322
1323 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1324 Self {
1325 builder: self.builder.property("child", child.clone().upcast()),
1326 }
1327 }
1328
1329 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1330 Self {
1331 builder: self.builder.property("resize-mode", resize_mode),
1332 }
1333 }
1334
1335 pub fn app_paintable(self, app_paintable: bool) -> Self {
1336 Self {
1337 builder: self.builder.property("app-paintable", app_paintable),
1338 }
1339 }
1340
1341 pub fn can_default(self, can_default: bool) -> Self {
1342 Self {
1343 builder: self.builder.property("can-default", can_default),
1344 }
1345 }
1346
1347 pub fn can_focus(self, can_focus: bool) -> Self {
1348 Self {
1349 builder: self.builder.property("can-focus", can_focus),
1350 }
1351 }
1352
1353 pub fn events(self, events: gdk::EventMask) -> Self {
1354 Self {
1355 builder: self.builder.property("events", events),
1356 }
1357 }
1358
1359 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1360 pub fn expand(self, expand: bool) -> Self {
1361 Self {
1362 builder: self.builder.property("expand", expand),
1363 }
1364 }
1365
1366 /// Whether the widget should grab focus when it is clicked with the mouse.
1367 ///
1368 /// This property is only relevant for widgets that can take focus.
1369 ///
1370 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1371 /// GtkComboBox) implemented this property individually.
1372 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1373 Self {
1374 builder: self.builder.property("focus-on-click", focus_on_click),
1375 }
1376 }
1377
1378 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1379 pub fn halign(self, halign: Align) -> Self {
1380 Self {
1381 builder: self.builder.property("halign", halign),
1382 }
1383 }
1384
1385 pub fn has_default(self, has_default: bool) -> Self {
1386 Self {
1387 builder: self.builder.property("has-default", has_default),
1388 }
1389 }
1390
1391 pub fn has_focus(self, has_focus: bool) -> Self {
1392 Self {
1393 builder: self.builder.property("has-focus", has_focus),
1394 }
1395 }
1396
1397 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1398 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1399 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1400 /// whether it will provide a tooltip or not.
1401 ///
1402 /// Note that setting this property to [`true`] for the first time will change
1403 /// the event masks of the GdkWindows of this widget to include leave-notify
1404 /// and motion-notify events. This cannot and will not be undone when the
1405 /// property is set to [`false`] again.
1406 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1407 Self {
1408 builder: self.builder.property("has-tooltip", has_tooltip),
1409 }
1410 }
1411
1412 pub fn height_request(self, height_request: i32) -> Self {
1413 Self {
1414 builder: self.builder.property("height-request", height_request),
1415 }
1416 }
1417
1418 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1419 pub fn hexpand(self, hexpand: bool) -> Self {
1420 Self {
1421 builder: self.builder.property("hexpand", hexpand),
1422 }
1423 }
1424
1425 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1426 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1427 Self {
1428 builder: self.builder.property("hexpand-set", hexpand_set),
1429 }
1430 }
1431
1432 pub fn is_focus(self, is_focus: bool) -> Self {
1433 Self {
1434 builder: self.builder.property("is-focus", is_focus),
1435 }
1436 }
1437
1438 /// Sets all four sides' margin at once. If read, returns max
1439 /// margin on any side.
1440 pub fn margin(self, margin: i32) -> Self {
1441 Self {
1442 builder: self.builder.property("margin", margin),
1443 }
1444 }
1445
1446 /// Margin on bottom side of widget.
1447 ///
1448 /// This property adds margin outside of the widget's normal size
1449 /// request, the margin will be added in addition to the size from
1450 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1451 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1452 Self {
1453 builder: self.builder.property("margin-bottom", margin_bottom),
1454 }
1455 }
1456
1457 /// Margin on end of widget, horizontally. This property supports
1458 /// left-to-right and right-to-left text directions.
1459 ///
1460 /// This property adds margin outside of the widget's normal size
1461 /// request, the margin will be added in addition to the size from
1462 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1463 pub fn margin_end(self, margin_end: i32) -> Self {
1464 Self {
1465 builder: self.builder.property("margin-end", margin_end),
1466 }
1467 }
1468
1469 /// Margin on start of widget, horizontally. This property supports
1470 /// left-to-right and right-to-left text directions.
1471 ///
1472 /// This property adds margin outside of the widget's normal size
1473 /// request, the margin will be added in addition to the size from
1474 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1475 pub fn margin_start(self, margin_start: i32) -> Self {
1476 Self {
1477 builder: self.builder.property("margin-start", margin_start),
1478 }
1479 }
1480
1481 /// Margin on top side of widget.
1482 ///
1483 /// This property adds margin outside of the widget's normal size
1484 /// request, the margin will be added in addition to the size from
1485 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1486 pub fn margin_top(self, margin_top: i32) -> Self {
1487 Self {
1488 builder: self.builder.property("margin-top", margin_top),
1489 }
1490 }
1491
1492 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1493 Self {
1494 builder: self.builder.property("name", name.into()),
1495 }
1496 }
1497
1498 pub fn no_show_all(self, no_show_all: bool) -> Self {
1499 Self {
1500 builder: self.builder.property("no-show-all", no_show_all),
1501 }
1502 }
1503
1504 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1505 /// more details about window opacity.
1506 ///
1507 /// Before 3.8 this was only available in GtkWindow
1508 pub fn opacity(self, opacity: f64) -> Self {
1509 Self {
1510 builder: self.builder.property("opacity", opacity),
1511 }
1512 }
1513
1514 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1515 Self {
1516 builder: self.builder.property("parent", parent.clone().upcast()),
1517 }
1518 }
1519
1520 pub fn receives_default(self, receives_default: bool) -> Self {
1521 Self {
1522 builder: self.builder.property("receives-default", receives_default),
1523 }
1524 }
1525
1526 pub fn sensitive(self, sensitive: bool) -> Self {
1527 Self {
1528 builder: self.builder.property("sensitive", sensitive),
1529 }
1530 }
1531
1532 /// Sets the text of tooltip to be the given string, which is marked up
1533 /// with the [Pango text markup language][PangoMarkupFormat].
1534 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1535 ///
1536 /// This is a convenience property which will take care of getting the
1537 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1538 /// will automatically be set to [`true`] and there will be taken care of
1539 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1540 ///
1541 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1542 /// are set, the last one wins.
1543 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1544 Self {
1545 builder: self
1546 .builder
1547 .property("tooltip-markup", tooltip_markup.into()),
1548 }
1549 }
1550
1551 /// Sets the text of tooltip to be the given string.
1552 ///
1553 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1554 ///
1555 /// This is a convenience property which will take care of getting the
1556 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1557 /// will automatically be set to [`true`] and there will be taken care of
1558 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1559 ///
1560 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1561 /// are set, the last one wins.
1562 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1563 Self {
1564 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1565 }
1566 }
1567
1568 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1569 pub fn valign(self, valign: Align) -> Self {
1570 Self {
1571 builder: self.builder.property("valign", valign),
1572 }
1573 }
1574
1575 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1576 pub fn vexpand(self, vexpand: bool) -> Self {
1577 Self {
1578 builder: self.builder.property("vexpand", vexpand),
1579 }
1580 }
1581
1582 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1583 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1584 Self {
1585 builder: self.builder.property("vexpand-set", vexpand_set),
1586 }
1587 }
1588
1589 pub fn visible(self, visible: bool) -> Self {
1590 Self {
1591 builder: self.builder.property("visible", visible),
1592 }
1593 }
1594
1595 pub fn width_request(self, width_request: i32) -> Self {
1596 Self {
1597 builder: self.builder.property("width-request", width_request),
1598 }
1599 }
1600
1601 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1602 Self {
1603 builder: self.builder.property("action-name", action_name.into()),
1604 }
1605 }
1606
1607 pub fn action_target(self, action_target: &glib::Variant) -> Self {
1608 Self {
1609 builder: self
1610 .builder
1611 .property("action-target", action_target.clone()),
1612 }
1613 }
1614
1615 // rustdoc-stripper-ignore-next
1616 /// Build the [`Button`].
1617 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1618 pub fn build(self) -> Button {
1619 assert_initialized_main_thread!();
1620 self.builder.build()
1621 }
1622}
1623
1624/// Trait containing all [`struct@Button`] methods.
1625///
1626/// # Implementors
1627///
1628/// [`Button`][struct@crate::Button], [`ColorButton`][struct@crate::ColorButton], [`FontButton`][struct@crate::FontButton], [`LinkButton`][struct@crate::LinkButton], [`LockButton`][struct@crate::LockButton], [`ModelButton`][struct@crate::ModelButton], [`ScaleButton`][struct@crate::ScaleButton], [`ToggleButton`][struct@crate::ToggleButton]
1629pub trait ButtonExt: IsA<Button> + 'static {
1630 /// Emits a [`clicked`][struct@crate::Button#clicked] signal to the given [`Button`][crate::Button].
1631 #[doc(alias = "gtk_button_clicked")]
1632 fn clicked(&self) {
1633 unsafe {
1634 ffi::gtk_button_clicked(self.as_ref().to_glib_none().0);
1635 }
1636 }
1637
1638 /// Returns whether the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
1639 /// setting and always show the image, if available.
1640 ///
1641 /// # Returns
1642 ///
1643 /// [`true`] if the button will always show the image
1644 #[doc(alias = "gtk_button_get_always_show_image")]
1645 #[doc(alias = "get_always_show_image")]
1646 #[doc(alias = "always-show-image")]
1647 fn must_always_show_image(&self) -> bool {
1648 unsafe {
1649 from_glib(ffi::gtk_button_get_always_show_image(
1650 self.as_ref().to_glib_none().0,
1651 ))
1652 }
1653 }
1654
1655 /// Returns the button’s event window if it is realized, [`None`] otherwise.
1656 /// This function should be rarely needed.
1657 ///
1658 /// # Returns
1659 ///
1660 /// `self`’s event window.
1661 #[doc(alias = "gtk_button_get_event_window")]
1662 #[doc(alias = "get_event_window")]
1663 fn event_window(&self) -> Option<gdk::Window> {
1664 unsafe {
1665 from_glib_none(ffi::gtk_button_get_event_window(
1666 self.as_ref().to_glib_none().0,
1667 ))
1668 }
1669 }
1670
1671 /// Gets the widget that is currenty set as the image of `self`.
1672 /// This may have been explicitly set by [`set_image()`][Self::set_image()]
1673 /// or constructed by `gtk_button_new_from_stock()`.
1674 ///
1675 /// # Returns
1676 ///
1677 /// a [`Widget`][crate::Widget] or [`None`] in case
1678 /// there is no image
1679 #[doc(alias = "gtk_button_get_image")]
1680 #[doc(alias = "get_image")]
1681 fn image(&self) -> Option<Widget> {
1682 unsafe { from_glib_none(ffi::gtk_button_get_image(self.as_ref().to_glib_none().0)) }
1683 }
1684
1685 /// Gets the position of the image relative to the text
1686 /// inside the button.
1687 ///
1688 /// # Returns
1689 ///
1690 /// the position
1691 #[doc(alias = "gtk_button_get_image_position")]
1692 #[doc(alias = "get_image_position")]
1693 #[doc(alias = "image-position")]
1694 fn image_position(&self) -> PositionType {
1695 unsafe {
1696 from_glib(ffi::gtk_button_get_image_position(
1697 self.as_ref().to_glib_none().0,
1698 ))
1699 }
1700 }
1701
1702 /// Fetches the text from the label of the button, as set by
1703 /// [`set_label()`][Self::set_label()]. If the label text has not
1704 /// been set the return value will be [`None`]. This will be the
1705 /// case if you create an empty button with [`Button::new()`][crate::Button::new()] to
1706 /// use as a container.
1707 ///
1708 /// # Returns
1709 ///
1710 /// The text of the label widget. This string is owned
1711 /// by the widget and must not be modified or freed.
1712 #[doc(alias = "gtk_button_get_label")]
1713 #[doc(alias = "get_label")]
1714 fn label(&self) -> Option<glib::GString> {
1715 unsafe { from_glib_none(ffi::gtk_button_get_label(self.as_ref().to_glib_none().0)) }
1716 }
1717
1718 /// Returns the current relief style of the given [`Button`][crate::Button].
1719 ///
1720 /// # Returns
1721 ///
1722 /// The current [`ReliefStyle`][crate::ReliefStyle]
1723 #[doc(alias = "gtk_button_get_relief")]
1724 #[doc(alias = "get_relief")]
1725 fn relief(&self) -> ReliefStyle {
1726 unsafe { from_glib(ffi::gtk_button_get_relief(self.as_ref().to_glib_none().0)) }
1727 }
1728
1729 /// Returns whether an embedded underline in the button label indicates a
1730 /// mnemonic. See gtk_button_set_use_underline ().
1731 ///
1732 /// # Returns
1733 ///
1734 /// [`true`] if an embedded underline in the button label
1735 /// indicates the mnemonic accelerator keys.
1736 #[doc(alias = "gtk_button_get_use_underline")]
1737 #[doc(alias = "get_use_underline")]
1738 #[doc(alias = "use-underline")]
1739 fn uses_underline(&self) -> bool {
1740 unsafe {
1741 from_glib(ffi::gtk_button_get_use_underline(
1742 self.as_ref().to_glib_none().0,
1743 ))
1744 }
1745 }
1746
1747 /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
1748 /// setting and always show the image, if available.
1749 ///
1750 /// Use this property if the button would be useless or hard to use
1751 /// without the image.
1752 /// ## `always_show`
1753 /// [`true`] if the menuitem should always show the image
1754 #[doc(alias = "gtk_button_set_always_show_image")]
1755 #[doc(alias = "always-show-image")]
1756 fn set_always_show_image(&self, always_show: bool) {
1757 unsafe {
1758 ffi::gtk_button_set_always_show_image(
1759 self.as_ref().to_glib_none().0,
1760 always_show.into_glib(),
1761 );
1762 }
1763 }
1764
1765 /// Set the image of `self` to the given widget. The image will be
1766 /// displayed if the label text is [`None`] or if
1767 /// [`always-show-image`][struct@crate::Button#always-show-image] is [`true`]. You don’t have to call
1768 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()] on `image` yourself.
1769 /// ## `image`
1770 /// a widget to set as the image for the button, or [`None`] to unset
1771 #[doc(alias = "gtk_button_set_image")]
1772 #[doc(alias = "image")]
1773 fn set_image(&self, image: Option<&impl IsA<Widget>>) {
1774 unsafe {
1775 ffi::gtk_button_set_image(
1776 self.as_ref().to_glib_none().0,
1777 image.map(|p| p.as_ref()).to_glib_none().0,
1778 );
1779 }
1780 }
1781
1782 /// Sets the position of the image relative to the text
1783 /// inside the button.
1784 /// ## `position`
1785 /// the position
1786 #[doc(alias = "gtk_button_set_image_position")]
1787 #[doc(alias = "image-position")]
1788 fn set_image_position(&self, position: PositionType) {
1789 unsafe {
1790 ffi::gtk_button_set_image_position(
1791 self.as_ref().to_glib_none().0,
1792 position.into_glib(),
1793 );
1794 }
1795 }
1796
1797 /// Sets the text of the label of the button to `str`. This text is
1798 /// also used to select the stock item if `gtk_button_set_use_stock()`
1799 /// is used.
1800 ///
1801 /// This will also clear any previously set labels.
1802 /// ## `label`
1803 /// a string
1804 #[doc(alias = "gtk_button_set_label")]
1805 #[doc(alias = "label")]
1806 fn set_label(&self, label: &str) {
1807 unsafe {
1808 ffi::gtk_button_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0);
1809 }
1810 }
1811
1812 /// Sets the relief style of the edges of the given [`Button`][crate::Button] widget.
1813 /// Two styles exist, [`ReliefStyle::Normal`][crate::ReliefStyle::Normal] and [`ReliefStyle::None`][crate::ReliefStyle::None].
1814 /// The default style is, as one can guess, [`ReliefStyle::Normal`][crate::ReliefStyle::Normal].
1815 /// The deprecated value [`ReliefStyle::Half`][crate::ReliefStyle::Half] behaves the same as
1816 /// [`ReliefStyle::Normal`][crate::ReliefStyle::Normal].
1817 /// ## `relief`
1818 /// The GtkReliefStyle as described above
1819 #[doc(alias = "gtk_button_set_relief")]
1820 #[doc(alias = "relief")]
1821 fn set_relief(&self, relief: ReliefStyle) {
1822 unsafe {
1823 ffi::gtk_button_set_relief(self.as_ref().to_glib_none().0, relief.into_glib());
1824 }
1825 }
1826
1827 /// If true, an underline in the text of the button label indicates
1828 /// the next character should be used for the mnemonic accelerator key.
1829 /// ## `use_underline`
1830 /// [`true`] if underlines in the text indicate mnemonics
1831 #[doc(alias = "gtk_button_set_use_underline")]
1832 #[doc(alias = "use-underline")]
1833 fn set_use_underline(&self, use_underline: bool) {
1834 unsafe {
1835 ffi::gtk_button_set_use_underline(
1836 self.as_ref().to_glib_none().0,
1837 use_underline.into_glib(),
1838 );
1839 }
1840 }
1841
1842 /// The ::activate signal on GtkButton is an action signal and
1843 /// emitting it causes the button to animate press then release.
1844 /// Applications should never connect to this signal, but use the
1845 /// [`clicked`][struct@crate::Button#clicked] signal.
1846 #[doc(alias = "activate")]
1847 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1848 unsafe extern "C" fn activate_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1849 this: *mut ffi::GtkButton,
1850 f: glib::ffi::gpointer,
1851 ) {
1852 unsafe {
1853 let f: &F = &*(f as *const F);
1854 f(Button::from_glib_borrow(this).unsafe_cast_ref())
1855 }
1856 }
1857 unsafe {
1858 let f: Box_<F> = Box_::new(f);
1859 connect_raw(
1860 self.as_ptr() as *mut _,
1861 c"activate".as_ptr(),
1862 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1863 activate_trampoline::<Self, F> as *const (),
1864 )),
1865 Box_::into_raw(f),
1866 )
1867 }
1868 }
1869
1870 fn emit_activate(&self) {
1871 self.emit_by_name::<()>("activate", &[]);
1872 }
1873
1874 /// Emitted when the button has been activated (pressed and released).
1875 #[doc(alias = "clicked")]
1876 fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1877 unsafe extern "C" fn clicked_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1878 this: *mut ffi::GtkButton,
1879 f: glib::ffi::gpointer,
1880 ) {
1881 unsafe {
1882 let f: &F = &*(f as *const F);
1883 f(Button::from_glib_borrow(this).unsafe_cast_ref())
1884 }
1885 }
1886 unsafe {
1887 let f: Box_<F> = Box_::new(f);
1888 connect_raw(
1889 self.as_ptr() as *mut _,
1890 c"clicked".as_ptr(),
1891 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1892 clicked_trampoline::<Self, F> as *const (),
1893 )),
1894 Box_::into_raw(f),
1895 )
1896 }
1897 }
1898
1899 fn emit_clicked(&self) {
1900 self.emit_by_name::<()>("clicked", &[]);
1901 }
1902
1903 #[doc(alias = "always-show-image")]
1904 fn connect_always_show_image_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1905 unsafe extern "C" fn notify_always_show_image_trampoline<
1906 P: IsA<Button>,
1907 F: Fn(&P) + 'static,
1908 >(
1909 this: *mut ffi::GtkButton,
1910 _param_spec: glib::ffi::gpointer,
1911 f: glib::ffi::gpointer,
1912 ) {
1913 unsafe {
1914 let f: &F = &*(f as *const F);
1915 f(Button::from_glib_borrow(this).unsafe_cast_ref())
1916 }
1917 }
1918 unsafe {
1919 let f: Box_<F> = Box_::new(f);
1920 connect_raw(
1921 self.as_ptr() as *mut _,
1922 c"notify::always-show-image".as_ptr(),
1923 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1924 notify_always_show_image_trampoline::<Self, F> as *const (),
1925 )),
1926 Box_::into_raw(f),
1927 )
1928 }
1929 }
1930
1931 #[doc(alias = "image")]
1932 fn connect_image_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1933 unsafe extern "C" fn notify_image_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1934 this: *mut ffi::GtkButton,
1935 _param_spec: glib::ffi::gpointer,
1936 f: glib::ffi::gpointer,
1937 ) {
1938 unsafe {
1939 let f: &F = &*(f as *const F);
1940 f(Button::from_glib_borrow(this).unsafe_cast_ref())
1941 }
1942 }
1943 unsafe {
1944 let f: Box_<F> = Box_::new(f);
1945 connect_raw(
1946 self.as_ptr() as *mut _,
1947 c"notify::image".as_ptr(),
1948 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1949 notify_image_trampoline::<Self, F> as *const (),
1950 )),
1951 Box_::into_raw(f),
1952 )
1953 }
1954 }
1955
1956 #[doc(alias = "image-position")]
1957 fn connect_image_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1958 unsafe extern "C" fn notify_image_position_trampoline<
1959 P: IsA<Button>,
1960 F: Fn(&P) + 'static,
1961 >(
1962 this: *mut ffi::GtkButton,
1963 _param_spec: glib::ffi::gpointer,
1964 f: glib::ffi::gpointer,
1965 ) {
1966 unsafe {
1967 let f: &F = &*(f as *const F);
1968 f(Button::from_glib_borrow(this).unsafe_cast_ref())
1969 }
1970 }
1971 unsafe {
1972 let f: Box_<F> = Box_::new(f);
1973 connect_raw(
1974 self.as_ptr() as *mut _,
1975 c"notify::image-position".as_ptr(),
1976 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1977 notify_image_position_trampoline::<Self, F> as *const (),
1978 )),
1979 Box_::into_raw(f),
1980 )
1981 }
1982 }
1983
1984 #[doc(alias = "label")]
1985 fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1986 unsafe extern "C" fn notify_label_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
1987 this: *mut ffi::GtkButton,
1988 _param_spec: glib::ffi::gpointer,
1989 f: glib::ffi::gpointer,
1990 ) {
1991 unsafe {
1992 let f: &F = &*(f as *const F);
1993 f(Button::from_glib_borrow(this).unsafe_cast_ref())
1994 }
1995 }
1996 unsafe {
1997 let f: Box_<F> = Box_::new(f);
1998 connect_raw(
1999 self.as_ptr() as *mut _,
2000 c"notify::label".as_ptr(),
2001 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2002 notify_label_trampoline::<Self, F> as *const (),
2003 )),
2004 Box_::into_raw(f),
2005 )
2006 }
2007 }
2008
2009 #[doc(alias = "relief")]
2010 fn connect_relief_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2011 unsafe extern "C" fn notify_relief_trampoline<P: IsA<Button>, F: Fn(&P) + 'static>(
2012 this: *mut ffi::GtkButton,
2013 _param_spec: glib::ffi::gpointer,
2014 f: glib::ffi::gpointer,
2015 ) {
2016 unsafe {
2017 let f: &F = &*(f as *const F);
2018 f(Button::from_glib_borrow(this).unsafe_cast_ref())
2019 }
2020 }
2021 unsafe {
2022 let f: Box_<F> = Box_::new(f);
2023 connect_raw(
2024 self.as_ptr() as *mut _,
2025 c"notify::relief".as_ptr(),
2026 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2027 notify_relief_trampoline::<Self, F> as *const (),
2028 )),
2029 Box_::into_raw(f),
2030 )
2031 }
2032 }
2033
2034 #[doc(alias = "use-underline")]
2035 fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2036 unsafe extern "C" fn notify_use_underline_trampoline<
2037 P: IsA<Button>,
2038 F: Fn(&P) + 'static,
2039 >(
2040 this: *mut ffi::GtkButton,
2041 _param_spec: glib::ffi::gpointer,
2042 f: glib::ffi::gpointer,
2043 ) {
2044 unsafe {
2045 let f: &F = &*(f as *const F);
2046 f(Button::from_glib_borrow(this).unsafe_cast_ref())
2047 }
2048 }
2049 unsafe {
2050 let f: Box_<F> = Box_::new(f);
2051 connect_raw(
2052 self.as_ptr() as *mut _,
2053 c"notify::use-underline".as_ptr(),
2054 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2055 notify_use_underline_trampoline::<Self, F> as *const (),
2056 )),
2057 Box_::into_raw(f),
2058 )
2059 }
2060 }
2061}
2062
2063impl<O: IsA<Button>> ButtonExt for O {}