glibmm: Gio::Action Class Reference

glibmm 2.33.14

- 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.
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.
void | get_state_hint () 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.
void | get_state () const
| Queries the current state of action.
void | change_state (const Glib::VariantBase& value)
| Request for the state of action to be changed to value.
void | activate (const Glib::VariantBase& parameter)
| Activates the action.
Glib::PropertyProxy_ReadOnly < bool > | property_enabled () const
| If the action can be activated.
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_name () const
| The name used to invoke the action.
Glib::PropertyProxy_ReadOnly < Glib::VariantType > | property_parameter_type () const
| The type of GVariant passed to activate().
Glib::PropertyProxy_ReadOnly < Glib::VariantBase > | property_state () const
| The state the action is in.
Glib::PropertyProxy_ReadOnly < Glib::VariantType > | property_state_type () const
| The type of the state kept by the action.
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 (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes.
| Interface (GObject* castitem)
| Called by constructors of derived classes.
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.
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.
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.
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.
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.
Public Member Functions inherited from sigc::trackable
| trackable (const trackable &src)
trackable & | operator= (const trackable &src)
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | remove_destroy_notify_callback (void *data) const
void | notify_callbacks ()

## 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.

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

## 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.

## Additional Inherited Members
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## 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 | ( | const Glib::VariantBase& | parameter | ) |

Activates the action.

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

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

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:

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

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

void Gio::Action::get_state_hint | ( |  | ) | 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

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.

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 that allows you to get or set the property of the value, 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 that allows you to get or set the property of the value, 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 that allows you to get or set the property of the value, 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 that allows you to get or set the property of the value, 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 that allows you to get or set the property of the value, 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.