]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkstyleproperties.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkstyleproperties.c
index 5dc088f29ee8d8e8e0121483a50d285a7397eb0c..9788006b1612f5dec65c947af8bdea3d25edf9dd 100644 (file)
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 
-#include "gtkstyleproperties.h"
+#include "gtkstylepropertiesprivate.h"
 
 #include <stdlib.h>
 #include <gobject/gvaluecollector.h>
 #include <cairo-gobject.h>
 
-#include "gtktypebuiltins.h"
 #include "gtkstyleprovider.h"
-#include "gtksymboliccolor.h"
-#include "gtkprivate.h"
 #include "gtkthemingengine.h"
-#include "gtkanimationdescription.h"
-#include "gtkborder.h"
-#include "gtkgradient.h"
-#include "gtk9slice.h"
+#include "gtkcssshorthandpropertyprivate.h"
+#include "gtkcsstypedvalueprivate.h"
+#include "gtkcsstypesprivate.h"
+#include "gtkborderimageprivate.h"
+
+#include "gtkprivatetypebuiltins.h"
+#include "gtkstylepropertyprivate.h"
+#include "gtkstyleproviderprivate.h"
 #include "gtkintl.h"
+#include "gtkwin32themeprivate.h"
+
+#include "deprecated/gtkgradient.h"
+#include "deprecated/gtksymboliccolorprivate.h"
 
 /**
  * SECTION:gtkstyleproperties
  * should use the APIs provided by #GtkThemingEngine instead.
  */
 
-typedef struct GtkStylePropertiesPrivate GtkStylePropertiesPrivate;
 typedef struct PropertyData PropertyData;
-typedef struct PropertyNode PropertyNode;
 typedef struct ValueData ValueData;
 
-struct PropertyNode
-{
-  GQuark property_quark;
-  GParamSpec *pspec;
-  GtkStylePropertyParser parse_func;
-};
-
 struct ValueData
 {
   GtkStateFlags state;
-  GValue value;
+  GtkCssValue *value;
 };
 
 struct PropertyData
@@ -78,21 +72,22 @@ struct PropertyData
   GArray *values;
 };
 
-struct GtkStylePropertiesPrivate
+struct _GtkStylePropertiesPrivate
 {
   GHashTable *color_map;
   GHashTable *properties;
 };
 
-static GArray *properties = NULL;
-
-static void gtk_style_properties_provider_init (GtkStyleProviderIface *iface);
-static void gtk_style_properties_finalize      (GObject      *object);
+static void gtk_style_properties_provider_init         (GtkStyleProviderIface            *iface);
+static void gtk_style_properties_provider_private_init (GtkStyleProviderPrivateInterface *iface);
+static void gtk_style_properties_finalize              (GObject                          *object);
 
 
 G_DEFINE_TYPE_EXTENDED (GtkStyleProperties, gtk_style_properties, G_TYPE_OBJECT, 0,
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
-                                               gtk_style_properties_provider_init));
+                                               gtk_style_properties_provider_init)
+                        G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE,
+                                               gtk_style_properties_provider_private_init));
 
 static void
 gtk_style_properties_class_init (GtkStylePropertiesClass *klass)
@@ -101,76 +96,6 @@ gtk_style_properties_class_init (GtkStylePropertiesClass *klass)
 
   object_class->finalize = gtk_style_properties_finalize;
 
-  /* Initialize default property set */
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("color",
-                                                              "Foreground color",
-                                                              "Foreground color",
-                                                              GDK_TYPE_RGBA, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("background-color",
-                                                              "Background color",
-                                                              "Background color",
-                                                              GDK_TYPE_RGBA, 0));
-
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("font",
-                                                              "Font Description",
-                                                              "Font Description",
-                                                              PANGO_TYPE_FONT_DESCRIPTION, 0));
-
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("margin",
-                                                              "Margin",
-                                                              "Margin",
-                                                              GTK_TYPE_BORDER, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("padding",
-                                                              "Padding",
-                                                              "Padding",
-                                                              GTK_TYPE_BORDER, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("border-width",
-                                                              "Border width",
-                                                              "Border width, in pixels",
-                                                              GTK_TYPE_BORDER, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_int ("border-radius",
-                                                            "Border radius",
-                                                            "Border radius, in pixels",
-                                                            0, G_MAXINT, 0, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_enum ("border-style",
-                                                             "Border style",
-                                                             "Border style",
-                                                             GTK_TYPE_BORDER_STYLE,
-                                                             GTK_BORDER_STYLE_NONE, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("border-color",
-                                                              "Border color",
-                                                              "Border color",
-                                                              GDK_TYPE_RGBA, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("background-image",
-                                                              "Background Image",
-                                                              "Background Image",
-                                                              CAIRO_GOBJECT_TYPE_PATTERN, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("border-image",
-                                                              "Border Image",
-                                                              "Border Image",
-                                                              GTK_TYPE_9SLICE, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_object ("engine",
-                                                               "Theming Engine",
-                                                               "Theming Engine",
-                                                               GTK_TYPE_THEMING_ENGINE, 0));
-  gtk_style_properties_register_property (NULL,
-                                          g_param_spec_boxed ("transition",
-                                                              "Transition animation description",
-                                                              "Transition animation description",
-                                                              GTK_TYPE_ANIMATION_DESCRIPTION, 0));
-
   g_type_class_add_private (object_class, sizeof (GtkStylePropertiesPrivate));
 }
 
@@ -186,7 +111,7 @@ property_data_new (void)
 }
 
 static void
-property_data_free (PropertyData *data)
+property_data_remove_values (PropertyData *data)
 {
   guint i;
 
@@ -196,10 +121,18 @@ property_data_free (PropertyData *data)
 
       value_data = &g_array_index (data->values, ValueData, i);
 
-      if (G_IS_VALUE (&value_data->value))
-        g_value_unset (&value_data->value);
+      _gtk_css_value_unref (value_data->value);
+      value_data->value = NULL;
     }
 
+  if (data->values->len > 0)
+    g_array_remove_range (data->values, 0, data->values->len);
+}
+
+static void
+property_data_free (PropertyData *data)
+{
+  property_data_remove_values (data);
   g_array_free (data->values, TRUE);
   g_slice_free (PropertyData, data);
 }
@@ -254,11 +187,10 @@ property_data_find_position (PropertyData  *data,
   return found;
 }
 
-static GValue *
+static ValueData *
 property_data_get_value (PropertyData  *data,
                          GtkStateFlags  state)
 {
-  ValueData *val_data;
   guint pos;
 
   if (!property_data_find_position (data, state, &pos))
@@ -269,12 +201,10 @@ property_data_get_value (PropertyData  *data,
       g_array_insert_val (data->values, pos, new);
     }
 
-  val_data = &g_array_index (data->values, ValueData, pos);
-
-  return &val_data->value;
+  return &g_array_index (data->values, ValueData, pos);
 }
 
-static GValue *
+static GtkCssValue *
 property_data_match_state (PropertyData  *data,
                            GtkStateFlags  state)
 {
@@ -287,7 +217,7 @@ property_data_match_state (PropertyData  *data,
 
       /* Exact match */
       val_data = &g_array_index (data->values, ValueData, pos);
-      return &val_data->value;
+      return val_data->value;
     }
 
   if (pos >= data->values->len)
@@ -314,7 +244,7 @@ property_data_match_state (PropertyData  *data,
       if (val_data->state == 0 ||
           ((val_data->state & state) != 0 &&
            (val_data->state & ~state) == 0))
-        return &val_data->value;
+        return val_data->value;
     }
 
   return NULL;
@@ -349,163 +279,77 @@ gtk_style_properties_finalize (GObject *object)
   G_OBJECT_CLASS (gtk_style_properties_parent_class)->finalize (object);
 }
 
-GtkStyleProperties *
-gtk_style_properties_get_style (GtkStyleProvider *provider,
-                                GtkWidgetPath    *path)
-{
-  /* Return style set itself */
-  return g_object_ref (provider);
-}
-
 static void
 gtk_style_properties_provider_init (GtkStyleProviderIface *iface)
 {
-  iface->get_style = gtk_style_properties_get_style;
-}
-
-static int
-compare_property (gconstpointer p1,
-                  gconstpointer p2)
-{
-  PropertyNode *key = (PropertyNode *) p1;
-  PropertyNode *node = (PropertyNode *) p2;
-
-  if (key->property_quark > node->property_quark)
-    return 1;
-  else if (key->property_quark < node->property_quark)
-    return -1;
-
-  return 0;
 }
 
-static PropertyNode *
-property_node_lookup (GQuark quark)
+static GtkCssValue *
+gtk_style_properties_provider_get_color (GtkStyleProviderPrivate *provider,
+                                         const char              *name)
 {
-  PropertyNode key = { 0 };
+  GtkSymbolicColor *symbolic;
 
-  if (!quark)
-    return NULL;
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
 
-  if (!properties)
+  symbolic = gtk_style_properties_lookup_color (GTK_STYLE_PROPERTIES (provider), name);
+  if (symbolic == NULL)
     return NULL;
 
-  key.property_quark = quark;
+  return _gtk_symbolic_color_get_css_value (symbolic);
 
-  return bsearch (&key, properties->data, properties->len,
-                  sizeof (PropertyNode), compare_property);
+  G_GNUC_END_IGNORE_DEPRECATIONS;
 }
 
-/* Property registration functions */
-
-/**
- * gtk_style_properties_register_property:
- * @parse_func: parsing function to use, or %NULL
- * @pspec: the #GParamSpec for the new property
- *
- * Registers a property so it can be used in the CSS file format.
- * This function is the low-level equivalent of
- * gtk_theming_engine_register_property(), if you are implementing
- * a theming engine, you want to use that function instead.
- *
- * Since: 3.0
- **/
-void
-gtk_style_properties_register_property (GtkStylePropertyParser  parse_func,
-                                        GParamSpec             *pspec)
+static void
+gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
+                                      const GtkCssMatcher     *matcher,
+                                      GtkCssLookup            *lookup)
 {
-  PropertyNode *node, new = { 0 };
-  GQuark quark;
-  gint i;
-
-  g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+  GtkStyleProperties *props;
+  GtkStylePropertiesPrivate *priv;
+  GHashTableIter iter;
+  gpointer key, value;
 
-  if (G_UNLIKELY (!properties))
-    properties = g_array_new (FALSE, TRUE, sizeof (PropertyNode));
+  props = GTK_STYLE_PROPERTIES (provider);
+  priv = props->priv;
 
-  quark = g_quark_from_string (pspec->name);
+  /* Merge symbolic style properties */
+  g_hash_table_iter_init (&iter, priv->properties);
 
-  if ((node = property_node_lookup (quark)) != NULL)
+  while (g_hash_table_iter_next (&iter, &key, &value))
     {
-      g_warning ("Property \"%s\" was already registered with type %s",
-                 pspec->name, g_type_name (node->pspec->value_type));
-      return;
-    }
+      GtkCssStyleProperty *prop = key;
+      PropertyData *data = value;
+      GtkCssValue *value;
+      guint id;
 
-  new.property_quark = quark;
-  new.pspec = pspec;
+      id = _gtk_css_style_property_get_id (prop);
 
-  if (parse_func)
-    new.parse_func = parse_func;
+      if (!_gtk_css_lookup_is_missing (lookup, id))
+          continue;
 
-  for (i = 0; i < properties->len; i++)
-    {
-      node = &g_array_index (properties, PropertyNode, i);
+      value = property_data_match_state (data, _gtk_css_matcher_get_state (matcher));
+      if (value == NULL)
+        continue;
 
-      if (node->property_quark > quark)
-        break;
+      _gtk_css_lookup_set_computed (lookup, id, NULL, value);
     }
-
-  g_array_insert_val (properties, i, new);
 }
 
-/**
- * gtk_style_properties_lookup_property:
- * @property_name: property name to look up
- * @parse_func: (out): return location for the parse function
- * @pspec: (out): return location for the #GParamSpec
- *
- * Returns %TRUE if a property has been registered, if @pspec or
- * @parse_func are not %NULL, the #GParamSpec and parsing function
- * will be respectively returned.
- *
- * Returns: %TRUE if the property is registered, %FALSE otherwise
- *
- * Since: 3.0
- **/
-gboolean
-gtk_style_properties_lookup_property (const gchar             *property_name,
-                                      GtkStylePropertyParser  *parse_func,
-                                      GParamSpec             **pspec)
+static GtkCssChange
+gtk_style_properties_provider_get_change (GtkStyleProviderPrivate *provider,
+                                          const GtkCssMatcher     *matcher)
 {
-  PropertyNode *node;
-  GtkStylePropertiesClass *klass;
-  gboolean found = FALSE;
-  GQuark quark;
-  gint i;
-
-  g_return_val_if_fail (property_name != NULL, FALSE);
-
-  klass = g_type_class_ref (GTK_TYPE_STYLE_PROPERTIES);
-  quark = g_quark_try_string (property_name);
-
-  if (quark == 0)
-    {
-      g_type_class_unref (klass);
-      return FALSE;
-    }
-
-  for (i = 0; i < properties->len; i++)
-    {
-      node = &g_array_index (properties, PropertyNode, i);
-
-      if (node->property_quark == quark)
-        {
-          if (pspec)
-            *pspec = node->pspec;
-
-          if (parse_func)
-            *parse_func = node->parse_func;
-
-          found = TRUE;
-          break;
-        }
-      else if (node->property_quark > quark)
-        break;
-    }
-
-  g_type_class_unref (klass);
+  return GTK_CSS_CHANGE_STATE;
+}
 
-  return found;
+static void
+gtk_style_properties_provider_private_init (GtkStyleProviderPrivateInterface *iface)
+{
+  iface->get_color = gtk_style_properties_provider_get_color;
+  iface->lookup = gtk_style_properties_provider_lookup;
+  iface->get_change = gtk_style_properties_provider_get_change;
 }
 
 /* GtkStyleProperties methods */
@@ -533,6 +377,8 @@ gtk_style_properties_new (void)
  * gtk_style_properties_lookup_color()
  *
  * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkSymbolicColor is deprecated.
  **/
 void
 gtk_style_properties_map_color (GtkStyleProperties *props,
@@ -547,6 +393,8 @@ gtk_style_properties_map_color (GtkStyleProperties *props,
 
   priv = props->priv;
 
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
   if (G_UNLIKELY (!priv->color_map))
     priv->color_map = g_hash_table_new_full (g_str_hash,
                                              g_str_equal,
@@ -556,6 +404,10 @@ gtk_style_properties_map_color (GtkStyleProperties *props,
   g_hash_table_replace (priv->color_map,
                         g_strdup (name),
                         gtk_symbolic_color_ref (color));
+
+  G_GNUC_END_IGNORE_DEPRECATIONS;
+
+  _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
 }
 
 /**
@@ -566,9 +418,11 @@ gtk_style_properties_map_color (GtkStyleProperties *props,
  * Returns the symbolic color that is mapped
  * to @name.
  *
- * Returns: The mapped color
+ * Returns: (transfer none): The mapped color
  *
  * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkSymbolicColor is deprecated.
  **/
 GtkSymbolicColor *
 gtk_style_properties_lookup_color (GtkStyleProperties *props,
@@ -587,6 +441,33 @@ gtk_style_properties_lookup_color (GtkStyleProperties *props,
   return g_hash_table_lookup (priv->color_map, name);
 }
 
+void
+_gtk_style_properties_set_property_by_property (GtkStyleProperties  *props,
+                                                GtkCssStyleProperty *style_prop,
+                                                GtkStateFlags        state,
+                                                GtkCssValue         *value)
+{
+  GtkStylePropertiesPrivate *priv;
+  PropertyData *prop;
+  ValueData *val;
+
+  priv = props->priv;
+  prop = g_hash_table_lookup (priv->properties, style_prop);
+
+  if (!prop)
+    {
+      prop = property_data_new ();
+      g_hash_table_insert (priv->properties, (gpointer) style_prop, prop);
+    }
+
+  val = property_data_get_value (prop, state);
+
+  _gtk_css_value_unref (val->value);
+  val->value = _gtk_css_value_ref (value);
+
+  _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
+}
+
 /**
  * gtk_style_properties_set_property:
  * @props: a #GtkStyleProperties
@@ -604,67 +485,26 @@ gtk_style_properties_set_property (GtkStyleProperties *props,
                                    GtkStateFlags       state,
                                    const GValue       *value)
 {
-  GtkStylePropertiesPrivate *priv;
-  PropertyNode *node;
-  PropertyData *prop;
-  GType value_type;
-  GValue *val;
+  GtkStyleProperty *node;
 
   g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
   g_return_if_fail (property != NULL);
   g_return_if_fail (value != NULL);
 
-  value_type = G_VALUE_TYPE (value);
-  node = property_node_lookup (g_quark_try_string (property));
+  node = _gtk_style_property_lookup (property);
 
   if (!node)
     {
       g_warning ("Style property \"%s\" is not registered", property);
       return;
     }
-
-  if (node->pspec->value_type == GDK_TYPE_RGBA ||
-      node->pspec->value_type == GDK_TYPE_COLOR)
-    {
-      /* Allow GtkSymbolicColor as well */
-      g_return_if_fail (value_type == GDK_TYPE_RGBA ||
-                        value_type == GDK_TYPE_COLOR ||
-                        value_type == GTK_TYPE_SYMBOLIC_COLOR);
-    }
-  else if (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN)
-    {
-      /* Allow GtkGradient as a substitute */
-      g_return_if_fail (value_type == CAIRO_GOBJECT_TYPE_PATTERN ||
-                        value_type == GTK_TYPE_GRADIENT);
-    }
-  else
-    g_return_if_fail (node->pspec->value_type == value_type);
-
-  priv = props->priv;
-  prop = g_hash_table_lookup (priv->properties,
-                              GINT_TO_POINTER (node->property_quark));
-
-  if (!prop)
-    {
-      prop = property_data_new ();
-      g_hash_table_insert (priv->properties,
-                           GINT_TO_POINTER (node->property_quark),
-                           prop);
-    }
-
-  val = property_data_get_value (prop, state);
-
-  if (G_VALUE_TYPE (val) == value_type)
-    g_value_reset (val);
-  else
+  if (_gtk_style_property_get_value_type (node) == G_TYPE_NONE)
     {
-      if (G_IS_VALUE (val))
-        g_value_unset (val);
-
-      g_value_init (val, value_type);
+      g_warning ("Style property \"%s\" is not settable", property);
+      return;
     }
-
-  g_value_copy (value, val);
+  
+  _gtk_style_property_assign (node, props, state, value);
 }
 
 /**
@@ -682,22 +522,20 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
                                  GtkStateFlags       state,
                                  va_list             args)
 {
-  GtkStylePropertiesPrivate *priv;
   const gchar *property_name;
 
   g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
 
-  priv = props->priv;
   property_name = va_arg (args, const gchar *);
 
   while (property_name)
     {
-      PropertyNode *node;
-      PropertyData *prop;
+      GtkStyleProperty *node;
       gchar *error = NULL;
-      GValue *val;
+      GType val_type;
+      GValue val = G_VALUE_INIT;
 
-      node = property_node_lookup (g_quark_try_string (property_name));
+      node = _gtk_style_property_lookup (property_name);
 
       if (!node)
         {
@@ -705,33 +543,26 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
           break;
         }
 
-      prop = g_hash_table_lookup (priv->properties,
-                                  GINT_TO_POINTER (node->property_quark));
-
-      if (!prop)
+      val_type = _gtk_style_property_get_value_type (node);
+      if (val_type == G_TYPE_NONE)
         {
-          prop = property_data_new ();
-          g_hash_table_insert (priv->properties,
-                               GINT_TO_POINTER (node->property_quark),
-                               prop);
+          g_warning ("Style property \"%s\" is not settable", property_name);
+          break;
         }
 
-      val = property_data_get_value (prop, state);
-
-      if (G_IS_VALUE (val))
-        g_value_unset (val);
-
-      g_value_init (val, node->pspec->value_type);
-      G_VALUE_COLLECT (val, args, 0, &error);
-
+      G_VALUE_COLLECT_INIT (&val, _gtk_style_property_get_value_type (node),
+                            args, 0, &error);
       if (error)
         {
           g_warning ("Could not set style property \"%s\": %s", property_name, error);
-          g_value_unset (val);
+          g_value_unset (&val);
           g_free (error);
           break;
         }
 
+      _gtk_style_property_assign (node, props, state, &val);
+      g_value_unset (&val);
+
       property_name = va_arg (args, const gchar *);
     }
 }
@@ -760,146 +591,39 @@ gtk_style_properties_set (GtkStyleProperties *props,
   va_end (args);
 }
 
-static gboolean
-resolve_color (GtkStyleProperties *props,
-              GValue             *value)
-{
-  GdkRGBA color;
-
-  /* Resolve symbolic color to GdkRGBA */
-  if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), props, &color))
-    return FALSE;
-
-  /* Store it back, this is where GdkRGBA caching happens */
-  g_value_unset (value);
-  g_value_init (value, GDK_TYPE_RGBA);
-  g_value_set_boxed (value, &color);
-
-  return TRUE;
-}
-
-static gboolean
-resolve_color_rgb (GtkStyleProperties *props,
-                   GValue             *value)
-{
-  GdkColor color = { 0 };
-  GdkRGBA rgba;
-
-  if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), props, &rgba))
-    return FALSE;
-
-  color.red = rgba.red * 65535. + 0.5;
-  color.green = rgba.green * 65535. + 0.5;
-  color.blue = rgba.blue * 65535. + 0.5;
-
-  g_value_unset (value);
-  g_value_init (value, GDK_TYPE_COLOR);
-  g_value_set_boxed (value, &color);
-
-  return TRUE;
-}
-
-static gboolean
-resolve_gradient (GtkStyleProperties *props,
-                  GValue             *value)
-{
-  cairo_pattern_t *gradient;
-
-  if (!gtk_gradient_resolve (g_value_get_boxed (value), props, &gradient))
-    return FALSE;
-
-  /* Store it back, this is where cairo_pattern_t caching happens */
-  g_value_unset (value);
-  g_value_init (value, CAIRO_GOBJECT_TYPE_PATTERN);
-  g_value_take_boxed (value, gradient);
-
-  return TRUE;
-}
-
-static gboolean
-style_properties_resolve_type (GtkStyleProperties *props,
-                               PropertyNode       *node,
-                               GValue             *val)
-{
-  if (val && G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR)
-    {
-      if (node->pspec->value_type == GDK_TYPE_RGBA)
-        {
-          if (!resolve_color (props, val))
-            return FALSE;
-        }
-      else if (node->pspec->value_type == GDK_TYPE_COLOR)
-        {
-          if (!resolve_color_rgb (props, val))
-            return FALSE;
-        }
-      else
-        return FALSE;
-    }
-  else if (val && G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT)
-    {
-      g_return_val_if_fail (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN, FALSE);
-
-      if (!resolve_gradient (props, val))
-        return FALSE;
-    }
-
-  return TRUE;
-}
-
-static void
-lookup_default_value (PropertyNode *node,
-                      GValue       *value)
-{
-  if (node->pspec->value_type == GTK_TYPE_THEMING_ENGINE)
-    g_value_set_object (value, gtk_theming_engine_load (NULL));
-  else if (node->pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
-    g_value_take_boxed (value, pango_font_description_from_string ("Sans 10"));
-  else if (node->pspec->value_type == GDK_TYPE_RGBA)
-    {
-      GdkRGBA color;
-      gdk_rgba_parse (&color, "pink");
-      g_value_set_boxed (value, &color);
-    }
-  else
-    g_param_value_set_default (node->pspec, value);
-}
-
-const GValue *
-_gtk_style_properties_peek_property (GtkStyleProperties *props,
-                                     const gchar        *prop_name,
-                                     GtkStateFlags       state)
+GtkCssValue *
+_gtk_style_properties_peek_property (GtkStyleProperties  *props,
+                                     GtkCssStyleProperty *property,
+                                     GtkStateFlags        state)
 {
   GtkStylePropertiesPrivate *priv;
-  PropertyNode *node;
   PropertyData *prop;
-  GValue *val;
 
-  g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), NULL);
-  g_return_val_if_fail (prop_name != NULL, NULL);
-
-  node = property_node_lookup (g_quark_try_string (prop_name));
-
-  if (!node)
-    {
-      g_warning ("Style property \"%s\" is not registered", prop_name);
-      return NULL;
-    }
+  g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
+  g_return_val_if_fail (property != NULL, FALSE);
 
   priv = props->priv;
-  prop = g_hash_table_lookup (priv->properties,
-                              GINT_TO_POINTER (node->property_quark));
-
-  if (!prop)
+  prop = g_hash_table_lookup (priv->properties, property);
+  if (prop == NULL)
     return NULL;
 
-  val = property_data_match_state (prop, state);
+  return property_data_match_state (prop, state);
+}
+
+typedef struct {
+  GtkStyleProperties *props;
+  GtkStateFlags       state;
+} StyleQueryData;
 
-  if (val &&
-      !style_properties_resolve_type (props, node, val))
-    return NULL;
+static GtkCssValue *
+style_query_func (guint    id,
+                  gpointer data)
+{
+  StyleQueryData *query = data;
 
-  return val;
+  return _gtk_style_properties_peek_property (query->props,
+                                              _gtk_css_style_property_lookup_by_id (id),
+                                              query->state);
 }
 
 /**
@@ -922,44 +646,29 @@ gtk_style_properties_get_property (GtkStyleProperties *props,
                                    GtkStateFlags       state,
                                    GValue             *value)
 {
-  GtkStylePropertiesPrivate *priv;
-  PropertyNode *node;
-  PropertyData *prop;
-  GValue *val;
+  StyleQueryData query = { props, state };
+  GtkStyleProperty *node;
 
   g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
   g_return_val_if_fail (property != NULL, FALSE);
   g_return_val_if_fail (value != NULL, FALSE);
 
-  node = property_node_lookup (g_quark_try_string (property));
-
+  node = _gtk_style_property_lookup (property);
   if (!node)
     {
       g_warning ("Style property \"%s\" is not registered", property);
       return FALSE;
     }
-
-  priv = props->priv;
-  prop = g_hash_table_lookup (priv->properties,
-                              GINT_TO_POINTER (node->property_quark));
-
-  if (!prop)
-    return FALSE;
-
-  g_value_init (value, node->pspec->value_type);
-  val = property_data_match_state (prop, state);
-
-  if (val &&
-      !style_properties_resolve_type (props, node, val))
-    return FALSE;
-
-  if (val)
+  if (_gtk_style_property_get_value_type (node) == G_TYPE_NONE)
     {
-      g_param_value_validate (node->pspec, val);
-      g_value_copy (val, value);
+      g_warning ("Style property \"%s\" is not gettable", property);
+      return FALSE;
     }
-  else
-    lookup_default_value (node, value);
+
+  _gtk_style_property_query (node,
+                             value,
+                             style_query_func,
+                             &query);
 
   return TRUE;
 }
@@ -979,53 +688,25 @@ gtk_style_properties_get_valist (GtkStyleProperties *props,
                                  GtkStateFlags       state,
                                  va_list             args)
 {
-  GtkStylePropertiesPrivate *priv;
   const gchar *property_name;
 
   g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
 
-  priv = props->priv;
   property_name = va_arg (args, const gchar *);
 
   while (property_name)
     {
-      PropertyNode *node;
-      PropertyData *prop;
       gchar *error = NULL;
-      GValue *val = NULL;
-
-      node = property_node_lookup (g_quark_try_string (property_name));
+      GValue value = G_VALUE_INIT;
 
-      if (!node)
-        {
-          g_warning ("Style property \"%s\" is not registered", property_name);
-          break;
-        }
+      if (!gtk_style_properties_get_property (props,
+                                             property_name,
+                                             state,
+                                             &value))
+       break;
 
-      prop = g_hash_table_lookup (priv->properties,
-                                  GINT_TO_POINTER (node->property_quark));
-
-      if (prop)
-        val = property_data_match_state (prop, state);
-
-      if (val &&
-          !style_properties_resolve_type (props, node, val))
-        val = NULL;
-
-      if (val)
-        {
-          g_param_value_validate (node->pspec, val);
-          G_VALUE_LCOPY (val, args, 0, &error);
-        }
-      else
-        {
-          GValue default_value = { 0 };
-
-          g_value_init (&default_value, node->pspec->value_type);
-          lookup_default_value (node, &default_value);
-          G_VALUE_LCOPY (&default_value, args, 0, &error);
-          g_value_unset (&default_value);
-        }
+      G_VALUE_LCOPY (&value, args, 0, &error);
+      g_value_unset (&value);
 
       if (error)
         {
@@ -1079,24 +760,42 @@ gtk_style_properties_unset_property (GtkStyleProperties *props,
                                      GtkStateFlags       state)
 {
   GtkStylePropertiesPrivate *priv;
-  PropertyNode *node;
+  GtkStyleProperty *node;
   PropertyData *prop;
   guint pos;
 
   g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
   g_return_if_fail (property != NULL);
 
-  node = property_node_lookup (g_quark_try_string (property));
+  node = _gtk_style_property_lookup (property);
 
   if (!node)
     {
       g_warning ("Style property \"%s\" is not registered", property);
       return;
     }
+  if (_gtk_style_property_get_value_type (node) == G_TYPE_NONE)
+    {
+      g_warning ("Style property \"%s\" is not settable", property);
+      return;
+    }
+
+  if (GTK_IS_CSS_SHORTHAND_PROPERTY (node))
+    {
+      GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (node);
+
+      for (pos = 0; pos < _gtk_css_shorthand_property_get_n_subproperties (shorthand); pos++)
+        {
+          GtkCssStyleProperty *sub = _gtk_css_shorthand_property_get_subproperty (shorthand, pos);
+          gtk_style_properties_unset_property (props,
+                                               _gtk_style_property_get_name (GTK_STYLE_PROPERTY (sub)),
+                                               state);
+        }
+      return;
+    }
 
   priv = props->priv;
-  prop = g_hash_table_lookup (priv->properties,
-                              GINT_TO_POINTER (node->property_quark));
+  prop = g_hash_table_lookup (priv->properties, node);
 
   if (!prop)
     return;
@@ -1107,10 +806,12 @@ gtk_style_properties_unset_property (GtkStyleProperties *props,
 
       data = &g_array_index (prop->values, ValueData, pos);
 
-      if (G_IS_VALUE (&data->value))
-        g_value_unset (&data->value);
+      _gtk_css_value_unref (data->value);
+      data->value = NULL;
 
       g_array_remove_index (prop->values, pos);
+
+      _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
     }
 }
 
@@ -1129,6 +830,8 @@ gtk_style_properties_clear (GtkStyleProperties *props)
 
   priv = props->priv;
   g_hash_table_remove_all (priv->properties);
+
+  _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
 }
 
 /**
@@ -1176,7 +879,9 @@ gtk_style_properties_merge (GtkStyleProperties       *props,
               g_hash_table_lookup (priv->color_map, name))
             continue;
 
+          G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
           gtk_style_properties_map_color (props, name, color);
+          G_GNUC_END_IGNORE_DEPRECATIONS;
         }
     }
 
@@ -1200,35 +905,55 @@ gtk_style_properties_merge (GtkStyleProperties       *props,
       for (i = 0; i < prop_to_merge->values->len; i++)
         {
           ValueData *data;
-          GValue *value;
+          ValueData *value;
 
           data = &g_array_index (prop_to_merge->values, ValueData, i);
+
+          if (replace && data->state == GTK_STATE_FLAG_NORMAL &&
+              _gtk_is_css_typed_value_of_type (data->value, PANGO_TYPE_FONT_DESCRIPTION))
+            {
+              /* Let normal state override all states
+               * previously set in the original set
+               */
+              property_data_remove_values (prop);
+            }
+
           value = property_data_get_value (prop, data->state);
 
-          if (G_VALUE_TYPE (&data->value) == PANGO_TYPE_FONT_DESCRIPTION &&
-              G_IS_VALUE (value))
+          if (_gtk_is_css_typed_value_of_type (data->value, PANGO_TYPE_FONT_DESCRIPTION) &&
+              value->value != NULL)
             {
               PangoFontDescription *font_desc;
               PangoFontDescription *font_desc_to_merge;
 
               /* Handle merging of font descriptions */
-              font_desc = g_value_get_boxed (value);
-              font_desc_to_merge = g_value_get_boxed (&data->value);
+              font_desc = g_value_get_boxed (_gtk_css_typed_value_get (value->value));
+              font_desc_to_merge = g_value_get_boxed (_gtk_css_typed_value_get (data->value));
 
               pango_font_description_merge (font_desc, font_desc_to_merge, replace);
             }
-          else if (replace || !G_IS_VALUE (value))
+          else if (_gtk_is_css_typed_value_of_type (data->value, G_TYPE_PTR_ARRAY) &&
+                   value->value != NULL)
             {
-              if (!G_IS_VALUE (value))
-                g_value_init (value, G_VALUE_TYPE (&data->value));
-              else if (G_VALUE_TYPE (value) != G_VALUE_TYPE (&data->value))
-                {
-                  g_value_unset (value);
-                  g_value_init (value, G_VALUE_TYPE (&data->value));
-                }
-
-              g_value_copy (&data->value, value);
+              GPtrArray *array, *array_to_merge;
+              gint i;
+
+              /* Append the array, mainly thought
+               * for the gtk-key-bindings property
+               */
+              array = g_value_get_boxed (_gtk_css_typed_value_get (value->value));
+              array_to_merge = g_value_get_boxed (_gtk_css_typed_value_get (data->value));
+
+              for (i = 0; i < array_to_merge->len; i++)
+                g_ptr_array_add (array, g_ptr_array_index (array_to_merge, i));
+            }
+          else if (replace || value->value == NULL)
+            {
+             _gtk_css_value_unref (value->value);
+             value->value = _gtk_css_value_ref (data->value);
             }
         }
     }
+
+  _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
 }