[gtk+/gtk-3-2] prop-editor: Implement property editing for GdkRGBA properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-2] prop-editor: Implement property editing for GdkRGBA properties
- Date: Mon, 12 Dec 2011 15:11:25 +0000 (UTC)
commit 901449adf761c520afa3de6466d583b95c2cf319
Author: Christian Persch <chpe gnome org>
Date: Mon Nov 21 14:07:06 2011 +0100
prop-editor: Implement property editing for GdkRGBA properties
Bug #664467.
tests/prop-editor.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/tests/prop-editor.c b/tests/prop-editor.c
index 674fb0c..edb6e3b 100644
--- a/tests/prop-editor.c
+++ b/tests/prop-editor.c
@@ -661,6 +661,50 @@ object_properties (GtkWidget *button,
}
static void
+rgba_modified (GtkColorButton *cb, gpointer data)
+{
+ ObjectProperty *p = data;
+ GdkRGBA color;
+
+ gtk_color_button_get_rgba (cb, &color);
+
+ if (is_child_property (p->spec))
+ {
+ GtkWidget *widget = GTK_WIDGET (p->obj);
+ GtkWidget *parent = gtk_widget_get_parent (widget);
+
+ gtk_container_child_set (GTK_CONTAINER (parent),
+ widget, p->spec->name, &color, NULL);
+ }
+ else
+ g_object_set (p->obj, p->spec->name, &color, NULL);
+}
+
+static void
+rgba_changed (GObject *object, GParamSpec *pspec, gpointer data)
+{
+ GtkColorButton *cb = GTK_COLOR_BUTTON (data);
+ GValue val = G_VALUE_INIT;
+ GdkRGBA *color;
+ GdkRGBA cb_color;
+
+ g_value_init (&val, GDK_TYPE_RGBA);
+ get_property_value (object, pspec, &val);
+
+ color = g_value_get_boxed (&val);
+ gtk_color_button_get_rgba (cb, &cb_color);
+
+ if (color != NULL && !gdk_rgba_equal (color, &cb_color))
+ {
+ block_controller (G_OBJECT (cb));
+ gtk_color_button_set_rgba (cb, color);
+ unblock_controller (G_OBJECT (cb));
+ }
+
+ g_value_unset (&val);
+}
+
+static void
color_modified (GtkColorButton *cb, gpointer data)
{
ObjectProperty *p = data;
@@ -968,6 +1012,20 @@ property_widget (GObject *object,
can_modify = TRUE;
}
else if (type == G_TYPE_PARAM_BOXED &&
+ G_PARAM_SPEC_VALUE_TYPE (spec) == GDK_TYPE_RGBA)
+ {
+ prop_edit = gtk_color_button_new ();
+ gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (prop_edit), TRUE);
+
+ g_object_connect_property (object, spec,
+ G_CALLBACK (rgba_changed),
+ prop_edit, G_OBJECT (prop_edit));
+
+ if (can_modify)
+ connect_controller (G_OBJECT (prop_edit), "color-set",
+ object, spec, G_CALLBACK (rgba_modified));
+ }
+ else if (type == G_TYPE_PARAM_BOXED &&
G_PARAM_SPEC_VALUE_TYPE (spec) == GDK_TYPE_COLOR)
{
prop_edit = gtk_color_button_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]