glibmm: Gio::Action Class Reference

glibmm 2.38.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gio::Action Class Reference

Action - An action. More...

`#include <giomm/action.h>`

Inheritance diagram for Gio::Action:
[legend]

## Public Member Functions
virtual | ~Action ()
GAction* | gobj ()
| Provides access to the underlying C GObject. More...
const GAction* | gobj () const
| Provides access to the underlying C GObject. More...
Glib::ustring | get_name () const
| Queries the name of action. More...
Glib::VariantType | get_parameter_type () const
| Queries the type of the parameter that must be given when activating action. More...
Glib::VariantType | get_state_type () const
| Queries the type of the state of action. More...
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. More...
Glib::VariantBase | get_state_hint_variant () const
| Requests a hint about the valid range of values for the state of action. More...
bool | get_enabled () const
| Checks if action is currently enabled. More...
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. More...
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. More...
void | change_state (const Glib::VariantBase&value)
| Request for the state of action to be changed to value. More...
template<typename T_Value >
void | get_state (T_Value&value) const
| Queries the current state of the action. More...
Glib::VariantBase | get_state_variant () const
| Queries the current state of action. More...
void | activate ()
| Activates the action. More...
template<typename T_Value >
void | activate (const T_Value& parameter)
| Activates the action. More...
template<typename T_Value >
void | activate (const Glib::Variant< T_Value >& parameter)
void | activate_variant (const Glib::VariantBase& parameter)
| Activates the action. More...
void | activate (const Glib::VariantBase& parameter)
| Activates the action. More...
template<typename T_Value >
Glib::ustring | print_detailed_name (const T_Value&value)
| Formats a detailed action name from the action's action_name and target_value. More...
Glib::PropertyProxy_ReadOnly < bool > | property_enabled () const
| If the action can be activated. More...
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_name () const
| The name used to invoke the action. More...
Glib::PropertyProxy_ReadOnly < Glib::VariantType > | property_parameter_type () const
| The type of GVariant passed to activate(). More...
Glib::PropertyProxy_ReadOnly < Glib::VariantBase > | property_state () const
| The state the action is in. More...
Glib::PropertyProxy_ReadOnly < Glib::VariantType > | property_state_type () const
| The type of the state kept by the action. More...
virtual Glib::ustring | get_name_vfunc () const
virtual Glib::VariantType | get_parameter_type_vfunc () const
virtual Glib::VariantType | get_state_type_vfunc () const
virtual Glib::VariantBase | get_state_hint_vfunc () const
virtual bool | get_enabled_vfunc () const
virtual Glib::VariantBase | get_state_vfunc () const
virtual void | change_state_vfunc (const Glib::VariantBase&value)
virtual void | activate_vfunc (const Glib::VariantBase& parameter)
Public Member Functions inherited from Glib::Interface
| Interface ()
| A Default constructor. More...
| Interface (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes. More...
| Interface (GObject* castitem)
| Called by constructors of derived classes. More...
virtual | ~Interface ()
GObject* | gobj ()
const GObject* | gobj () const
Public Member Functions inherited from Glib::ObjectBase
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase&value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase&value) const
| You probably want to use a specific property_*() accessor method instead. More...
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. More...
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. More...
void | 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, but this is necessary when using the reduced API. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...

## 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. More...
static bool | name_is_valid (const Glib::ustring& action_name)
| Checks if action_name is valid. More...
static Glib::ustring | print_detailed_name_variant (const Glib::ustring& action_name, const Glib::VariantBase& parameter)
| Formats a detailed action name from action_name and target_value. More...

## Protected Member Functions
| Action ()
| You should derive from this class to use it. More...

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::Action > | wrap (GAction* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

Action - An action.

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 has a Glib::VariantBase parameter (which may be `0`). 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(). This call takes a Glib::VariantBase. The correct type for the state is determined by a static state type (which is given at construction time).

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 and Gtk::Action.

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 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 a Action is to put it inside of a SimpleActionGroup.

Since glibmm 2.32:

## Constructor & Destructor Documentation

Gio::Action::Action | ( |  | ) |
| protected

You should derive from this class to use it.

virtual Gio::Action::~Action | ( |  | ) |
| virtual

## Member Function Documentation

void Gio::Action::activate | ( |  | ) |

Activates the action.

template <typename T_Value >

void Gio::Action::activate | ( | const T_Value & | parameter | ) |

Activates the action.

The parameter must be the correct type of parameter for the action (ie: the parameter type given at construction time), if any.

Parameters

  parameter,: | The parameter to the activation

template <typename T_Value >

void Gio::Action::activate | ( | const Glib::Variant< T_Value >& | parameter | ) |

void Gio::Action::activate | ( | 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 `0` then parameter must also be `0`.

If the parameter GVariant is floating, it is consumed.

Since glibmm 2.28:

Deprecated:
  Use the templated method instead

Parameters

  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 `0` then parameter must also be `0`.

If the parameter GVariant is floating, it is consumed.

Since glibmm 2.28:

Parameters

  parameter | The parameter to the activation.

virtual void Gio::Action::activate_vfunc | ( | const Glib::VariantBase& | parameter | ) |
| virtual

static void Gio::Action::add_interface | ( | GType | gtype_implementer | ) |
| static

template <typename T_Value >

void Gio::Action::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.

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().

Since glibmm 2.38:

Parameters

  value | The new state.

template <typename T_Value >

void Gio::Action::change_state | ( | const Glib::Variant< T_Value >& | value | ) |

void Gio::Action::change_state | ( | 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 g_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 g_action_get_state_hint().

If the value GVariant is floating, it is consumed.

Since glibmm 2.30:

Deprecated:
  Use the templated method instead

Parameters

  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 g_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 g_action_get_state_hint().

If the value GVariant is floating, it is consumed.

Since glibmm 2.30:

Parameters

  value | The new state.

virtual void Gio::Action::change_state_vfunc | ( | const Glib::VariantBase& | value | ) |
| virtual

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.

Since glibmm 2.28:

Returns
  Whether the action is enabled.

virtual bool Gio::Action::get_enabled_vfunc | ( |  | ) | const
| virtual

Glib::ustring Gio::Action::get_name | ( |  | ) | const

Queries the name of action.

Since glibmm 2.28:

Returns
  The name of the action.

virtual Glib::ustring Gio::Action::get_name_vfunc | ( |  | ) | const
| virtual

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 g_action_activate(), the Variant given to that function must be of the type returned by this function.

In the case that this function returns `0`, you must not give any Variant, but `0` instead.

Since glibmm 2.28:

Returns
  The parameter type.

virtual Glib::VariantType Gio::Action::get_parameter_type_vfunc | ( |  | ) | const
| virtual

template <typename T_Value >

void Gio::Action::get_state | ( | T_Value & | value | ) | const

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().

Parameters

  value | This will be set to the current state of the action.

template <typename T_Value >

void Gio::Action::get_state_hint | ( | T_Value & | value | ) | const

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.

Parameters

  value | This will be set to the state range hint.

Glib::VariantBase Gio::Action::get_state_hint_variant | ( |  | ) | const

Requests a hint about the valid range of values for the state of action.

If `0` 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.

The return value (if non-`0`) should be freed with Glib::variant_unref() when it is no longer required.

Since glibmm 2.28:

Returns
  The state range hint.

virtual Glib::VariantBase Gio::Action::get_state_hint_vfunc | ( |  | ) | const
| virtual

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 g_simple_action_new_stateful()) then this function returns the VariantType of the state. This is the type of the initial value given as the state. All calls to g_action_change_state() must give a Variant of this type and g_action_get_state() will return a Variant of the same type.

If the action is not stateful (e.g. created with g_simple_action_new()) then this function will return `0`. In that case, g_action_get_state() will return `0` and you must not call g_action_change_state().

Since glibmm 2.28:

Returns
  The state type, if the action is stateful.

virtual Glib::VariantType Gio::Action::get_state_type_vfunc | ( |  | ) | const
| virtual

Glib::VariantBase Gio::Action::get_state_variant | ( |  | ) | const

Queries the current state of action.

If the action is not stateful then `0` will be returned. If the action is stateful then the type of the return value is the type given by g_action_get_state_type().

The return value (if non-`0`) should be freed with Glib::variant_unref() when it is no longer required.

Since glibmm 2.28:

Returns
  The current state of the action.

virtual Glib::VariantBase Gio::Action::get_state_vfunc | ( |  | ) | const
| virtual

static GType Gio::Action::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

GAction* Gio::Action::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

const GAction* Gio::Action::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

static bool Gio::Action::name_is_valid | ( | const Glib::ustring& | action_name | ) |
| 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-utf8 action_name. action_name must not be `0`.

Since glibmm 2.38:

Parameters

  action_name | An potential action name.

Returns
  `true` if action_name is valid.

template <typename T_Value >

Glib::ustring Gio::Action::print_detailed_name | ( | const T_Value & | 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.

Parameters

  target_value | A Variant target value.

Returns
  A detailed format string.

static Glib::ustring Gio::Action::print_detailed_name_variant | ( | const Glib::ustring& | action_name,
|  | const Glib::VariantBase& | parameter
| ) |  |
| 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 Glib::action_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.

Since glibmm 2.38:

Parameters

  action_name | A valid action name.
  target_value | A Variant target value, or `0`.

Returns
  A detailed format string.

Glib::PropertyProxy_ReadOnly< bool > Gio::Action::property_enabled | ( |  | ) | const

If the action can be activated.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gio::Action::property_name | ( |  | ) | const

The name used to invoke the action.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::VariantType > Gio::Action::property_parameter_type | ( |  | ) | const

The type of GVariant passed to activate().

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::VariantBase > Gio::Action::property_state | ( |  | ) | const

The state the action is in.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::VariantType > Gio::Action::property_state_type | ( |  | ) | const

The type of the state kept by the action.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::Action > wrap | ( | GAction * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  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.

Returns
  A C++ instance that wraps this C instance.