glibmm  2.36.2
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:
Inheritance graph
[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...
 
void get_state_hint () 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...
 
void get_state () const
 Queries the current state of action. More...
 
void change_state (const Glib::VariantBase& value)
 Request for the state of action to be changed to value. More...
 
void activate (const Glib::VariantBase& parameter)
 Activates the action. 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 (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...
 

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::Actionwrap (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 ( 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.

Since glibmm 2.28:
Parameters
parameterThe 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
valueThe 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.

Note
This method is useless in its present form. It should return Glib::VariantBase, but it returns void. This bug cannot be fixed until the ABI of glibmm can be broken. Meanwhile you can use property_state() like so:
Glib::VariantBase state = myAction.property_state();
You can also use the C function in glib like so:
Glib::VariantBase state = Glib::wrap(g_action_get_state(myAction.gobj()));
If myAction is a const object:
Glib::VariantBase state = Glib::wrap(g_action_get_state(const_cast<GAction*>(myAction.gobj())));

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

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.

Note
This method is useless in its present form. It should return Glib::VariantBase, but it returns void. This bug cannot be fixed until the ABI of glibmm can be broken. Meanwhile you can use the C function in glib like so:
Glib::VariantBase state_hint = Glib::wrap(g_action_get_state_hint(myAction.gobj()));
If myAction is a const object:
Glib::VariantBase state_hint = Glib::wrap(g_action_get_state_hint(const_cast<GAction*>(myAction.gobj())));

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.

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_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
objectThe C instance.
take_copyFalse 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.