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 "gtkcssimagevalueprivate.h"
22 #include "gtkcssimagecrossfadeprivate.h"
30 gtk_css_value_image_free (GtkCssValue *value)
32 g_object_unref (value->image);
33 g_slice_free (GtkCssValue, value);
37 gtk_css_value_image_compute (GtkCssValue *value,
39 GtkStyleProviderPrivate *provider,
40 GtkCssComputedValues *values,
41 GtkCssComputedValues *parent_values,
42 GtkCssDependencies *dependencies)
44 GtkCssImage *image, *computed;
46 image = _gtk_css_image_value_get_image (value);
49 return _gtk_css_value_ref (value);
51 computed = _gtk_css_image_compute (image, property_id, provider, values, parent_values, dependencies);
53 if (computed == image)
55 g_object_unref (computed);
56 return _gtk_css_value_ref (value);
59 return _gtk_css_image_value_new (computed);
63 gtk_css_value_image_equal (const GtkCssValue *value1,
64 const GtkCssValue *value2)
66 return value1->image == value2->image;
70 gtk_css_value_image_transition (GtkCssValue *start,
77 fade = _gtk_css_image_cross_fade_new (_gtk_css_image_value_get_image (start),
78 _gtk_css_image_value_get_image (end),
81 return _gtk_css_image_value_new (fade);
85 gtk_css_value_image_print (const GtkCssValue *value,
89 _gtk_css_image_print (value->image, string);
91 g_string_append (string, "none");
94 static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
95 gtk_css_value_image_free,
96 gtk_css_value_image_compute,
97 gtk_css_value_image_equal,
98 gtk_css_value_image_transition,
99 gtk_css_value_image_print
103 _gtk_css_image_value_new (GtkCssImage *image)
105 static GtkCssValue none_singleton = { >K_CSS_VALUE_IMAGE, 1, NULL };
109 return _gtk_css_value_ref (&none_singleton);
111 value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_IMAGE);
112 value->image = image;
118 _gtk_css_image_value_get_image (const GtkCssValue *value)
120 g_return_val_if_fail (value->class == >K_CSS_VALUE_IMAGE, NULL);