Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
ActionGroup
represents a group of actions. Actions can be used to
expose functionality in a structured way, either from one part of a
program to another, or to the outside world. Action groups are often
used together with a MenuModel
that provides additional
representation data for displaying the actions to the user, e.g. in
a menu.
The main way to interact with the actions in a GActionGroup is to
activate them with actionGroupActivateAction
. Activating an
action may require a GVariant
parameter. The required type of the
parameter can be inquired with actionGroupGetActionParameterType
.
Actions may be disabled, see actionGroupGetActionEnabled
.
Activating a disabled action has no effect.
Actions may optionally have a state in the form of a GVariant
. The
current state of an action can be inquired with
actionGroupGetActionState
. Activating a stateful action may
change its state, but it is also possible to set the state by calling
actionGroupChangeActionState
.
As typical example, consider a text editing application which has an option to change the current font to 'bold'. A good way to represent this would be a stateful action, with a boolean state. Activating the action would toggle the state.
Each action in the group has a unique name (which is a string). All
method calls, except actionGroupListActions
take the name of
an action as an argument.
The ActionGroup
API is meant to be the 'public' API to the action
group. The calls here are exactly the interaction that 'external
forces' (eg: UI, incoming D-Bus messages, etc.) are supposed to have
with actions. 'Internal' APIs (ie: ones meant only to be accessed by
the action group implementation) are found on subclasses. This is
why you will find - for example - actionGroupGetActionEnabled
but not an equivalent set()
call.
Signals are emitted on the action group in response to state changes on individual actions.
Implementations of ActionGroup
should provide implementations for
the virtual functions actionGroupListActions
and
actionGroupQueryAction
. The other virtual functions should
not be implemented - their "wrappers" are actually implemented with
calls to actionGroupQueryAction
.
- newtype ActionGroup = ActionGroup (ManagedPtr ActionGroup)
- noActionGroup :: Maybe ActionGroup
- class GObject o => IsActionGroup o
- toActionGroup :: IsActionGroup o => o -> IO ActionGroup
- data ActionGroupActionAddedMethodInfo
- actionGroupActionAdded :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m ()
- data ActionGroupActionEnabledChangedMethodInfo
- actionGroupActionEnabledChanged :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> Bool -> m ()
- data ActionGroupActionRemovedMethodInfo
- actionGroupActionRemoved :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m ()
- data ActionGroupActionStateChangedMethodInfo
- actionGroupActionStateChanged :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> GVariant -> m ()
- data ActionGroupActivateActionMethodInfo
- actionGroupActivateAction :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> Maybe GVariant -> m ()
- data ActionGroupChangeActionStateMethodInfo
- actionGroupChangeActionState :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> GVariant -> m ()
- data ActionGroupGetActionEnabledMethodInfo
- actionGroupGetActionEnabled :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m Bool
- data ActionGroupGetActionParameterTypeMethodInfo
- actionGroupGetActionParameterType :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Maybe VariantType)
- data ActionGroupGetActionStateMethodInfo
- actionGroupGetActionState :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Maybe GVariant)
- data ActionGroupGetActionStateHintMethodInfo
- actionGroupGetActionStateHint :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Maybe GVariant)
- data ActionGroupGetActionStateTypeMethodInfo
- actionGroupGetActionStateType :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Maybe VariantType)
- data ActionGroupHasActionMethodInfo
- actionGroupHasAction :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m Bool
- data ActionGroupListActionsMethodInfo
- actionGroupListActions :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> m [Text]
- data ActionGroupQueryActionMethodInfo
- actionGroupQueryAction :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Bool, Bool, VariantType, VariantType, GVariant, GVariant)
- type ActionGroupActionAddedCallback = Text -> IO ()
- data ActionGroupActionAddedSignalInfo
- type C_ActionGroupActionAddedCallback = Ptr () -> CString -> Ptr () -> IO ()
- afterActionGroupActionAdded :: (GObject a, MonadIO m) => a -> ActionGroupActionAddedCallback -> m SignalHandlerId
- genClosure_ActionGroupActionAdded :: ActionGroupActionAddedCallback -> IO Closure
- mk_ActionGroupActionAddedCallback :: C_ActionGroupActionAddedCallback -> IO (FunPtr C_ActionGroupActionAddedCallback)
- noActionGroupActionAddedCallback :: Maybe ActionGroupActionAddedCallback
- onActionGroupActionAdded :: (GObject a, MonadIO m) => a -> ActionGroupActionAddedCallback -> m SignalHandlerId
- wrap_ActionGroupActionAddedCallback :: ActionGroupActionAddedCallback -> Ptr () -> CString -> Ptr () -> IO ()
- type ActionGroupActionEnabledChangedCallback = Text -> Bool -> IO ()
- data ActionGroupActionEnabledChangedSignalInfo
- type C_ActionGroupActionEnabledChangedCallback = Ptr () -> CString -> CInt -> Ptr () -> IO ()
- afterActionGroupActionEnabledChanged :: (GObject a, MonadIO m) => a -> ActionGroupActionEnabledChangedCallback -> m SignalHandlerId
- genClosure_ActionGroupActionEnabledChanged :: ActionGroupActionEnabledChangedCallback -> IO Closure
- mk_ActionGroupActionEnabledChangedCallback :: C_ActionGroupActionEnabledChangedCallback -> IO (FunPtr C_ActionGroupActionEnabledChangedCallback)
- noActionGroupActionEnabledChangedCallback :: Maybe ActionGroupActionEnabledChangedCallback
- onActionGroupActionEnabledChanged :: (GObject a, MonadIO m) => a -> ActionGroupActionEnabledChangedCallback -> m SignalHandlerId
- wrap_ActionGroupActionEnabledChangedCallback :: ActionGroupActionEnabledChangedCallback -> Ptr () -> CString -> CInt -> Ptr () -> IO ()
- type ActionGroupActionRemovedCallback = Text -> IO ()
- data ActionGroupActionRemovedSignalInfo
- type C_ActionGroupActionRemovedCallback = Ptr () -> CString -> Ptr () -> IO ()
- afterActionGroupActionRemoved :: (GObject a, MonadIO m) => a -> ActionGroupActionRemovedCallback -> m SignalHandlerId
- genClosure_ActionGroupActionRemoved :: ActionGroupActionRemovedCallback -> IO Closure
- mk_ActionGroupActionRemovedCallback :: C_ActionGroupActionRemovedCallback -> IO (FunPtr C_ActionGroupActionRemovedCallback)
- noActionGroupActionRemovedCallback :: Maybe ActionGroupActionRemovedCallback
- onActionGroupActionRemoved :: (GObject a, MonadIO m) => a -> ActionGroupActionRemovedCallback -> m SignalHandlerId
- wrap_ActionGroupActionRemovedCallback :: ActionGroupActionRemovedCallback -> Ptr () -> CString -> Ptr () -> IO ()
- type ActionGroupActionStateChangedCallback = Text -> GVariant -> IO ()
- data ActionGroupActionStateChangedSignalInfo
- type C_ActionGroupActionStateChangedCallback = Ptr () -> CString -> Ptr GVariant -> Ptr () -> IO ()
- afterActionGroupActionStateChanged :: (GObject a, MonadIO m) => a -> ActionGroupActionStateChangedCallback -> m SignalHandlerId
- genClosure_ActionGroupActionStateChanged :: ActionGroupActionStateChangedCallback -> IO Closure
- mk_ActionGroupActionStateChangedCallback :: C_ActionGroupActionStateChangedCallback -> IO (FunPtr C_ActionGroupActionStateChangedCallback)
- noActionGroupActionStateChangedCallback :: Maybe ActionGroupActionStateChangedCallback
- onActionGroupActionStateChanged :: (GObject a, MonadIO m) => a -> ActionGroupActionStateChangedCallback -> m SignalHandlerId
- wrap_ActionGroupActionStateChangedCallback :: ActionGroupActionStateChangedCallback -> Ptr () -> CString -> Ptr GVariant -> Ptr () -> IO ()
Exported types
newtype ActionGroup Source #
GObject ActionGroup Source # | |
IsObject ActionGroup Source # | |
IsActionGroup ActionGroup Source # | |
((~) * info (ResolveActionGroupMethod t ActionGroup), MethodInfo * info ActionGroup p) => IsLabel t (ActionGroup -> p) Source # | |
((~) * info (ResolveActionGroupMethod t ActionGroup), MethodInfo * info ActionGroup p) => IsLabelProxy t (ActionGroup -> p) Source # | |
HasAttributeList * ActionGroup Source # | |
type AttributeList ActionGroup Source # | |
type SignalList ActionGroup Source # | |
class GObject o => IsActionGroup o Source #
toActionGroup :: IsActionGroup o => o -> IO ActionGroup Source #
Methods
actionAdded
data ActionGroupActionAddedMethodInfo Source #
((~) * signature (Text -> m ()), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupActionAddedMethodInfo a signature Source # | |
actionGroupActionAdded Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m () |
Emits the ActionGroup
::action-added
signal on actionGroup
.
This function should only be called by ActionGroup
implementations.
Since: 2.28
actionEnabledChanged
data ActionGroupActionEnabledChangedMethodInfo Source #
((~) * signature (Text -> Bool -> m ()), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupActionEnabledChangedMethodInfo a signature Source # | |
actionGroupActionEnabledChanged Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> Bool |
|
-> m () |
Emits the ActionGroup
::action-enabled-changed
signal on actionGroup
.
This function should only be called by ActionGroup
implementations.
Since: 2.28
actionRemoved
data ActionGroupActionRemovedMethodInfo Source #
((~) * signature (Text -> m ()), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupActionRemovedMethodInfo a signature Source # | |
actionGroupActionRemoved Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m () |
Emits the ActionGroup
::action-removed
signal on actionGroup
.
This function should only be called by ActionGroup
implementations.
Since: 2.28
actionStateChanged
data ActionGroupActionStateChangedMethodInfo Source #
((~) * signature (Text -> GVariant -> m ()), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupActionStateChangedMethodInfo a signature Source # | |
actionGroupActionStateChanged Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> GVariant |
|
-> m () |
Emits the ActionGroup
::action-state-changed
signal on actionGroup
.
This function should only be called by ActionGroup
implementations.
Since: 2.28
activateAction
data ActionGroupActivateActionMethodInfo Source #
((~) * signature (Text -> Maybe GVariant -> m ()), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupActivateActionMethodInfo a signature Source # | |
actionGroupActivateAction Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> Maybe GVariant |
|
-> m () |
Activate the named action within actionGroup
.
If the action is expecting a parameter, then the correct type of
parameter must be given as parameter
. If the action is expecting no
parameters then parameter
must be Nothing
. See
actionGroupGetActionParameterType
.
Since: 2.28
changeActionState
data ActionGroupChangeActionStateMethodInfo Source #
((~) * signature (Text -> GVariant -> m ()), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupChangeActionStateMethodInfo a signature Source # | |
actionGroupChangeActionState Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> GVariant |
|
-> m () |
Request for the state of the named action within actionGroup
to be
changed to value
.
The action must be stateful and value
must be of the correct type.
See actionGroupGetActionStateType
.
This call merely requests a change. The action may refuse to change
its state or may change its state to something other than value
.
See actionGroupGetActionStateHint
.
If the value
GVariant is floating, it is consumed.
Since: 2.28
getActionEnabled
data ActionGroupGetActionEnabledMethodInfo Source #
((~) * signature (Text -> m Bool), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupGetActionEnabledMethodInfo a signature Source # | |
actionGroupGetActionEnabled Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m Bool | Returns: whether or not the action is currently enabled |
Checks if the named action within actionGroup
is currently enabled.
An action must be enabled in order to be activated or in order to have its state changed from outside callers.
Since: 2.28
getActionParameterType
data ActionGroupGetActionParameterTypeMethodInfo Source #
((~) * signature (Text -> m (Maybe VariantType)), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupGetActionParameterTypeMethodInfo a signature Source # | |
actionGroupGetActionParameterType Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m (Maybe VariantType) | Returns: the parameter type |
Queries the type of the parameter that must be given when activating
the named action within actionGroup
.
When activating the action using actionGroupActivateAction
,
the GVariant
given to that function must be of the type returned
by this function.
In the case that this function returns Nothing
, you must not give any
GVariant
, but Nothing
instead.
The parameter type of a particular action will never change but it is possible for an action to be removed and for a new action to be added with the same name but a different parameter type.
Since: 2.28
getActionState
data ActionGroupGetActionStateMethodInfo Source #
((~) * signature (Text -> m (Maybe GVariant)), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupGetActionStateMethodInfo a signature Source # | |
actionGroupGetActionState Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m (Maybe GVariant) | Returns: the current state of the action |
Queries the current state of the named action within actionGroup
.
If the action is not stateful then Nothing
will be returned. If the
action is stateful then the type of the return value is the type
given by actionGroupGetActionStateType
.
The return value (if non-Nothing
) should be freed with
variantUnref
when it is no longer required.
Since: 2.28
getActionStateHint
data ActionGroupGetActionStateHintMethodInfo Source #
((~) * signature (Text -> m (Maybe GVariant)), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupGetActionStateHintMethodInfo a signature Source # | |
actionGroupGetActionStateHint Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m (Maybe GVariant) | Returns: the state range hint |
Requests a hint about the valid range of values for the state of the
named action within actionGroup
.
If Nothing
is returned it either means that the action is not stateful
or that there is no hint about the valid range of values for the
state of the action.
If a GVariant
array is returned then each item in the array is a
possible value for the state. If a GVariant
pair (ie: two-tuple) is
returned then the tuple specifies the inclusive lower and upper bound
of valid values for the state.
In any case, the information is merely a hint. It may be possible to have a state value outside of the hinted range and setting a value within the range may fail.
The return value (if non-Nothing
) should be freed with
variantUnref
when it is no longer required.
Since: 2.28
getActionStateType
data ActionGroupGetActionStateTypeMethodInfo Source #
((~) * signature (Text -> m (Maybe VariantType)), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupGetActionStateTypeMethodInfo a signature Source # | |
actionGroupGetActionStateType Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m (Maybe VariantType) | Returns: the state type, if the action is stateful |
Queries the type of the state of the named action within
actionGroup
.
If the action is stateful then this function returns the
VariantType
of the state. All calls to
actionGroupChangeActionState
must give a GVariant
of this
type and actionGroupGetActionState
will return a GVariant
of the same type.
If the action is not stateful then this function will return Nothing
.
In that case, actionGroupGetActionState
will return Nothing
and you must not call actionGroupChangeActionState
.
The state type of a particular action will never change but it is possible for an action to be removed and for a new action to be added with the same name but a different state type.
Since: 2.28
hasAction
data ActionGroupHasActionMethodInfo Source #
((~) * signature (Text -> m Bool), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupHasActionMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m Bool | Returns: whether the named action exists |
Checks if the named action exists within actionGroup
.
Since: 2.28
listActions
data ActionGroupListActionsMethodInfo Source #
((~) * signature (m [Text]), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupListActionsMethodInfo a signature Source # | |
actionGroupListActions Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> m [Text] | Returns: a |
Lists the actions contained within actionGroup
.
The caller is responsible for freeing the list with strfreev
when
it is no longer required.
Since: 2.28
queryAction
data ActionGroupQueryActionMethodInfo Source #
((~) * signature (Text -> m (Bool, Bool, VariantType, VariantType, GVariant, GVariant)), MonadIO m, IsActionGroup a) => MethodInfo * ActionGroupQueryActionMethodInfo a signature Source # | |
actionGroupQueryAction Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m (Bool, Bool, VariantType, VariantType, GVariant, GVariant) |
Queries all aspects of the named action within an actionGroup
.
This function acquires the information available from
actionGroupHasAction
, actionGroupGetActionEnabled
,
actionGroupGetActionParameterType
,
actionGroupGetActionStateType
,
actionGroupGetActionStateHint
and
actionGroupGetActionState
with a single function call.
This provides two main benefits.
The first is the improvement in efficiency that comes with not having
to perform repeated lookups of the action in order to discover
different things about it. The second is that implementing
ActionGroup
can now be done by only overriding this one virtual
function.
The interface provides a default implementation of this function that calls the individual functions, as required, to fetch the information. The interface also provides default implementations of those functions that call this function. All implementations, therefore, must override either this function or all of the others.
If the action exists, True
is returned and any of the requested
fields (as indicated by having a non-Nothing
reference passed in) are
filled. If the action doesn't exist, False
is returned and the
fields may or may not have been modified.
Since: 2.32
Signals
actionAdded
type ActionGroupActionAddedCallback = Text -> IO () Source #
afterActionGroupActionAdded :: (GObject a, MonadIO m) => a -> ActionGroupActionAddedCallback -> m SignalHandlerId Source #
mk_ActionGroupActionAddedCallback :: C_ActionGroupActionAddedCallback -> IO (FunPtr C_ActionGroupActionAddedCallback) Source #
onActionGroupActionAdded :: (GObject a, MonadIO m) => a -> ActionGroupActionAddedCallback -> m SignalHandlerId Source #
wrap_ActionGroupActionAddedCallback :: ActionGroupActionAddedCallback -> Ptr () -> CString -> Ptr () -> IO () Source #
actionEnabledChanged
type C_ActionGroupActionEnabledChangedCallback = Ptr () -> CString -> CInt -> Ptr () -> IO () Source #
afterActionGroupActionEnabledChanged :: (GObject a, MonadIO m) => a -> ActionGroupActionEnabledChangedCallback -> m SignalHandlerId Source #
genClosure_ActionGroupActionEnabledChanged :: ActionGroupActionEnabledChangedCallback -> IO Closure Source #
mk_ActionGroupActionEnabledChangedCallback :: C_ActionGroupActionEnabledChangedCallback -> IO (FunPtr C_ActionGroupActionEnabledChangedCallback) Source #
onActionGroupActionEnabledChanged :: (GObject a, MonadIO m) => a -> ActionGroupActionEnabledChangedCallback -> m SignalHandlerId Source #
wrap_ActionGroupActionEnabledChangedCallback :: ActionGroupActionEnabledChangedCallback -> Ptr () -> CString -> CInt -> Ptr () -> IO () Source #
actionRemoved
type ActionGroupActionRemovedCallback = Text -> IO () Source #
afterActionGroupActionRemoved :: (GObject a, MonadIO m) => a -> ActionGroupActionRemovedCallback -> m SignalHandlerId Source #
mk_ActionGroupActionRemovedCallback :: C_ActionGroupActionRemovedCallback -> IO (FunPtr C_ActionGroupActionRemovedCallback) Source #
onActionGroupActionRemoved :: (GObject a, MonadIO m) => a -> ActionGroupActionRemovedCallback -> m SignalHandlerId Source #
wrap_ActionGroupActionRemovedCallback :: ActionGroupActionRemovedCallback -> Ptr () -> CString -> Ptr () -> IO () Source #
actionStateChanged
type C_ActionGroupActionStateChangedCallback = Ptr () -> CString -> Ptr GVariant -> Ptr () -> IO () Source #
afterActionGroupActionStateChanged :: (GObject a, MonadIO m) => a -> ActionGroupActionStateChangedCallback -> m SignalHandlerId Source #
genClosure_ActionGroupActionStateChanged :: ActionGroupActionStateChangedCallback -> IO Closure Source #
mk_ActionGroupActionStateChangedCallback :: C_ActionGroupActionStateChangedCallback -> IO (FunPtr C_ActionGroupActionStateChangedCallback) Source #
onActionGroupActionStateChanged :: (GObject a, MonadIO m) => a -> ActionGroupActionStateChangedCallback -> m SignalHandlerId Source #
wrap_ActionGroupActionStateChangedCallback :: ActionGroupActionStateChangedCallback -> Ptr () -> CString -> Ptr GVariant -> Ptr () -> IO () Source #