glibmm 2.82.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gio::SimpleAction Class Reference

SimpleAction - A simple Action implementation. More...

#include <giomm/simpleaction.h>

Inheritance diagram for Gio::SimpleAction:
Inheritance graph
[legend]

Public Member Functions

 SimpleAction (SimpleAction &&src) noexcept
 
SimpleActionoperator= (SimpleAction &&src) noexcept
 
 ~SimpleAction () noexcept override
 
GSimpleActiongobj ()
 Provides access to the underlying C GObject.
 
const GSimpleActiongobj () const
 Provides access to the underlying C GObject.
 
GSimpleActiongobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
void set_enabled (bool enabled=true)
 Sets the action as enabled or not.
 
void set_state (const Glib::VariantBase & value)
 Sets the state of the action.
 
void set_state_hint (const Glib::VariantBase &state_hint)
 Sets the state hint for the action.
 
Glib::PropertyProxy< bool > property_enabled ()
 If action is currently enabled.
 
Glib::PropertyProxy_ReadOnly< bool > property_enabled () const
 If action is currently enabled.
 
Glib::PropertyProxy_ReadOnly< Glib::ustringproperty_name () const
 The name of the action.
 
Glib::PropertyProxy_ReadOnly< Glib::VariantTypeproperty_parameter_type () const
 The type of the parameter that must be given when activating the action.
 
Glib::PropertyProxy< Glib::VariantBaseproperty_state ()
 The state of the action, or nullptr if the action is stateless.
 
Glib::PropertyProxy_ReadOnly< Glib::VariantBaseproperty_state () const
 The state of the action, or nullptr if the action is stateless.
 
Glib::PropertyProxy_ReadOnly< Glib::VariantTypeproperty_state_type () const
 The VariantType of the state that the action has, or nullptr if the action is stateless.
 
Glib::SignalProxy< void(const Glib::VariantBase &)> signal_activate ()
 
Glib::SignalProxy< void(const Glib::VariantBase &)> signal_change_state ()
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
voidget_data (const QueryQuark & key)
 
void set_data (const Quark & key, void *data)
 
void set_data_with_c_callback (const Quark & key, void *data, GDestroyNotify notify)
 
void set_data (const Quark & key, void *data, DestroyNotify notify)
 Prefer set_data_with_c_callback() with a callback with C linkage.
 
void remove_data (const QueryQuark &quark)
 
voidsteal_data (const QueryQuark &quark)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (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.
 
- Public Member Functions inherited from Gio::Action
 Action (Action &&src) noexcept
 
Actionoperator= (Action &&src) noexcept
 
 ~Action () noexcept override
 
GActiongobj ()
 Provides access to the underlying C GObject.
 
const GActiongobj () 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 &parameter)
 Activates the action with a parameter.
 
template<typename T_Value >
void activate (const Glib::Variant< T_Value > &parameter)
 
void activate_variant (const Glib::VariantBase &parameter)
 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::ustringproperty_name () const
 The name of the action.
 
Glib::PropertyProxy_ReadOnly< Glib::VariantTypeproperty_parameter_type () const
 The type of the parameter that must be given when activating the action.
 
Glib::PropertyProxy_ReadOnly< Glib::VariantBaseproperty_state () const
 The state of the action, or nullptr if the action is stateless.
 
Glib::PropertyProxy_ReadOnly< Glib::VariantTypeproperty_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
 
Interfaceoperator= (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
 
Interfaceoperator= (const Interface &)=delete
 
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.
 
static Glib::RefPtr< SimpleActioncreate (const Glib::ustring & name)
 
static Glib::RefPtr< SimpleActioncreate (const Glib::ustring & name, const Glib::VariantType &parameter_type)
 Creates a new action.
 
static Glib::RefPtr< SimpleActioncreate (const Glib::ustring & name, const Glib::VariantType &parameter_type, const Glib::VariantBase & state)
 Creates a new stateful action.
 
static Glib::RefPtr< SimpleActioncreate (const Glib::ustring & name, const Glib::VariantBase & state)
 Creates a new stateful action.
 
static Glib::RefPtr< SimpleActioncreate_bool (const Glib::ustring & name, bool state=false)
 Creates a new boolean stateful action.
 
static Glib::RefPtr< SimpleActioncreate_radio_string (const Glib::ustring & name, const Glib::ustring &initial_state)
 Creates a new radio action with a string-based target value.
 
static Glib::RefPtr< SimpleActioncreate_radio_integer (const Glib::ustring & name, gint32 initial_state)
 Creates a new radio action with an integer-based target value.
 
- 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.
 
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.
 

Protected Member Functions

 SimpleAction (const Glib::ustring & name)
 Creates a new action.
 
 SimpleAction (const Glib::ustring & name, const Glib::VariantBase & state)
 Creates a new stateful action.
 
 SimpleAction (const Glib::ustring & name, const Glib::VariantType &parameter_type)
 
 SimpleAction (const Glib::ustring & name, const Glib::VariantType &parameter_type, const Glib::VariantBase & state)
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- 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.
 
 ObjectBase (const char *custom_type_name)
 A derived constructor always overrides this choice.
 
 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.
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 
- Protected Member Functions inherited from Gio::Action
 Action ()
 You should derive from this class to use it.
 
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)
 

Related Symbols

(Note that these are not member symbols.)

Glib::RefPtr< Gio::SimpleActionwrap (GSimpleAction *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Additional Inherited Members

- Public Types inherited from Glib::Object
using DestroyNotify = void(*)(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

◆ SimpleAction() [1/5]

Gio::SimpleAction::SimpleAction ( SimpleAction &&  src)
noexcept

◆ ~SimpleAction()

Gio::SimpleAction::~SimpleAction ( )
overridenoexcept

◆ SimpleAction() [2/5]

Gio::SimpleAction::SimpleAction ( const Glib::ustring name)
explicitprotected

Creates a new action.

The created action is stateless.

Parameters
nameThe name of the action.

◆ SimpleAction() [3/5]

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

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.

Parameters
nameThe name of the action.
stateThe initial state of the action.

◆ SimpleAction() [4/5]

Gio::SimpleAction::SimpleAction ( const Glib::ustring name,
const Glib::VariantType parameter_type 
)
explicitprotected

◆ SimpleAction() [5/5]

Gio::SimpleAction::SimpleAction ( const Glib::ustring name,
const Glib::VariantType parameter_type,
const Glib::VariantBase state 
)
explicitprotected

Member Function Documentation

◆ create() [1/4]

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

◆ create() [2/4]

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
nameThe name of the action.
stateThe initial state of the action.
Returns
A new SimpleAction.

◆ create() [3/4]

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() to create an action that has state.

Since glibmm 2.28:
Parameters
nameThe name of the action.
parameter_typeThe type of parameter that will be passed to handlers for the SimpleAction::signal_activate() signal, or nullptr for no parameter.
Returns
A new SimpleAction.

◆ create() [4/4]

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.

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

If the state Variant is floating, it is consumed.

Since glibmm 2.28:
Parameters
nameThe name of the action.
parameter_typeThe type of the parameter that will be passed to handlers for the SimpleAction::signal_activate() signal, or nullptr for no parameter.
stateThe initial state of the action.
Returns
A new SimpleAction.

◆ create_bool()

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
nameThe name of the action.
stateThe initial state of the action.
Returns
A new SimpleAction.

◆ create_radio_integer()

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

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

Since glibmm 2.38:
Parameters
nameThe name of the action.
initial_stateThe initial state of the action.
Returns
A new SimpleAction.

◆ create_radio_string()

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
nameThe name of the action.
initial_stateThe initial state of the action.
Returns
A new SimpleAction.

◆ get_type()

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

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

◆ gobj() [1/2]

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

Provides access to the underlying C GObject.

◆ gobj() [2/2]

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

Provides access to the underlying C GObject.

◆ gobj_copy()

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.

◆ operator=()

SimpleAction & Gio::SimpleAction::operator= ( SimpleAction &&  src)
noexcept

◆ property_enabled() [1/2]

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

If action is currently enabled.

If the action is disabled then calls to g_action_activate() and g_action_change_state() have no effect.

Since glibmm 2.28:

Default value: true

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.

◆ property_enabled() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gio::SimpleAction::property_enabled ( ) const

If action is currently enabled.

If the action is disabled then calls to g_action_activate() and g_action_change_state() have no effect.

Since glibmm 2.28:

Default value: true

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

◆ property_name()

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gio::SimpleAction::property_name ( ) const

The name of the action.

This is mostly meaningful for identifying the action once it has been added to a SimpleActionGroup.

Since glibmm 2.28:

Default value: ""

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

◆ property_parameter_type()

Glib::PropertyProxy_ReadOnly< Glib::VariantType > Gio::SimpleAction::property_parameter_type ( ) const

The type of the parameter that must be given when activating the action.

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

◆ property_state() [1/2]

Glib::PropertyProxy< Glib::VariantBase > Gio::SimpleAction::property_state ( )

The state of the action, or nullptr if the action is stateless.

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

◆ property_state() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::VariantBase > Gio::SimpleAction::property_state ( ) const

The state of the action, or nullptr if the action is stateless.

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

◆ property_state_type()

Glib::PropertyProxy_ReadOnly< Glib::VariantType > Gio::SimpleAction::property_state_type ( ) const

The VariantType of the state that the action has, or nullptr if the action is stateless.

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

◆ set_enabled()

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
enabledWhether the action is enabled.

◆ set_state()

void Gio::SimpleAction::set_state ( const Glib::VariantBase value)

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
valueThe new Variant for the state.

◆ set_state_hint()

void Gio::SimpleAction::set_state_hint ( const Glib::VariantBase state_hint)

Sets the state hint for the action.

See g_action_get_state_hint() for more information about action state hints.

Since glibmm 2.44:
Parameters
state_hintA Variant representing the state hint.

◆ signal_activate()

Glib::SignalProxy< void(const Glib::VariantBase &)> Gio::SimpleAction::signal_activate ( )
Slot Prototype:
void on_my_activate(const Glib::VariantBase& parameter)

Flags: Run Last, Must Collect

Indicates that the action was just activated.

parameter will always be of the expected type, i.e. the parameter type specified when the action was created. If an incorrect type is given when activating the action, this signal is not emitted.

Since GLib 2.40, if no handler is connected to this signal then the default behaviour for boolean-stated actions with a nullptr parameter type is to toggle them via the SimpleAction::signal_change_state() signal. For stateful actions where the state type is equal to the parameter type, the default is to forward them directly to SimpleAction::signal_change_state(). This should allow almost all users of SimpleAction to connect only one handler or the other.

Since glibmm 2.28:
Parameters
parameterThe parameter to the activation, or nullptr if it has no parameter.

◆ signal_change_state()

Glib::SignalProxy< void(const Glib::VariantBase &)> Gio::SimpleAction::signal_change_state ( )
Slot Prototype:
void on_my_change_state(const Glib::VariantBase& value)

Flags: Run Last, Must Collect

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

value will always be of the correct state type, i.e. the type of the initial state passed to g_simple_action_new_stateful(). If an incorrect type is given when requesting to change the state, this signal is not 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.

An example of a 'change-state' handler:

[C example ellipted]

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
valueThe requested value for the state.

Friends And Related Symbol Documentation

◆ wrap()

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