Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 Switch::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
- 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 SwitchActivateCallback = IO ()
- afterSwitchActivate :: (IsSwitch a, MonadIO m) => a -> ((?self :: a) => SwitchActivateCallback) -> m SignalHandlerId
- onSwitchActivate :: (IsSwitch a, MonadIO m) => a -> ((?self :: a) => SwitchActivateCallback) -> m SignalHandlerId
- type SwitchStateSetCallback = Bool -> IO Bool
- afterSwitchStateSet :: (IsSwitch a, MonadIO m) => a -> ((?self :: a) => SwitchStateSetCallback) -> m SignalHandlerId
- onSwitchStateSet :: (IsSwitch a, MonadIO m) => a -> ((?self :: a) => SwitchStateSetCallback) -> m SignalHandlerId
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 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 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
activate, addAccelerator, addChild, addDeviceEvents, addEvents, addMnemonicLabel, addTickCallback, bindProperty, bindPropertyFull, canActivateAccel, childFocus, childNotify, classPath, computeExpand, constructChild, createPangoContext, createPangoLayout, customFinished, customTagEnd, customTagStart, destroy, destroyed, deviceIsShadowed, doSetRelatedAction, dragBegin, dragBeginWithCoordinates, dragCheckThreshold, dragDestAddImageTargets, dragDestAddTextTargets, dragDestAddUriTargets, dragDestFindTarget, dragDestGetTargetList, dragDestGetTrackMotion, dragDestSet, dragDestSetProxy, dragDestSetTargetList, dragDestSetTrackMotion, dragDestUnset, dragGetData, dragHighlight, dragSourceAddImageTargets, dragSourceAddTextTargets, dragSourceAddUriTargets, dragSourceGetTargetList, dragSourceSet, dragSourceSetIconGicon, dragSourceSetIconName, dragSourceSetIconPixbuf, dragSourceSetIconStock, dragSourceSetTargetList, dragSourceUnset, dragUnhighlight, draw, ensureStyle, errorBell, event, forceFloating, freezeChildNotify, freezeNotify, getv, grabAdd, grabDefault, grabFocus, grabRemove, hasDefault, hasFocus, hasGrab, hasRcStyle, hasScreen, hasVisibleFocus, hide, hideOnDelete, inDestruction, initTemplate, inputShapeCombineRegion, insertActionGroup, intersect, isAncestor, isComposited, isDrawable, isFloating, isFocus, isSensitive, isToplevel, isVisible, keynavFailed, listAccelClosures, listActionPrefixes, listMnemonicLabels, map, mnemonicActivate, modifyBase, modifyBg, modifyCursor, modifyFg, modifyFont, modifyStyle, modifyText, notify, notifyByPspec, overrideBackgroundColor, overrideColor, overrideCursor, overrideFont, overrideSymbolicColor, parserFinished, path, queueAllocate, queueComputeExpand, queueDraw, queueDrawArea, queueDrawRegion, queueResize, queueResizeNoRedraw, realize, ref, refSink, regionIntersect, registerWindow, removeAccelerator, removeMnemonicLabel, removeTickCallback, renderIcon, renderIconPixbuf, reparent, resetRcStyles, resetStyle, runDispose, sendExpose, sendFocusChange, shapeCombineRegion, show, showAll, showNow, sizeAllocate, sizeAllocateWithBaseline, sizeRequest, stealData, stealQdata, styleAttach, styleGetProperty, syncActionProperties, thawChildNotify, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unregisterWindow, unsetStateFlags, watchClosure.
Getters
getAccessible, getActionGroup, getActionName, getActionTargetValue, getActive, getAllocatedBaseline, getAllocatedHeight, getAllocatedSize, getAllocatedWidth, getAllocation, getAncestor, getAppPaintable, getCanDefault, getCanFocus, getChildRequisition, getChildVisible, getClip, getClipboard, getCompositeName, getData, getDeviceEnabled, getDeviceEvents, getDirection, getDisplay, getDoubleBuffered, getEvents, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHasWindow, getHexpand, getHexpandSet, getInternalChild, getMapped, getMarginBottom, getMarginEnd, getMarginLeft, getMarginRight, getMarginStart, getMarginTop, getModifierMask, getModifierStyle, getName, getNoShowAll, getOpacity, getPangoContext, getParent, getParentWindow, getPath, getPointer, getPreferredHeight, getPreferredHeightAndBaselineForWidth, getPreferredHeightForWidth, getPreferredSize, getPreferredWidth, getPreferredWidthForHeight, getProperty, getQdata, getRealized, getReceivesDefault, getRelatedAction, getRequestMode, getRequisition, getRootWindow, getScaleFactor, getScreen, getSensitive, getSettings, getSizeRequest, getState, getStateFlags, getStyle, getStyleContext, getSupportMultidevice, getTemplateChild, getTooltipMarkup, getTooltipText, getTooltipWindow, getToplevel, getUseActionAppearance, getValign, getValignWithBaseline, getVexpand, getVexpandSet, getVisible, getVisual, getWindow.
Setters
setAccelPath, setActionName, setActionTargetValue, setActive, setAllocation, setAppPaintable, setBuildableProperty, setCanDefault, setCanFocus, setChildVisible, setClip, setCompositeName, setData, setDataFull, setDetailedActionName, setDeviceEnabled, setDeviceEvents, setDirection, setDoubleBuffered, setEvents, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHasWindow, setHexpand, setHexpandSet, setMapped, setMarginBottom, setMarginEnd, setMarginLeft, setMarginRight, setMarginStart, setMarginTop, setName, setNoShowAll, setOpacity, setParent, setParentWindow, setProperty, setRealized, setReceivesDefault, setRedrawOnAllocate, setRelatedAction, setSensitive, setSizeRequest, setState, setStateFlags, setStyle, setSupportMultidevice, setTooltipMarkup, setTooltipText, setTooltipWindow, setUseActionAppearance, setValign, setVexpand, setVexpandSet, setVisible, setVisual, setWindow.
getActive
:: (HasCallStack, MonadIO m, IsSwitch a) | |
=> a |
|
-> m Bool |
Gets whether the Switch
is in its “on” or “off” state.
Since: 3.0
getState
:: (HasCallStack, MonadIO m, IsSwitch a) | |
=> a |
|
-> m Bool | Returns: the underlying state |
Gets the underlying state of the Switch
.
Since: 3.14
new
:: (HasCallStack, MonadIO m) | |
=> m Switch | Returns: the newly created |
Creates a new Switch
widget.
Since: 3.0
setActive
:: (HasCallStack, MonadIO m, IsSwitch a) | |
=> a |
|
-> Bool | |
-> m () |
Changes the state of sw
to the desired one.
Since: 3.0
setState
:: (HasCallStack, MonadIO m, IsSwitch a) | |
=> a |
|
-> Bool |
|
-> 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 Switch::stateSet signal handler.
See Switch::stateSet for details.
Since: 3.14
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
set
switch [ #active:=
value ]
state
The backend state that is controlled by the switch. See Switch::stateSet for details.
Since: 3.14
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
set
switch [ #state:=
value ]
Signals
activate
type SwitchActivateCallback = IO () Source #
afterSwitchActivate :: (IsSwitch a, MonadIO m) => a -> ((?self :: 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
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onSwitchActivate :: (IsSwitch a, MonadIO m) => a -> ((?self :: 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 SwitchStateSetCallback Source #
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 -> ((?self :: 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
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onSwitchStateSet :: (IsSwitch a, MonadIO m) => a -> ((?self :: 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