| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte | 
|---|---|
| License | LGPL-2.1 | 
| Maintainer | Iñaki García Etxebarria | 
| Safe Haskell | Safe-Inferred | 
| Language | Haskell2010 | 
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 ├── label ├── label ╰── slider
GtkSwitch has four css nodes, the main node with the name switch and subnodes for the slider and the on and off labels. Neither of them is using any style classes.
Accessibility
GtkSwitch uses the GTK_ACCESSIBLE_ROLE_SWITCH role.
Synopsis
- newtype Switch = Switch (ManagedPtr Switch)
- class (GObject o, IsDescendantOf Switch o) => IsSwitch o
- toSwitch :: (MonadIO m, IsSwitch o) => o -> m Switch
- switchGetActive :: (HasCallStack, MonadIO m, IsSwitch a) => a -> m Bool
- switchGetState :: (HasCallStack, MonadIO m, IsSwitch a) => a -> m Bool
- switchNew :: (HasCallStack, MonadIO m) => m Switch
- switchSetActive :: (HasCallStack, MonadIO m, IsSwitch a) => a -> Bool -> m ()
- switchSetState :: (HasCallStack, MonadIO m, IsSwitch a) => a -> Bool -> m ()
- constructSwitchActive :: (IsSwitch o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSwitchActive :: (MonadIO m, IsSwitch o) => o -> m Bool
- setSwitchActive :: (MonadIO m, IsSwitch o) => o -> Bool -> m ()
- constructSwitchState :: (IsSwitch o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSwitchState :: (MonadIO m, IsSwitch o) => o -> m Bool
- setSwitchState :: (MonadIO m, IsSwitch o) => o -> Bool -> m ()
- type C_SwitchActivateCallback = Ptr () -> Ptr () -> IO ()
- type SwitchActivateCallback = IO ()
- afterSwitchActivate :: (IsSwitch a, MonadIO m) => a -> SwitchActivateCallback -> m SignalHandlerId
- genClosure_SwitchActivate :: MonadIO m => SwitchActivateCallback -> m (GClosure C_SwitchActivateCallback)
- mk_SwitchActivateCallback :: C_SwitchActivateCallback -> IO (FunPtr C_SwitchActivateCallback)
- noSwitchActivateCallback :: Maybe SwitchActivateCallback
- onSwitchActivate :: (IsSwitch a, MonadIO m) => a -> SwitchActivateCallback -> m SignalHandlerId
- wrap_SwitchActivateCallback :: SwitchActivateCallback -> C_SwitchActivateCallback
- type C_SwitchStateSetCallback = Ptr () -> CInt -> Ptr () -> IO CInt
- type SwitchStateSetCallback = Bool -> IO Bool
- afterSwitchStateSet :: (IsSwitch a, MonadIO m) => a -> SwitchStateSetCallback -> m SignalHandlerId
- genClosure_SwitchStateSet :: MonadIO m => SwitchStateSetCallback -> m (GClosure C_SwitchStateSetCallback)
- mk_SwitchStateSetCallback :: C_SwitchStateSetCallback -> IO (FunPtr C_SwitchStateSetCallback)
- noSwitchStateSetCallback :: Maybe SwitchStateSetCallback
- onSwitchStateSet :: (IsSwitch a, MonadIO m) => a -> SwitchStateSetCallback -> m SignalHandlerId
- wrap_SwitchStateSetCallback :: SwitchStateSetCallback -> C_SwitchStateSetCallback
Exported types
Memory-managed wrapper type.
Instances
| Eq Switch Source # | |
| GObject Switch Source # | |
| Defined in GI.Gtk.Objects.Switch | |
| ManagedPtrNewtype Switch Source # | |
| Defined in GI.Gtk.Objects.Switch Methods toManagedPtr :: Switch -> ManagedPtr Switch | |
| TypedObject Switch Source # | |
| Defined in GI.Gtk.Objects.Switch | |
| HasParentTypes Switch Source # | |
| Defined in GI.Gtk.Objects.Switch | |
| IsGValue (Maybe Switch) Source # | Convert  | 
| Defined in GI.Gtk.Objects.Switch Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Switch -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Switch) | |
| type ParentTypes Switch Source # | |
| Defined in GI.Gtk.Objects.Switch | |
class (GObject o, IsDescendantOf Switch o) => IsSwitch o Source #
Instances
| (GObject o, IsDescendantOf Switch o) => IsSwitch o Source # | |
| Defined in GI.Gtk.Objects.Switch | |
Methods
Click to display all available methods, including inherited ones
Methods
actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateProperty, updateRelation, updateState, watchClosure.
Getters
getAccessibleRole, getActionName, getActionTargetValue, getActive, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getState, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth.
Setters
setActionName, setActionTargetValue, setActive, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDetailedActionName, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setState, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible.
getActive
Arguments
| :: (HasCallStack, MonadIO m, IsSwitch a) | |
| => a | 
 | 
| -> m Bool | 
Gets whether the Switch is in its “on” or “off” state.
getState
Arguments
| :: (HasCallStack, MonadIO m, IsSwitch a) | |
| => a | 
 | 
| -> m Bool | Returns: the underlying state | 
Gets the underlying state of the Switch.
new
Arguments
| :: (HasCallStack, MonadIO m) | |
| => m Switch | Returns: the newly created  | 
Creates a new Switch widget.
setActive
Arguments
| :: (HasCallStack, MonadIO m, IsSwitch a) | |
| => a | 
 | 
| -> Bool | 
 | 
| -> m () | 
Changes the state of self to the desired one.
setState
Arguments
| :: (HasCallStack, MonadIO m, IsSwitch a) | |
| => a | 
 | 
| -> Bool | 
 | 
| -> m () | 
Properties
active
Whether the Switch widget is in its on or off state.
constructSwitchActive :: (IsSwitch o, MonadIO m) => Bool -> m (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
setswitch [ #active:=value ]
state
The backend state that is controlled by the switch. See stateSet for details.
constructSwitchState :: (IsSwitch o, MonadIO m) => Bool -> m (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
setswitch [ #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](#g: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
genClosure_SwitchActivate :: MonadIO m => SwitchActivateCallback -> m (GClosure C_SwitchActivateCallback) Source #
Wrap the callback into a GClosure.
mk_SwitchActivateCallback :: C_SwitchActivateCallback -> IO (FunPtr C_SwitchActivateCallback) Source #
Generate a function pointer callable from C code, from a C_SwitchActivateCallback.
noSwitchActivateCallback :: Maybe SwitchActivateCallback Source #
A convenience synonym for Nothing :: Maybe SwitchActivateCallback
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
wrap_SwitchActivateCallback :: SwitchActivateCallback -> C_SwitchActivateCallback Source #
Wrap a SwitchActivateCallback into a C_SwitchActivateCallback.
stateSet
type C_SwitchStateSetCallback = Ptr () -> CInt -> Ptr () -> IO CInt Source #
Type for the callback on the (unwrapped) C side.
type SwitchStateSetCallback Source #
Arguments
| = Bool | 
 | 
| -> IO Bool | Returns:  | 
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.
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
genClosure_SwitchStateSet :: MonadIO m => SwitchStateSetCallback -> m (GClosure C_SwitchStateSetCallback) Source #
Wrap the callback into a GClosure.
mk_SwitchStateSetCallback :: C_SwitchStateSetCallback -> IO (FunPtr C_SwitchStateSetCallback) Source #
Generate a function pointer callable from C code, from a C_SwitchStateSetCallback.
noSwitchStateSetCallback :: Maybe SwitchStateSetCallback Source #
A convenience synonym for Nothing :: Maybe SwitchStateSetCallback
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