diff options
author | Benjamin Otte <otte@redhat.com> | 2012-03-26 07:46:18 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-04-17 08:59:11 +0200 |
commit | df45983fcb26b0cab9fa95b40c87f5029eecb133 (patch) | |
tree | 28b133b23c80a6c57efb84ed35864cf0a3d8e557 | |
parent | 8e3e3d582f7df902caa3c3e0ec9f503d1c6d9fd0 (diff) | |
download | gtk+-df45983fcb26b0cab9fa95b40c87f5029eecb133.tar.gz |
cssvalue: Remove _gtk_css_value_new_take_gvalue()
Having two constructors from GValues complicates refactorings, so I'd
rather not have them.
-rw-r--r-- | gtk/gtkcsscustomproperty.c | 6 | ||||
-rw-r--r-- | gtk/gtkcssstylepropertyimpl.c | 3 | ||||
-rw-r--r-- | gtk/gtkcssvalue.c | 57 | ||||
-rw-r--r-- | gtk/gtkcssvalueprivate.h | 1 |
4 files changed, 7 insertions, 60 deletions
diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c index 1be60d25b6..4f4e15f4b7 100644 --- a/gtk/gtkcsscustomproperty.c +++ b/gtk/gtkcsscustomproperty.c @@ -85,6 +85,7 @@ static GtkCssValue * gtk_css_custom_property_create_initial_value (GParamSpec *pspec) { GValue value = G_VALUE_INIT; + GtkCssValue *result; g_value_init (&value, pspec->value_type); @@ -111,7 +112,10 @@ gtk_css_custom_property_create_initial_value (GParamSpec *pspec) else g_param_value_set_default (pspec, &value); - return _gtk_css_value_new_take_gvalue (&value); + result = _gtk_css_value_new_from_gvalue (&value); + g_value_unset (&value); + + return result; } /* Property registration functions */ diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c index a6a06db7ef..dc6af9250a 100644 --- a/gtk/gtkcssstylepropertyimpl.c +++ b/gtk/gtkcssstylepropertyimpl.c @@ -80,7 +80,8 @@ gtk_css_style_property_register (const char * name, va_end (args); - initial_value = _gtk_css_value_new_take_gvalue (&initial_gvalue); + initial_value = _gtk_css_value_new_from_gvalue (&initial_gvalue); + g_value_unset (&initial_gvalue); node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY, "value-type", value_type, diff --git a/gtk/gtkcssvalue.c b/gtk/gtkcssvalue.c index b79c4ee180..7bd1a55e45 100644 --- a/gtk/gtkcssvalue.c +++ b/gtk/gtkcssvalue.c @@ -160,63 +160,6 @@ _gtk_css_value_new_from_gvalue (const GValue *g_value) } GtkCssValue * -_gtk_css_value_new_take_gvalue (GValue *g_value) -{ - GtkCssValue *value; - GType type; - - g_return_val_if_fail (g_value != NULL, NULL); - - type = G_VALUE_TYPE (g_value); - - /* Make sure we reuse the int/number singletons */ - if (type == G_TYPE_INT) - { - value = _gtk_css_value_new_from_int (g_value_get_int (g_value)); - g_value_unset (g_value); - } - else if (type == GTK_TYPE_CSS_NUMBER) - { - value = _gtk_css_value_new_from_number (g_value_get_boxed (g_value)); - g_value_unset (g_value); - } - else - { - value = gtk_css_value_new (type); - - if (g_type_is_a (type, G_TYPE_OBJECT)) - value->u.ptr = g_value_get_object (g_value); - else if (g_type_is_a (type, G_TYPE_BOXED)) - value->u.ptr = g_value_get_boxed (g_value); - else if (g_type_is_a (type, G_TYPE_INT)) - value->u.gint = g_value_get_int (g_value); - else if (g_type_is_a (type, G_TYPE_UINT)) - value->u.guint = g_value_get_uint (g_value); - else if (g_type_is_a (type, G_TYPE_BOOLEAN)) - value->u.gint = g_value_get_boolean (g_value); - else if (g_type_is_a (type, G_TYPE_ENUM)) - value->u.gint = g_value_get_enum (g_value); - else if (g_type_is_a (type, G_TYPE_FLAGS)) - value->u.guint = g_value_get_flags (g_value); - else if (g_type_is_a (type, G_TYPE_STRING)) - value->u.ptr = g_value_dup_string (g_value); - else if (g_type_is_a (type, G_TYPE_DOUBLE)) - value->u.dbl = g_value_get_double (g_value); - else if (g_type_is_a (type, G_TYPE_FLOAT)) - value->u.flt = g_value_get_float (g_value); - else - { - value->u.ptr = g_slice_new0 (GValue); - g_value_init (value->u.ptr, G_VALUE_TYPE (g_value)); - g_value_copy (g_value, value->u.ptr); - g_value_unset (g_value); - } - } - - return value; -} - -GtkCssValue * _gtk_css_value_new_from_int (gint val) { GtkCssValue *value; diff --git a/gtk/gtkcssvalueprivate.h b/gtk/gtkcssvalueprivate.h index 047f9ea8c0..39af9b344e 100644 --- a/gtk/gtkcssvalueprivate.h +++ b/gtk/gtkcssvalueprivate.h @@ -68,7 +68,6 @@ GType _gtk_css_value_get_content_type (const GtkCssValue gboolean _gtk_css_value_holds (const GtkCssValue *value, GType type); GtkCssValue *_gtk_css_value_new_from_gvalue (const GValue *g_value); -GtkCssValue *_gtk_css_value_new_take_gvalue (GValue *g_value); GtkCssValue *_gtk_css_value_new_from_int (gint val); GtkCssValue *_gtk_css_value_new_take_string (char *string); GtkCssValue *_gtk_css_value_new_from_rgba (const GdkRGBA *v); |