gi-gtk-3.0.32: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.Switch

Description

Switch is a widget that has two states: on or off. The user can control which state should be active by clicking the empty area, or by dragging the handle.

GtkSwitch can also handle situations where the underlying state changes with a delay. See stateSet for details.

CSS nodes

plain code

switch
╰── slider

GtkSwitch has two css nodes, the main node with the name switch and a subnode named slider. Neither of them is using any style classes.

Synopsis

Exported types

newtype Switch Source #

Memory-managed wrapper type.

Constructors

Switch (ManagedPtr Switch) 

Instances

Instances details
Eq Switch Source # 
Instance details

Defined in GI.Gtk.Objects.Switch

Methods

(==) :: Switch -> Switch -> Bool #

(/=) :: Switch -> Switch -> Bool #

IsGValue Switch Source #

Convert Switch to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.Switch

GObject Switch Source # 
Instance details

Defined in GI.Gtk.Objects.Switch

Methods

gobjectType :: IO GType #

HasParentTypes Switch Source # 
Instance details

Defined in GI.Gtk.Objects.Switch

type ParentTypes Switch Source # 
Instance details

Defined in GI.Gtk.Objects.Switch

class (GObject o, IsDescendantOf Switch o) => IsSwitch o Source #

Type class for types which can be safely cast to Switch, for instance with toSwitch.

Instances

Instances details
(GObject o, IsDescendantOf Switch o) => IsSwitch o Source # 
Instance details

Defined in GI.Gtk.Objects.Switch

toSwitch :: (MonadIO m, IsSwitch o) => o -> m Switch Source #

Cast to Switch, for types for which this is known to be safe. For general casts, use castTo.

noSwitch :: Maybe Switch Source #

A convenience alias for Nothing :: Maybe Switch.

Methods

Overloaded methods

getActive

switchGetActive Source #

Arguments

:: (HasCallStack, MonadIO m, IsSwitch a) 
=> a

sw: a Switch

-> m Bool

Returns: True if the Switch is active, and False otherwise

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

Since: 3.0

getState

switchGetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsSwitch a) 
=> a

sw: a Switch

-> m Bool

Returns: the underlying state

Gets the underlying state of the Switch.

Since: 3.14

new

switchNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Switch

Returns: the newly created Switch instance

Creates a new Switch widget.

Since: 3.0

setActive

switchSetActive Source #

Arguments

:: (HasCallStack, MonadIO m, IsSwitch a) 
=> a

sw: a Switch

-> Bool

isActive: True if sw should be active, and False otherwise

-> m () 

Changes the state of sw to the desired one.

Since: 3.0

setState

switchSetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsSwitch a) 
=> a

sw: a Switch

-> Bool

state: the new state

-> m () 

Sets the underlying state of the Switch.

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

See stateSet for details.

Since: 3.14

Properties

active

Whether the Switch widget is in its on or off state.

constructSwitchActive :: IsSwitch o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “active” property. This is rarely needed directly, but it is used by new.

getSwitchActive :: (MonadIO m, IsSwitch o) => o -> m Bool Source #

Get the value of the “active” property. When overloading is enabled, this is equivalent to

get switch #active

setSwitchActive :: (MonadIO m, IsSwitch o) => o -> Bool -> m () Source #

Set the value of the “active” property. When overloading is enabled, this is equivalent to

set switch [ #active := value ]

state

The backend state that is controlled by the switch. See stateSet for details.

Since: 3.14

constructSwitchState :: IsSwitch o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “state” property. This is rarely needed directly, but it is used by new.

getSwitchState :: (MonadIO m, IsSwitch o) => o -> m Bool Source #

Get the value of the “state” property. When overloading is enabled, this is equivalent to

get switch #state

setSwitchState :: (MonadIO m, IsSwitch o) => o -> Bool -> m () Source #

Set the value of the “state” property. When overloading is enabled, this is equivalent to

set switch [ #state := value ]

Signals

activate

type C_SwitchActivateCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type SwitchActivateCallback = IO () Source #

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:active) signal.

afterSwitchActivate :: (IsSwitch a, MonadIO m) => a -> SwitchActivateCallback -> m SignalHandlerId Source #

Connect a signal handler for the activate signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after switch #activate callback

onSwitchActivate :: (IsSwitch a, MonadIO m) => a -> SwitchActivateCallback -> m SignalHandlerId Source #

Connect a signal handler for the activate signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on switch #activate callback

stateSet

type C_SwitchStateSetCallback = Ptr () -> CInt -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

type SwitchStateSetCallback Source #

Arguments

 = Bool

state: the new state of the switch

-> IO Bool

Returns: True to stop the signal emission

The stateSet 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 Switch:active property.

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

Since: 3.14

afterSwitchStateSet :: (IsSwitch a, MonadIO m) => a -> SwitchStateSetCallback -> m SignalHandlerId Source #

Connect a signal handler for the stateSet signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after switch #stateSet callback

onSwitchStateSet :: (IsSwitch a, MonadIO m) => a -> SwitchStateSetCallback -> m SignalHandlerId Source #

Connect a signal handler for the stateSet signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on switch #stateSet callback