diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 9b05ee6493..f34cca3a0e 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -137,6 +137,7 @@ struct _GtkCssProviderPrivate GtkCssSelectorTree *tree; GResource *resource; char *path; + GBytes *bytes; /* *no* reference */ }; enum { @@ -565,6 +566,16 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider, *change = gtk_css_selector_tree_get_change_all (priv->tree, filter, node); } +static gboolean +gtk_css_style_provider_has_section (GtkStyleProvider *provider, + GtkCssSection *section) +{ + GtkCssProvider *self = GTK_CSS_PROVIDER (provider); + GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (self); + + return priv->bytes == gtk_css_section_get_bytes (section); +} + static void gtk_css_style_provider_iface_init (GtkStyleProviderInterface *iface) { @@ -572,6 +583,7 @@ gtk_css_style_provider_iface_init (GtkStyleProviderInterface *iface) iface->get_keyframes = gtk_css_style_provider_get_keyframes; iface->lookup = gtk_css_style_provider_lookup; iface->emit_error = gtk_css_style_provider_emit_error; + iface->has_section = gtk_css_style_provider_has_section; } static void @@ -1157,6 +1169,7 @@ gtk_css_provider_load_internal (GtkCssProvider *self, GFile *file, GBytes *bytes) { + GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (self); gint64 before G_GNUC_UNUSED; before = GDK_PROFILER_CURRENT_TIME; @@ -1191,6 +1204,8 @@ gtk_css_provider_load_internal (GtkCssProvider *self, } } + priv->bytes = bytes; + if (bytes) { GtkCssScanner *scanner; diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index d7c8af8687..a8098a3d60 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -170,6 +170,19 @@ gtk_style_provider_emit_error (GtkStyleProvider *provider, iface->emit_error (provider, section, error); } +gboolean +gtk_style_provider_has_section (GtkStyleProvider *provider, + GtkCssSection *section) +{ + GtkStyleProviderInterface *iface; + + iface = GTK_STYLE_PROVIDER_GET_INTERFACE (provider); + + if (iface->has_section) + return iface->has_section (provider, section); + + return FALSE; +} /* These apis are misnamed, and the rest of GtkStyleContext is deprecated, * so put them here for now @@ -230,4 +243,3 @@ gtk_style_context_remove_provider_for_display (GdkDisplay *display, cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1); _gtk_style_cascade_remove_provider (cascade, provider); } - diff --git a/gtk/gtkstyleproviderprivate.h b/gtk/gtkstyleproviderprivate.h index 5319d57155..d2fca2c402 100644 --- a/gtk/gtkstyleproviderprivate.h +++ b/gtk/gtkstyleproviderprivate.h @@ -52,6 +52,8 @@ struct _GtkStyleProviderInterface const GError *error); /* signal */ void (* changed) (GtkStyleProvider *provider); + gboolean (* has_section) (GtkStyleProvider *provider, + GtkCssSection *section); }; GtkSettings * gtk_style_provider_get_settings (GtkStyleProvider *provider); @@ -71,6 +73,8 @@ void gtk_style_provider_changed (GtkStyleProvid void gtk_style_provider_emit_error (GtkStyleProvider *provider, GtkCssSection *section, GError *error); +gboolean gtk_style_provider_has_section (GtkStyleProvider *provider, + GtkCssSection *section); G_END_DECLS