]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkstylecascade.c
GtkWidget::draw() - Document how to get the dirty region
[~andy/gtk] / gtk / gtkstylecascade.c
index f1bf5161258f35bede28d903ad19975a40b3dd35..ea63fc86f6637c56c2a05f3e0cf29150ebfe0f38 100644 (file)
@@ -34,6 +34,7 @@ struct _GtkStyleProviderData
 {
   GtkStyleProvider *provider;
   guint priority;
+  guint changed_signal_id;
 };
 
 static GtkStyleProvider *
@@ -90,16 +91,6 @@ gtk_style_cascade_iter_init (GtkStyleCascade     *cascade,
   return gtk_style_cascade_iter_next (cascade, iter);
 }
 
-static GtkStyleProperties * 
-gtk_style_cascade_get_style (GtkStyleProvider *provider,
-                             GtkWidgetPath    *path)
-{
-  /* This function is not used anymore by GTK and nobody
-   * else is ever supposed to call it */
-  g_warn_if_reached ();
-  return NULL;
-}
-
 static gboolean
 gtk_style_cascade_get_style_property (GtkStyleProvider *provider,
                                       GtkWidgetPath    *path,
@@ -126,30 +117,42 @@ gtk_style_cascade_get_style_property (GtkStyleProvider *provider,
   return FALSE;
 }
 
-static GtkIconFactory *
-gtk_style_cascade_get_icon_factory (GtkStyleProvider *provider,
-                                   GtkWidgetPath    *path)
-{
-  /* If anyone ever implements get_icon_factory(), I'll
-   * look at this function. Until then I'll just: */
-  return NULL;
-}
-
 static void
 gtk_style_cascade_provider_iface_init (GtkStyleProviderIface *iface)
 {
-  iface->get_style = gtk_style_cascade_get_style;
   iface->get_style_property = gtk_style_cascade_get_style_property;
-  iface->get_icon_factory = gtk_style_cascade_get_icon_factory;
 }
 
-static GtkSymbolicColor *
+static GtkSettings *
+gtk_style_cascade_get_settings (GtkStyleProviderPrivate *provider)
+{
+  GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
+  GtkStyleCascadeIter iter;
+  GtkSettings *settings;
+  GtkStyleProvider *item;
+
+  for (item = gtk_style_cascade_iter_init (cascade, &iter);
+       item;
+       item = gtk_style_cascade_iter_next (cascade, &iter))
+    {
+      if (!GTK_IS_STYLE_PROVIDER_PRIVATE (item))
+        continue;
+          
+      settings = _gtk_style_provider_private_get_settings (GTK_STYLE_PROVIDER_PRIVATE (item));
+      if (settings)
+        return settings;
+    }
+
+  return NULL;
+}
+
+static GtkCssValue *
 gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
                              const char              *name)
 {
   GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
   GtkStyleCascadeIter iter;
-  GtkSymbolicColor *symbolic;
+  GtkCssValue *color;
   GtkStyleProvider *item;
 
   for (item = gtk_style_cascade_iter_init (cascade, &iter);
@@ -158,9 +161,9 @@ gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
     {
       if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
         {
-          symbolic = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name);
-          if (symbolic)
-            return symbolic;
+          color = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name);
+          if (color)
+            return color;
         }
       else
         {
@@ -171,6 +174,30 @@ gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
   return NULL;
 }
 
+static GtkCssKeyframes *
+gtk_style_cascade_get_keyframes (GtkStyleProviderPrivate *provider,
+                                 const char              *name)
+{
+  GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
+  GtkStyleCascadeIter iter;
+  GtkCssKeyframes *keyframes;
+  GtkStyleProvider *item;
+
+  for (item = gtk_style_cascade_iter_init (cascade, &iter);
+       item;
+       item = gtk_style_cascade_iter_next (cascade, &iter))
+    {
+      if (!GTK_IS_STYLE_PROVIDER_PRIVATE (item))
+        continue;
+          
+      keyframes = _gtk_style_provider_private_get_keyframes (GTK_STYLE_PROVIDER_PRIVATE (item), name);
+      if (keyframes)
+        return keyframes;
+    }
+
+  return NULL;
+}
+
 static void
 gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
                           const GtkCssMatcher     *matcher,
@@ -198,11 +225,41 @@ gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
     }
 }
 
+static GtkCssChange
+gtk_style_cascade_get_change (GtkStyleProviderPrivate *provider,
+                              const GtkCssMatcher     *matcher)
+{
+  GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
+  GtkStyleCascadeIter iter;
+  GtkStyleProvider *item;
+  GtkCssChange change = 0;
+
+  for (item = gtk_style_cascade_iter_init (cascade, &iter);
+       item;
+       item = gtk_style_cascade_iter_next (cascade, &iter))
+    {
+      if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
+        {
+          change |= _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (item),
+                                                            matcher);
+        }
+      else
+        {
+          g_return_val_if_reached (GTK_CSS_CHANGE_ANY);
+        }
+    }
+
+  return change;
+}
+
 static void
 gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface)
 {
   iface->get_color = gtk_style_cascade_get_color;
+  iface->get_settings = gtk_style_cascade_get_settings;
+  iface->get_keyframes = gtk_style_cascade_get_keyframes;
   iface->lookup = gtk_style_cascade_lookup;
+  iface->get_change = gtk_style_cascade_get_change;
 }
 
 G_DEFINE_TYPE_EXTENDED (GtkStyleCascade, _gtk_style_cascade, G_TYPE_OBJECT, 0,
@@ -235,6 +292,7 @@ style_provider_data_clear (gpointer data_)
 {
   GtkStyleProviderData *data = data_;
 
+  g_signal_handler_disconnect (data->provider, data->changed_signal_id);
   g_object_unref (data->provider);
 }
 
@@ -285,10 +343,21 @@ _gtk_style_cascade_set_parent (GtkStyleCascade *cascade,
     return;
 
   if (parent)
-    g_object_ref (parent);
+    {
+      g_object_ref (parent);
+      g_signal_connect_swapped (parent,
+                                "-gtk-private-changed",
+                                G_CALLBACK (_gtk_style_provider_private_changed),
+                                cascade);
+    }
 
   if (cascade->parent)
-    g_object_unref (cascade->parent);
+    {
+      g_signal_handlers_disconnect_by_func (cascade->parent, 
+                                            _gtk_style_provider_private_changed,
+                                            cascade);
+      g_object_unref (cascade->parent);
+    }
 
   cascade->parent = parent;
 }
@@ -307,6 +376,10 @@ _gtk_style_cascade_add_provider (GtkStyleCascade  *cascade,
 
   data.provider = g_object_ref (provider);
   data.priority = priority;
+  data.changed_signal_id = g_signal_connect_swapped (provider,
+                                                     "-gtk-private-changed",
+                                                     G_CALLBACK (_gtk_style_provider_private_changed),
+                                                     cascade);
 
   /* ensure it gets removed first */
   _gtk_style_cascade_remove_provider (cascade, provider);
@@ -317,6 +390,8 @@ _gtk_style_cascade_add_provider (GtkStyleCascade  *cascade,
         break;
     }
   g_array_insert_val (cascade->providers, i, data);
+
+  _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade));
 }
 
 void
@@ -335,6 +410,8 @@ _gtk_style_cascade_remove_provider (GtkStyleCascade  *cascade,
       if (data->provider == provider)
         {
           g_array_remove_index (cascade->providers, i);
+  
+          _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade));
           break;
         }
     }