glibmm 2.38.0

- 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::SimpleAction Class Reference

SimpleAction - A simple Action implementation. More...

`#include <giomm/simpleaction.h>`

Inheritance diagram for Gio::SimpleAction:
[legend]

## Public Member Functions
virtual | ~SimpleAction ()
GSimpleAction* | gobj ()
| Provides access to the underlying C GObject. More...
const GSimpleAction* | gobj () const
| Provides access to the underlying C GObject. More...
GSimpleAction* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
void | set_enabled (bool enabled=true)
| Sets the action as enabled or not. More...
Glib::PropertyProxy< bool > | property_enabled ()
| If the action can be activated. 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 < Glib::VariantBase > | property_state ()
| The state the action is in. 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...
Glib::SignalProxy1< void, const Glib::VariantBase& > | signal_activate ()
Glib::SignalProxy1< void, const Glib::VariantBase& > | signal_change_state ()
Public Member Functions inherited from Glib::Object
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
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...
Public Member Functions inherited from Gio::Action
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

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr< SimpleAction > | create (const Glib::ustring& name)
static Glib::RefPtr< SimpleAction > | create (const Glib::ustring& name, const Glib::VariantType& parameter_type)
| Creates a new action. More...
static Glib::RefPtr< SimpleAction > | create (const Glib::ustring& name, const Glib::VariantType& parameter_type, const Glib::VariantBase& state)
| Creates a new stateful action. More...
static Glib::RefPtr< SimpleAction > | create (const Glib::ustring& name, const Glib::VariantBase& state)
| Creates a new stateful action. More...
static Glib::RefPtr< SimpleAction > | create_bool (const Glib::ustring& name, bool state=false)
| Creates a new boolean stateful action. More...
static Glib::RefPtr< SimpleAction > | create_radio_string (const Glib::ustring& name, const Glib::ustring& initial_state)
| Creates a new radio action with a string-based target value. More...
static Glib::RefPtr< SimpleAction > | create_radio_integer (const Glib::ustring& name, gint32 inital_state)
| Creates a new radio action with an integer-based target value. More...
Static Public Member Functions inherited from Gio::Action
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
| SimpleAction (const Glib::ustring& name)
| Creates a new action. More...
| SimpleAction (const Glib::ustring& name, const Glib::VariantBase& state)
| Creates a new new stateful action. More...
| SimpleAction (const Glib::ustring& name, const Glib::VariantType& parameter_type)
| SimpleAction (const Glib::ustring& name, const Glib::VariantType& parameter_type, const Glib::VariantBase& state)
void | set_state (const Glib::VariantBase&value)
| Sets the state of the action. More...
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
virtual | ~Object ()
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
virtual | ~ObjectBase ()=0
void | initialize (GObject* castitem)
Protected Member Functions inherited from Gio::Action
| Action ()
| You should derive from this class to use it. More...

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

## Additional Inherited Members
Public Types inherited from Glib::Object
typedef void(* | DestroyNotify )(gpointer data)

## Detailed Description

SimpleAction - A simple Action implementation.

A SimpleAction is the obvious simple implementation of the Action interface. This is the easiest way to create an action for purposes of adding it to a SimpleActionGroup.

See also Gtk::Action.

Since glibmm 2.32:

## Constructor & Destructor Documentation

virtual Gio::SimpleAction::~SimpleAction | ( |  | ) |
| virtual

Gio::SimpleAction::SimpleAction | ( | const Glib::ustring& | name | ) |
| explicit protected

Creates a new action.

The created action is stateless.

Parameters

  name | The name of the action.
  state | The initial state of the action.

Gio::SimpleAction::SimpleAction | ( | const Glib::ustring& | name,
|  | const Glib::VariantBase& | state
| ) |  |
| protected

Creates a new new stateful action.

The created action is stateless.

state is the initial state of the action. All future state values must have the same VariantType as the initial state.

Parameters

  name | The name of the action.
  state | The initial state of the action.

Gio::SimpleAction::SimpleAction | ( | const Glib::ustring& | name,
|  | const Glib::VariantType& | parameter_type
| ) |  |
| explicit protected

Gio::SimpleAction::SimpleAction | ( | const Glib::ustring& | name,
|  | const Glib::VariantType& | parameter_type,
|  | const Glib::VariantBase& | state
| ) |  |
| explicit protected

## Member Function Documentation

static Glib::RefPtr<SimpleAction> Gio::SimpleAction::create | ( | const Glib::ustring& | name | ) |
| static

static Glib::RefPtr<SimpleAction> Gio::SimpleAction::create | ( | const Glib::ustring& | name,
|  | const Glib::VariantType& | parameter_type
| ) |  |
| static

Creates a new action.

The created action is stateless. See g_simple_action_new_stateful().

Since glibmm 2.28:

Parameters

  name | The name of the action.
  parameter_type | The type of parameter to the activate function.

Returns
  A new SimpleAction.

static Glib::RefPtr<SimpleAction> Gio::SimpleAction::create | ( | const Glib::ustring& | name,
|  | const Glib::VariantType& | parameter_type,
|  | const Glib::VariantBase& | state
| ) |  |
| static

Creates a new stateful action.

state is the initial state of the action. All future state values must have the same VariantType as the initial state.

If the state GVariant is floating, it is consumed.

Since glibmm 2.28:

Parameters

  name | The name of the action.
  parameter_type | The type of the parameter to the activate function.
  state | The initial state of the action.

Returns
  A new SimpleAction.

static Glib::RefPtr<SimpleAction> Gio::SimpleAction::create | ( | const Glib::ustring& | name,
|  | const Glib::VariantBase& | state
| ) |  |
| static

Creates a new stateful action.

state is the initial state of the action. All future state values must have the same VariantType as the initial state.

Since glibmm 2.38:

Parameters

  name | The name of the action.
  state | The initial state of the action.

Returns
  A new SimpleAction.

static Glib::RefPtr<SimpleAction> Gio::SimpleAction::create_bool | ( | const Glib::ustring& | name,
|  | bool | state = `false`
| ) |  |
| static

Creates a new boolean stateful action.

state is the initial state of the action. All future state values must also be bool.

Since glibmm 2.38:

Parameters

  name | The name of the action.
  state | The initial state of the action.

Returns
  A new SimpleAction.

static Glib::RefPtr<SimpleAction> Gio::SimpleAction::create_radio_integer | ( | const Glib::ustring& | name,
|  | gint32 | inital_state
| ) |  |
| static

Creates a new radio action with an integer-based target value.

Since glibmm 2.38:

Parameters

  name | The name of the action.

Returns
  A new SimpleAction.

static Glib::RefPtr<SimpleAction> Gio::SimpleAction::create_radio_string | ( | const Glib::ustring& | name,
|  | const Glib::ustring& | initial_state
| ) |  |
| static

Creates a new radio action with a string-based target value.

Since glibmm 2.38:

Parameters

  name | The name of the action.

Returns
  A new SimpleAction.

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

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

GSimpleAction* Gio::SimpleAction::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

const GSimpleAction* Gio::SimpleAction::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

GSimpleAction* Gio::SimpleAction::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Glib::PropertyProxy< bool > Gio::SimpleAction::property_enabled | ( |  | ) |

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 value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< bool > Gio::SimpleAction::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::SimpleAction::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::SimpleAction::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< Glib::VariantBase > Gio::SimpleAction::property_state | ( |  | ) |

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 value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::VariantBase > Gio::SimpleAction::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::SimpleAction::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.

void Gio::SimpleAction::set_enabled | ( | bool | enabled = `true` | ) |

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.

Since glibmm 2.28:

Parameters

  enabled | Whether the action is enabled.

void Gio::SimpleAction::set_state | ( | const Glib::VariantBase& | value | ) |
| protected

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.

Since glibmm 2.30:

Parameters

  value | The new Variant for the state.

Glib::SignalProxy1< void,const Glib::VariantBase& > Gio::SimpleAction::signal_activate | ( |  | ) |

Slot Prototype:
  `void on_my_activate(const Glib::VariantBase& parameter)`

Indicates that the action was just activated.

parameter will always be of the expected type. In the event that an incorrect type was given, no signal will be emitted.

Since glibmm 2.28:

Parameters

  parameter | The parameter to the activation.

Glib::SignalProxy1< void,const Glib::VariantBase& > Gio::SimpleAction::signal_change_state | ( |  | ) |

Slot Prototype:
  `void on_my_change_state(const Glib::VariantBase& value)`

Indicates that the action just received a request to change its state.

value will always be of the correct state type. In the event that an incorrect type was given, no signal will be emitted.

If no handler is connected to this signal then the default behaviour is to call g_simple_action_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 g_simple_action_set_state() from the handler.

<title>Example 'change-state' handler</title>

static void change_volume_state (GSimpleAction *action, GVariant *value, gpointer user_data) { `int` requested;

requested = g_variant_get_int32 (value);

// Volume only goes from 0 to 10 if (0 <= requested&& requested <= 10) g_simple_action_set_state (action, value); }

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.

Since glibmm 2.30:

Parameters

  value | The requested value for the state.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::SimpleAction > wrap | ( | GSimpleAction * | 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.