diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 93201007aa..022d408ebd 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1299,6 +1299,12 @@ gtk_css_ruleset_matches (GtkCssRuleset *ruleset, return _gtk_css_selector_matches (ruleset->selector, matcher); } +static GtkCssChange +gtk_css_ruleset_get_change (GtkCssRuleset *ruleset) +{ + return _gtk_css_selector_get_change (ruleset->selector); +} + static void gtk_css_scanner_destroy (GtkCssScanner *scanner) { @@ -1627,11 +1633,42 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider, } } +static GtkCssChange +gtk_css_style_provider_get_change (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher) +{ + GtkCssProvider *css_provider; + GtkCssProviderPrivate *priv; + GtkCssChange change = 0; + int i; + + css_provider = GTK_CSS_PROVIDER (provider); + priv = css_provider->priv; + + for (i = priv->rulesets->len - 1; i >= 0; i--) + { + GtkCssRuleset *ruleset; + + ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i); + + if (ruleset->styles == NULL) + continue; + + if (!gtk_css_ruleset_matches (ruleset, matcher)) + continue; + + change |= gtk_css_ruleset_get_change (ruleset); + } + + return change; +} + static void gtk_css_style_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface) { iface->get_color = gtk_css_style_provider_get_color; iface->lookup = gtk_css_style_provider_lookup; + iface->get_change = gtk_css_style_provider_get_change; } static void diff --git a/gtk/gtkmodifierstyle.c b/gtk/gtkmodifierstyle.c index c16a051c44..2700250690 100644 --- a/gtk/gtkmodifierstyle.c +++ b/gtk/gtkmodifierstyle.c @@ -154,11 +154,22 @@ gtk_modifier_style_provider_lookup (GtkStyleProviderPrivate *provider, lookup); } +static GtkCssChange +gtk_modifier_style_provider_get_change (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher) +{ + GtkModifierStyle *style = GTK_MODIFIER_STYLE (provider); + + return _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (style->priv->style), + matcher); +} + static void gtk_modifier_style_provider_private_init (GtkStyleProviderPrivateInterface *iface) { iface->get_color = gtk_modifier_style_provider_get_color; iface->lookup = gtk_modifier_style_provider_lookup; + iface->get_change = gtk_modifier_style_provider_get_change; } static void diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 75487b8239..f1b03ee72b 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -1481,11 +1481,24 @@ gtk_settings_style_provider_lookup (GtkStyleProviderPrivate *provider, lookup); } +static GtkCssChange +gtk_settings_style_provider_get_change (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher) +{ + GtkSettings *settings = GTK_SETTINGS (provider); + + settings_ensure_style (settings); + + return _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style), + matcher); +} + static void gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface) { iface->get_color = gtk_settings_style_provider_get_color; iface->lookup = gtk_settings_style_provider_lookup; + iface->get_change = gtk_settings_style_provider_get_change; } static void diff --git a/gtk/gtkstylecascade.c b/gtk/gtkstylecascade.c index f1bf516125..a05d36dd77 100644 --- a/gtk/gtkstylecascade.c +++ b/gtk/gtkstylecascade.c @@ -198,11 +198,39 @@ 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->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, diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 5add14dfc2..d63b659dde 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -337,11 +337,19 @@ gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider, } } +static GtkCssChange +gtk_style_properties_provider_get_change (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher) +{ + return GTK_CSS_CHANGE_STATE; +} + 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 */ diff --git a/gtk/gtkstyleproviderprivate.c b/gtk/gtkstyleproviderprivate.c index 43ae1712ff..fc7e29862e 100644 --- a/gtk/gtkstyleproviderprivate.c +++ b/gtk/gtkstyleproviderprivate.c @@ -61,3 +61,20 @@ _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider, iface->lookup (provider, matcher, lookup); } + +GtkCssChange +_gtk_style_provider_private_get_change (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher) +{ + GtkStyleProviderPrivateInterface *iface; + + g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), GTK_CSS_CHANGE_ANY); + g_return_val_if_fail (matcher != NULL, GTK_CSS_CHANGE_ANY); + + iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider); + + if (!iface->get_change) + return GTK_CSS_CHANGE_ANY; + + return iface->get_change (provider, matcher); +} diff --git a/gtk/gtkstyleproviderprivate.h b/gtk/gtkstyleproviderprivate.h index e0555026c6..88b64a03b3 100644 --- a/gtk/gtkstyleproviderprivate.h +++ b/gtk/gtkstyleproviderprivate.h @@ -44,6 +44,8 @@ struct _GtkStyleProviderPrivateInterface void (* lookup) (GtkStyleProviderPrivate *provider, const GtkCssMatcher *matcher, GtkCssLookup *lookup); + GtkCssChange (* get_change) (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher); }; GType _gtk_style_provider_private_get_type (void) G_GNUC_CONST; @@ -53,6 +55,8 @@ GtkSymbolicColor * _gtk_style_provider_private_get_color (GtkStyleProvid void _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider, const GtkCssMatcher *matcher, GtkCssLookup *lookup); +GtkCssChange _gtk_style_provider_private_get_change (GtkStyleProviderPrivate *provider, + const GtkCssMatcher *matcher); G_END_DECLS