glibmm 2.80.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
Glib::Binding Class Reference

Bind two object properties. More...

#include <glibmm/binding.h>

Inheritance diagram for Glib::Binding:
Inheritance graph
[legend]

Public Types

enum class  Flags {
  DEFAULT = 0x0 ,
  BIDIRECTIONAL = 1 << 0 ,
  SYNC_CREATE = 1 << 1 ,
  INVERT_BOOLEAN = 1 << 2
}
 
using SlotTransform = sigc::slot< bool(const GValue *, GValue *)>
 A slot to be called to transform values in a binding created by bind_property_value().
 
template<typename T_from , typename T_to >
using SlotTypedTransform = sigc::slot< std::optional< T_to >(const T_from &)>
 A slot to be called to transform values in a binding created by bind_property().
 
- Public Types inherited from Glib::Object
using DestroyNotify = void(*)(gpointer data)
 

Public Member Functions

 Binding (Binding &&src) noexcept
 
Bindingoperator= (Binding &&src) noexcept
 
 ~Binding () noexcept override
 
GBindinggobj ()
 Provides access to the underlying C GObject.
 
const GBindinggobj () const
 Provides access to the underlying C GObject.
 
GBindinggobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
Glib::ObjectBaseget_source ()
 Retrieves the Object instance used as the source of the binding.
 
const Glib::ObjectBaseget_source () const
 Retrieves the Object instance used as the source of the binding.
 
Glib::RefPtr< Glib::ObjectBasedup_source ()
 Retrieves the Object instance used as the source of the binding.
 
Glib::RefPtr< const Glib::ObjectBasedup_source () const
 Retrieves the Object instance used as the source of the binding.
 
Glib::ustring get_source_property () const
 Retrieves the name of the property of Binding::property_source() used as the source of the binding.
 
Glib::ObjectBaseget_target ()
 Retrieves the Object instance used as the target of the binding.
 
const Glib::ObjectBaseget_target () const
 Retrieves the Object instance used as the target of the binding.
 
Glib::RefPtr< Glib::ObjectBasedup_target ()
 Retrieves the Object instance used as the target of the binding.
 
Glib::RefPtr< const Glib::ObjectBasedup_target () const
 Retrieves the Object instance used as the target of the binding.
 
Glib::ustring get_target_property () const
 Retrieves the name of the property of Binding::property_target() used as the target of the binding.
 
Flags get_flags () const
 Retrieves the flags passed when constructing the Binding.
 
void unbind ()
 Explicitly releases the binding between the source and the target property expressed by this Binding instance.
 
Glib::PropertyProxy_ReadOnly< Flagsproperty_flags () const
 Flags to be used to control the Binding.
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Glib::ObjectBase > > property_source () const
 The Object that should be used as the source of the binding.
 
Glib::PropertyProxy_ReadOnly< Glib::ustringproperty_source_property () const
 The name of the property of Binding::property_source() that should be used as the source of the binding.
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Glib::ObjectBase > > property_target () const
 The Object that should be used as the target of the binding.
 
Glib::PropertyProxy_ReadOnly< Glib::ustringproperty_target_property () const
 The name of the property of Binding::property_target() that should be used as the target of the binding.
 
- 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.
 

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< Bindingbind_property_value (const PropertyProxy_Base &source_property, const PropertyProxy_Base &target_property, Flags flags=Flags::DEFAULT, const SlotTransform &transform_to={}, const SlotTransform &transform_from={})
 Creates a binding between source_property and target_property, allowing you to set the transformation functions to be used by the binding.
 
static Glib::RefPtr< Bindingbind_property (const PropertyProxy_Base &source_property, const PropertyProxy_Base &target_property, Flags flags=Flags::DEFAULT)
 Creates a binding between source_property and target_property.
 
template<typename T_source , typename T_target , typename T_functor_to >
static Glib::RefPtr< Bindingbind_property (const PropertyProxy< T_source > &source_property, const PropertyProxy< T_target > &target_property, Flags flags, const T_functor_to &transform_to)
 Creates a binding between source_property and target_property, allowing you to set a transformation function to be used by the binding.
 
template<typename T_source , typename T_target , typename T_functor_to >
static Glib::RefPtr< Bindingbind_property (const PropertyProxy< T_source > &source_property, const PropertyProxy_WriteOnly< T_target > &target_property, Flags flags, const T_functor_to &transform_to)
 Creates a binding between source_property and target_property, allowing you to set a transformation function to be used by the binding.
 
template<typename T_source , typename T_target , typename T_functor_to >
static Glib::RefPtr< Bindingbind_property (const PropertyProxy_ReadOnly< T_source > &source_property, const PropertyProxy< T_target > &target_property, Flags flags, const T_functor_to &transform_to)
 Creates a binding between source_property and target_property, allowing you to set a transformation function to be used by the binding.
 
template<typename T_source , typename T_target , typename T_functor_to >
static Glib::RefPtr< Bindingbind_property (const PropertyProxy_ReadOnly< T_source > &source_property, const PropertyProxy_WriteOnly< T_target > &target_property, Flags flags, const T_functor_to &transform_to)
 Creates a binding between source_property and target_property, allowing you to set a transformation function to be used by the binding.
 
template<typename T_source , typename T_target , typename T_functor_to , typename T_functor_from >
static Glib::RefPtr< Bindingbind_property (const PropertyProxy< T_source > &source_property, const PropertyProxy< T_target > &target_property, Flags flags, const T_functor_to &transform_to, const T_functor_from &transform_from)
 Creates a binding between source_property and target_property, allowing you to set the transformation functions to be used by the binding.
 

Additional Inherited Members

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

Detailed Description

Bind two object properties.

Glib::Binding is the representation of a binding between a property on a Glib::ObjectBase instance (or source) and another property on another Glib::ObjectBase instance (or target). Whenever the source property changes, the same value is applied to the target property; for instance, the following binding:

Glib::Binding::bind_property(object1->property_a(), object2->property_b());
static Glib::RefPtr< Binding > bind_property(const PropertyProxy_Base &source_property, const PropertyProxy_Base &target_property, Flags flags=Flags::DEFAULT)
Creates a binding between source_property and target_property.
Definition binding.h:308

will cause property_b() of object2 to be updated every time the value of property_a() of object1 changes.

It is possible to create a bidirectional binding between two properties of two Glib::ObjectBase instances, so that if either property changes, the other is updated as well, for instance:

Glib::Binding::bind_property(object1->property_a(), object2->property_b(),
@ BIDIRECTIONAL
Bidirectional binding; if either the property of the source or the property of the target changes,...

will keep the two properties in sync.

It is also possible to set a custom transformation function (in both directions, in case of a bidirectional binding) to apply a custom transformation from the source value to the target value before applying it; for instance, the following binding:

bool celsius_to_fahrenheit(const double& celsius, double& fahrenheit);
bool fahrenheit_to_celsius(const double& fahrenheit, double& celsius);
Glib::Binding::bind_property(adjustment1->property_value(),
adjustment2->property_value(), Glib::Binding::Flags::BIDIRECTIONAL,
sigc::ptr_fun(celsius_to_fahrenheit), sigc::ptr_fun(fahrenheit_to_celsius));

will keep property_value() of the two adjustments in sync; the celsius_to_fahrenheit() function will be called whenever property_value() of adjustment1 changes and will transform the current value of the property before applying it to property_value() of adjustment2.

Vice versa, the fahrenheit_to_celsius() function will be called whenever property_value() of adjustment2 changes, and will transform the current value of the property before applying it to property_value() of adjustment1.

Note that Glib::Binding does not resolve cycles by itself; a cycle like

object1->property_A() -> object2->property_B()
object2->property_B() -> object3->property_C()
object3->property_C() -> object1->property_A()

might lead to an infinite loop. The loop, in this particular case, can be avoided if the objects emit the GObject::notify signal only if the value has effectively been changed. A binding is implemented using the GObject::notify signal, so it is susceptible to all the various ways of blocking a signal emission, like Glib::SignalProxyNormal::emission_stop() or g_signal_handler_block().

The binding between the two properties is broken whenever either one of the Glib::ObjectBase instances it refers to is deleted or when unbind() is called. If a RefPtr<Binding> remains after the binding has been broken, get_source() and get_target() return a nullptr, and dup_source() and dup_target() return an empty RefPtr. It's not necessary to keep a RefPtr<Binding> in order to keep the binding alive.

Since glibmm 2.44:

Member Typedef Documentation

◆ SlotTransform

using Glib::Binding::SlotTransform = sigc::slot<bool(const GValue*, GValue*)>

A slot to be called to transform values in a binding created by bind_property_value().

For instance:

bool on_transform_to(const GValue* from_value, GValue* to_value);
Returns
true if the transformation was successful, and false otherwise.

◆ SlotTypedTransform

A slot to be called to transform values in a binding created by bind_property().

For instance:

std::optional<int> on_transform_to(const Glib::ustring& from_string);
Glib::ustring has much the same interface as std::string, but contains Unicode characters encoded as ...
Definition ustring.h:336
Returns
a value of type T_to if the transformation was successful, and an empty optional with no value (i.e. std::nullopt) otherwise.

Member Enumeration Documentation

◆ Flags

Enumerator
DEFAULT 

The default binding; if the source property changes, the target property is updated with its value.

BIDIRECTIONAL 

Bidirectional binding; if either the property of the source or the property of the target changes, the other is updated.

SYNC_CREATE 

Synchronize the values of the source and target properties when creating the binding; the direction of the synchronization is always from the source to the target.

INVERT_BOOLEAN 

If the two properties being bound are booleans, setting one to true will result in the other being set to false and vice versa.

This flag will only work for boolean properties, and cannot be used when passing custom transformation functions to g_object_bind_property_full().

Constructor & Destructor Documentation

◆ Binding()

Glib::Binding::Binding ( Binding &&  src)
noexcept

◆ ~Binding()

Glib::Binding::~Binding ( )
overridenoexcept

Member Function Documentation

◆ bind_property() [1/6]

static Glib::RefPtr< Binding > Glib::Binding::bind_property ( const PropertyProxy< T_source > &  source_property,
const PropertyProxy< T_target > &  target_property,
Flags  flags,
const T_functor_to transform_to 
)
inlinestatic

Creates a binding between source_property and target_property, allowing you to set a transformation function to be used by the binding.

Parameters
source_propertyThe source property to bind.
target_propertyThe target property to bind.
flagsFlags to pass to Binding.
transform_toThe transformation function from the source to the target, or an empty slot to use the default.
Returns
The Binding instance representing the binding between the two Glib::ObjectBase instances, or nullptr in case of error.
Template Parameters
T_sourceType of the source property. Must be a type that can be stored in a Glib::Value<T_source> object.
T_targetType of the target property. Must be a type that can be stored in a Glib::Value<T_target> object.
T_functor_toType of functor that translates from the source to the target. Must be convertible to SlotTypedTransform<T_source, T_target>.
See also
bind_property_value()
Since glibmm 2.44:

◆ bind_property() [2/6]

static Glib::RefPtr< Binding > Glib::Binding::bind_property ( const PropertyProxy< T_source > &  source_property,
const PropertyProxy< T_target > &  target_property,
Flags  flags,
const T_functor_to transform_to,
const T_functor_from transform_from 
)
inlinestatic

Creates a binding between source_property and target_property, allowing you to set the transformation functions to be used by the binding.

Parameters
source_propertyThe source property to bind.
target_propertyThe target property to bind.
flagsFlags to pass to Binding.
transform_toThe transformation function from the source to the target, or an empty slot to use the default.
transform_fromThe transformation function from the target to the source, or an empty slot to use the default.
Returns
The Binding instance representing the binding between the two Glib::ObjectBase instances, or nullptr in case of error.
Template Parameters
T_sourceType of the source property. Must be a type that can be stored in a Glib::Value<T_source> object.
T_targetType of the target property. Must be a type that can be stored in a Glib::Value<T_target> object.
T_functor_toType of functor that translates from the source to the target. Must be convertible to SlotTypedTransform<T_source, T_target>.
T_functor_fromType of functor that translates from the target to the source. Must be convertible to SlotTypedTransform<T_target, T_source>.
See also
bind_property_value()
Since glibmm 2.44:

◆ bind_property() [3/6]

static Glib::RefPtr< Binding > Glib::Binding::bind_property ( const PropertyProxy< T_source > &  source_property,
const PropertyProxy_WriteOnly< T_target > &  target_property,
Flags  flags,
const T_functor_to transform_to 
)
inlinestatic

Creates a binding between source_property and target_property, allowing you to set a transformation function to be used by the binding.

Parameters
source_propertyThe source property to bind.
target_propertyThe target property to bind.
flagsFlags to pass to Binding.
transform_toThe transformation function from the source to the target, or an empty slot to use the default.
Returns
The Binding instance representing the binding between the two Glib::ObjectBase instances, or nullptr in case of error.
Template Parameters
T_sourceType of the source property. Must be a type that can be stored in a Glib::Value<T_source> object.
T_targetType of the target property. Must be a type that can be stored in a Glib::Value<T_target> object.
T_functor_toType of functor that translates from the source to the target. Must be convertible to SlotTypedTransform<T_source, T_target>.
See also
bind_property_value()
Since glibmm 2.44:

◆ bind_property() [4/6]

static Glib::RefPtr< Binding > Glib::Binding::bind_property ( const PropertyProxy_Base source_property,
const PropertyProxy_Base target_property,
Flags  flags = Flags::DEFAULT 
)
inlinestatic

Creates a binding between source_property and target_property.

Parameters
source_propertyThe source property to bind.
target_propertyThe target property to bind.
flagsFlags to pass to Binding.
Returns
The Binding instance representing the binding between the two Glib::ObjectBase instances, or nullptr in case of error.
See also
bind_property_value()
Since glibmm 2.44:

◆ bind_property() [5/6]

static Glib::RefPtr< Binding > Glib::Binding::bind_property ( const PropertyProxy_ReadOnly< T_source > &  source_property,
const PropertyProxy< T_target > &  target_property,
Flags  flags,
const T_functor_to transform_to 
)
inlinestatic

Creates a binding between source_property and target_property, allowing you to set a transformation function to be used by the binding.

Parameters
source_propertyThe source property to bind.
target_propertyThe target property to bind.
flagsFlags to pass to Binding.
transform_toThe transformation function from the source to the target, or an empty slot to use the default.
Returns
The Binding instance representing the binding between the two Glib::ObjectBase instances, or nullptr in case of error.
Template Parameters
T_sourceType of the source property. Must be a type that can be stored in a Glib::Value<T_source> object.
T_targetType of the target property. Must be a type that can be stored in a Glib::Value<T_target> object.
T_functor_toType of functor that translates from the source to the target. Must be convertible to SlotTypedTransform<T_source, T_target>.
See also
bind_property_value()
Since glibmm 2.44:

◆ bind_property() [6/6]

static Glib::RefPtr< Binding > Glib::Binding::bind_property ( const PropertyProxy_ReadOnly< T_source > &  source_property,
const PropertyProxy_WriteOnly< T_target > &  target_property,
Flags  flags,
const T_functor_to transform_to 
)
inlinestatic

Creates a binding between source_property and target_property, allowing you to set a transformation function to be used by the binding.

Parameters
source_propertyThe source property to bind.
target_propertyThe target property to bind.
flagsFlags to pass to Binding.
transform_toThe transformation function from the source to the target, or an empty slot to use the default.
Returns
The Binding instance representing the binding between the two Glib::ObjectBase instances, or nullptr in case of error.
Template Parameters
T_sourceType of the source property. Must be a type that can be stored in a Glib::Value<T_source> object.
T_targetType of the target property. Must be a type that can be stored in a Glib::Value<T_target> object.
T_functor_toType of functor that translates from the source to the target. Must be convertible to SlotTypedTransform<T_source, T_target>.
See also
bind_property_value()
Since glibmm 2.44:

◆ bind_property_value()

static Glib::RefPtr< Binding > Glib::Binding::bind_property_value ( const PropertyProxy_Base source_property,
const PropertyProxy_Base target_property,
Flags  flags = Flags::DEFAULT,
const SlotTransform transform_to = {},
const SlotTransform transform_from = {} 
)
static

Creates a binding between source_property and target_property, allowing you to set the transformation functions to be used by the binding.

If flags contains Glib::Binding::Flags::BIDIRECTIONAL then the binding will be mutual: if target_property changes then the source_property will be updated as well. The transform_from function is only used in case of bidirectional bindings, otherwise it will be ignored.

The binding will automatically be removed when either the source or the target instance is deleted. To remove the binding without affecting the source and the target you can call unbind() on the returned Binding instance.

A Glib::ObjectBase instance can have multiple bindings.

If you supply transformation functions, it is usually easier to use one of the bind_property() overloads, to avoid the use of GValue in the transformation functions.

Parameters
source_propertyThe source property to bind.
target_propertyThe target property to bind.
flagsFlags to pass to Binding.
transform_toThe transformation function from the source to the target, or an empty slot to use the default.
transform_fromThe transformation function from the target to the source, or an empty slot to use the default.
Returns
The Binding instance representing the binding between the two Glib::ObjectBase instances, or nullptr in case of error.
Since glibmm 2.44:

◆ dup_source() [1/2]

Glib::RefPtr< Glib::ObjectBase > Glib::Binding::dup_source ( )

Retrieves the Object instance used as the source of the binding.

A Binding can outlive the source Object as the binding does not hold a strong reference to the source. If the source is destroyed before the binding then this function will return nullptr.

Since glibmm 2.70:
Returns
The source Object, or nullptr if the source does not exist any more.

◆ dup_source() [2/2]

Glib::RefPtr< const Glib::ObjectBase > Glib::Binding::dup_source ( ) const

Retrieves the Object instance used as the source of the binding.

A Binding can outlive the source Object as the binding does not hold a strong reference to the source. If the source is destroyed before the binding then this function will return nullptr.

Since glibmm 2.70:
Returns
The source Object, or nullptr if the source does not exist any more.

◆ dup_target() [1/2]

Glib::RefPtr< Glib::ObjectBase > Glib::Binding::dup_target ( )

Retrieves the Object instance used as the target of the binding.

A Binding can outlive the target Object as the binding does not hold a strong reference to the target. If the target is destroyed before the binding then this function will return nullptr.

Since glibmm 2.70:
Returns
The target Object, or nullptr if the target does not exist any more.

◆ dup_target() [2/2]

Glib::RefPtr< const Glib::ObjectBase > Glib::Binding::dup_target ( ) const

Retrieves the Object instance used as the target of the binding.

A Binding can outlive the target Object as the binding does not hold a strong reference to the target. If the target is destroyed before the binding then this function will return nullptr.

Since glibmm 2.70:
Returns
The target Object, or nullptr if the target does not exist any more.

◆ get_flags()

Flags Glib::Binding::get_flags ( ) const

Retrieves the flags passed when constructing the Binding.

Since glibmm 2.44:
Returns
The Glib::Binding::Flags used by the Binding.

◆ get_source() [1/2]

Glib::ObjectBase * Glib::Binding::get_source ( )

Retrieves the Object instance used as the source of the binding.

A Binding can outlive the source Object as the binding does not hold a strong reference to the source. If the source is destroyed before the binding then this function will return nullptr.

Use g_binding_dup_source() if the source or binding are used from different threads as otherwise the pointer returned from this function might become invalid if the source is finalized from another thread in the meantime.

Deprecated: 2.68: Use g_binding_dup_source() for a safer version of this function.

Since glibmm 2.44:
Deprecated:
Use dup_source() instead.
Returns
The source Object, or nullptr if the source does not exist any more.

◆ get_source() [2/2]

const Glib::ObjectBase * Glib::Binding::get_source ( ) const

Retrieves the Object instance used as the source of the binding.

A Binding can outlive the source Object as the binding does not hold a strong reference to the source. If the source is destroyed before the binding then this function will return nullptr.

Use g_binding_dup_source() if the source or binding are used from different threads as otherwise the pointer returned from this function might become invalid if the source is finalized from another thread in the meantime.

Deprecated: 2.68: Use g_binding_dup_source() for a safer version of this function.

Since glibmm 2.44:
Deprecated:
Use dup_source() instead.
Returns
The source Object, or nullptr if the source does not exist any more.

◆ get_source_property()

Glib::ustring Glib::Binding::get_source_property ( ) const

Retrieves the name of the property of Binding::property_source() used as the source of the binding.

Since glibmm 2.44:
Returns
The name of the source property.

◆ get_target() [1/2]

Glib::ObjectBase * Glib::Binding::get_target ( )

Retrieves the Object instance used as the target of the binding.

A Binding can outlive the target Object as the binding does not hold a strong reference to the target. If the target is destroyed before the binding then this function will return nullptr.

Use g_binding_dup_target() if the target or binding are used from different threads as otherwise the pointer returned from this function might become invalid if the target is finalized from another thread in the meantime.

Deprecated: 2.68: Use g_binding_dup_target() for a safer version of this function.

Since glibmm 2.44:
Deprecated:
Use dup_target() instead.
Returns
The target Object, or nullptr if the target does not exist any more.

◆ get_target() [2/2]

const Glib::ObjectBase * Glib::Binding::get_target ( ) const

Retrieves the Object instance used as the target of the binding.

A Binding can outlive the target Object as the binding does not hold a strong reference to the target. If the target is destroyed before the binding then this function will return nullptr.

Use g_binding_dup_target() if the target or binding are used from different threads as otherwise the pointer returned from this function might become invalid if the target is finalized from another thread in the meantime.

Deprecated: 2.68: Use g_binding_dup_target() for a safer version of this function.

Since glibmm 2.44:
Deprecated:
Use dup_target() instead.
Returns
The target Object, or nullptr if the target does not exist any more.

◆ get_target_property()

Glib::ustring Glib::Binding::get_target_property ( ) const

Retrieves the name of the property of Binding::property_target() used as the target of the binding.

Since glibmm 2.44:
Returns
The name of the target property.

◆ get_type()

static GType Glib::Binding::get_type ( )
static

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

◆ gobj() [1/2]

GBinding * Glib::Binding::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GBinding * Glib::Binding::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GBinding * Glib::Binding::gobj_copy ( )

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

◆ operator=()

Binding & Glib::Binding::operator= ( Binding &&  src)
noexcept

◆ property_flags()

Glib::PropertyProxy_ReadOnly< Flags > Glib::Binding::property_flags ( ) const

Flags to be used to control the Binding.

Since glibmm 2.44:

Default value: Glib::Binding::Flags::DEFAULT

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

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Glib::ObjectBase > > Glib::Binding::property_source ( ) const

The Object that should be used as the source of the binding.

Since glibmm 2.44:
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_source_property()

Glib::PropertyProxy_ReadOnly< Glib::ustring > Glib::Binding::property_source_property ( ) const

The name of the property of Binding::property_source() that should be used as the source of the binding.

This should be in [canonical form][canonical-parameter-names] to get the best performance.

Since glibmm 2.44:

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

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Glib::ObjectBase > > Glib::Binding::property_target ( ) const

The Object that should be used as the target of the binding.

Since glibmm 2.44:
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_target_property()

Glib::PropertyProxy_ReadOnly< Glib::ustring > Glib::Binding::property_target_property ( ) const

The name of the property of Binding::property_target() that should be used as the target of the binding.

This should be in [canonical form][canonical-parameter-names] to get the best performance.

Since glibmm 2.44:

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.

◆ unbind()

void Glib::Binding::unbind ( )

Explicitly releases the binding between the source and the target property expressed by this Binding instance.

The binding is also released if either the source object or the target object is deleted.

Since glibmm 2.44: