Skip to main content

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