Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
GtkSwitch
is a "light switch" 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 slider.
GtkSwitch
can also express situations where the underlying state changes
with a delay. In this case, the slider position indicates the user's recent
change (represented by the Switch:active property), while the
trough color indicates the present underlying state (represented by the
Switch:state property).
See Switch::stateSet for details.
Shortcuts and Gestures
GtkSwitch
supports pan and drag gestures to move the slider.
CSS nodes
switch ├── image ├── image ╰── slider
GtkSwitch
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
GtkSwitch
uses the AccessibleRoleSwitch
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 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 | |
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, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, 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, updateNextAccessibleSibling, updateProperty, updateRelation, updateState, watchClosure.
Getters
getAccessibleParent, getAccessibleRole, getActionName, getActionTargetValue, getActive, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextAccessibleSibling, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPlatformState, 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
setAccessibleParent, 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
:: (HasCallStack, MonadIO m, IsSwitch a) | |
=> a |
|
-> m Bool | Returns: |
Gets whether the GtkSwitch
is in its “on” or “off” state.
getState
:: (HasCallStack, MonadIO m, IsSwitch a) | |
=> a |
|
-> m Bool | Returns: the underlying state |
Gets the underlying state of the GtkSwitch
.
new
:: (HasCallStack, MonadIO m) | |
=> m Switch | Returns: the newly created |
Creates a new GtkSwitch
widget.
setActive
:: (HasCallStack, MonadIO m, IsSwitch a) | |
=> a |
|
-> Bool |
|
-> m () |
Changes the state of self
to the desired one.
setState
:: (HasCallStack, MonadIO m, IsSwitch a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets the underlying state of the GtkSwitch
.
This function is typically called from a Switch::stateSet signal handler in order to set up delayed state changes.
See Switch::stateSet for details.
Properties
active
Whether the GtkSwitch
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.
Applications should usually set the Switch:active property, except when indicating a change to the backend state which occurs separately from the user's interaction.
See Switch::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
set
switch [ #state:=
value ]
Signals
activate
type SwitchActivateCallback = IO () Source #
Emitted to animate the switch.
Applications should never connect to this signal, but use the Switch:active property.
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 #
Emitted to change the underlying state.
The stateSet signal is emitted when the user changes the switch
position. The default handler calls switchSetState
with the
value of state
.
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.
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