[gtksourceview/gnome-3-24] gtksourcestylescheme: re-apply CSS when parent style is set



commit 66c758d40ee1248290daa671f47514e05b751a28
Author: Christian Hergert <chergert redhat com>
Date:   Fri Feb 15 13:22:13 2019 -0800

    gtksourcestylescheme: re-apply CSS when parent style is set
    
    We generate the CSS before the parent_id has been resolved into a pointer
    for another style within the style manager. That means we have cached
    values that are incorrect.
    
    This updates the CSS when the parent pointer is set so that the background
    and other text styles are updated correctly in the CSS provider.
    
    Fixes #37

 gtksourceview/gtksourcestylescheme.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/gtksourceview/gtksourcestylescheme.c b/gtksourceview/gtksourcestylescheme.c
index 702714f4..cbbb05cb 100644
--- a/gtksourceview/gtksourcestylescheme.c
+++ b/gtksourceview/gtksourcestylescheme.c
@@ -1442,6 +1442,11 @@ _gtk_source_style_scheme_set_parent (GtkSourceStyleScheme *scheme,
        g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME (scheme));
        g_return_if_fail (parent_scheme == NULL || GTK_SOURCE_IS_STYLE_SCHEME (parent_scheme));
 
+       if (scheme->priv->parent == parent_scheme)
+       {
+               return;
+       }
+
        g_clear_object (&scheme->priv->parent);
 
        if (parent_scheme != NULL)
@@ -1450,6 +1455,10 @@ _gtk_source_style_scheme_set_parent (GtkSourceStyleScheme *scheme,
        }
 
        scheme->priv->parent = parent_scheme;
+
+       /* Update CSS based on parent styles */
+       g_hash_table_remove_all (scheme->priv->style_cache);
+       generate_css_style (scheme);
 }
 
 /**


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