]> 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 f838299de9d20f219d78f722f652f0aa69ad1522..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
 };
@@ -31,11 +37,52 @@ gtk_css_value_initial_free (GtkCssValue *value)
 }
 
 static GtkCssValue *
-gtk_css_value_initial_compute (GtkCssValue     *value,
-                               GtkStyleContext *context)
+gtk_css_value_initial_compute (GtkCssValue             *value,
+                               guint                    property_id,
+                               GtkStyleProviderPrivate *provider,
+                               GtkCssComputedValues    *values,
+                               GtkCssComputedValues    *parent_values,
+                               GtkCssDependencies      *dependencies)
 {
-  /* This value should be caught further up */
-  g_return_val_if_reached (_gtk_css_value_ref (value));
+  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,
+                                 provider,
+                                 values,
+                                 parent_values,
+                                 dependencies);
 }
 
 static gboolean
@@ -48,6 +95,7 @@ gtk_css_value_initial_equal (const GtkCssValue *value1,
 static GtkCssValue *
 gtk_css_value_initial_transition (GtkCssValue *start,
                                   GtkCssValue *end,
+                                  guint        property_id,
                                   double       progress)
 {
   return NULL;
@@ -76,10 +124,8 @@ _gtk_css_initial_value_new (void)
   return _gtk_css_value_ref (&initial);
 }
 
-gboolean
-_gtk_css_value_is_initial (const GtkCssValue *value)
+GtkCssValue *
+_gtk_css_initial_value_get (void)
 {
-  g_return_val_if_fail (value != NULL, FALSE);
-
-  return value == &initial;
+  return &initial;
 }