It derives from <GObject>.
<GObject> instance (or source) and another property
on another <GObject> 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 GObject.set 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 <GObject> 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 celsius-to-fahrenheit function 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 fahrenheit-to-celsius function 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 <GBinding> 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 object:notify signal only if the value has effectively been
changed. A binding is implemented using the object:notify signal, so it is susceptible to all the various
ways of blocking a signal emission, like
signal-stop-emission or
signal-handler-block.
A binding will be severed, and the resources it allocates freed,
whenever either one of the <GObject> instances it
refers to are finalized, or when the <GBinding>
instance loses its last reference.
Bindings for languages with garbage collection can use
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.
Flags to be used to control the <GBinding>
Its value is a <GBindingFlags> (or, to set
it, a list of its symbols, or one of them).
It can only be set when the object is made, with #:flags.
The <GObject> that should be used as the source of
the binding
Its value is a <GObject>, or #f.
It can only be set when the object is made, with #:source.
The name of the property of binding:source that should be used as the source of the
binding.
This should be in [canonical form][class@GObject.ParamSpec#parameter-names] to get the best performance.
Its value is a string, or #f.
It can only be set when the object is made, with
#:source-property.
The <GObject> that should be used as the target of
the binding
Its value is a <GObject>, or #f.
It can only be set when the object is made, with #:target.
The name of the property of binding:target that should be used as the target of the
binding.
This should be in [canonical form][class@GObject.ParamSpec#parameter-names] to get the best performance.
Its value is a string, or #f.
It can only be set when the object is made, with
#:target-property.
Retrieves the <GObject> instance used as the source
of the binding.
A <GBinding> can outlive the source
<GObject> 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 #f.
Passed: a <GBinding>.
Returned: a <GObject>, or #f.
the source <GObject>, or #f if the source
does not exist any more.
Retrieves the <GObject> instance used as the target
of the binding.
A <GBinding> can outlive the target
<GObject> 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 #f.
Passed: a <GBinding>.
Returned: a <GObject>, or #f.
the target <GObject>, or #f if the target
does not exist any more.
Retrieves the flags passed when constructing the
<GBinding>.
Passed: a <GBinding>.
Returned: a <GBindingFlags>.
the <GBindingFlags> used by the
<GBinding>
Retrieves the <GObject> instance used as the source
of the binding.
A <GBinding> can outlive the source
<GObject> 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 #f.
Use 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.
Passed: a <GBinding>.
Returned: a <GObject>, or #f.
the source <GObject>, or #f if the source
does not exist any more.
Retrieves the name of the property of binding:source used as the source of the binding.
Passed: a <GBinding>.
Returned: a string.
the name of the source property
Retrieves the <GObject> instance used as the target
of the binding.
A <GBinding> can outlive the target
<GObject> 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 #f.
Use 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.
Passed: a <GBinding>.
Returned: a <GObject>, or #f.
the target <GObject>, or #f if the target
does not exist any more.
Retrieves the name of the property of binding:target used as the target of the binding.
Passed: a <GBinding>.
Returned: a string.
the name of the target property
Explicitly releases the binding between the source and the target property expressed by self.
This function will release the reference that is being held on the
self instance if the binding is still bound; if you want to hold
on to the <GBinding> instance after calling
binding:unbind, you will need to hold a
reference to it.
Note however that this function does not take ownership of self,
it only unrefs the reference that was initially created by
object:bind-property and is owned by
the binding.
Passed: a <GBinding>.