]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssshadowsvalue.c
filechooserbutton: whitespace fixes
[~andy/gtk] / gtk / gtkcssshadowsvalue.c
index 41b521fb6daca7c2a45f4331cf625ce150cad85f..0438316935a2dfc697ea5abb3826e852146833f4 100644 (file)
@@ -31,6 +31,9 @@ struct _GtkCssValue {
   GtkCssValue  *values[1];
 };
 
+static GtkCssValue *    gtk_css_shadows_value_new       (GtkCssValue **values,
+                                                         guint         len);
+
 static void
 gtk_css_value_shadows_free (GtkCssValue *value)
 {
@@ -44,6 +47,31 @@ gtk_css_value_shadows_free (GtkCssValue *value)
   g_slice_free1 (sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (value->len - 1), value);
 }
 
+static GtkCssValue *
+gtk_css_value_shadows_compute (GtkCssValue             *value,
+                               guint                    property_id,
+                               GtkStyleProviderPrivate *provider,
+                               GtkCssComputedValues    *values,
+                               GtkCssComputedValues    *parent_values,
+                               GtkCssDependencies      *dependencies)
+{
+  GtkCssValue *result;
+  GtkCssDependencies child_deps;
+  guint i;
+
+  if (value->len == 0)
+    return _gtk_css_value_ref (value);
+
+  result = gtk_css_shadows_value_new (value->values, value->len);
+  for (i = 0; i < value->len; i++)
+    {
+      result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, values, parent_values, &child_deps);
+      *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
+    }
+
+  return result;
+}
+
 static gboolean
 gtk_css_value_shadows_equal (const GtkCssValue *value1,
                              const GtkCssValue *value2)
@@ -67,9 +95,67 @@ gtk_css_value_shadows_equal (const GtkCssValue *value1,
 static GtkCssValue *
 gtk_css_value_shadows_transition (GtkCssValue *start,
                                   GtkCssValue *end,
+                                  guint        property_id,
                                   double       progress)
 {
-  return NULL;
+  guint i, len;
+  GtkCssValue **values;
+
+  /* catches the important case of 2 none values */
+  if (start == end)
+    return _gtk_css_value_ref (start);
+
+  if (start->len > end->len)
+    len = start->len;
+  else
+    len = end->len;
+
+  values = g_newa (GtkCssValue *, len);
+
+  for (i = 0; i < MIN (start->len, end->len); i++)
+    {
+      values[i] = _gtk_css_value_transition (start->values[i], end->values[i], property_id, progress);
+      if (values[i] == NULL)
+        {
+          while (i--)
+            _gtk_css_value_unref (values[i]);
+          return NULL;
+        }
+    }
+  if (start->len > end->len)
+    {
+      for (; i < len; i++)
+        {
+          GtkCssValue *fill = _gtk_css_shadow_value_new_for_transition (start->values[i]);
+          values[i] = _gtk_css_value_transition (start->values[i], fill, property_id, progress);
+          _gtk_css_value_unref (fill);
+
+          if (values[i] == NULL)
+            {
+              while (i--)
+                _gtk_css_value_unref (values[i]);
+              return NULL;
+            }
+        }
+    }
+  else
+    {
+      for (; i < len; i++)
+        {
+          GtkCssValue *fill = _gtk_css_shadow_value_new_for_transition (end->values[i]);
+          values[i] = _gtk_css_value_transition (fill, end->values[i], property_id, progress);
+          _gtk_css_value_unref (fill);
+
+          if (values[i] == NULL)
+            {
+              while (i--)
+                _gtk_css_value_unref (values[i]);
+              return NULL;
+            }
+        }
+    }
+
+  return gtk_css_shadows_value_new (values, len);
 }
 
 static void
@@ -94,6 +180,7 @@ gtk_css_value_shadows_print (const GtkCssValue *value,
 
 static const GtkCssValueClass GTK_CSS_VALUE_SHADOWS = {
   gtk_css_value_shadows_free,
+  gtk_css_value_shadows_compute,
   gtk_css_value_shadows_equal,
   gtk_css_value_shadows_transition,
   gtk_css_value_shadows_print
@@ -107,7 +194,7 @@ _gtk_css_shadows_value_new_none (void)
   return _gtk_css_value_ref (&none_singleton);
 }
 
-GtkCssValue *
+static GtkCssValue *
 gtk_css_shadows_value_new (GtkCssValue **values,
                            guint         len)
 {
@@ -152,27 +239,6 @@ _gtk_css_shadows_value_parse (GtkCssParser *parser)
   return result;
 }
 
-GtkCssValue *
-_gtk_css_shadows_value_compute (GtkCssValue     *value,
-                                GtkStyleContext *context)
-{
-  GtkCssValue *result;
-  guint i;
-
-  g_return_val_if_fail (value->class == &GTK_CSS_VALUE_SHADOWS, NULL);
-
-  if (value->len == 0)
-    return _gtk_css_value_ref (value);
-
-  result = gtk_css_shadows_value_new (value->values, value->len);
-  for (i = 0; i < value->len; i++)
-    {
-      result->values[i] = _gtk_css_shadow_value_compute (value->values[i], context);
-    }
-
-  return result;
-}
-
 void
 _gtk_css_shadows_value_paint_layout (const GtkCssValue *shadows,
                                      cairo_t           *cr,