Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
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
- noSimpleAction :: Maybe 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 => Bool -> IO (GValueConstruct o)
- getSimpleActionEnabled :: (MonadIO m, IsSimpleAction o) => o -> m Bool
- setSimpleActionEnabled :: (MonadIO m, IsSimpleAction o) => o -> Bool -> m ()
- constructSimpleActionName :: IsSimpleAction o => Text -> IO (GValueConstruct o)
- getSimpleActionName :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe Text)
- constructSimpleActionParameterType :: IsSimpleAction o => VariantType -> IO (GValueConstruct o)
- getSimpleActionParameterType :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe VariantType)
- constructSimpleActionState :: IsSimpleAction o => GVariant -> IO (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 C_SimpleActionActivateCallback = Ptr () -> Ptr GVariant -> Ptr () -> IO ()
- type SimpleActionActivateCallback = Maybe GVariant -> IO ()
- afterSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => a -> SimpleActionActivateCallback -> m SignalHandlerId
- genClosure_SimpleActionActivate :: MonadIO m => SimpleActionActivateCallback -> m (GClosure C_SimpleActionActivateCallback)
- mk_SimpleActionActivateCallback :: C_SimpleActionActivateCallback -> IO (FunPtr C_SimpleActionActivateCallback)
- noSimpleActionActivateCallback :: Maybe SimpleActionActivateCallback
- onSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => a -> SimpleActionActivateCallback -> m SignalHandlerId
- wrap_SimpleActionActivateCallback :: SimpleActionActivateCallback -> C_SimpleActionActivateCallback
- type C_SimpleActionChangeStateCallback = Ptr () -> Ptr GVariant -> Ptr () -> IO ()
- type SimpleActionChangeStateCallback = Maybe GVariant -> IO ()
- afterSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => a -> SimpleActionChangeStateCallback -> m SignalHandlerId
- genClosure_SimpleActionChangeState :: MonadIO m => SimpleActionChangeStateCallback -> m (GClosure C_SimpleActionChangeStateCallback)
- mk_SimpleActionChangeStateCallback :: C_SimpleActionChangeStateCallback -> IO (FunPtr C_SimpleActionChangeStateCallback)
- noSimpleActionChangeStateCallback :: Maybe SimpleActionChangeStateCallback
- onSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => a -> SimpleActionChangeStateCallback -> m SignalHandlerId
- wrap_SimpleActionChangeStateCallback :: SimpleActionChangeStateCallback -> C_SimpleActionChangeStateCallback
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 gobjectType :: IO GType # | |
IsGValue SimpleAction Source # | Convert |
Defined in GI.Gio.Objects.SimpleAction toGValue :: SimpleAction -> IO GValue # fromGValue :: GValue -> IO SimpleAction # | |
HasParentTypes SimpleAction Source # | |
Defined in GI.Gio.Objects.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
.
noSimpleAction :: Maybe SimpleAction Source #
A convenience alias for Nothing
:: Maybe
SimpleAction
.
Methods
Overloaded methods
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 => Bool -> IO (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 => Text -> IO (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 => VariantType -> IO (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 => GVariant -> 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
.
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 C_SimpleActionActivateCallback = Ptr () -> Ptr GVariant -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
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 changeState signal.
For stateful actions where the state type is equal to the parameter
type, the default is to forward them directly to
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 -> 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
genClosure_SimpleActionActivate :: MonadIO m => SimpleActionActivateCallback -> m (GClosure C_SimpleActionActivateCallback) Source #
Wrap the callback into a GClosure
.
mk_SimpleActionActivateCallback :: C_SimpleActionActivateCallback -> IO (FunPtr C_SimpleActionActivateCallback) Source #
Generate a function pointer callable from C code, from a C_SimpleActionActivateCallback
.
noSimpleActionActivateCallback :: Maybe SimpleActionActivateCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SimpleActionActivateCallback
onSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => 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
wrap_SimpleActionActivateCallback :: SimpleActionActivateCallback -> C_SimpleActionActivateCallback Source #
Wrap a SimpleActionActivateCallback
into a C_SimpleActionActivateCallback
.
changeState
type C_SimpleActionChangeStateCallback = Ptr () -> Ptr GVariant -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
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 -> 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
genClosure_SimpleActionChangeState :: MonadIO m => SimpleActionChangeStateCallback -> m (GClosure C_SimpleActionChangeStateCallback) Source #
Wrap the callback into a GClosure
.
mk_SimpleActionChangeStateCallback :: C_SimpleActionChangeStateCallback -> IO (FunPtr C_SimpleActionChangeStateCallback) Source #
Generate a function pointer callable from C code, from a C_SimpleActionChangeStateCallback
.
noSimpleActionChangeStateCallback :: Maybe SimpleActionChangeStateCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SimpleActionChangeStateCallback
onSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => 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