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 "gtkcsscustompropertyprivate.h"
23 #include "gtkcssstylefuncsprivate.h"
31 gtk_css_value_typed_free (GtkCssValue *value)
33 g_value_unset (&value->value);
34 g_slice_free (GtkCssValue, value);
38 gtk_css_value_typed_compute (GtkCssValue *value,
40 GtkStyleProviderPrivate *provider,
41 GtkCssComputedValues *values,
42 GtkCssComputedValues *parent_values,
43 GtkCssDependencies *dependencies)
45 GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (_gtk_css_style_property_lookup_by_id (property_id));
47 return _gtk_css_style_compute_value (provider, values, parent_values, custom->pspec->value_type, value, dependencies);
51 gtk_css_value_typed_equal (const GtkCssValue *value1,
52 const GtkCssValue *value2)
58 gtk_css_value_typed_transition (GtkCssValue *start,
67 gtk_css_value_typed_print (const GtkCssValue *value,
70 _gtk_css_style_print_value (&value->value, string);
73 static const GtkCssValueClass GTK_CSS_VALUE_TYPED = {
74 gtk_css_value_typed_free,
75 gtk_css_value_typed_compute,
76 gtk_css_value_typed_equal,
77 gtk_css_value_typed_transition,
78 gtk_css_value_typed_print
82 gtk_css_typed_value_new_for_type (GType type)
86 result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_TYPED);
88 g_value_init (&result->value, type);
94 _gtk_css_typed_value_new (const GValue *value)
98 g_return_val_if_fail (G_IS_VALUE (value), NULL);
100 result = gtk_css_typed_value_new_for_type (G_VALUE_TYPE (value));
102 g_value_copy (value, &result->value);
108 _gtk_css_typed_value_new_take (GValue *value)
112 g_return_val_if_fail (G_IS_VALUE (value), NULL);
114 result = _gtk_css_typed_value_new (value);
115 g_value_unset (value);
121 _gtk_is_css_typed_value_of_type (const GtkCssValue *value,
124 if (value->class != >K_CSS_VALUE_TYPED)
127 return G_VALUE_HOLDS (&value->value, type);
131 _gtk_css_typed_value_get (const GtkCssValue *value)
133 g_return_val_if_fail (value->class == >K_CSS_VALUE_TYPED, NULL);
135 return &value->value;