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 GtkStyleContext *context)
42 return _gtk_css_value_ref (value);
46 gtk_css_value_engine_equal (const GtkCssValue *value1,
47 const GtkCssValue *value2)
49 return value1->engine == value2->engine;
53 gtk_css_value_engine_transition (GtkCssValue *start,
61 gtk_css_value_engine_print (const GtkCssValue *value,
66 g_object_get (value->engine, "name", &name, NULL);
69 g_string_append (string, name);
71 g_string_append (string, "none");
76 static const GtkCssValueClass GTK_CSS_VALUE_ENGINE = {
77 gtk_css_value_engine_free,
78 gtk_css_value_engine_compute,
79 gtk_css_value_engine_equal,
80 gtk_css_value_engine_transition,
81 gtk_css_value_engine_print
85 _gtk_css_engine_value_new (GtkThemingEngine *engine)
89 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
91 result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_ENGINE);
92 result->engine = g_object_ref (engine);
98 _gtk_css_engine_value_parse (GtkCssParser *parser)
100 GtkThemingEngine *engine;
103 g_return_val_if_fail (parser != NULL, NULL);
105 if (_gtk_css_parser_try (parser, "none", TRUE))
106 return _gtk_css_engine_value_new (gtk_theming_engine_load (NULL));
108 str = _gtk_css_parser_try_ident (parser, TRUE);
111 _gtk_css_parser_error (parser, "Expected a valid theme name");
115 engine = gtk_theming_engine_load (str);
119 _gtk_css_parser_error (parser, "Theming engine '%s' not found", str);
126 return _gtk_css_engine_value_new (engine);
130 _gtk_css_engine_value_get_engine (const GtkCssValue *value)
132 g_return_val_if_fail (value->class == >K_CSS_VALUE_ENGINE, NULL);
134 return value->engine;