Commit df45983f authored by Benjamin Otte's avatar Benjamin Otte

cssvalue: Remove _gtk_css_value_new_take_gvalue()

Having two constructors from GValues complicates refactorings, so I'd
rather not have them.
parent 8e3e3d58
......@@ -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)
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 */
......@@ -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,
......@@ -159,63 +159,6 @@ _gtk_css_value_new_from_gvalue (const GValue *g_value)
return 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);
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);
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)
......@@ -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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment