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 |
A SimpleAction
is the obvious simple implementation of the Action
interface. This is the easiest way to create an action for purposes of
adding it to a SimpleActionGroup
.
See also GtkAction
.
Synopsis
- newtype SimpleAction = SimpleAction (ManagedPtr SimpleAction)
- class (GObject o, IsDescendantOf SimpleAction o) => IsSimpleAction o
- toSimpleAction :: (MonadIO m, IsSimpleAction o) => o -> m SimpleAction
- simpleActionNew :: (HasCallStack, MonadIO m) => Text -> Maybe VariantType -> m SimpleAction
- simpleActionNewStateful :: (HasCallStack, MonadIO m) => Text -> Maybe VariantType -> GVariant -> m SimpleAction
- simpleActionSetEnabled :: (HasCallStack, MonadIO m, IsSimpleAction a) => a -> Bool -> m ()
- simpleActionSetState :: (HasCallStack, MonadIO m, IsSimpleAction a) => a -> GVariant -> m ()
- simpleActionSetStateHint :: (HasCallStack, MonadIO m, IsSimpleAction a) => a -> Maybe GVariant -> m ()
- constructSimpleActionEnabled :: (IsSimpleAction o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSimpleActionEnabled :: (MonadIO m, IsSimpleAction o) => o -> m Bool
- setSimpleActionEnabled :: (MonadIO m, IsSimpleAction o) => o -> Bool -> m ()
- constructSimpleActionName :: (IsSimpleAction o, MonadIO m) => Text -> m (GValueConstruct o)
- getSimpleActionName :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe Text)
- constructSimpleActionParameterType :: (IsSimpleAction o, MonadIO m) => VariantType -> m (GValueConstruct o)
- getSimpleActionParameterType :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe VariantType)
- constructSimpleActionState :: (IsSimpleAction o, MonadIO m) => GVariant -> m (GValueConstruct o)
- getSimpleActionState :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe GVariant)
- setSimpleActionState :: (MonadIO m, IsSimpleAction o) => o -> GVariant -> m ()
- getSimpleActionStateType :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe VariantType)
- type SimpleActionActivateCallback = Maybe GVariant -> IO ()
- afterSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => a -> ((?self :: a) => SimpleActionActivateCallback) -> m SignalHandlerId
- onSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => a -> ((?self :: a) => SimpleActionActivateCallback) -> m SignalHandlerId
- type SimpleActionChangeStateCallback = Maybe GVariant -> IO ()
- afterSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => a -> ((?self :: a) => SimpleActionChangeStateCallback) -> m SignalHandlerId
- onSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => a -> ((?self :: a) => SimpleActionChangeStateCallback) -> m SignalHandlerId
Exported types
newtype SimpleAction Source #
Memory-managed wrapper type.
Instances
Eq SimpleAction Source # | |
Defined in GI.Gio.Objects.SimpleAction (==) :: SimpleAction -> SimpleAction -> Bool # (/=) :: SimpleAction -> SimpleAction -> Bool # | |
GObject SimpleAction Source # | |
Defined in GI.Gio.Objects.SimpleAction | |
ManagedPtrNewtype SimpleAction Source # | |
Defined in GI.Gio.Objects.SimpleAction | |
TypedObject SimpleAction Source # | |
Defined in GI.Gio.Objects.SimpleAction | |
HasParentTypes SimpleAction Source # | |
Defined in GI.Gio.Objects.SimpleAction | |
IsGValue (Maybe SimpleAction) Source # | Convert |
Defined in GI.Gio.Objects.SimpleAction gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe SimpleAction -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe SimpleAction) # | |
type ParentTypes SimpleAction Source # | |
Defined in GI.Gio.Objects.SimpleAction |
class (GObject o, IsDescendantOf SimpleAction o) => IsSimpleAction o Source #
Type class for types which can be safely cast to SimpleAction
, for instance with toSimpleAction
.
Instances
(GObject o, IsDescendantOf SimpleAction o) => IsSimpleAction o Source # | |
Defined in GI.Gio.Objects.SimpleAction |
toSimpleAction :: (MonadIO m, IsSimpleAction o) => o -> m SimpleAction Source #
Cast to SimpleAction
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
activate, bindProperty, bindPropertyFull, changeState, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getEnabled, getName, getParameterType, getProperty, getQdata, getState, getStateHint, getStateType.
Setters
setData, setDataFull, setEnabled, setProperty, setState, setStateHint.
new
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Maybe VariantType |
|
-> m SimpleAction | Returns: a new |
Creates a new action.
The created action is stateless. See simpleActionNewStateful
to create
an action that has state.
Since: 2.28
newStateful
simpleActionNewStateful Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Maybe VariantType |
|
-> GVariant |
|
-> m SimpleAction | Returns: a new |
Creates a new stateful action.
All future state values must have the same VariantType
as the initial
state
.
If the state
GVariant
is floating, it is consumed.
Since: 2.28
setEnabled
simpleActionSetEnabled Source #
:: (HasCallStack, MonadIO m, IsSimpleAction a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets the action as enabled or not.
An action must be enabled in order to be activated or in order to have its state changed from outside callers.
This should only be called by the implementor of the action. Users of the action should not attempt to modify its enabled flag.
Since: 2.28
setState
:: (HasCallStack, MonadIO m, IsSimpleAction a) | |
=> a |
|
-> GVariant |
|
-> m () |
Sets the state of the action.
This directly updates the 'state' property to the given value.
This should only be called by the implementor of the action. Users
of the action should not attempt to directly modify the 'state'
property. Instead, they should call actionChangeState
to
request the change.
If the value
GVariant is floating, it is consumed.
Since: 2.30
setStateHint
simpleActionSetStateHint Source #
:: (HasCallStack, MonadIO m, IsSimpleAction a) | |
=> a |
|
-> Maybe GVariant |
|
-> m () |
Sets the state hint for the action.
See actionGetStateHint
for more information about
action state hints.
Since: 2.44
Properties
enabled
If action
is currently enabled.
If the action is disabled then calls to actionActivate
and
actionChangeState
have no effect.
Since: 2.28
constructSimpleActionEnabled :: (IsSimpleAction o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “enabled
” property. This is rarely needed directly, but it is used by new
.
getSimpleActionEnabled :: (MonadIO m, IsSimpleAction o) => o -> m Bool Source #
Get the value of the “enabled
” property.
When overloading is enabled, this is equivalent to
get
simpleAction #enabled
setSimpleActionEnabled :: (MonadIO m, IsSimpleAction o) => o -> Bool -> m () Source #
Set the value of the “enabled
” property.
When overloading is enabled, this is equivalent to
set
simpleAction [ #enabled:=
value ]
name
The name of the action. This is mostly meaningful for identifying
the action once it has been added to a SimpleActionGroup
.
Since: 2.28
constructSimpleActionName :: (IsSimpleAction o, MonadIO m) => Text -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “name
” property. This is rarely needed directly, but it is used by new
.
getSimpleActionName :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe Text) Source #
Get the value of the “name
” property.
When overloading is enabled, this is equivalent to
get
simpleAction #name
parameterType
The type of the parameter that must be given when activating the action.
Since: 2.28
constructSimpleActionParameterType :: (IsSimpleAction o, MonadIO m) => VariantType -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “parameter-type
” property. This is rarely needed directly, but it is used by new
.
getSimpleActionParameterType :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe VariantType) Source #
Get the value of the “parameter-type
” property.
When overloading is enabled, this is equivalent to
get
simpleAction #parameterType
state
The state of the action, or Nothing
if the action is stateless.
Since: 2.28
constructSimpleActionState :: (IsSimpleAction o, MonadIO m) => GVariant -> 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
.
getSimpleActionState :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe GVariant) Source #
Get the value of the “state
” property.
When overloading is enabled, this is equivalent to
get
simpleAction #state
setSimpleActionState :: (MonadIO m, IsSimpleAction o) => o -> GVariant -> m () Source #
Set the value of the “state
” property.
When overloading is enabled, this is equivalent to
set
simpleAction [ #state:=
value ]
stateType
The VariantType
of the state that the action has, or Nothing
if the
action is stateless.
Since: 2.28
getSimpleActionStateType :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe VariantType) Source #
Get the value of the “state-type
” property.
When overloading is enabled, this is equivalent to
get
simpleAction #stateType
Signals
activate
type SimpleActionActivateCallback Source #
= Maybe GVariant |
|
-> IO () |
Indicates that the action was just activated.
parameter
will always be of the expected type, i.e. the parameter type
specified when the action was created. If an incorrect type is given when
activating the action, this signal is not emitted.
Since GLib 2.40, if no handler is connected to this signal then the
default behaviour for boolean-stated actions with a Nothing
parameter
type is to toggle them via the SimpleAction::changeState signal.
For stateful actions where the state type is equal to the parameter
type, the default is to forward them directly to
SimpleAction::changeState. This should allow almost all users
of SimpleAction
to connect only one handler or the other.
Since: 2.28
afterSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => a -> ((?self :: a) => SimpleActionActivateCallback) -> 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
simpleAction #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.
onSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => a -> ((?self :: a) => SimpleActionActivateCallback) -> 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
simpleAction #activate callback
changeState
type SimpleActionChangeStateCallback Source #
Indicates that the action just received a request to change its state.
value
will always be of the correct state type, i.e. the type of the
initial state passed to simpleActionNewStateful
. If an incorrect
type is given when requesting to change the state, this signal is not
emitted.
If no handler is connected to this signal then the default
behaviour is to call simpleActionSetState
to set the state
to the requested value. If you connect a signal handler then no
default action is taken. If the state should change then you must
call simpleActionSetState
from the handler.
An example of a 'change-state' handler:
C code
static void change_volume_state (GSimpleAction *action, GVariant *value, gpointer user_data) { gint requested; requested = g_variant_get_int32 (value); // Volume only goes from 0 to 10 if (0 <= requested && requested <= 10) g_simple_action_set_state (action, value); }
The handler need not set the state to the requested value. It could set it to any value at all, or take some other action.
Since: 2.30
afterSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => a -> ((?self :: a) => SimpleActionChangeStateCallback) -> m SignalHandlerId Source #
Connect a signal handler for the changeState signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
simpleAction #changeState 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.
onSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => a -> ((?self :: a) => SimpleActionChangeStateCallback) -> m SignalHandlerId Source #
Connect a signal handler for the changeState signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
simpleAction #changeState callback