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 "gtkcssinitialvalueprivate.h"
22 #include "gtkcssarrayvalueprivate.h"
23 #include "gtkcssnumbervalueprivate.h"
24 #include "gtkcssstringvalueprivate.h"
25 #include "gtkcssstylepropertyprivate.h"
26 #include "gtkstyleproviderprivate.h"
33 gtk_css_value_initial_free (GtkCssValue *value)
35 /* Can only happen if the unique value gets unreffed too often */
36 g_assert_not_reached ();
40 gtk_css_value_initial_compute (GtkCssValue *value,
42 GtkStyleProviderPrivate *provider,
43 GtkCssComputedValues *values,
44 GtkCssComputedValues *parent_values,
45 GtkCssDependencies *dependencies)
47 GtkSettings *settings;
51 case GTK_CSS_PROPERTY_FONT_FAMILY:
52 settings = _gtk_style_provider_private_get_settings (provider);
55 PangoFontDescription *description;
59 g_object_get (settings, "gtk-font-name", &font_name, NULL);
60 description = pango_font_description_from_string (font_name);
62 if (description == NULL)
65 if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_FAMILY)
67 value = _gtk_css_array_value_new (_gtk_css_string_value_new (pango_font_description_get_family (description)));
68 pango_font_description_free (description);
72 pango_font_description_free (description);
80 return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
89 gtk_css_value_initial_equal (const GtkCssValue *value1,
90 const GtkCssValue *value2)
96 gtk_css_value_initial_transition (GtkCssValue *start,
105 gtk_css_value_initial_print (const GtkCssValue *value,
108 g_string_append (string, "initial");
111 static const GtkCssValueClass GTK_CSS_VALUE_INITIAL = {
112 gtk_css_value_initial_free,
113 gtk_css_value_initial_compute,
114 gtk_css_value_initial_equal,
115 gtk_css_value_initial_transition,
116 gtk_css_value_initial_print
119 static GtkCssValue initial = { >K_CSS_VALUE_INITIAL, 1 };
122 _gtk_css_initial_value_new (void)
124 return _gtk_css_value_ref (&initial);
128 _gtk_css_initial_value_get (void)