[gtk+] Make selectors with no explicit state from higher priority GtkStyleProviders override lower ones wit



commit 2f207ca749c4d705c39062761335458522c803d2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jan 17 04:06:57 2011 +0100

    Make selectors with no explicit state from higher priority GtkStyleProviders override lower ones with a state.
    
    This makes overriding information from the themes more intuitive

 gtk/gtkstyleproperties.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index 5dc088f..0052257 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -186,7 +186,7 @@ property_data_new (void)
 }
 
 static void
-property_data_free (PropertyData *data)
+property_data_remove_values (PropertyData *data)
 {
   guint i;
 
@@ -200,6 +200,14 @@ property_data_free (PropertyData *data)
         g_value_unset (&value_data->value);
     }
 
+  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);
 }
@@ -1203,6 +1211,16 @@ gtk_style_properties_merge (GtkStyleProperties       *props,
           GValue *value;
 
           data = &g_array_index (prop_to_merge->values, ValueData, i);
+
+          if (replace && data->state == GTK_STATE_FLAG_NORMAL &&
+              G_VALUE_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 &&



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]