1 /* gbinding.h: Binding for object properties
3 * Copyright (C) 2010 Intel Corp.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Emmanuele Bassi <ebassi@linux.intel.com>
23 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
24 #error "Only <glib-object.h> can be included directly."
27 #ifndef __G_BINDING_H__
28 #define __G_BINDING_H__
31 #include <gobject/gobject.h>
35 #define G_TYPE_BINDING_FLAGS (g_binding_flags_get_type ())
37 #define G_TYPE_BINDING (g_binding_get_type ())
38 #define G_BINDING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_BINDING, GBinding))
39 #define G_IS_BINDING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_BINDING))
44 * <structname>GBinding</structname> is an opaque structure whose members
45 * cannot be accessed directly.
49 typedef struct _GBinding GBinding;
52 * GBindingTransformFunc:
53 * @binding: a #GBinding
54 * @source_value: the value of the source property
55 * @target_value: the value of the target property
56 * @user_data: data passed to the transform function
58 * A function to be called to transform the source property of @source
59 * from @source_value into the target property of @target using
62 * Return value: %TRUE if the transformation was successful, and %FALSE
67 typedef gboolean (* GBindingTransformFunc) (GBinding *binding,
68 const GValue *source_value,
74 * @G_BINDING_DEFAULT: The default binding; if the source property
75 * changes, the target property is updated with its value
76 * @G_BINDING_BIDIRECTIONAL: Bidirectional binding; if either the
77 * property of the source or the property of the target changes,
78 * the other is updated
79 * @G_BINDING_SYNC_CREATE: Synchronize the values of the source and
80 * target properties when creating the binding; the direction of
81 * the synchronization is always from the source to the target
83 * Flags to be passed to g_object_bind_property() or
84 * g_object_bind_property_full().
86 * This enumeration can be extended at later date.
90 typedef enum { /*< prefix=G_BINDING >*/
91 G_BINDING_DEFAULT = 0,
93 G_BINDING_BIDIRECTIONAL = 1 << 0,
94 G_BINDING_SYNC_CREATE = 1 << 1
97 GType g_binding_flags_get_type (void) G_GNUC_CONST;
98 GType g_binding_get_type (void) G_GNUC_CONST;
100 GBindingFlags g_binding_get_flags (GBinding *binding);
101 GObject * g_binding_get_source (GBinding *binding);
102 GObject * g_binding_get_target (GBinding *binding);
103 G_CONST_RETURN gchar *g_binding_get_source_property (GBinding *binding);
104 G_CONST_RETURN gchar *g_binding_get_target_property (GBinding *binding);
106 GBinding *g_object_bind_property (gpointer source,
107 const gchar *source_property,
109 const gchar *target_property,
110 GBindingFlags flags);
111 GBinding *g_object_bind_property_full (gpointer source,
112 const gchar *source_property,
114 const gchar *target_property,
116 GBindingTransformFunc transform_to,
117 GBindingTransformFunc transform_from,
119 GDestroyNotify notify);
123 #endif /* __G_BINDING_H__ */