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 "gtkcssenginevalueprivate.h"
22 #include "gtkstylepropertyprivate.h"
26 GtkThemingEngine *engine;
30 gtk_css_value_engine_free (GtkCssValue *value)
32 g_object_unref (value->engine);
34 g_slice_free (GtkCssValue, value);
38 gtk_css_value_engine_compute (GtkCssValue *value,
40 GtkStyleProviderPrivate *provider,
41 GtkCssComputedValues *values,
42 GtkCssComputedValues *parent_values,
43 GtkCssDependencies *dependencies)
45 return _gtk_css_value_ref (value);
49 gtk_css_value_engine_equal (const GtkCssValue *value1,
50 const GtkCssValue *value2)
52 return value1->engine == value2->engine;
56 gtk_css_value_engine_transition (GtkCssValue *start,
65 gtk_css_value_engine_print (const GtkCssValue *value,
70 g_object_get (value->engine, "name", &name, NULL);
73 g_string_append (string, name);
75 g_string_append (string, "none");
80 static const GtkCssValueClass GTK_CSS_VALUE_ENGINE = {
81 gtk_css_value_engine_free,
82 gtk_css_value_engine_compute,
83 gtk_css_value_engine_equal,
84 gtk_css_value_engine_transition,
85 gtk_css_value_engine_print
89 _gtk_css_engine_value_new (GtkThemingEngine *engine)
93 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
95 result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_ENGINE);
96 result->engine = g_object_ref (engine);
102 _gtk_css_engine_value_parse (GtkCssParser *parser)
104 GtkThemingEngine *engine;
107 g_return_val_if_fail (parser != NULL, NULL);
109 if (_gtk_css_parser_try (parser, "none", TRUE))
110 return _gtk_css_engine_value_new (gtk_theming_engine_load (NULL));
112 str = _gtk_css_parser_try_ident (parser, TRUE);
115 _gtk_css_parser_error (parser, "Expected a valid theme name");
119 engine = gtk_theming_engine_load (str);
123 _gtk_css_parser_error (parser, "Theming engine '%s' not found", str);
130 return _gtk_css_engine_value_new (engine);
134 _gtk_css_engine_value_get_engine (const GtkCssValue *value)
136 g_return_val_if_fail (value->class == >K_CSS_VALUE_ENGINE, NULL);
138 return value->engine;