Package: gobject

Class g-binding

Superclasses

g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

flags
The flags property of type g-binding-flags (Read / Write / Construct Only)
Flags to be used to control the binding.
source
The source property of type g-object (Read / Write / Construct Only)
The object that should be used as the source of the binding.
source-property
The source-property property of type :string (Read / Write / Construct Only)
The name of the property of the source that should be used as the source of the binding. Default value: nil
target
The target property of type g-object (Read / Write / Construct Only)
The object that should be used as the target of the binding.
target-property
The target-property property of type :string (Read / Write / Construct Only)
The name of the property of the target that should be used for the binding.
Default value: nil

Details

g-binding is the representation of a binding between a property on a g-object instance, or source, and another property on another g-object instance, or target. Whenever the source property changes, the same value is applied to the target property. For instance, the following binding:
g_object_bind_property (object1, "property-a",
                        object2, "property-b",
                        G_BINDING_DEFAULT);  
will cause the property named property-b of object2 to be updated every time the g-object-set function or the specific accessor changes the value of the property property-a of object1.

It is possible to create a bidirectional binding between two properties of two g-object instances, so that if either property changes, the other is updated as well, for instance:
g_object_bind_property (object1, "property-a",
                        object2, "property-b",
                        G_BINDING_BIDIRECTIONAL);  
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:
g_object_bind_property_full (adjustment1, "value",
                             adjustment2, "value",
                             G_BINDING_BIDIRECTIONAL,
                             celsius_to_fahrenheit,
                             fahrenheit_to_celsius,
                             NULL, NULL);  
will keep the value property of the two adjustments in sync. The function celsius_to_fahrenheit will be called whenever the value property of adjustment1 changes and will transform the current value of the property before applying it to the value property of adjustment2.

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

Note that g-binding does not resolve cycles by itself. A cycle like
object1:propertyA -> object2:propertyB
object2:propertyB -> object3:propertyC
object3:propertyC -> object1:propertyA  
might lead to an infinite loop. The loop, in this particular case, can be avoided if the objects emit the "notify" signal only if the value has effectively been changed. A binding is implemented using the "notify" signal, so it is susceptible to all the various ways of blocking a signal emission, like the functions g-signal-stop-emission or g-signal-handler-block.

A binding will be severed, and the resources it allocates freed, whenever either one of the g-object instances it refers to are finalized, or when the g-binding instance loses its last reference.

Bindings for languages with garbage collection can use the function g-binding-unbind to explicitly release a binding between the source and target properties, instead of relying on the last reference on the binding, source, and target instances to drop.
 

Slot Access Functions

Inherited Slot Access Functions

2020-10-18