[glide] More binding stuff
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] More binding stuff
- Date: Fri, 7 May 2010 23:20:17 +0000 (UTC)
commit 7ff1f33a4b2f63beaf234e11884135cfe3ed1520
Author: Robert Carr <racarr Valentine localdomain>
Date: Fri May 7 19:16:06 2010 -0400
More binding stuff
libglide/glide-binding.c | 68 +++++++++++++++++++++++++++++++++
libglide/glide-binding.h | 20 ++++++++++
libglide/glide-inspector-shape-priv.h | 3 +-
libglide/glide-inspector-shape.c | 60 ++++++++++++++++++-----------
4 files changed, 127 insertions(+), 24 deletions(-)
---
diff --git a/libglide/glide-binding.c b/libglide/glide-binding.c
index 4b89cbd..b122e53 100644
--- a/libglide/glide-binding.c
+++ b/libglide/glide-binding.c
@@ -600,3 +600,71 @@ glide_binding_transform_gdk_color_to_clutter_color (const GValue *src_value,
g_value_set_boxed (dst_value, &cc);
return TRUE;
}
+
+GlideMutualBindingPool *
+glide_mutual_binding_pool_new ()
+{
+ GlideMutualBindingPool *ret = g_malloc0 (sizeof (GlideMutualBindingPool));
+
+ return ret;
+}
+
+typedef struct _glide_binding_pool_destroy_data {
+ GlideMutualBindingPool *pool;
+ gpointer binding;
+} glide_binding_pool_destroy_data;
+
+static void
+glide_mutual_binding_pool_binding_destroyed (gpointer user_data)
+{
+ glide_binding_pool_destroy_data *data = (glide_binding_pool_destroy_data *)user_data;
+ data->pool->bindings = g_list_remove (data->pool->bindings,data->binding);
+
+ g_slice_free (glide_binding_pool_destroy_data, data);
+}
+
+GlideMutualBindingPool *
+glide_mutual_binding_pool_add_full (GlideMutualBindingPool *pool,
+ GObject *object1,
+ const gchar *property1,
+ GObject *object2,
+ const gchar *property2,
+ GlideBindingTransform transform,
+ GlideBindingTransform reverse_transform)
+{
+ GlideMutualBinding *binding;
+ glide_binding_pool_destroy_data *data = g_slice_new (glide_binding_pool_destroy_data);
+
+ binding = glide_mutual_binding_new_full (object1, property1,
+ object2, property2,
+ transform, reverse_transform,
+ glide_mutual_binding_pool_binding_destroyed,
+ data);
+ data->binding = binding;
+ data->pool = pool;
+
+
+ pool->bindings = g_list_append (pool->bindings, binding);
+}
+
+void
+glide_mutual_binding_pool_unbind (GlideMutualBindingPool *pool)
+{
+ GList *t;
+
+ for (t = pool->bindings; t;)
+ {
+ GList *o = t;
+ t = t->next;
+ glide_mutual_binding_unbind ((GlideMutualBinding *)o->data);
+ }
+ g_list_free (pool->bindings);
+ pool->bindings = NULL;
+}
+
+void
+glide_mutual_binding_pool_free (GlideMutualBindingPool *pool)
+{
+ glide_mutual_binding_pool_unbind (pool);
+ g_free (pool);
+}
diff --git a/libglide/glide-binding.h b/libglide/glide-binding.h
index 74530b2..250ea77 100644
--- a/libglide/glide-binding.h
+++ b/libglide/glide-binding.h
@@ -53,6 +53,10 @@ typedef struct _GlideBindingBase GlideBindingBase;
typedef struct _GlideBindingLink GlideBindingLink;
typedef struct _GlideMutualBinding GlideMutualBinding;
+typedef struct _GlideMutualBindingPool {
+ GList *bindings;
+} GlideMutualBindingPool;
+
typedef gboolean (*GlideBindingTransform) (const GValue *src_value,
GValue *dst_value,
gpointer user_data);
@@ -137,6 +141,22 @@ gboolean glide_binding_transform_clutter_color_to_gdk_color (const GValue *src_v
GValue *dst_value,
gpointer user_data);
+GlideMutualBindingPool *glide_mutual_binding_pool_new ();
+
+GlideMutualBindingPool *
+glide_mutual_binding_pool_add_full (GlideMutualBindingPool *pool,
+ GObject *object1,
+ const gchar *property1,
+ GObject *object2,
+ const gchar *property2,
+ GlideBindingTransform transform,
+ GlideBindingTransform reverse_transform);
+
+
+void glide_mutual_binding_pool_unbind (GlideMutualBindingPool *pool);
+
+void glide_mutual_binding_pool_free (GlideMutualBindingPool *pool);
+
G_END_DECLS
#endif /* __GLIDE_BINDING_H__ */
diff --git a/libglide/glide-inspector-shape-priv.h b/libglide/glide-inspector-shape-priv.h
index e04d9d8..da0051b 100644
--- a/libglide/glide-inspector-shape-priv.h
+++ b/libglide/glide-inspector-shape-priv.h
@@ -29,8 +29,9 @@ struct _GlideInspectorShapePrivate
GlideActor *actor;
GtkWidget *color_button;
+ GtkWidget *border_color_button;
- GlideMutualBinding *color_binding;
+ GlideMutualBindingPool *pool;
};
G_END_DECLS
diff --git a/libglide/glide-inspector-shape.c b/libglide/glide-inspector-shape.c
index 316ceb3..dfd090a 100644
--- a/libglide/glide-inspector-shape.c
+++ b/libglide/glide-inspector-shape.c
@@ -46,39 +46,29 @@ enum {
};
static void
-glide_inspector_shape_binding_destroyed (gpointer data)
+glide_inspector_shape_make_color_binding (GlideInspectorShape *ins,
+ GObject *actor, const gchar *actor_prop,
+ GObject *button)
{
- *(GlideMutualBinding **)data = NULL;
-}
-
-static GlideMutualBinding *
-glide_inspector_shape_make_color_binding (GObject *actor, GObject *button, GlideMutualBinding **location)
-{
- return glide_mutual_binding_new_full (actor, "color", button, "color",
- glide_binding_transform_clutter_color_to_gdk_color,
- glide_binding_transform_gdk_color_to_clutter_color,
- glide_inspector_shape_binding_destroyed,location);
-}
-
-static void
-glide_inspector_shape_unbind (GlideInspectorShape *ins)
-{
- if (ins->priv->color_binding)
- glide_mutual_binding_unbind (ins->priv->color_binding);
+ glide_mutual_binding_pool_add_full (ins->priv->pool, actor, actor_prop, button, "color",
+ glide_binding_transform_clutter_color_to_gdk_color,
+ glide_binding_transform_gdk_color_to_clutter_color);
}
static void
glide_inspector_shape_bind (GlideInspectorShape *ins)
{
- ins->priv->color_binding = glide_inspector_shape_make_color_binding (G_OBJECT (ins->priv->actor),
- G_OBJECT (ins->priv->color_button),
- &ins->priv->color_binding);
+ glide_inspector_shape_make_color_binding (ins, G_OBJECT (ins->priv->actor), "color",
+ G_OBJECT (ins->priv->color_button));
+ glide_inspector_shape_make_color_binding (ins, G_OBJECT (ins->priv->actor), "border-color",
+ G_OBJECT (ins->priv->border_color_button));
}
static void
glide_inspector_shape_finalize (GObject *object)
{
-
+ GlideInspectorShape *ins = (GlideInspectorShape *)object;
+ glide_mutual_binding_pool_free (ins->priv->pool);
}
static void
@@ -139,13 +129,35 @@ glide_inspector_shape_make_color_box (GlideInspectorShape *ins)
return ret;
}
+static GtkWidget*
+glide_inspector_shape_make_border_color_box (GlideInspectorShape *ins)
+{
+ GtkWidget *ret = gtk_hbox_new (FALSE, 0);
+ GtkWidget *label = gtk_label_new (NULL);
+ GtkWidget *align = gtk_alignment_new (1, 0, 0.6, 1);
+ GtkWidget *button = gtk_color_button_new ();
+
+ gtk_label_set_markup (GTK_LABEL (label), "<b>Border Color:</b>");
+
+ gtk_container_add (GTK_CONTAINER (align), button);
+
+ gtk_box_pack_start (GTK_BOX(ret), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(ret), align, TRUE, TRUE, 0);
+
+ ins->priv->border_color_button = button;
+
+ return ret;
+}
+
static void
glide_inspector_shape_setup_ui (GlideInspectorShape *ins)
{
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
GtkWidget *color_box = glide_inspector_shape_make_color_box (ins);
+ GtkWidget *border_color_box = glide_inspector_shape_make_border_color_box (ins);
gtk_box_pack_start (GTK_BOX (vbox), color_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), border_color_box, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (ins), vbox);
}
@@ -162,6 +174,8 @@ glide_inspector_shape_init (GlideInspectorShape *inspector)
gtk_alignment_set (GTK_ALIGNMENT (inspector), .5, 0, 0.8, 1.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (inspector), 5, 0, 0, 0);
+
+ inspector->priv->pool = glide_mutual_binding_pool_new ();
}
static void
@@ -202,7 +216,7 @@ void
glide_inspector_shape_set_actor (GlideInspectorShape *inspector,
GlideActor *actor)
{
- glide_inspector_shape_unbind (inspector);
+ glide_mutual_binding_pool_unbind (inspector->priv->pool);
inspector->priv->actor = actor;
if (!actor)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]