summaryrefslogtreecommitdiff
path: root/gtk/gtkcsscustomproperty.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2012-03-06 14:16:32 +0100
committerAlexander Larsson <alexl@redhat.com>2012-03-08 11:03:57 +0100
commit7603e6e47395b8e1d66522a22255637fa10d3a47 (patch)
tree0f5e58f31234cea8f6b6503e2b85b646dc603b29 /gtk/gtkcsscustomproperty.c
parent0ece7a5de3eae5f4d7e4d1623d191a0a0628e652 (diff)
downloadgtk+-7603e6e47395b8e1d66522a22255637fa10d3a47.tar.gz
css: Use GtkCssValues instead of GValue in the css machinery
Also, in places where we're computing a new CssValue based on an old one, make sure that if nothing changes we're returning a reference to the old one, rather than creating a new identical instance.
Diffstat (limited to 'gtk/gtkcsscustomproperty.c')
-rw-r--r--gtk/gtkcsscustomproperty.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c
index a7009f8490..179705b5c1 100644
--- a/gtk/gtkcsscustomproperty.c
+++ b/gtk/gtkcsscustomproperty.c
@@ -91,29 +91,32 @@ gtk_css_custom_property_get_specified_type (GParamSpec *pspec)
return pspec->value_type;
}
-static void
-gtk_css_custom_property_create_initial_value (GParamSpec *pspec,
- GValue *value)
+static GtkCssValue *
+gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
{
- g_value_init (value, gtk_css_custom_property_get_specified_type (pspec));
+ GValue value = G_VALUE_INIT;
+
+ g_value_init (&value, gtk_css_custom_property_get_specified_type (pspec));
if (pspec->value_type == GTK_TYPE_THEMING_ENGINE)
- g_value_set_object (value, gtk_theming_engine_load (NULL));
+ g_value_set_object (&value, gtk_theming_engine_load (NULL));
else if (pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
- g_value_take_boxed (value, pango_font_description_from_string ("Sans 10"));
+ g_value_take_boxed (&value, pango_font_description_from_string ("Sans 10"));
else if (pspec->value_type == GDK_TYPE_RGBA ||
pspec->value_type == GDK_TYPE_COLOR)
{
GdkRGBA color;
gdk_rgba_parse (&color, "pink");
- g_value_take_boxed (value, gtk_symbolic_color_new_literal (&color));
+ g_value_take_boxed (&value, gtk_symbolic_color_new_literal (&color));
}
else if (pspec->value_type == GTK_TYPE_BORDER)
{
- g_value_take_boxed (value, gtk_border_new ());
+ g_value_take_boxed (&value, gtk_border_new ());
}
else
- g_param_value_set_default (pspec, value);
+ g_param_value_set_default (pspec, &value);
+
+ return _gtk_css_value_new_take_gvalue (&value);
}
/* Property registration functions */
@@ -164,7 +167,7 @@ gtk_theming_engine_register_property (const gchar *name_space,
GParamSpec *pspec)
{
GtkCssCustomProperty *node;
- GValue initial = { 0, };
+ GtkCssValue *initial;
gchar *name;
g_return_if_fail (name_space != NULL);
@@ -172,10 +175,10 @@ gtk_theming_engine_register_property (const gchar *name_space,
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
name = g_strdup_printf ("-%s-%s", name_space, pspec->name);
- gtk_css_custom_property_create_initial_value (pspec, &initial);
+ initial = gtk_css_custom_property_create_initial_value (pspec);
node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
- "initial-value", &initial,
+ "initial-value", initial,
"name", name,
"computed-type", pspec->value_type,
"value-type", pspec->value_type,
@@ -183,7 +186,7 @@ gtk_theming_engine_register_property (const gchar *name_space,
node->pspec = pspec;
node->property_parse_func = parse_func;
- g_value_unset (&initial);
+ _gtk_css_value_unref (initial);
g_free (name);
}
@@ -204,14 +207,14 @@ gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
GParamSpec *pspec)
{
GtkCssCustomProperty *node;
- GValue initial = { 0, };
+ GtkCssValue *initial;
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
- gtk_css_custom_property_create_initial_value (pspec, &initial);
+ initial = gtk_css_custom_property_create_initial_value (pspec);
node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
- "initial-value", &initial,
+ "initial-value", initial,
"name", pspec->name,
"computed-type", pspec->value_type,
"value-type", pspec->value_type,
@@ -219,7 +222,7 @@ gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
node->pspec = pspec;
node->property_parse_func = parse_func;
- g_value_unset (&initial);
+ _gtk_css_value_unref (initial);
}
/**