]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssinitialvalue.c
filechooserbutton: Update the combo box even after the dialog is cancelled
[~andy/gtk] / gtk / gtkcssinitialvalue.c
index d9d960f0fcff7b6e4d179502c72df7732ce994d4..427044d57466f9eeed0f5dc13b1e437a74b18b6c 100644 (file)
 
 #include "gtkcssinitialvalueprivate.h"
 
+#include "gtkcssarrayvalueprivate.h"
+#include "gtkcssnumbervalueprivate.h"
+#include "gtkcssstringvalueprivate.h"
 #include "gtkcssstylepropertyprivate.h"
+#include "gtkstyleproviderprivate.h"
 
 struct _GtkCssValue {
   GTK_CSS_VALUE_BASE
@@ -33,14 +37,51 @@ gtk_css_value_initial_free (GtkCssValue *value)
 }
 
 static GtkCssValue *
-gtk_css_value_initial_compute (GtkCssValue        *value,
-                               guint               property_id,
-                               GtkStyleContext    *context,
-                               GtkCssDependencies *dependencies)
+gtk_css_value_initial_compute (GtkCssValue             *value,
+                               guint                    property_id,
+                               GtkStyleProviderPrivate *provider,
+                               GtkCssComputedValues    *values,
+                               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;
+
+    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,
-                                 context,
+                                 provider,
+                                 values,
+                                 parent_values,
                                  dependencies);
 }
 
@@ -82,3 +123,9 @@ _gtk_css_initial_value_new (void)
 {
   return _gtk_css_value_ref (&initial);
 }
+
+GtkCssValue *
+_gtk_css_initial_value_get (void)
+{
+  return &initial;
+}