Package: gtk

Class gtk-switch

Superclasses

gtk-widget, gtk-buildable, gtk-actionable, gtk-activatable, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

active
The active property of type :boolean (Read / Write)
Whether the switch is in its on or off state.
Default value: false
state
The state property of type :boolean (Read / Write)
The backend state that is controlled by the switch. See the "state-set" signal for details.
Default value: false

Details

The gtk-switch widget is a widget that has two states: on or off.



The user can control which state should be active by clicking the switch, or by dragging the handle.

CSS nodes

 switch
 ╰── slider    
The gtk-switch implementation has two CSS nodes, the main node with the name switch and a subnode named slider. Neither of them is using any style classes.

Style Property Details

slider-height
The slider-height style property of type :int (Read)
The minimum height of the switch handle, in pixels.
Warning: The slider-height style property has been deprecated since version 3.20 and should not be used in newly written code. Use the CSS min-height property instead.
Allowed values: >= 22
Default value: 22
slider-width
The slider-width style property of type :int (Read)
The minimum width of the switch handle, in pixels.
Warning: The slider-width style property has been deprecated since version 3.20 and should not be used in newly written code. Use the CSS min-height property instead.
Allowed values: >= 36
Default value: 36

Signal Details

The "activate" signal
 lambda (widget)    :action      
The signal on the switch is an action signal and emitting it causes the switch to animate. Applications should never connect to this signal, but use the "notify::active" signal.
widget
The gtk-switch widget which received the signal.
The "state-set" signal
 lambda (widget state)    :run-last      
The signal on the switch is emitted to change the underlying state. It is emitted when the user changes the switch position. The default handler keeps the state in sync with the active property.

To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call the gtk-switch-state function when the underlying state change is complete. The signal handler should return true to prevent the default handler from running.

Visually, the underlying state is represented by the trough color of the switch, while the active property is represented by the position of the switch.
widget
The gtk-switch widget which received the signal.
state
A boolean with the state of the switch.
Returns
True to stop the signal emission.
 

Slot Access Functions

Inherited Slot Access Functions

*2021-12-23