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



commit 4d1db0f7b9b91215b233658400d0cc0ef9613d6c
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             |   52 -----------------------------------------
 gtk/gtkcssvalueprivate.h      |    1 -
 4 files changed, 7 insertions(+), 55 deletions(-)
---
diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c
index 179705b..0b470e0 100644
--- a/gtk/gtkcsscustomproperty.c
+++ b/gtk/gtkcsscustomproperty.c
@@ -95,6 +95,7 @@ static GtkCssValue *
 gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
 {
   GValue value = G_VALUE_INIT;
+  GtkCssValue *result;
 
   g_value_init (&value, gtk_css_custom_property_get_specified_type (pspec));
 
@@ -116,7 +117,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 46ba202..5707acc 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 143316e..a7a03e2 100644
--- a/gtk/gtkcssvalue.c
+++ b/gtk/gtkcssvalue.c
@@ -131,58 +131,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
-	g_assert_not_reached ();
-    }
-
-  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]