[gtk+/wip/cssvalue: 44/164] cssvalue: Remove _gtk_css_value_new_take_gvalue()



commit fa10f9bc178f94da5896bcf2c830bb737eff47b7
Author: Benjamin Otte <otte redhat com>
Date:   Mon Mar 26 07:46:18 2012 +0200

    cssvalue: Remove _gtk_css_value_new_take_gvalue()
    
    Having two constructors from GValues complicates refactorings, so I'd
    rather not have them.

 gtk/gtkcsscustomproperty.c    |    6 +++-
 gtk/gtkcssstylepropertyimpl.c |    3 +-
 gtk/gtkcssvalue.c             |   57 -----------------------------------------
 gtk/gtkcssvalueprivate.h      |    1 -
 4 files changed, 7 insertions(+), 60 deletions(-)
---
diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c
index 1be60d2..4f4e15f 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 a6a06db..dc6af92 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 b79c4ee..7bd1a55 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 047f9ea..39af9b3 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]