glibmm 2.82.0
|
Action - An action interface. More...
#include <giomm/action.h>
Public Member Functions | |
Action (Action &&src) noexcept | |
Action & | operator= (Action &&src) noexcept |
~Action () noexcept override | |
GAction * | gobj () |
Provides access to the underlying C GObject. | |
const GAction * | gobj () const |
Provides access to the underlying C GObject. | |
Glib::ustring | get_name () const |
Queries the name of action. | |
Glib::VariantType | get_parameter_type () const |
Queries the type of the parameter that must be given when activating action. | |
Glib::VariantType | get_state_type () const |
Queries the type of the state of action. | |
template<typename T_Value > | |
void | get_state_hint (T_Value & value) const |
Requests a hint about the valid range of values for the state of the action. | |
Glib::VariantContainerBase | get_state_hint_variant () const |
Requests a hint about the valid range of values for the state of action. | |
bool | get_enabled () const |
Checks if action is currently enabled. | |
template<typename T_Value > | |
void | change_state (const T_Value & value) |
Request for the state of action to be changed to value, assuming that the action has the expected state type. | |
template<typename T_Value > | |
void | change_state (const Glib::Variant< T_Value > & value) |
void | change_state_variant (const Glib::VariantBase & value) |
Request for the state of action to be changed to value. | |
template<typename T_Value > | |
void | get_state (T_Value & value) const |
Queries the current state of the action. | |
Glib::VariantBase | get_state_variant () const |
Queries the current state of action. | |
void | activate () |
Activates the action without a parameter. | |
template<typename T_Value > | |
void | activate (const T_Value ¶meter) |
Activates the action with a parameter. | |
template<typename T_Value > | |
void | activate (const Glib::Variant< T_Value > ¶meter) |
void | activate_variant (const Glib::VariantBase ¶meter) |
Activates the action. | |
template<typename T_Value > | |
Glib::ustring | print_detailed_name (const T_Value &target_value) |
Formats a detailed action name from the action's action_name and target_value. | |
Glib::PropertyProxy_ReadOnly< bool > | property_enabled () const |
If action is currently enabled. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_name () const |
The name of the action. | |
Glib::PropertyProxy_ReadOnly< Glib::VariantType > | property_parameter_type () const |
The type of the parameter that must be given when activating the action. | |
Glib::PropertyProxy_ReadOnly< Glib::VariantBase > | property_state () const |
The state of the action, or nullptr if the action is stateless. | |
Glib::PropertyProxy_ReadOnly< Glib::VariantType > | property_state_type () const |
The Glib::VariantType of the state that the action has, or nullptr if the action is stateless. | |
Public Member Functions inherited from Glib::Interface | |
Interface () | |
A Default constructor. | |
Interface (Interface &&src) noexcept | |
Interface & | operator= (Interface &&src) noexcept |
Interface (const Glib::Interface_Class &interface_class) | |
Called by constructors of derived classes. | |
Interface (GObject *castitem) | |
Called by constructors of derived classes. | |
~Interface () noexcept override | |
Interface (const Interface &)=delete | |
Interface & | operator= (const Interface &)=delete |
GObject * | gobj () |
const GObject * | gobj () const |
Public Member Functions inherited from Glib::ObjectBase | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
void | set_property_value (const Glib::ustring & property_name, const Glib::ValueBase & value) |
You probably want to use a specific property_*() accessor method instead. | |
void | get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
void | set_property (const Glib::ustring & property_name, const PropertyType & value) |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
void | get_property (const Glib::ustring & property_name, PropertyType & value) const |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
PropertyType | get_property (const Glib::ustring & property_name) const |
You probably want to use a specific property_*() accessor method instead. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, const sigc::slot< void()> &slot) |
You can use the signal_changed() signal of the property proxy instead. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot) |
You can use the signal_changed() signal of the property proxy instead. | |
void | freeze_notify () |
Increases the freeze count on object. | |
void | thaw_notify () |
Reverts the effect of a previous call to freeze_notify(). | |
virtual void | reference () const |
Increment the reference count for this object. | |
virtual void | unreference () const |
Decrement the reference count for this object. | |
GObject * | gobj () |
Provides access to the underlying C GObject. | |
const GObject * | gobj () const |
Provides access to the underlying C GObject. | |
GObject * | gobj_copy () const |
Give a ref-ed copy to someone. Use for direct struct access. | |
Static Public Member Functions | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static bool | name_is_valid (const Glib::ustring &action_name) |
Checks if action_name is valid. | |
template<typename T_Value > | |
static void | parse_detailed_name (const Glib::ustring &detailed_name, Glib::ustring &action_name, T_Value &target_value) |
Parses a detailed action name into its separate name and target components. | |
static void | parse_detailed_name_variant (const Glib::ustring &detailed_name, Glib::ustring &action_name, Glib::VariantBase &target_value) |
Parses a detailed action name into its separate name and target components. | |
static Glib::ustring | print_detailed_name_variant (const Glib::ustring &action_name, const Glib::VariantBase &target_value) |
Formats a detailed action name from action_name and target_value. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gio::Action > | wrap (GAction *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Action - An action interface.
Action represents a single named action.
The main interface to an action is that it can be activated with activate(). This results in the signal_activate() signal being emitted. An activation may optionally have a parameter, activate(const T_Value& parameter). The correct type for the parameter is determined by a static parameter type (which is given at construction time).
An action may optionally have a state, in which case the state may be set with change_state(). The correct type for the state is determined by a static state type (which is given at construction time).
An Action can have a state, but no parameter, or vice versa. If it has both, the parameter type can differ from the state type.
The state may have a hint associated with it, specifying its valid range.
Action is merely the interface to the concept of an action, as described above. Various implementations of actions exist, including SimpleAction.
In all cases, the implementing class is responsible for storing the name of the action, the parameter type, the enabled state, the optional state type and the state and emitting the appropriate signals when these change. The implementor is responsible for filtering calls to activate() and change_state() for type safety and for the state being enabled.
Probably the only useful thing to do with an Action is to put it inside of a SimpleActionGroup.
|
protected |
You should derive from this class to use it.
|
noexcept |
|
overridenoexcept |
void Gio::Action::activate | ( | ) |
Activates the action without a parameter.
void Gio::Action::activate | ( | const Glib::Variant< T_Value > & | parameter | ) |
Activates the action with a parameter.
The parameter must be the correct type of parameter for the action (ie: the parameter type given at construction time).
parameter | The parameter to the activation |
void Gio::Action::activate_variant | ( | const Glib::VariantBase & | parameter | ) |
Activates the action.
parameter must be the correct type of parameter for the action (ie: the parameter type given at construction time). If the parameter type was nullptr
then parameter must also be nullptr
.
If the parameter Glib::Variant is floating, it is consumed.
parameter | The parameter to the activation. |
|
protectedvirtual |
void Gio::Action::change_state | ( | const Glib::Variant< T_Value > & | value | ) |
Request for the state of action to be changed to value, assuming that the action has the expected state type.
See get_state_type().
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 get_state_hint().
value | The new state. |
void Gio::Action::change_state_variant | ( | const Glib::VariantBase & | value | ) |
Request for the state of action to be changed to value.
The action must be stateful and value must be of the correct type. See Gio::Action::get_state_type().
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 Gio::Action::get_state_hint().
If the value Glib::Variant is floating, it is consumed.
value | The new state. |
|
protectedvirtual |
bool Gio::Action::get_enabled | ( | ) | const |
Checks if action is currently enabled.
An action must be enabled in order to be activated or in order to have its state changed from outside callers.
|
protectedvirtual |
Glib::ustring Gio::Action::get_name | ( | ) | const |
|
protectedvirtual |
Glib::VariantType Gio::Action::get_parameter_type | ( | ) | const |
Queries the type of the parameter that must be given when activating action.
When activating the action using Gio::Action::activate(), the Glib::Variant given to that function must be of the type returned by this function.
In the case that this function returns nullptr
, you must not give any Glib::Variant, but nullptr
instead.
|
protectedvirtual |
Queries the current state of the action.
If the action is not stateful then a null Variant will be returned. If the action is stateful then the type of the return value is the type given by get_state_type().
value | This will be set to the current state of the action. |
Requests a hint about the valid range of values for the state of the action.
If a null Variant 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 Variant array is returned then each item in the array is a possible value for the state. If a 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.
value | This will be set to the state range hint. |
Glib::VariantContainerBase Gio::Action::get_state_hint_variant | ( | ) | const |
Requests a hint about the valid range of values for the state of action.
If nullptr
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 Glib::Variant array is returned then each item in the array is a possible value for the state. If a Glib::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-nullptr
) should be freed with Glib::Variant::unref() when it is no longer required.
|
protectedvirtual |
Glib::VariantType Gio::Action::get_state_type | ( | ) | const |
Queries the type of the state of action.
If the action is stateful (e.g. created with Gio::SimpleAction::new_stateful()) then this function returns the Glib::VariantType of the state. This is the type of the initial value given as the state. All calls to Gio::Action::change_state() must give a Glib::Variant of this type and Gio::Action::get_state() will return a Glib::Variant of the same type.
If the action is not stateful (e.g. created with Gio::SimpleAction::new()) then this function will return nullptr
. In that case, Gio::Action::get_state() will return nullptr
and you must not call Gio::Action::change_state().
|
protectedvirtual |
Glib::VariantBase Gio::Action::get_state_variant | ( | ) | const |
Queries the current state of action.
If the action is not stateful then nullptr
will be returned. If the action is stateful then the type of the return value is the type given by Gio::Action::get_state_type().
The return value (if non-nullptr
) should be freed with Glib::Variant::unref() when it is no longer required.
|
protectedvirtual |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
static |
Checks if action_name is valid.
action_name is valid if it consists only of alphanumeric characters, plus -
and .
. The empty string is not a valid action name.
It is an error to call this function with a non-UTF-8 action_name. action_name must not be nullptr
.
action_name | A potential action name. |
true
if action_name is valid.
|
static |
Parses a detailed action name into its separate name and target components.
Detailed action names can have three formats. See parse_detailed_name_variant().
detailed_name | A detailed action name. | |
[out] | action_name | The action name. |
[out] | target_value | The target value. |
Glib::VariantParseError | if detailed_name has an invalid format or a target of an unexpected type. |
|
static |
Parses a detailed action name into its separate name and target components.
Detailed action names can have three formats.
The first format is used to represent an action name with no target value and consists of just an action name containing no whitespace nor the characters :
, (
or )
. For example: app.action
.
The second format is used to represent an action with a target value that is a non-empty string consisting only of alphanumerics, plus -
and .
. In that case, the action name and target value are separated by a double colon (::
). For example: app.action::target
.
The third format is used to represent an action with any type of target value, including strings. The target value follows the action name, surrounded in parens. For example: app.action(42)
. The target value is parsed using glib_variant_parse(). If a tuple-typed value is desired, it must be specified in the same way, resulting in two sets of parens, for example: app.action((1,2,3))
. A string target can be specified this way as well: ‘app.action('target’). For strings, this third format must be used if target value is empty or contains characters other than alphanumerics,
-and
.`.
If this function returns true
, a non-nullptr
value is guaranteed to be returned in action_name (if a pointer is passed in). A nullptr
value may still be returned in target_value, as the detailed_name may not contain a target.
If returned, the Glib::Variant in target_value is guaranteed to not be floating.
detailed_name | A detailed action name. |
action_name | The action name. |
target_value | The target value, or nullptr for no target. |
Glib::VariantParseError |
Glib::ustring Gio::Action::print_detailed_name | ( | const T_Value & | target_value | ) |
Formats a detailed action name from the action's action_name and target_value.
This function is the opposite of parse_detailed_action_name(). It will produce a string that can be parsed back to the action_name and target_value by that function.
See that function for the types of strings that will be printed by this function.
target_value | A Variant target value. |
|
static |
Formats a detailed action name from action_name and target_value.
It is an error to call this function with an invalid action name.
This function is the opposite of gio_action_parse_detailed_name(). It will produce a string that can be parsed back to the action_name and target_value by that function.
See that function for the types of strings that will be printed by this function.
action_name | A valid action name. |
target_value | A Glib::Variant target value, or nullptr . |
Glib::PropertyProxy_ReadOnly< bool > Gio::Action::property_enabled | ( | ) | const |
If action is currently enabled.
If the action is disabled then calls to Gio::Action::activate() and Gio::Action::change_state() have no effect.
Default value: true
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gio::Action::property_name | ( | ) | const |
The name of the action.
This is mostly meaningful for identifying the action once it has been added to a Gio::ActionGroup. It is immutable.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::VariantType > Gio::Action::property_parameter_type | ( | ) | const |
The type of the parameter that must be given when activating the action.
This is immutable, and may be nullptr
if no parameter is needed when activating the action.
Glib::PropertyProxy_ReadOnly< Glib::VariantBase > Gio::Action::property_state | ( | ) | const |
The state of the action, or nullptr
if the action is stateless.
Glib::PropertyProxy_ReadOnly< Glib::VariantType > Gio::Action::property_state_type | ( | ) | const |
The Glib::VariantType of the state that the action has, or nullptr
if the action is stateless.
This is immutable.
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |