[glide] Start implementing binding stuff in shape inspector as a testbed
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] Start implementing binding stuff in shape inspector as a testbed
- Date: Fri, 7 May 2010 23:20:12 +0000 (UTC)
commit 226137ace7dc0d741ecbcc5f94d830e0afa10b76
Author: Robert Carr <racarr Valentine localdomain>
Date: Fri May 7 18:44:01 2010 -0400
Start implementing binding stuff in shape inspector as a testbed
libglide/glide-inspector-shape-priv.h | 4 ++
libglide/glide-inspector-shape.c | 70 ++++++++++++++++++++++++++++++++-
libglide/glide-inspector-shape.h | 1 +
3 files changed, 74 insertions(+), 1 deletions(-)
---
diff --git a/libglide/glide-inspector-shape-priv.h b/libglide/glide-inspector-shape-priv.h
index 1dc3a69..e04d9d8 100644
--- a/libglide/glide-inspector-shape-priv.h
+++ b/libglide/glide-inspector-shape-priv.h
@@ -27,6 +27,10 @@ G_BEGIN_DECLS
struct _GlideInspectorShapePrivate
{
GlideActor *actor;
+
+ GtkWidget *color_button;
+
+ GlideMutualBinding *color_binding;
};
G_END_DECLS
diff --git a/libglide/glide-inspector-shape.c b/libglide/glide-inspector-shape.c
index 08d02b3..316ceb3 100644
--- a/libglide/glide-inspector-shape.c
+++ b/libglide/glide-inspector-shape.c
@@ -31,6 +31,8 @@
#include "glide-gtk-util.h"
+
+
#include <string.h>
#include <math.h>
@@ -44,9 +46,39 @@ enum {
};
static void
+glide_inspector_shape_binding_destroyed (gpointer data)
+{
+ *(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);
+}
+
+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);
+}
+
+static void
glide_inspector_shape_finalize (GObject *object)
{
-
+
}
static void
@@ -87,6 +119,37 @@ glide_inspector_shape_set_property (GObject *object,
}
}
+static GtkWidget*
+glide_inspector_shape_make_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>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->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);
+
+ gtk_box_pack_start (GTK_BOX (vbox), color_box, FALSE, FALSE, 0);
+
+ gtk_container_add (GTK_CONTAINER (ins), vbox);
+}
+
static void
glide_inspector_shape_init (GlideInspectorShape *inspector)
{
@@ -94,6 +157,8 @@ glide_inspector_shape_init (GlideInspectorShape *inspector)
gtk_widget_set_sensitive (GTK_WIDGET (inspector), FALSE);
+ glide_inspector_shape_setup_ui (inspector);
+
gtk_alignment_set (GTK_ALIGNMENT (inspector), .5, 0, 0.8, 1.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (inspector), 5, 0, 0, 0);
@@ -132,10 +197,12 @@ glide_inspector_shape_get_actor (GlideInspectorShape *inspector)
return inspector->priv->actor;
}
+
void
glide_inspector_shape_set_actor (GlideInspectorShape *inspector,
GlideActor *actor)
{
+ glide_inspector_shape_unbind (inspector);
inspector->priv->actor = actor;
if (!actor)
@@ -148,6 +215,7 @@ glide_inspector_shape_set_actor (GlideInspectorShape *inspector,
else
{
gtk_widget_set_sensitive (GTK_WIDGET (inspector), TRUE);
+ glide_inspector_shape_bind (inspector);
}
g_object_notify (G_OBJECT (inspector), "actor");
diff --git a/libglide/glide-inspector-shape.h b/libglide/glide-inspector-shape.h
index b494ece..c93aa90 100644
--- a/libglide/glide-inspector-shape.h
+++ b/libglide/glide-inspector-shape.h
@@ -21,6 +21,7 @@
#include <gtk/gtk.h>
#include "glide-actor.h"
+#include "glide-binding.h"
G_BEGIN_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]