1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2011 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 #include "gtkcsstypedvalueprivate.h"
22 #include "gtkcssstylefuncsprivate.h"
30 gtk_css_value_typed_free (GtkCssValue *value)
32 g_value_unset (&value->value);
33 g_slice_free (GtkCssValue, value);
37 gtk_css_value_typed_compute (GtkCssValue *value,
38 GtkStyleContext *context)
40 return _gtk_css_value_ref (value);
44 gtk_css_value_typed_equal (const GtkCssValue *value1,
45 const GtkCssValue *value2)
51 gtk_css_value_typed_transition (GtkCssValue *start,
59 gtk_css_value_typed_print (const GtkCssValue *value,
62 _gtk_css_style_print_value (&value->value, string);
65 static const GtkCssValueClass GTK_CSS_VALUE_TYPED = {
66 gtk_css_value_typed_free,
67 gtk_css_value_typed_compute,
68 gtk_css_value_typed_equal,
69 gtk_css_value_typed_transition,
70 gtk_css_value_typed_print
74 gtk_css_typed_value_new_for_type (GType type)
78 result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_TYPED);
80 g_value_init (&result->value, type);
86 _gtk_css_typed_value_new (const GValue *value)
90 g_return_val_if_fail (G_IS_VALUE (value), NULL);
92 result = gtk_css_typed_value_new_for_type (G_VALUE_TYPE (value));
94 g_value_copy (value, &result->value);
100 _gtk_css_typed_value_new_take (GValue *value)
104 g_return_val_if_fail (G_IS_VALUE (value), NULL);
106 result = _gtk_css_typed_value_new (value);
107 g_value_unset (value);
113 _gtk_is_css_typed_value_of_type (const GtkCssValue *value,
116 if (value->class != >K_CSS_VALUE_TYPED)
119 return G_VALUE_HOLDS (&value->value, type);
123 _gtk_css_typed_value_get (const GtkCssValue *value)
125 g_return_val_if_fail (value->class == >K_CSS_VALUE_TYPED, NULL);
127 return &value->value;