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