
Gnome::Gio::SimpleAction
Description
A Gnome::Gio::SimpleAction is the obvious simple implementation of the Gnome::Gio::R-Action interface. This is the easiest way to create an action for purposes of adding it to a Gnome::Gio::SimpleActionGroup.
See also GtkAction.
Uml Diagram

Class initialization
new
:native-object
Create an object using a native object from an object of the same type found elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object() :$native-object! )
new-simpleaction
Creates a new action.
The created action is stateless. See .new-stateful()
to create an action that has state.
method new-simpleaction ( Str $name, CArray[N-VariantType] $parameter-type --> Gnome::Gio::SimpleAction \)
$name; the name of the action.
$parameter-type; the type of parameter that will be passed to handlers for the activate signal, or undefined for no parameter.
new-stateful
Creates a new stateful action.
All future state values must have the same Gnome::Glib::N-VariantType as the initial $state
.
If the $state
Gnome::Glib::N-Variant is floating, it is consumed.
method new-stateful ( Str $name, CArray[N-VariantType] $parameter-type, CArray[N-Variant] $state --> Gnome::Gio::SimpleAction \)
$name; the name of the action.
$parameter-type; the type of the parameter that will be passed to handlers for the activate signal, or undefined for no parameter.
$state; the initial state of the action.
Methods
set-enabled
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.
method set-enabled ( Bool() $enabled )
$enabled; whether the action is enabled.
set-state
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 g_action_change_state() to request the change.
If the $value
GVariant is floating, it is consumed.
method set-state ( CArray[N-Variant] $value )
$value; the new Gnome::Glib::N-Variant for the state.
set-state-hint
Sets the state hint for the action.
See g_action_get_state_hint() for more information about action state hints.
method set-state-hint ( CArray[N-Variant] $state-hint )
$state-hint; a Gnome::Glib::N-Variant representing the state hint.
Signals
activate
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 undefined parameter type is to toggle them via the change-state signal. For stateful actions where the state type is equal to the parameter type, the default is to forward them directly to change-state. This should allow almost all users of Gnome::Gio::SimpleAction to connect only one handler or the other.
method handler ( N-Object $parameter, Int :$_handle_id, N-GObject :$_native-object, Gnome::Gio::SimpleAction :$_widget, *C<user>-options )
$parameter; the parameter to the activation, or undefined if it has no parameter. It is a native Gnome::Glib::Variant.
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gio::SimpleAction object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.
change-state
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 .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 .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 .set-state()
from the handler.
An example of a 'change-state' handler:
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.
method handler ( $value, Int :$_handle_id, N-GObject :$_native-object, Gnome::Gio::SimpleAction :$_widget, *C<user>-options )
$value; the requested value for the state.
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gio::SimpleAction object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.