diff options
author | Benjamin Otte <otte@redhat.com> | 2012-12-01 01:49:06 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-12-01 01:49:06 +0100 |
commit | 1dd3ee6b594e7a9fe9aeca0be8c67aedada16764 (patch) | |
tree | 9e02cea29a2959ba96d56b9125085cb370224160 /gtk/gtkcssinitialvalue.c | |
parent | 3ff7f1fd43965d425f2e7fe81f9caa03f1fa97ea (diff) | |
download | gtk+-1dd3ee6b594e7a9fe9aeca0be8c67aedada16764.tar.gz |
css: Move default font handling
The default font is no longer handled like a custom style sheet that
overrides everything, but as the initial value. This is the same
behavior as in web browsers.
And it allows the theme to actually use the 'font-family' and
'font-size' properties. Of course, a well behaved theme will respect the
setting as much as possible and for example use relative font sizes
(which aren't yet supported, but will be soon).
Diffstat (limited to 'gtk/gtkcssinitialvalue.c')
-rw-r--r-- | gtk/gtkcssinitialvalue.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/gtk/gtkcssinitialvalue.c b/gtk/gtkcssinitialvalue.c index c9d253427f..b70b794112 100644 --- a/gtk/gtkcssinitialvalue.c +++ b/gtk/gtkcssinitialvalue.c @@ -19,7 +19,11 @@ #include "gtkcssinitialvalueprivate.h" +#include "gtkcssarrayvalueprivate.h" +#include "gtkcssnumbervalueprivate.h" +#include "gtkcssstringvalueprivate.h" #include "gtkcssstylepropertyprivate.h" +#include "gtkstyleproviderprivate.h" struct _GtkCssValue { GTK_CSS_VALUE_BASE @@ -40,6 +44,64 @@ gtk_css_value_initial_compute (GtkCssValue *value, GtkCssComputedValues *parent_values, GtkCssDependencies *dependencies) { + GtkSettings *settings; + + switch (property_id) + { + case GTK_CSS_PROPERTY_FONT_FAMILY: + settings = _gtk_style_provider_private_get_settings (provider); + if (settings) + { + PangoFontDescription *description; + char *font_name; + GtkCssValue *value; + + g_object_get (settings, "gtk-font-name", &font_name, NULL); + description = pango_font_description_from_string (font_name); + g_free (font_name); + if (description == NULL) + break; + + if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_FAMILY) + { + value = _gtk_css_array_value_new (_gtk_css_string_value_new (pango_font_description_get_family (description))); + pango_font_description_free (description); + return value; + } + + pango_font_description_free (description); + } + break; + + case GTK_CSS_PROPERTY_FONT_SIZE: + settings = _gtk_style_provider_private_get_settings (provider); + if (settings) + { + PangoFontDescription *description; + char *font_name; + GtkCssValue *value; + + g_object_get (settings, "gtk-font-name", &font_name, NULL); + description = pango_font_description_from_string (font_name); + g_free (font_name); + if (description == NULL) + break; + + if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_SIZE) + { + value = _gtk_css_number_value_new ((double) pango_font_description_get_size (description) / PANGO_SCALE, GTK_CSS_PX); + pango_font_description_free (description); + return value; + } + + pango_font_description_free (description); + } + break; + + default: + break; + } + return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)), property_id, provider, |