pub trait SwitchExt: 'static {
    fn is_active(&self) -> bool;
    fn state(&self) -> bool;
    fn set_active(&self, is_active: bool);
    fn set_state(&self, state: bool);
    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
    fn emit_activate(&self);
    fn connect_state_set<F: Fn(&Self, bool) -> Inhibit + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_active_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_state_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }
Expand description

Trait containing all Switch methods.

Implementors

Switch

Required Methods

Gets whether the Switch is in its “on” or “off” state.

Returns

true if the Switch is active, and false otherwise

Gets the underlying state of the Switch.

Returns

the underlying state

Changes the state of self to the desired one.

is_active

true if self should be active, and false otherwise

Sets the underlying state of the Switch.

Normally, this is the same as property::Switch::active, unless the switch is set up for delayed state changes. This function is typically called from a signal::Switch::state-set signal handler.

See signal::Switch::state-set for details.

state

the new state

The ::activate signal on GtkSwitch 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.

The ::state-set signal on GtkSwitch 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 property::Switch::active property.

To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call set_state() 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 property::Switch::active property is represented by the position of the switch.

state

the new state of the switch

Returns

true to stop the signal emission

Implementors