gtk.switch_

Module for [Switch] class

Types 3

gtk.switch_.Switch is a "light switch" that has two states: on or off.

!An example GtkSwitch

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

gtk.switch_.Switch can also handle situations where the underlying state changes with a delay. In this case, the slider position indicates the user's recent change (as indicated by the gtk.switch_.Switch.active property), and the color indicates whether the underlying state (represented by the gtk.switch_.Switch.state property) has been updated yet.

!GtkSwitch with delayed state change

See gtk.switch_.Switch.stateSet for details.

CSS nodes

switch
├── image
├── image
╰── slider

gtk.switch_.Switch has four css nodes, the main node with the name switch and subnodes for the slider and the on and off images. Neither of them is using any style classes.

Accessibility

gtk.switch_.Switch uses the gtk.types.AccessibleRole.Switch role.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
Switch self() nothrowReturns `this`, for use in `with` statements.
SwitchGidBuilder builder() static nothrowGet builder for [gtk.switch_.Switch] Returns: New builder object
bool active() @property nothrowGet `active` property. Returns: Whether the [gtk.switch_.Switch] widget is in its on or off state.
void active(bool propval) @property nothrowSet `active` property. Params: propval = Whether the [gtk.switch_.Switch] widget is in its on or off state.
bool state() @property nothrowGet `state` property. Returns: The backend state that is controlled by the switch.
void state(bool propval) @property nothrowSet `state` property. Params: propval = The backend state that is controlled by the switch.
bool getActive() nothrowGets whether the [gtk.switch_.Switch] is in its “on” or “off” state. Returns: true if the [gtk.switch_.Switch] is active, and false otherwise
bool getState() nothrowGets the underlying state of the [gtk.switch_.Switch]. Returns: the underlying state
void setActive(bool isActive) nothrowChanges the state of self to the desired one.
void setState(bool state) nothrowSets the underlying state of the [gtk.switch_.Switch].
gulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.switch_.Switch))) && Parameters!T.length < 2) nothrowConnect to `Activate` signal.
gulong connectStateSet(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == bool))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.switch_.Switch))) && Parameters!T.length < 3) nothrowConnect to `StateSet` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.switch_.Switch] widget. Returns: the newly created [gtk.switch_.Switch] instance

Fluent builder implementation template for gtk.switch_.Switch

Methods
T active(bool propval) nothrowSet `active` property. Params: propval = Whether the [gtk.switch_.Switch] widget is in its on or off state. Returns: Builder instance for fluent chaining
T state(bool propval) nothrowSet `state` property. Params: propval = The backend state that is controlled by the switch.

Fluent builder for gtk.switch_.Switch

Methods
Switch build() nothrowCreate object from builder. Returns: New object