Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
GActionGroup
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 [typegio
.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 [typegLib
.Variant] 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 [typegLib
.Variant]. 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 GActionGroup
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_action_enabled()
method.
Signals are emitted on the action group in response to state changes on individual actions.
Implementations of GActionGroup
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
.
Synopsis
- newtype ActionGroup = ActionGroup (ManagedPtr ActionGroup)
- class (GObject o, IsDescendantOf ActionGroup o) => IsActionGroup o
- toActionGroup :: (MonadIO m, IsActionGroup o) => o -> m ActionGroup
- actionGroupActionAdded :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m ()
- actionGroupActionEnabledChanged :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> Bool -> m ()
- actionGroupActionRemoved :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m ()
- actionGroupActionStateChanged :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> GVariant -> m ()
- actionGroupActivateAction :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> Maybe GVariant -> m ()
- actionGroupChangeActionState :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> GVariant -> m ()
- actionGroupGetActionEnabled :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m Bool
- actionGroupGetActionParameterType :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Maybe VariantType)
- actionGroupGetActionState :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Maybe GVariant)
- actionGroupGetActionStateHint :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Maybe GVariant)
- actionGroupGetActionStateType :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Maybe VariantType)
- actionGroupHasAction :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m Bool
- actionGroupListActions :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> m [Text]
- actionGroupQueryAction :: (HasCallStack, MonadIO m, IsActionGroup a) => a -> Text -> m (Bool, Bool, VariantType, VariantType, GVariant, GVariant)
- type ActionGroupActionAddedCallback = Text -> IO ()
- afterActionGroupActionAdded :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionAddedCallback) -> m SignalHandlerId
- onActionGroupActionAdded :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionAddedCallback) -> m SignalHandlerId
- type ActionGroupActionEnabledChangedCallback = Text -> Bool -> IO ()
- afterActionGroupActionEnabledChanged :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionEnabledChangedCallback) -> m SignalHandlerId
- onActionGroupActionEnabledChanged :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionEnabledChangedCallback) -> m SignalHandlerId
- type ActionGroupActionRemovedCallback = Text -> IO ()
- afterActionGroupActionRemoved :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionRemovedCallback) -> m SignalHandlerId
- onActionGroupActionRemoved :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionRemovedCallback) -> m SignalHandlerId
- type ActionGroupActionStateChangedCallback = Text -> GVariant -> IO ()
- afterActionGroupActionStateChanged :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionStateChangedCallback) -> m SignalHandlerId
- onActionGroupActionStateChanged :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionStateChangedCallback) -> m SignalHandlerId
Exported types
newtype ActionGroup Source #
Memory-managed wrapper type.
Instances
Eq ActionGroup Source # | |
Defined in GI.Gio.Interfaces.ActionGroup (==) :: ActionGroup -> ActionGroup -> Bool # (/=) :: ActionGroup -> ActionGroup -> Bool # | |
GObject ActionGroup Source # | |
Defined in GI.Gio.Interfaces.ActionGroup | |
ManagedPtrNewtype ActionGroup Source # | |
Defined in GI.Gio.Interfaces.ActionGroup | |
TypedObject ActionGroup Source # | |
Defined in GI.Gio.Interfaces.ActionGroup | |
HasParentTypes ActionGroup Source # | |
Defined in GI.Gio.Interfaces.ActionGroup | |
IsGValue (Maybe ActionGroup) Source # | Convert |
Defined in GI.Gio.Interfaces.ActionGroup gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe ActionGroup -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe ActionGroup) # | |
type ParentTypes ActionGroup Source # | |
Defined in GI.Gio.Interfaces.ActionGroup |
class (GObject o, IsDescendantOf ActionGroup o) => IsActionGroup o Source #
Type class for types which can be safely cast to ActionGroup
, for instance with toActionGroup
.
Instances
(GObject o, IsDescendantOf ActionGroup o) => IsActionGroup o Source # | |
Defined in GI.Gio.Interfaces.ActionGroup |
toActionGroup :: (MonadIO m, IsActionGroup o) => o -> m ActionGroup Source #
Cast to ActionGroup
, 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
actionAdded, actionEnabledChanged, actionRemoved, actionStateChanged, activateAction, bindProperty, bindPropertyFull, changeActionState, forceFloating, freezeNotify, getv, hasAction, isFloating, listActions, notify, notifyByPspec, queryAction, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getActionEnabled, getActionParameterType, getActionState, getActionStateHint, getActionStateType, getData, getProperty, getQdata.
Setters
actionAdded
actionGroupActionAdded Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m () |
Emits the ActionGroup::actionAdded signal on actionGroup
.
This function should only be called by [typegio
.ActionGroup] implementations.
Since: 2.28
actionEnabledChanged
actionGroupActionEnabledChanged Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> Bool |
|
-> m () |
Emits the ActionGroup::actionEnabledChanged signal on actionGroup
.
This function should only be called by [typegio
.ActionGroup] implementations.
Since: 2.28
actionRemoved
actionGroupActionRemoved Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m () |
Emits the ActionGroup::actionRemoved signal on actionGroup
.
This function should only be called by [typegio
.ActionGroup] implementations.
Since: 2.28
actionStateChanged
actionGroupActionStateChanged Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> GVariant |
|
-> m () |
Emits the ActionGroup::actionStateChanged signal on actionGroup
.
This function should only be called by [typegio
.ActionGroup] implementations.
Since: 2.28
activateAction
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 NULL
. See
actionGroupGetActionParameterType
.
If the [typegio
.ActionGroup] implementation supports asynchronous remote
activation over D-Bus, this call may return before the relevant
D-Bus traffic has been sent, or any replies have been received. In
order to block on such asynchronous activation calls,
dBusConnectionFlush
should be called prior to the code, which
depends on the result of the action activation. Without flushing
the D-Bus connection, there is no guarantee that the action would
have been activated.
The following code which runs in a remote app instance, shows an
example of a ‘quit’ action being activated on the primary app
instance over D-Bus. Here dBusConnectionFlush
is called
before exit()
. Without g_dbus_connection_flush()
, the ‘quit’ action
may fail to be activated on the primary instance.
c code
// call ‘quit’ action on primary instance g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL); // make sure the action is activated now g_dbus_connection_flush (…); g_debug ("Application has been terminated. Exiting."); exit (0);
Since: 2.28
changeActionState
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
actionGroupGetActionEnabled Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m Bool | Returns: whether 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
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 [typegLib
.Variant] given to that function must be of the type returned
by this function.
In the case that this function returns NULL
, you must not give any
[typegLib
.Variant], but NULL
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
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 NULL
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-NULL
) should be freed with
variantUnref
when it is no longer required.
Since: 2.28
getActionStateHint
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 NULL
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 [typegLib
.Variant] array is returned then each item in the array is a
possible value for the state. If a [typegLib
.Variant] 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-NULL
) should be freed with
variantUnref
when it is no longer required.
Since: 2.28
getActionStateType
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
[typegLib
.VariantType] of the state. All calls to
actionGroupChangeActionState
must give a [typegLib
.Variant] of this
type and actionGroupGetActionState
will return a [typegLib
.Variant]
of the same type.
If the action is not stateful then this function will return NULL
.
In that case, actionGroupGetActionState
will return NULL
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
:: (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
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
actionGroupQueryAction Source #
:: (HasCallStack, MonadIO m, IsActionGroup a) | |
=> a |
|
-> Text |
|
-> m (Bool, Bool, VariantType, VariantType, GVariant, GVariant) | Returns: |
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
[typegio
.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-NULL
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 Source #
Signals that a new action was just added to the group.
This signal is emitted after the action has been added and is now visible.
Since: 2.28
afterActionGroupActionAdded :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionAddedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the actionAdded signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
actionGroup #actionAdded callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “action-added::detail
” instead.
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.
onActionGroupActionAdded :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionAddedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the actionAdded signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
actionGroup #actionAdded callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “action-added::detail
” instead.
actionEnabledChanged
type ActionGroupActionEnabledChangedCallback Source #
= Text |
|
-> Bool |
|
-> IO () |
Signals that the enabled status of the named action has changed.
Since: 2.28
afterActionGroupActionEnabledChanged :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionEnabledChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the actionEnabledChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
actionGroup #actionEnabledChanged callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “action-enabled-changed::detail
” instead.
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.
onActionGroupActionEnabledChanged :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionEnabledChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the actionEnabledChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
actionGroup #actionEnabledChanged callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “action-enabled-changed::detail
” instead.
actionRemoved
type ActionGroupActionRemovedCallback Source #
Signals that an action is just about to be removed from the group.
This signal is emitted before the action is removed, so the action is still visible and can be queried from the signal handler.
Since: 2.28
afterActionGroupActionRemoved :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionRemovedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the actionRemoved signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
actionGroup #actionRemoved callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “action-removed::detail
” instead.
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.
onActionGroupActionRemoved :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionRemovedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the actionRemoved signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
actionGroup #actionRemoved callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “action-removed::detail
” instead.
actionStateChanged
type ActionGroupActionStateChangedCallback Source #
= Text |
|
-> GVariant |
|
-> IO () |
Signals that the state of the named action has changed.
Since: 2.28
afterActionGroupActionStateChanged :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionStateChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the actionStateChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
actionGroup #actionStateChanged callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “action-state-changed::detail
” instead.
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.
onActionGroupActionStateChanged :: (IsActionGroup a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => ActionGroupActionStateChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the actionStateChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
actionGroup #actionStateChanged callback
This signal admits a optional parameter detail
.
If it's not Nothing
, we will connect to “action-state-changed::detail
” instead.