Skip to main content

gtk/auto/
switch.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::{Actionable, Align, Buildable, Container, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14    /// [`Switch`][crate::Switch] is a widget that has two states: on or off. The user can control
15    /// which state should be active by clicking the empty area, or by dragging the
16    /// handle.
17    ///
18    /// GtkSwitch can also handle situations where the underlying state changes with
19    /// a delay. See [`state-set`][struct@crate::Switch#state-set] for details.
20    ///
21    /// # CSS nodes
22    ///
23    ///
24    ///
25    /// **⚠️ The following code is in plain ⚠️**
26    ///
27    /// ```plain
28    /// switch
29    /// ╰── slider
30    /// ```
31    ///
32    /// GtkSwitch has two css nodes, the main node with the name switch and a subnode
33    /// named slider. Neither of them is using any style classes.
34    ///
35    /// ## Properties
36    ///
37    ///
38    /// #### `active`
39    ///  Whether the [`Switch`][crate::Switch] widget is in its on or off state.
40    ///
41    /// Readable | Writeable
42    ///
43    ///
44    /// #### `state`
45    ///  The backend state that is controlled by the switch.
46    /// See [`state-set`][struct@crate::Switch#state-set] for details.
47    ///
48    /// Readable | Writeable
49    /// <details><summary><h4>Widget</h4></summary>
50    ///
51    ///
52    /// #### `app-paintable`
53    ///  Readable | Writeable
54    ///
55    ///
56    /// #### `can-default`
57    ///  Readable | Writeable
58    ///
59    ///
60    /// #### `can-focus`
61    ///  Readable | Writeable
62    ///
63    ///
64    /// #### `composite-child`
65    ///  Readable
66    ///
67    ///
68    /// #### `double-buffered`
69    ///  Whether the widget is double buffered.
70    ///
71    /// Readable | Writeable
72    ///
73    ///
74    /// #### `events`
75    ///  Readable | Writeable
76    ///
77    ///
78    /// #### `expand`
79    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
80    ///
81    /// Readable | Writeable
82    ///
83    ///
84    /// #### `focus-on-click`
85    ///  Whether the widget should grab focus when it is clicked with the mouse.
86    ///
87    /// This property is only relevant for widgets that can take focus.
88    ///
89    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
90    /// GtkComboBox) implemented this property individually.
91    ///
92    /// Readable | Writeable
93    ///
94    ///
95    /// #### `halign`
96    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
97    ///
98    /// Readable | Writeable
99    ///
100    ///
101    /// #### `has-default`
102    ///  Readable | Writeable
103    ///
104    ///
105    /// #### `has-focus`
106    ///  Readable | Writeable
107    ///
108    ///
109    /// #### `has-tooltip`
110    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
111    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
112    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
113    /// whether it will provide a tooltip or not.
114    ///
115    /// Note that setting this property to [`true`] for the first time will change
116    /// the event masks of the GdkWindows of this widget to include leave-notify
117    /// and motion-notify events. This cannot and will not be undone when the
118    /// property is set to [`false`] again.
119    ///
120    /// Readable | Writeable
121    ///
122    ///
123    /// #### `height-request`
124    ///  Readable | Writeable
125    ///
126    ///
127    /// #### `hexpand`
128    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
129    ///
130    /// Readable | Writeable
131    ///
132    ///
133    /// #### `hexpand-set`
134    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
135    ///
136    /// Readable | Writeable
137    ///
138    ///
139    /// #### `is-focus`
140    ///  Readable | Writeable
141    ///
142    ///
143    /// #### `margin`
144    ///  Sets all four sides' margin at once. If read, returns max
145    /// margin on any side.
146    ///
147    /// Readable | Writeable
148    ///
149    ///
150    /// #### `margin-bottom`
151    ///  Margin on bottom side of widget.
152    ///
153    /// This property adds margin outside of the widget's normal size
154    /// request, the margin will be added in addition to the size from
155    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
156    ///
157    /// Readable | Writeable
158    ///
159    ///
160    /// #### `margin-end`
161    ///  Margin on end of widget, horizontally. This property supports
162    /// left-to-right and right-to-left text directions.
163    ///
164    /// This property adds margin outside of the widget's normal size
165    /// request, the margin will be added in addition to the size from
166    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
167    ///
168    /// Readable | Writeable
169    ///
170    ///
171    /// #### `margin-left`
172    ///  Margin on left side of widget.
173    ///
174    /// This property adds margin outside of the widget's normal size
175    /// request, the margin will be added in addition to the size from
176    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
177    ///
178    /// Readable | Writeable
179    ///
180    ///
181    /// #### `margin-right`
182    ///  Margin on right side of widget.
183    ///
184    /// This property adds margin outside of the widget's normal size
185    /// request, the margin will be added in addition to the size from
186    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
187    ///
188    /// Readable | Writeable
189    ///
190    ///
191    /// #### `margin-start`
192    ///  Margin on start of widget, horizontally. This property supports
193    /// left-to-right and right-to-left text directions.
194    ///
195    /// This property adds margin outside of the widget's normal size
196    /// request, the margin will be added in addition to the size from
197    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
198    ///
199    /// Readable | Writeable
200    ///
201    ///
202    /// #### `margin-top`
203    ///  Margin on top side of widget.
204    ///
205    /// This property adds margin outside of the widget's normal size
206    /// request, the margin will be added in addition to the size from
207    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
208    ///
209    /// Readable | Writeable
210    ///
211    ///
212    /// #### `name`
213    ///  Readable | Writeable
214    ///
215    ///
216    /// #### `no-show-all`
217    ///  Readable | Writeable
218    ///
219    ///
220    /// #### `opacity`
221    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
222    /// more details about window opacity.
223    ///
224    /// Before 3.8 this was only available in GtkWindow
225    ///
226    /// Readable | Writeable
227    ///
228    ///
229    /// #### `parent`
230    ///  Readable | Writeable
231    ///
232    ///
233    /// #### `receives-default`
234    ///  Readable | Writeable
235    ///
236    ///
237    /// #### `scale-factor`
238    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
239    /// more details about widget scaling.
240    ///
241    /// Readable
242    ///
243    ///
244    /// #### `sensitive`
245    ///  Readable | Writeable
246    ///
247    ///
248    /// #### `style`
249    ///  The style of the widget, which contains information about how it will look (colors, etc).
250    ///
251    /// Readable | Writeable
252    ///
253    ///
254    /// #### `tooltip-markup`
255    ///  Sets the text of tooltip to be the given string, which is marked up
256    /// with the [Pango text markup language][PangoMarkupFormat].
257    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
258    ///
259    /// This is a convenience property which will take care of getting the
260    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
261    /// will automatically be set to [`true`] and there will be taken care of
262    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
263    ///
264    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
265    /// are set, the last one wins.
266    ///
267    /// Readable | Writeable
268    ///
269    ///
270    /// #### `tooltip-text`
271    ///  Sets the text of tooltip to be the given string.
272    ///
273    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
274    ///
275    /// This is a convenience property which will take care of getting the
276    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
277    /// will automatically be set to [`true`] and there will be taken care of
278    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
279    ///
280    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
281    /// are set, the last one wins.
282    ///
283    /// Readable | Writeable
284    ///
285    ///
286    /// #### `valign`
287    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
288    ///
289    /// Readable | Writeable
290    ///
291    ///
292    /// #### `vexpand`
293    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
294    ///
295    /// Readable | Writeable
296    ///
297    ///
298    /// #### `vexpand-set`
299    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
300    ///
301    /// Readable | Writeable
302    ///
303    ///
304    /// #### `visible`
305    ///  Readable | Writeable
306    ///
307    ///
308    /// #### `width-request`
309    ///  Readable | Writeable
310    ///
311    ///
312    /// #### `window`
313    ///  The widget's window if it is realized, [`None`] otherwise.
314    ///
315    /// Readable
316    /// </details>
317    /// <details><summary><h4>Actionable</h4></summary>
318    ///
319    ///
320    /// #### `action-name`
321    ///  Readable | Writeable
322    ///
323    ///
324    /// #### `action-target`
325    ///  Readable | Writeable
326    /// </details>
327    /// <details><summary><h4>Activatable</h4></summary>
328    ///
329    ///
330    /// #### `related-action`
331    ///  The action that this activatable will activate and receive
332    /// updates from for various states and possibly appearance.
333    ///
334    /// > `GtkActivatable` implementors need to handle the this property and
335    /// > call `gtk_activatable_do_set_related_action()` when it changes.
336    ///
337    /// Readable | Writeable
338    ///
339    ///
340    /// #### `use-action-appearance`
341    ///  Whether this activatable should reset its layout
342    /// and appearance when setting the related action or when
343    /// the action changes appearance.
344    ///
345    /// See the `GtkAction` documentation directly to find which properties
346    /// should be ignored by the `GtkActivatable` when this property is [`false`].
347    ///
348    /// > `GtkActivatable` implementors need to handle this property
349    /// > and call `gtk_activatable_sync_action_properties()` on the activatable
350    /// > widget when it changes.
351    ///
352    /// Readable | Writeable
353    /// </details>
354    ///
355    /// ## Signals
356    ///
357    ///
358    /// #### `activate`
359    ///  The ::activate signal on GtkSwitch is an action signal and
360    /// emitting it causes the switch to animate.
361    /// Applications should never connect to this signal, but use the
362    /// notify::active signal.
363    ///
364    /// Action
365    ///
366    ///
367    /// #### `state-set`
368    ///  The ::state-set signal on GtkSwitch is emitted to change the underlying
369    /// state. It is emitted when the user changes the switch position. The
370    /// default handler keeps the state in sync with the [`active`][struct@crate::Switch#active]
371    /// property.
372    ///
373    /// To implement delayed state change, applications can connect to this signal,
374    /// initiate the change of the underlying state, and call [`SwitchExt::set_state()`][crate::prelude::SwitchExt::set_state()]
375    /// when the underlying state change is complete. The signal handler should
376    /// return [`true`] to prevent the default handler from running.
377    ///
378    /// Visually, the underlying state is represented by the trough color of
379    /// the switch, while the [`active`][struct@crate::Switch#active] property is represented by the
380    /// position of the switch.
381    ///
382    ///
383    /// <details><summary><h4>Widget</h4></summary>
384    ///
385    ///
386    /// #### `accel-closures-changed`
387    ///
388    ///
389    ///
390    /// #### `button-press-event`
391    ///  The ::button-press-event signal will be emitted when a button
392    /// (typically from a mouse) is pressed.
393    ///
394    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
395    /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
396    ///
397    /// This signal will be sent to the grab widget if there is one.
398    ///
399    ///
400    ///
401    ///
402    /// #### `button-release-event`
403    ///  The ::button-release-event signal will be emitted when a button
404    /// (typically from a mouse) is released.
405    ///
406    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
407    /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
408    ///
409    /// This signal will be sent to the grab widget if there is one.
410    ///
411    ///
412    ///
413    ///
414    /// #### `can-activate-accel`
415    ///  Determines whether an accelerator that activates the signal
416    /// identified by `signal_id` can currently be activated.
417    /// This signal is present to allow applications and derived
418    /// widgets to override the default [`Widget`][crate::Widget] handling
419    /// for determining whether an accelerator can be activated.
420    ///
421    ///
422    ///
423    ///
424    /// #### `child-notify`
425    ///  The ::child-notify signal is emitted for each
426    /// [child property][child-properties] that has
427    /// changed on an object. The signal's detail holds the property name.
428    ///
429    /// Detailed
430    ///
431    ///
432    /// #### `composited-changed`
433    ///  The ::composited-changed signal is emitted when the composited
434    /// status of `widgets` screen changes.
435    /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
436    ///
437    /// Action
438    ///
439    ///
440    /// #### `configure-event`
441    ///  The ::configure-event signal will be emitted when the size, position or
442    /// stacking of the `widget`'s window has changed.
443    ///
444    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
445    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
446    /// automatically for all new windows.
447    ///
448    ///
449    ///
450    ///
451    /// #### `damage-event`
452    ///  Emitted when a redirected window belonging to `widget` gets drawn into.
453    /// The region/area members of the event shows what area of the redirected
454    /// drawable was drawn into.
455    ///
456    ///
457    ///
458    ///
459    /// #### `delete-event`
460    ///  The ::delete-event signal is emitted if a user requests that
461    /// a toplevel window is closed. The default handler for this signal
462    /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
463    /// this signal will cause the window to be hidden instead, so that
464    /// it can later be shown again without reconstructing it.
465    ///
466    ///
467    ///
468    ///
469    /// #### `destroy`
470    ///  Signals that all holders of a reference to the widget should release
471    /// the reference that they hold. May result in finalization of the widget
472    /// if all references are released.
473    ///
474    /// This signal is not suitable for saving widget state.
475    ///
476    ///
477    ///
478    ///
479    /// #### `destroy-event`
480    ///  The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
481    /// You rarely get this signal, because most widgets disconnect themselves
482    /// from their window before they destroy it, so no widget owns the
483    /// window at destroy time.
484    ///
485    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
486    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
487    /// automatically for all new windows.
488    ///
489    ///
490    ///
491    ///
492    /// #### `direction-changed`
493    ///  The ::direction-changed signal is emitted when the text direction
494    /// of a widget changes.
495    ///
496    ///
497    ///
498    ///
499    /// #### `drag-begin`
500    ///  The ::drag-begin signal is emitted on the drag source when a drag is
501    /// started. A typical reason to connect to this signal is to set up a
502    /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
503    ///
504    /// Note that some widgets set up a drag icon in the default handler of
505    /// this signal, so you may have to use `g_signal_connect_after()` to
506    /// override what the default handler did.
507    ///
508    ///
509    ///
510    ///
511    /// #### `drag-data-delete`
512    ///  The ::drag-data-delete signal is emitted on the drag source when a drag
513    /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
514    /// handler is responsible for deleting the data that has been dropped. What
515    /// "delete" means depends on the context of the drag operation.
516    ///
517    ///
518    ///
519    ///
520    /// #### `drag-data-get`
521    ///  The ::drag-data-get signal is emitted on the drag source when the drop
522    /// site requests the data which is dragged. It is the responsibility of
523    /// the signal handler to fill `data` with the data in the format which
524    /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
525    /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
526    ///
527    ///
528    ///
529    ///
530    /// #### `drag-data-received`
531    ///  The ::drag-data-received signal is emitted on the drop site when the
532    /// dragged data has been received. If the data was received in order to
533    /// determine whether the drop will be accepted, the handler is expected
534    /// to call `gdk_drag_status()` and not finish the drag.
535    /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
536    /// (and this is the last target to be received), the handler for this
537    /// signal is expected to process the received data and then call
538    /// `gtk_drag_finish()`, setting the `success` parameter depending on
539    /// whether the data was processed successfully.
540    ///
541    /// Applications must create some means to determine why the signal was emitted
542    /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
543    ///
544    /// The handler may inspect the selected action with
545    /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
546    /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
547    /// shown in the following example:
548    ///
549    ///
550    /// **⚠️ The following code is in C ⚠️**
551    ///
552    /// ```C
553    /// void
554    /// drag_data_received (GtkWidget          *widget,
555    ///                     GdkDragContext     *context,
556    ///                     gint                x,
557    ///                     gint                y,
558    ///                     GtkSelectionData   *data,
559    ///                     guint               info,
560    ///                     guint               time)
561    /// {
562    ///   if ((data->length >= 0) && (data->format == 8))
563    ///     {
564    ///       GdkDragAction action;
565    ///
566    ///       // handle data here
567    ///
568    ///       action = gdk_drag_context_get_selected_action (context);
569    ///       if (action == GDK_ACTION_ASK)
570    ///         {
571    ///           GtkWidget *dialog;
572    ///           gint response;
573    ///
574    ///           dialog = gtk_message_dialog_new (NULL,
575    ///                                            GTK_DIALOG_MODAL |
576    ///                                            GTK_DIALOG_DESTROY_WITH_PARENT,
577    ///                                            GTK_MESSAGE_INFO,
578    ///                                            GTK_BUTTONS_YES_NO,
579    ///                                            "Move the data ?\n");
580    ///           response = gtk_dialog_run (GTK_DIALOG (dialog));
581    ///           gtk_widget_destroy (dialog);
582    ///
583    ///           if (response == GTK_RESPONSE_YES)
584    ///             action = GDK_ACTION_MOVE;
585    ///           else
586    ///             action = GDK_ACTION_COPY;
587    ///          }
588    ///
589    ///       gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
590    ///     }
591    ///   else
592    ///     gtk_drag_finish (context, FALSE, FALSE, time);
593    ///  }
594    /// ```
595    ///
596    ///
597    ///
598    ///
599    /// #### `drag-drop`
600    ///  The ::drag-drop signal is emitted on the drop site when the user drops
601    /// the data onto the widget. The signal handler must determine whether
602    /// the cursor position is in a drop zone or not. If it is not in a drop
603    /// zone, it returns [`false`] and no further processing is necessary.
604    /// Otherwise, the handler returns [`true`]. In this case, the handler must
605    /// ensure that `gtk_drag_finish()` is called to let the source know that
606    /// the drop is done. The call to `gtk_drag_finish()` can be done either
607    /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
608    /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
609    /// or more of the supported targets.
610    ///
611    ///
612    ///
613    ///
614    /// #### `drag-end`
615    ///  The ::drag-end signal is emitted on the drag source when a drag is
616    /// finished. A typical reason to connect to this signal is to undo
617    /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
618    ///
619    ///
620    ///
621    ///
622    /// #### `drag-failed`
623    ///  The ::drag-failed signal is emitted on the drag source when a drag has
624    /// failed. The signal handler may hook custom code to handle a failed DnD
625    /// operation based on the type of error, it returns [`true`] is the failure has
626    /// been already handled (not showing the default "drag operation failed"
627    /// animation), otherwise it returns [`false`].
628    ///
629    ///
630    ///
631    ///
632    /// #### `drag-leave`
633    ///  The ::drag-leave signal is emitted on the drop site when the cursor
634    /// leaves the widget. A typical reason to connect to this signal is to
635    /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
636    /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
637    ///
638    ///
639    /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
640    /// ::drag-drop signal, for instance to allow cleaning up of a preview item
641    /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
642    ///
643    ///
644    ///
645    ///
646    /// #### `drag-motion`
647    ///  The ::drag-motion signal is emitted on the drop site when the user
648    /// moves the cursor over the widget during a drag. The signal handler
649    /// must determine whether the cursor position is in a drop zone or not.
650    /// If it is not in a drop zone, it returns [`false`] and no further processing
651    /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
652    /// handler is responsible for providing the necessary information for
653    /// displaying feedback to the user, by calling `gdk_drag_status()`.
654    ///
655    /// If the decision whether the drop will be accepted or rejected can't be
656    /// made based solely on the cursor position and the type of the data, the
657    /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
658    /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
659    /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
660    /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
661    /// when using the drag-motion signal that way.
662    ///
663    /// Also note that there is no drag-enter signal. The drag receiver has to
664    /// keep track of whether he has received any drag-motion signals since the
665    /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
666    /// an "enter" signal. Upon an "enter", the handler will typically highlight
667    /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
668    ///
669    ///
670    /// **⚠️ The following code is in C ⚠️**
671    ///
672    /// ```C
673    /// static void
674    /// drag_motion (GtkWidget      *widget,
675    ///              GdkDragContext *context,
676    ///              gint            x,
677    ///              gint            y,
678    ///              guint           time)
679    /// {
680    ///   GdkAtom target;
681    ///
682    ///   PrivateData *private_data = GET_PRIVATE_DATA (widget);
683    ///
684    ///   if (!private_data->drag_highlight)
685    ///    {
686    ///      private_data->drag_highlight = 1;
687    ///      gtk_drag_highlight (widget);
688    ///    }
689    ///
690    ///   target = gtk_drag_dest_find_target (widget, context, NULL);
691    ///   if (target == GDK_NONE)
692    ///     gdk_drag_status (context, 0, time);
693    ///   else
694    ///    {
695    ///      private_data->pending_status
696    ///         = gdk_drag_context_get_suggested_action (context);
697    ///      gtk_drag_get_data (widget, context, target, time);
698    ///    }
699    ///
700    ///   return TRUE;
701    /// }
702    ///
703    /// static void
704    /// drag_data_received (GtkWidget        *widget,
705    ///                     GdkDragContext   *context,
706    ///                     gint              x,
707    ///                     gint              y,
708    ///                     GtkSelectionData *selection_data,
709    ///                     guint             info,
710    ///                     guint             time)
711    /// {
712    ///   PrivateData *private_data = GET_PRIVATE_DATA (widget);
713    ///
714    ///   if (private_data->suggested_action)
715    ///    {
716    ///      private_data->suggested_action = 0;
717    ///
718    ///      // We are getting this data due to a request in drag_motion,
719    ///      // rather than due to a request in drag_drop, so we are just
720    ///      // supposed to call gdk_drag_status(), not actually paste in
721    ///      // the data.
722    ///
723    ///      str = gtk_selection_data_get_text (selection_data);
724    ///      if (!data_is_acceptable (str))
725    ///        gdk_drag_status (context, 0, time);
726    ///      else
727    ///        gdk_drag_status (context,
728    ///                         private_data->suggested_action,
729    ///                         time);
730    ///    }
731    ///   else
732    ///    {
733    ///      // accept the drop
734    ///    }
735    /// }
736    /// ```
737    ///
738    ///
739    ///
740    ///
741    /// #### `draw`
742    ///  This signal is emitted when a widget is supposed to render itself.
743    /// The `widget`'s top left corner must be painted at the origin of
744    /// the passed in context and be sized to the values returned by
745    /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
746    /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
747    ///
748    /// Signal handlers connected to this signal can modify the cairo
749    /// context passed as `cr` in any way they like and don't need to
750    /// restore it. The signal emission takes care of calling `cairo_save()`
751    /// before and `cairo_restore()` after invoking the handler.
752    ///
753    /// The signal handler will get a `cr` with a clip region already set to the
754    /// widget's dirty region, i.e. to the area that needs repainting. Complicated
755    /// widgets that want to avoid redrawing themselves completely can get the full
756    /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
757    /// get a finer-grained representation of the dirty region with
758    /// `cairo_copy_clip_rectangle_list()`.
759    ///
760    ///
761    ///
762    ///
763    /// #### `enter-notify-event`
764    ///  The ::enter-notify-event will be emitted when the pointer enters
765    /// 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::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
769    ///
770    /// This signal will be sent to the grab widget if there is one.
771    ///
772    ///
773    ///
774    ///
775    /// #### `event`
776    ///  The GTK+ main loop will emit three signals for each GDK event delivered
777    /// to a widget: one generic ::event signal, another, more specific,
778    /// signal that matches the type of event delivered (e.g.
779    /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
780    /// [`event-after`][struct@crate::Widget#event-after] signal.
781    ///
782    ///
783    ///
784    ///
785    /// #### `event-after`
786    ///  After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
787    /// the second more specific signal, ::event-after will be emitted
788    /// regardless of the previous two signals handlers return values.
789    ///
790    ///
791    ///
792    ///
793    /// #### `focus`
794    ///
795    ///
796    ///
797    /// #### `focus-in-event`
798    ///  The ::focus-in-event signal will be emitted when the keyboard focus
799    /// enters the `widget`'s window.
800    ///
801    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
802    /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
803    ///
804    ///
805    ///
806    ///
807    /// #### `focus-out-event`
808    ///  The ::focus-out-event signal will be emitted when the keyboard focus
809    /// leaves the `widget`'s window.
810    ///
811    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
812    /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
813    ///
814    ///
815    ///
816    ///
817    /// #### `grab-broken-event`
818    ///  Emitted when a pointer or keyboard grab on a window belonging
819    /// to `widget` gets broken.
820    ///
821    /// On X11, this happens when the grab window becomes unviewable
822    /// (i.e. it or one of its ancestors is unmapped), or if the same
823    /// application grabs the pointer or keyboard again.
824    ///
825    ///
826    ///
827    ///
828    /// #### `grab-focus`
829    ///  Action
830    ///
831    ///
832    /// #### `grab-notify`
833    ///  The ::grab-notify signal is emitted when a widget becomes
834    /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
835    /// another widget, or when it becomes unshadowed due to a grab
836    /// being removed.
837    ///
838    /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
839    /// grab widget in the grab stack of its window group is not
840    /// its ancestor.
841    ///
842    ///
843    ///
844    ///
845    /// #### `hide`
846    ///  The ::hide signal is emitted when `widget` is hidden, for example with
847    /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
848    ///
849    ///
850    ///
851    ///
852    /// #### `hierarchy-changed`
853    ///  The ::hierarchy-changed signal is emitted when the
854    /// anchored state of a widget changes. A widget is
855    /// “anchored” when its toplevel
856    /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
857    /// a widget changes from un-anchored to anchored or vice-versa.
858    ///
859    ///
860    ///
861    ///
862    /// #### `key-press-event`
863    ///  The ::key-press-event signal is emitted when a key is pressed. The signal
864    /// emission will reoccur at the key-repeat rate when the key is kept pressed.
865    ///
866    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
867    /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
868    ///
869    /// This signal will be sent to the grab widget if there is one.
870    ///
871    ///
872    ///
873    ///
874    /// #### `key-release-event`
875    ///  The ::key-release-event signal is emitted when a key is released.
876    ///
877    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
878    /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
879    ///
880    /// This signal will be sent to the grab widget if there is one.
881    ///
882    ///
883    ///
884    ///
885    /// #### `keynav-failed`
886    ///  Gets emitted if keyboard navigation fails.
887    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
888    ///
889    ///
890    ///
891    ///
892    /// #### `leave-notify-event`
893    ///  The ::leave-notify-event will be emitted when the pointer leaves
894    /// the `widget`'s window.
895    ///
896    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
897    /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
898    ///
899    /// This signal will be sent to the grab widget if there is one.
900    ///
901    ///
902    ///
903    ///
904    /// #### `map`
905    ///  The ::map signal is emitted when `widget` is going to be mapped, that is
906    /// when the widget is visible (which is controlled with
907    /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
908    /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
909    /// be emitted.
910    ///
911    /// The ::map signal can be used to determine whether a widget will be drawn,
912    /// for instance it can resume an animation that was stopped during the
913    /// emission of [`unmap`][struct@crate::Widget#unmap].
914    ///
915    ///
916    ///
917    ///
918    /// #### `map-event`
919    ///  The ::map-event signal will be emitted when the `widget`'s window is
920    /// mapped. A window is mapped when it becomes visible on the screen.
921    ///
922    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
923    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
924    /// automatically for all new windows.
925    ///
926    ///
927    ///
928    ///
929    /// #### `mnemonic-activate`
930    ///  The default handler for this signal activates `widget` if `group_cycling`
931    /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
932    ///
933    ///
934    ///
935    ///
936    /// #### `motion-notify-event`
937    ///  The ::motion-notify-event signal is emitted when the pointer moves
938    /// over the widget's [`gdk::Window`][crate::gdk::Window].
939    ///
940    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
941    /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
942    ///
943    /// This signal will be sent to the grab widget if there is one.
944    ///
945    ///
946    ///
947    ///
948    /// #### `move-focus`
949    ///  Action
950    ///
951    ///
952    /// #### `parent-set`
953    ///  The ::parent-set signal is emitted when a new parent
954    /// has been set on a widget.
955    ///
956    ///
957    ///
958    ///
959    /// #### `popup-menu`
960    ///  This signal gets emitted whenever a widget should pop up a context
961    /// menu. This usually happens through the standard key binding mechanism;
962    /// by pressing a certain key while a widget is focused, the user can cause
963    /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
964    /// a menu with clipboard commands. See the
965    /// [Popup Menu Migration Checklist][checklist-popup-menu]
966    /// for an example of how to use this signal.
967    ///
968    /// Action
969    ///
970    ///
971    /// #### `property-notify-event`
972    ///  The ::property-notify-event signal will be emitted when a property on
973    /// the `widget`'s window has been changed or deleted.
974    ///
975    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
976    /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
977    ///
978    ///
979    ///
980    ///
981    /// #### `proximity-in-event`
982    ///  To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
983    /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
984    ///
985    /// This signal will be sent to the grab widget if there is one.
986    ///
987    ///
988    ///
989    ///
990    /// #### `proximity-out-event`
991    ///  To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
992    /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
993    ///
994    /// This signal will be sent to the grab widget if there is one.
995    ///
996    ///
997    ///
998    ///
999    /// #### `query-tooltip`
1000    ///  Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1001    /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1002    /// focus in keyboard mode.
1003    ///
1004    /// Using the given coordinates, the signal handler should determine
1005    /// whether a tooltip should be shown for `widget`. If this is the case
1006    /// [`true`] should be returned, [`false`] otherwise. Note that if
1007    /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1008    /// should not be used.
1009    ///
1010    /// The signal handler is free to manipulate `tooltip` with the therefore
1011    /// destined function calls.
1012    ///
1013    ///
1014    ///
1015    ///
1016    /// #### `realize`
1017    ///  The ::realize signal is emitted when `widget` is associated with a
1018    /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1019    /// widget has been mapped (that is, it is going to be drawn).
1020    ///
1021    ///
1022    ///
1023    ///
1024    /// #### `screen-changed`
1025    ///  The ::screen-changed signal gets emitted when the
1026    /// screen of a widget has changed.
1027    ///
1028    ///
1029    ///
1030    ///
1031    /// #### `scroll-event`
1032    ///  The ::scroll-event signal is emitted when a button in the 4 to 7
1033    /// range is pressed. Wheel mice are usually configured to generate
1034    /// button press events for buttons 4 and 5 when the wheel is turned.
1035    ///
1036    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1037    /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1038    ///
1039    /// This signal will be sent to the grab widget if there is one.
1040    ///
1041    ///
1042    ///
1043    ///
1044    /// #### `selection-clear-event`
1045    ///  The ::selection-clear-event signal will be emitted when the
1046    /// the `widget`'s window has lost ownership of a selection.
1047    ///
1048    ///
1049    ///
1050    ///
1051    /// #### `selection-get`
1052    ///
1053    ///
1054    ///
1055    /// #### `selection-notify-event`
1056    ///
1057    ///
1058    ///
1059    /// #### `selection-received`
1060    ///
1061    ///
1062    ///
1063    /// #### `selection-request-event`
1064    ///  The ::selection-request-event signal will be emitted when
1065    /// another client requests ownership of the selection owned by
1066    /// the `widget`'s window.
1067    ///
1068    ///
1069    ///
1070    ///
1071    /// #### `show`
1072    ///  The ::show signal is emitted when `widget` is shown, for example with
1073    /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1074    ///
1075    ///
1076    ///
1077    ///
1078    /// #### `show-help`
1079    ///  Action
1080    ///
1081    ///
1082    /// #### `size-allocate`
1083    ///
1084    ///
1085    ///
1086    /// #### `state-changed`
1087    ///  The ::state-changed signal is emitted when the widget state changes.
1088    /// See `gtk_widget_get_state()`.
1089    ///
1090    ///
1091    ///
1092    ///
1093    /// #### `state-flags-changed`
1094    ///  The ::state-flags-changed signal is emitted when the widget state
1095    /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1096    ///
1097    ///
1098    ///
1099    ///
1100    /// #### `style-set`
1101    ///  The ::style-set signal is emitted when a new style has been set
1102    /// on a widget. Note that style-modifying functions like
1103    /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1104    ///
1105    /// Note that this signal is emitted for changes to the deprecated
1106    /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1107    /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1108    ///
1109    ///
1110    ///
1111    ///
1112    /// #### `style-updated`
1113    ///  The ::style-updated signal is a convenience signal that is emitted when the
1114    /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1115    /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1116    ///
1117    /// Note that style-modifying functions like `gtk_widget_override_color()` also
1118    /// cause this signal to be emitted.
1119    ///
1120    ///
1121    ///
1122    ///
1123    /// #### `touch-event`
1124    ///
1125    ///
1126    ///
1127    /// #### `unmap`
1128    ///  The ::unmap signal is emitted when `widget` is going to be unmapped, which
1129    /// means that either it or any of its parents up to the toplevel widget have
1130    /// been set as hidden.
1131    ///
1132    /// As ::unmap indicates that a widget will not be shown any longer, it can be
1133    /// used to, for example, stop an animation on the widget.
1134    ///
1135    ///
1136    ///
1137    ///
1138    /// #### `unmap-event`
1139    ///  The ::unmap-event signal will be emitted when the `widget`'s window is
1140    /// unmapped. A window is unmapped when it becomes invisible on the screen.
1141    ///
1142    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1143    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1144    /// automatically for all new windows.
1145    ///
1146    ///
1147    ///
1148    ///
1149    /// #### `unrealize`
1150    ///  The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1151    /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1152    /// called or the widget has been unmapped (that is, it is going to be
1153    /// hidden).
1154    ///
1155    ///
1156    ///
1157    ///
1158    /// #### `visibility-notify-event`
1159    ///  The ::visibility-notify-event will be emitted when the `widget`'s
1160    /// window is obscured or unobscured.
1161    ///
1162    /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1163    /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1164    ///
1165    ///
1166    ///
1167    ///
1168    /// #### `window-state-event`
1169    ///  The ::window-state-event will be emitted when the state of the
1170    /// toplevel window associated to the `widget` changes.
1171    ///
1172    /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1173    /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1174    /// this mask automatically for all new windows.
1175    ///
1176    ///
1177    /// </details>
1178    ///
1179    /// # Implements
1180    ///
1181    /// [`SwitchExt`][trait@crate::prelude::SwitchExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`SwitchExtManual`][trait@crate::prelude::SwitchExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1182    #[doc(alias = "GtkSwitch")]
1183    pub struct Switch(Object<ffi::GtkSwitch, ffi::GtkSwitchClass>) @extends Widget, @implements Buildable, Actionable;
1184
1185    match fn {
1186        type_ => || ffi::gtk_switch_get_type(),
1187    }
1188}
1189
1190impl Switch {
1191    pub const NONE: Option<&'static Switch> = None;
1192
1193    /// Creates a new [`Switch`][crate::Switch] widget.
1194    ///
1195    /// # Returns
1196    ///
1197    /// the newly created [`Switch`][crate::Switch] instance
1198    #[doc(alias = "gtk_switch_new")]
1199    pub fn new() -> Switch {
1200        assert_initialized_main_thread!();
1201        unsafe { Widget::from_glib_none(ffi::gtk_switch_new()).unsafe_cast() }
1202    }
1203
1204    // rustdoc-stripper-ignore-next
1205    /// Creates a new builder-pattern struct instance to construct [`Switch`] objects.
1206    ///
1207    /// This method returns an instance of [`SwitchBuilder`](crate::builders::SwitchBuilder) which can be used to create [`Switch`] objects.
1208    pub fn builder() -> SwitchBuilder {
1209        SwitchBuilder::new()
1210    }
1211}
1212
1213impl Default for Switch {
1214    fn default() -> Self {
1215        Self::new()
1216    }
1217}
1218
1219// rustdoc-stripper-ignore-next
1220/// A [builder-pattern] type to construct [`Switch`] objects.
1221///
1222/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1223#[must_use = "The builder must be built to be used"]
1224pub struct SwitchBuilder {
1225    builder: glib::object::ObjectBuilder<'static, Switch>,
1226}
1227
1228impl SwitchBuilder {
1229    fn new() -> Self {
1230        Self {
1231            builder: glib::object::Object::builder(),
1232        }
1233    }
1234
1235    /// Whether the [`Switch`][crate::Switch] widget is in its on or off state.
1236    pub fn active(self, active: bool) -> Self {
1237        Self {
1238            builder: self.builder.property("active", active),
1239        }
1240    }
1241
1242    /// The backend state that is controlled by the switch.
1243    /// See [`state-set`][struct@crate::Switch#state-set] for details.
1244    pub fn state(self, state: bool) -> Self {
1245        Self {
1246            builder: self.builder.property("state", state),
1247        }
1248    }
1249
1250    pub fn app_paintable(self, app_paintable: bool) -> Self {
1251        Self {
1252            builder: self.builder.property("app-paintable", app_paintable),
1253        }
1254    }
1255
1256    pub fn can_default(self, can_default: bool) -> Self {
1257        Self {
1258            builder: self.builder.property("can-default", can_default),
1259        }
1260    }
1261
1262    pub fn can_focus(self, can_focus: bool) -> Self {
1263        Self {
1264            builder: self.builder.property("can-focus", can_focus),
1265        }
1266    }
1267
1268    pub fn events(self, events: gdk::EventMask) -> Self {
1269        Self {
1270            builder: self.builder.property("events", events),
1271        }
1272    }
1273
1274    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1275    pub fn expand(self, expand: bool) -> Self {
1276        Self {
1277            builder: self.builder.property("expand", expand),
1278        }
1279    }
1280
1281    /// Whether the widget should grab focus when it is clicked with the mouse.
1282    ///
1283    /// This property is only relevant for widgets that can take focus.
1284    ///
1285    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1286    /// GtkComboBox) implemented this property individually.
1287    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1288        Self {
1289            builder: self.builder.property("focus-on-click", focus_on_click),
1290        }
1291    }
1292
1293    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1294    pub fn halign(self, halign: Align) -> Self {
1295        Self {
1296            builder: self.builder.property("halign", halign),
1297        }
1298    }
1299
1300    pub fn has_default(self, has_default: bool) -> Self {
1301        Self {
1302            builder: self.builder.property("has-default", has_default),
1303        }
1304    }
1305
1306    pub fn has_focus(self, has_focus: bool) -> Self {
1307        Self {
1308            builder: self.builder.property("has-focus", has_focus),
1309        }
1310    }
1311
1312    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1313    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1314    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1315    /// whether it will provide a tooltip or not.
1316    ///
1317    /// Note that setting this property to [`true`] for the first time will change
1318    /// the event masks of the GdkWindows of this widget to include leave-notify
1319    /// and motion-notify events. This cannot and will not be undone when the
1320    /// property is set to [`false`] again.
1321    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1322        Self {
1323            builder: self.builder.property("has-tooltip", has_tooltip),
1324        }
1325    }
1326
1327    pub fn height_request(self, height_request: i32) -> Self {
1328        Self {
1329            builder: self.builder.property("height-request", height_request),
1330        }
1331    }
1332
1333    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1334    pub fn hexpand(self, hexpand: bool) -> Self {
1335        Self {
1336            builder: self.builder.property("hexpand", hexpand),
1337        }
1338    }
1339
1340    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1341    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1342        Self {
1343            builder: self.builder.property("hexpand-set", hexpand_set),
1344        }
1345    }
1346
1347    pub fn is_focus(self, is_focus: bool) -> Self {
1348        Self {
1349            builder: self.builder.property("is-focus", is_focus),
1350        }
1351    }
1352
1353    /// Sets all four sides' margin at once. If read, returns max
1354    /// margin on any side.
1355    pub fn margin(self, margin: i32) -> Self {
1356        Self {
1357            builder: self.builder.property("margin", margin),
1358        }
1359    }
1360
1361    /// Margin on bottom side of widget.
1362    ///
1363    /// This property adds margin outside of the widget's normal size
1364    /// request, the margin will be added in addition to the size from
1365    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1366    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1367        Self {
1368            builder: self.builder.property("margin-bottom", margin_bottom),
1369        }
1370    }
1371
1372    /// Margin on end of widget, horizontally. This property supports
1373    /// left-to-right and right-to-left text directions.
1374    ///
1375    /// This property adds margin outside of the widget's normal size
1376    /// request, the margin will be added in addition to the size from
1377    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1378    pub fn margin_end(self, margin_end: i32) -> Self {
1379        Self {
1380            builder: self.builder.property("margin-end", margin_end),
1381        }
1382    }
1383
1384    /// Margin on start of widget, horizontally. This property supports
1385    /// left-to-right and right-to-left text directions.
1386    ///
1387    /// This property adds margin outside of the widget's normal size
1388    /// request, the margin will be added in addition to the size from
1389    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1390    pub fn margin_start(self, margin_start: i32) -> Self {
1391        Self {
1392            builder: self.builder.property("margin-start", margin_start),
1393        }
1394    }
1395
1396    /// Margin on top side of widget.
1397    ///
1398    /// This property adds margin outside of the widget's normal size
1399    /// request, the margin will be added in addition to the size from
1400    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1401    pub fn margin_top(self, margin_top: i32) -> Self {
1402        Self {
1403            builder: self.builder.property("margin-top", margin_top),
1404        }
1405    }
1406
1407    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1408        Self {
1409            builder: self.builder.property("name", name.into()),
1410        }
1411    }
1412
1413    pub fn no_show_all(self, no_show_all: bool) -> Self {
1414        Self {
1415            builder: self.builder.property("no-show-all", no_show_all),
1416        }
1417    }
1418
1419    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1420    /// more details about window opacity.
1421    ///
1422    /// Before 3.8 this was only available in GtkWindow
1423    pub fn opacity(self, opacity: f64) -> Self {
1424        Self {
1425            builder: self.builder.property("opacity", opacity),
1426        }
1427    }
1428
1429    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1430        Self {
1431            builder: self.builder.property("parent", parent.clone().upcast()),
1432        }
1433    }
1434
1435    pub fn receives_default(self, receives_default: bool) -> Self {
1436        Self {
1437            builder: self.builder.property("receives-default", receives_default),
1438        }
1439    }
1440
1441    pub fn sensitive(self, sensitive: bool) -> Self {
1442        Self {
1443            builder: self.builder.property("sensitive", sensitive),
1444        }
1445    }
1446
1447    /// Sets the text of tooltip to be the given string, which is marked up
1448    /// with the [Pango text markup language][PangoMarkupFormat].
1449    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1450    ///
1451    /// This is a convenience property which will take care of getting the
1452    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1453    /// will automatically be set to [`true`] and there will be taken care of
1454    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1455    ///
1456    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1457    /// are set, the last one wins.
1458    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1459        Self {
1460            builder: self
1461                .builder
1462                .property("tooltip-markup", tooltip_markup.into()),
1463        }
1464    }
1465
1466    /// Sets the text of tooltip to be the given string.
1467    ///
1468    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1469    ///
1470    /// This is a convenience property which will take care of getting the
1471    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1472    /// will automatically be set to [`true`] and there will be taken care of
1473    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1474    ///
1475    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1476    /// are set, the last one wins.
1477    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1478        Self {
1479            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1480        }
1481    }
1482
1483    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1484    pub fn valign(self, valign: Align) -> Self {
1485        Self {
1486            builder: self.builder.property("valign", valign),
1487        }
1488    }
1489
1490    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1491    pub fn vexpand(self, vexpand: bool) -> Self {
1492        Self {
1493            builder: self.builder.property("vexpand", vexpand),
1494        }
1495    }
1496
1497    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1498    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1499        Self {
1500            builder: self.builder.property("vexpand-set", vexpand_set),
1501        }
1502    }
1503
1504    pub fn visible(self, visible: bool) -> Self {
1505        Self {
1506            builder: self.builder.property("visible", visible),
1507        }
1508    }
1509
1510    pub fn width_request(self, width_request: i32) -> Self {
1511        Self {
1512            builder: self.builder.property("width-request", width_request),
1513        }
1514    }
1515
1516    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1517        Self {
1518            builder: self.builder.property("action-name", action_name.into()),
1519        }
1520    }
1521
1522    pub fn action_target(self, action_target: &glib::Variant) -> Self {
1523        Self {
1524            builder: self
1525                .builder
1526                .property("action-target", action_target.clone()),
1527        }
1528    }
1529
1530    // rustdoc-stripper-ignore-next
1531    /// Build the [`Switch`].
1532    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1533    pub fn build(self) -> Switch {
1534        self.builder.build()
1535    }
1536}
1537
1538mod sealed {
1539    pub trait Sealed {}
1540    impl<T: super::IsA<super::Switch>> Sealed for T {}
1541}
1542
1543/// Trait containing all [`struct@Switch`] methods.
1544///
1545/// # Implementors
1546///
1547/// [`Switch`][struct@crate::Switch]
1548pub trait SwitchExt: IsA<Switch> + sealed::Sealed + 'static {
1549    /// Gets whether the [`Switch`][crate::Switch] is in its “on” or “off” state.
1550    ///
1551    /// # Returns
1552    ///
1553    /// [`true`] if the [`Switch`][crate::Switch] is active, and [`false`] otherwise
1554    #[doc(alias = "gtk_switch_get_active")]
1555    #[doc(alias = "get_active")]
1556    fn is_active(&self) -> bool {
1557        unsafe { from_glib(ffi::gtk_switch_get_active(self.as_ref().to_glib_none().0)) }
1558    }
1559
1560    /// Gets the underlying state of the [`Switch`][crate::Switch].
1561    ///
1562    /// # Returns
1563    ///
1564    /// the underlying state
1565    #[doc(alias = "gtk_switch_get_state")]
1566    #[doc(alias = "get_state")]
1567    fn state(&self) -> bool {
1568        unsafe { from_glib(ffi::gtk_switch_get_state(self.as_ref().to_glib_none().0)) }
1569    }
1570
1571    /// Changes the state of `self` to the desired one.
1572    /// ## `is_active`
1573    /// [`true`] if `self` should be active, and [`false`] otherwise
1574    #[doc(alias = "gtk_switch_set_active")]
1575    fn set_active(&self, is_active: bool) {
1576        unsafe {
1577            ffi::gtk_switch_set_active(self.as_ref().to_glib_none().0, is_active.into_glib());
1578        }
1579    }
1580
1581    /// Sets the underlying state of the [`Switch`][crate::Switch].
1582    ///
1583    /// Normally, this is the same as [`active`][struct@crate::Switch#active], unless the switch
1584    /// is set up for delayed state changes. This function is typically
1585    /// called from a [`state-set`][struct@crate::Switch#state-set] signal handler.
1586    ///
1587    /// See [`state-set`][struct@crate::Switch#state-set] for details.
1588    /// ## `state`
1589    /// the new state
1590    #[doc(alias = "gtk_switch_set_state")]
1591    fn set_state(&self, state: bool) {
1592        unsafe {
1593            ffi::gtk_switch_set_state(self.as_ref().to_glib_none().0, state.into_glib());
1594        }
1595    }
1596
1597    /// The ::activate signal on GtkSwitch is an action signal and
1598    /// emitting it causes the switch to animate.
1599    /// Applications should never connect to this signal, but use the
1600    /// notify::active signal.
1601    #[doc(alias = "activate")]
1602    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1603        unsafe extern "C" fn activate_trampoline<P: IsA<Switch>, F: Fn(&P) + 'static>(
1604            this: *mut ffi::GtkSwitch,
1605            f: glib::ffi::gpointer,
1606        ) {
1607            let f: &F = &*(f as *const F);
1608            f(Switch::from_glib_borrow(this).unsafe_cast_ref())
1609        }
1610        unsafe {
1611            let f: Box_<F> = Box_::new(f);
1612            connect_raw(
1613                self.as_ptr() as *mut _,
1614                b"activate\0".as_ptr() as *const _,
1615                Some(transmute::<_, unsafe extern "C" fn()>(
1616                    activate_trampoline::<Self, F> as *const (),
1617                )),
1618                Box_::into_raw(f),
1619            )
1620        }
1621    }
1622
1623    fn emit_activate(&self) {
1624        self.emit_by_name::<()>("activate", &[]);
1625    }
1626
1627    /// The ::state-set signal on GtkSwitch is emitted to change the underlying
1628    /// state. It is emitted when the user changes the switch position. The
1629    /// default handler keeps the state in sync with the [`active`][struct@crate::Switch#active]
1630    /// property.
1631    ///
1632    /// To implement delayed state change, applications can connect to this signal,
1633    /// initiate the change of the underlying state, and call [`set_state()`][Self::set_state()]
1634    /// when the underlying state change is complete. The signal handler should
1635    /// return [`true`] to prevent the default handler from running.
1636    ///
1637    /// Visually, the underlying state is represented by the trough color of
1638    /// the switch, while the [`active`][struct@crate::Switch#active] property is represented by the
1639    /// position of the switch.
1640    /// ## `state`
1641    /// the new state of the switch
1642    ///
1643    /// # Returns
1644    ///
1645    /// [`true`] to stop the signal emission
1646    #[doc(alias = "state-set")]
1647    fn connect_state_set<F: Fn(&Self, bool) -> glib::Propagation + 'static>(
1648        &self,
1649        f: F,
1650    ) -> SignalHandlerId {
1651        unsafe extern "C" fn state_set_trampoline<
1652            P: IsA<Switch>,
1653            F: Fn(&P, bool) -> glib::Propagation + 'static,
1654        >(
1655            this: *mut ffi::GtkSwitch,
1656            state: glib::ffi::gboolean,
1657            f: glib::ffi::gpointer,
1658        ) -> glib::ffi::gboolean {
1659            let f: &F = &*(f as *const F);
1660            f(
1661                Switch::from_glib_borrow(this).unsafe_cast_ref(),
1662                from_glib(state),
1663            )
1664            .into_glib()
1665        }
1666        unsafe {
1667            let f: Box_<F> = Box_::new(f);
1668            connect_raw(
1669                self.as_ptr() as *mut _,
1670                b"state-set\0".as_ptr() as *const _,
1671                Some(transmute::<_, unsafe extern "C" fn()>(
1672                    state_set_trampoline::<Self, F> as *const (),
1673                )),
1674                Box_::into_raw(f),
1675            )
1676        }
1677    }
1678
1679    #[doc(alias = "active")]
1680    fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1681        unsafe extern "C" fn notify_active_trampoline<P: IsA<Switch>, F: Fn(&P) + 'static>(
1682            this: *mut ffi::GtkSwitch,
1683            _param_spec: glib::ffi::gpointer,
1684            f: glib::ffi::gpointer,
1685        ) {
1686            let f: &F = &*(f as *const F);
1687            f(Switch::from_glib_borrow(this).unsafe_cast_ref())
1688        }
1689        unsafe {
1690            let f: Box_<F> = Box_::new(f);
1691            connect_raw(
1692                self.as_ptr() as *mut _,
1693                b"notify::active\0".as_ptr() as *const _,
1694                Some(transmute::<_, unsafe extern "C" fn()>(
1695                    notify_active_trampoline::<Self, F> as *const (),
1696                )),
1697                Box_::into_raw(f),
1698            )
1699        }
1700    }
1701
1702    #[doc(alias = "state")]
1703    fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1704        unsafe extern "C" fn notify_state_trampoline<P: IsA<Switch>, F: Fn(&P) + 'static>(
1705            this: *mut ffi::GtkSwitch,
1706            _param_spec: glib::ffi::gpointer,
1707            f: glib::ffi::gpointer,
1708        ) {
1709            let f: &F = &*(f as *const F);
1710            f(Switch::from_glib_borrow(this).unsafe_cast_ref())
1711        }
1712        unsafe {
1713            let f: Box_<F> = Box_::new(f);
1714            connect_raw(
1715                self.as_ptr() as *mut _,
1716                b"notify::state\0".as_ptr() as *const _,
1717                Some(transmute::<_, unsafe extern "C" fn()>(
1718                    notify_state_trampoline::<Self, F> as *const (),
1719                )),
1720                Box_::into_raw(f),
1721            )
1722        }
1723    }
1724}
1725
1726impl<O: IsA<Switch>> SwitchExt for O {}
1727
1728impl fmt::Display for Switch {
1729    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1730        f.write_str("Switch")
1731    }
1732}