Binding Properties Functions

Binding Properties Functions — Functions used to bind two object properties together

Synopsis

#include <exo/exo.h>

                    ExoBinding;
                    ExoMutualBinding;
gboolean            (*ExoBindingTransform)              (const GValue *src_value,
                                                         GValue *dst_value,
                                                         gpointer user_data);
ExoBinding *        exo_binding_new                     (GObject *src_object,
                                                         const gchar *src_property,
                                                         GObject *dst_object,
                                                         const gchar *dst_property);
ExoBinding *        exo_binding_new_full                (GObject *src_object,
                                                         const gchar *src_property,
                                                         GObject *dst_object,
                                                         const gchar *dst_property,
                                                         ExoBindingTransform transform,
                                                         GDestroyNotify destroy_notify,
                                                         gpointer user_data);
ExoBinding *        exo_binding_new_with_negation       (GObject *src_object,
                                                         const gchar *src_property,
                                                         GObject *dst_object,
                                                         const gchar *dst_property);
void                exo_binding_unbind                  (ExoBinding *binding);
ExoMutualBinding *  exo_mutual_binding_new              (GObject *object1,
                                                         const gchar *property1,
                                                         GObject *object2,
                                                         const gchar *property2);
ExoMutualBinding *  exo_mutual_binding_new_full         (GObject *object1,
                                                         const gchar *property1,
                                                         GObject *object2,
                                                         const gchar *property2,
                                                         ExoBindingTransform transform,
                                                         ExoBindingTransform reverse_transform,
                                                         GDestroyNotify destroy_notify,
                                                         gpointer user_data);
ExoMutualBinding *  exo_mutual_binding_new_with_negation
                                                        (GObject *object1,
                                                         const gchar *property1,
                                                         GObject *object2,
                                                         const gchar *property2);
void                exo_mutual_binding_unbind           (ExoMutualBinding *binding);

Description

Binding properties is synchronizing values of several properties, so that when one of the bound properties changes, the other bound properties are automatically changed to the new value as well. These functions eliminate the need to write property change notification callbacks manually. It also increases the reliability of your project as you don't need to repeat similar code (and errors) manually.

Both uni-directional and mutual bindings are supported and you can specify functions to perform explicit transformation of values if required. Multiple properties can be bound together in a complex way and infinite loops are eliminated automatically.

For example, lets say, your program has a GtkEntry widget that allows the user to enter some text for the program, but this entry widget should only be sensitive if a GtkCheckButton is active.

Example 3. Connecting a GtkCheckButton and a GtkEntry

1
2
3
4
5
6
7
8
9
10
11
12
13