glibmm: Gio::PropertyAction Class Reference

glibmm 2.88.0

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

An Action reflecting a Glib::Object property. More...

`#include <giomm/propertyaction.h>`

Inheritance diagram for Gio::PropertyAction:
[legend]

## Public Member Functions
| PropertyAction (PropertyAction && src) noexcept
PropertyAction & | operator= (PropertyAction && src) noexcept
| ~PropertyAction () noexcept override
GPropertyAction * | gobj ()
| Provides access to the underlying C GObject.
const GPropertyAction * | gobj () const
| Provides access to the underlying C GObject.
GPropertyAction * | 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_ReadOnly< Glib::ustring > | property_name () const
| The name of the action.
Glib::PropertyProxy_ReadOnly< Glib::VariantType > | property_parameter_type () const
| The type of the parameter that must be given when activating the action.
Glib::PropertyProxy_ReadOnly< bool > | property_enabled () const
| If action is currently enabled.
Glib::PropertyProxy_ReadOnly< Glib::VariantType > | property_state_type () const
| The VariantType of the state that the action has, or nullptr if the action is stateless.
Glib::PropertyProxy_ReadOnly< Glib::VariantBase > | property_state () const
| The state of the action, or nullptr if the action is stateless.
Glib::PropertyProxy_ReadOnly< bool > | property_invert_boolean () const
| If true, the state of the action will be the negation of the property value, provided the property is boolean.
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object && src) noexcept
Object & | operator= (Object && src) noexcept
void * | get_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)
void * | steal_data (const QueryQuark & quark)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (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
Action & | operator= (Action && src) noexcept
| ~Action () noexcept override
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.
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::ustring > | property_name () const
| The name of the action.
Glib::PropertyProxy_ReadOnly< Glib::VariantType > | property_parameter_type () const
| The type of the parameter that must be given when activating the action.
Glib::PropertyProxy_ReadOnly< Glib::VariantBase > | property_state () const
| The state of the action, or nullptr if the action is stateless.
Glib::PropertyProxy_ReadOnly< Glib::VariantType > | property_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
Interface & | operator= (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
Interface & | operator= (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< PropertyAction > | create (const Glib::ustring & name, const Glib::PropertyProxy_Base & property_proxy, bool invert_boolean=false)
| Creates an Action corresponding to the value of property property_proxy.
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
| PropertyAction (const Glib::ustring & name, const Glib::PropertyProxy_Base & property_proxy, bool invert_boolean=false)
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
ObjectBase & | operator= (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::PropertyAction > | wrap (GPropertyAction * object, bool take_copy=false)
| A Glib::wrap() method for this object.
Related Symbols inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject * object, bool take_copy=false)
Related Symbols inherited from Gio::Action
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 Glib::Object
using | DestroyNotify = void (*)(gpointer data)

## Detailed Description

An Action reflecting a Glib::Object property.

A PropertyAction is a way to get an Action with a state value reflecting and controlling the value of a Glib::Object property.

The state of the action will correspond to the value of the property. Changing it will change the property (assuming the requested value matches the requirements as specified in the GParamSpec, used when the property was installed).

Only the most common types are presently supported. Booleans are mapped to booleans, strings to strings, signed/unsigned integers to int32/uint32 and floats and doubles to doubles.

If the property is an enum then the state will be string-typed and conversion will automatically be performed between the enum value and "nick" string as per the GEnumValue table.

Flags types are not currently supported.

Properties of object types, boxed types and pointer types are not supported and probably never will be.

Properties of Glib::Variant types are not currently supported.

If the property is boolean-valued then the action will have a nullptr parameter type, and activating the action (with no parameter) will toggle the value of the property.

In all other cases, the parameter type will correspond to the type of the property.

The general idea here is to reduce the number of locations where a particular piece of state is kept (and therefore has to be synchronised between). PropertyAction does not have a separate state that is kept in sync with the property value – its state is the property value.

For example, it might be useful to create an Action corresponding to property_visible_child_name() of a Gtk::Stack so that the current page can be switched from a menu. The active radio indication in the menu is then directly determined from the active page of the Gtk::Stack.

An anti-example would be binding property_active_id() on a Gtk::ComboBox. This is because the state of the combobox itself is probably uninteresting and is actually being used to control something else.

Another anti-example would be to bind to property_visible_child_name() of a Gtk::Stack if this value is actually stored in Gio::Settings. In that case, the real source of the value is Gio::Settings. If you want an Action to control a setting stored in Gio::Settings, see Gio::Settings::create_action() instead, and possibly combine its use with Gio::Settings::bind().

Since glibmm 2.58

## Constructor & Destructor Documentation

## ◆ PropertyAction() [1/2]

Gio::PropertyAction::PropertyAction | ( | PropertyAction && | src | ) |
| noexcept

## ◆ ~PropertyAction()

Gio::PropertyAction::~PropertyAction | ( |  | ) |
| overridenoexcept

## ◆ PropertyAction() [2/2]

Gio::PropertyAction::PropertyAction | ( | const Glib::ustring & | name,
|  | const Glib::PropertyProxy_Base & | property_proxy,
|  | bool | invert_boolean = false )
| protected

## Member Function Documentation

## ◆ create()

Glib::RefPtr< PropertyAction > Gio::PropertyAction::create | ( | const Glib::ustring & | name,
|  | const Glib::PropertyProxy_Base & | property_proxy,
|  | bool | invert_boolean = false )
| static

Creates an Action corresponding to the value of property property_proxy.

The property must be existent and readable and writable (and not construct-only).

This function takes a reference on the property's object and doesn't release it until the action is destroyed.

Parameters

  name | The name of the action to create.
  property_proxy | The property to bind.
  invert_boolean | If true, the state of the action will be the negation of the property value, provided the property is boolean.

Returns
  A new PropertyAction.

Since glibmm 2.58

## ◆ get_type()

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

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

## ◆ gobj() [1/2]

GPropertyAction * Gio::PropertyAction::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GPropertyAction * Gio::PropertyAction::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

GPropertyAction * Gio::PropertyAction::gobj_copy | ( |  | ) |

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

## ◆ operator=()

PropertyAction & Gio::PropertyAction::operator= | ( | PropertyAction && | src | ) |
| noexcept

## ◆ property_enabled()

Glib::PropertyProxy_ReadOnly< bool > Gio::PropertyAction::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.58

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

Glib::PropertyProxy_ReadOnly< bool > Gio::PropertyAction::property_invert_boolean | ( |  | ) | const

If true, the state of the action will be the negation of the property value, provided the property is boolean.

Since glibmm 2.58

Default value: false

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::PropertyAction::property_name | ( |  | ) | const

The name of the action.

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

Since glibmm 2.58

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::PropertyAction::property_parameter_type | ( |  | ) | const

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

Since glibmm 2.58

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

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

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

Since glibmm 2.58

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::PropertyAction::property_state_type | ( |  | ) | const

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

Since glibmm 2.58

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 Symbol Documentation

## ◆ wrap()

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