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,
41 GtkCssDependencies *dependencies)
43 return _gtk_css_value_ref (value);
47 gtk_css_value_engine_equal (const GtkCssValue *value1,
48 const GtkCssValue *value2)
50 return value1->engine == value2->engine;
54 gtk_css_value_engine_transition (GtkCssValue *start,
63 gtk_css_value_engine_print (const GtkCssValue *value,
68 g_object_get (value->engine, "name", &name, NULL);
71 g_string_append (string, name);
73 g_string_append (string, "none");
78 static const GtkCssValueClass GTK_CSS_VALUE_ENGINE = {
79 gtk_css_value_engine_free,
80 gtk_css_value_engine_compute,
81 gtk_css_value_engine_equal,
82 gtk_css_value_engine_transition,
83 gtk_css_value_engine_print
87 _gtk_css_engine_value_new (GtkThemingEngine *engine)
91 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
93 result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_ENGINE);
94 result->engine = g_object_ref (engine);
100 _gtk_css_engine_value_parse (GtkCssParser *parser)
102 GtkThemingEngine *engine;
105 g_return_val_if_fail (parser != NULL, NULL);
107 if (_gtk_css_parser_try (parser, "none", TRUE))
108 return _gtk_css_engine_value_new (gtk_theming_engine_load (NULL));
110 str = _gtk_css_parser_try_ident (parser, TRUE);
113 _gtk_css_parser_error (parser, "Expected a valid theme name");
117 engine = gtk_theming_engine_load (str);
121 _gtk_css_parser_error (parser, "Theming engine '%s' not found", str);
128 return _gtk_css_engine_value_new (engine);
132 _gtk_css_engine_value_get_engine (const GtkCssValue *value)
134 g_return_val_if_fail (value->class == >K_CSS_VALUE_ENGINE, NULL);
136 return value->engine;