mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 06:10:21 +00:00
style provider: Add a has_section api
Add gtk_style_provider_has_section and implement it for GtkCssProvider. This will be used later to direct error emissions to the right provider.
This commit is contained in:
parent
f2ef5d85ea
commit
b2fb624496
@ -137,6 +137,7 @@ struct _GtkCssProviderPrivate
|
|||||||
GtkCssSelectorTree *tree;
|
GtkCssSelectorTree *tree;
|
||||||
GResource *resource;
|
GResource *resource;
|
||||||
char *path;
|
char *path;
|
||||||
|
GBytes *bytes; /* *no* reference */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -565,6 +566,16 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
|
|||||||
*change = gtk_css_selector_tree_get_change_all (priv->tree, filter, node);
|
*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
|
static void
|
||||||
gtk_css_style_provider_iface_init (GtkStyleProviderInterface *iface)
|
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->get_keyframes = gtk_css_style_provider_get_keyframes;
|
||||||
iface->lookup = gtk_css_style_provider_lookup;
|
iface->lookup = gtk_css_style_provider_lookup;
|
||||||
iface->emit_error = gtk_css_style_provider_emit_error;
|
iface->emit_error = gtk_css_style_provider_emit_error;
|
||||||
|
iface->has_section = gtk_css_style_provider_has_section;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1157,6 +1169,7 @@ gtk_css_provider_load_internal (GtkCssProvider *self,
|
|||||||
GFile *file,
|
GFile *file,
|
||||||
GBytes *bytes)
|
GBytes *bytes)
|
||||||
{
|
{
|
||||||
|
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (self);
|
||||||
gint64 before G_GNUC_UNUSED;
|
gint64 before G_GNUC_UNUSED;
|
||||||
|
|
||||||
before = GDK_PROFILER_CURRENT_TIME;
|
before = GDK_PROFILER_CURRENT_TIME;
|
||||||
@ -1191,6 +1204,8 @@ gtk_css_provider_load_internal (GtkCssProvider *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->bytes = bytes;
|
||||||
|
|
||||||
if (bytes)
|
if (bytes)
|
||||||
{
|
{
|
||||||
GtkCssScanner *scanner;
|
GtkCssScanner *scanner;
|
||||||
|
@ -170,6 +170,19 @@ gtk_style_provider_emit_error (GtkStyleProvider *provider,
|
|||||||
iface->emit_error (provider, section, error);
|
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,
|
/* These apis are misnamed, and the rest of GtkStyleContext is deprecated,
|
||||||
* so put them here for now
|
* 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);
|
cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1);
|
||||||
_gtk_style_cascade_remove_provider (cascade, provider);
|
_gtk_style_cascade_remove_provider (cascade, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,8 @@ struct _GtkStyleProviderInterface
|
|||||||
const GError *error);
|
const GError *error);
|
||||||
/* signal */
|
/* signal */
|
||||||
void (* changed) (GtkStyleProvider *provider);
|
void (* changed) (GtkStyleProvider *provider);
|
||||||
|
gboolean (* has_section) (GtkStyleProvider *provider,
|
||||||
|
GtkCssSection *section);
|
||||||
};
|
};
|
||||||
|
|
||||||
GtkSettings * gtk_style_provider_get_settings (GtkStyleProvider *provider);
|
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,
|
void gtk_style_provider_emit_error (GtkStyleProvider *provider,
|
||||||
GtkCssSection *section,
|
GtkCssSection *section,
|
||||||
GError *error);
|
GError *error);
|
||||||
|
gboolean gtk_style_provider_has_section (GtkStyleProvider *provider,
|
||||||
|
GtkCssSection *section);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user