prop-editor: Implement property editing for GdkRGBA properties
Bug #664467.
This commit is contained in:

committed by
Matthias Clasen

parent
2831151405
commit
af0537bce1
@ -660,6 +660,50 @@ object_properties (GtkWidget *button,
|
|||||||
create_prop_editor (obj, 0);
|
create_prop_editor (obj, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
color_modified (GtkColorButton *cb, gpointer data)
|
color_modified (GtkColorButton *cb, gpointer data)
|
||||||
{
|
{
|
||||||
@ -967,6 +1011,20 @@ property_widget (GObject *object,
|
|||||||
/* The Properties button is not really modifying, anyway */
|
/* The Properties button is not really modifying, anyway */
|
||||||
can_modify = TRUE;
|
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 &&
|
else if (type == G_TYPE_PARAM_BOXED &&
|
||||||
G_PARAM_SPEC_VALUE_TYPE (spec) == GDK_TYPE_COLOR)
|
G_PARAM_SPEC_VALUE_TYPE (spec) == GDK_TYPE_COLOR)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user