It derives from <GObject>.
A <GSimpleAction> is the obvious simple
implementation of the <GAction> interface. This is
the easiest way to create an action for purposes of adding it to a
<GSimpleActionGroup>.
If action is currently enabled.
If the action is disabled then calls to action:activate and action:change-state have no effect.
Its value is a boolean.
Set it with (set! (simple-action:enabled self) value).
The name of the action. This is mostly meaningful for identifying the
action once it has been added to a
<GSimpleActionGroup>.
Its value is a string, or #f.
It can only be set when the object is made, with #:name.
The type of the parameter that must be given when activating the action.
Its value is a <GVariantType>, or
#f.
It can only be set when the object is made, with
#:parameter-type.
The state of the action, or #f if the action is stateless.
Its value is a <GVariant>, or #f.
Set it with (set! (simple-action:state self) value).
The <GVariantType> of the state that the
action has, or #f if the action is stateless.
Its value is a <GVariantType>, or
#f.
It is read only.
Creates a new action.
The created action is stateless. See simple-action:new-stateful to create an action that has
state.
Passed: a string.
the name of the action
Passed, or left out: a <GVariantType>, or
#f.
the type of parameter that will be passed to handlers for the
simple-action:activate
signal, or #f for no parameter
Returned: a <GSimpleAction>.
a new <GSimpleAction>
Creates a new stateful action.
All future state values must have the same
<GVariantType> as the initial
state.
If the state <GVariant> is floating, it
is consumed.
Passed: a string.
the name of the action
Passed: a <GVariantType>, or #f.
the type of the parameter that will be passed to handlers for the
simple-action:activate
signal, or #f for no parameter
Passed: a <GVariant>.
the initial state of the action
Returned: a <GSimpleAction>.
a new <GSimpleAction>
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.
Passed: a <GSimpleAction>.
Passed: a boolean.
whether the action is enabled
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 action:change-state to request the change.
If the value GVariant is floating, it is consumed.
Passed: a <GSimpleAction>.
Passed: a <GVariant>.
the new <GVariant> for the state
Sets the state hint for the action.
See action:get-state-hint for more
information about action state hints.
Passed: a <GSimpleAction>.
Passed, or left out: a <GVariant>, or
#f.
a <GVariant> representing the state hint
Connect a handler with (connect object simple-action:activate
handler). It is called as (handler self parameter).
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 #f parameter
type is to toggle them via the simple-action:change-state signal. For stateful actions
where the state type is equal to the parameter type, the default is to
forward them directly to simple-action:change-state. This should allow almost
all users of <GSimpleAction> to connect only
one handler or the other.
Passed: a <GSimpleAction>.
Passed: a <GVariant>, or #f.
the parameter to the activation, or #f if it has no parameter
Connect a handler with (connect object simple-action:change-state
handler). It is called as (handler self value).
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 simple-action:new-stateful. 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 simple-action:set-state 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 simple-action:set-state
from the handler.
An example of a ’change-state’ handler:
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.
Passed: a <GSimpleAction>.
Passed: a <GVariant>, or #f.
the requested value for the state