[gtk+] syleprovider: Add a vfunc to get the changes
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] syleprovider: Add a vfunc to get the changes
- Date: Tue, 17 Apr 2012 07:09:44 +0000 (UTC)
commit 8dbe8c83491c5877c9b19928f257ec7a671cb45e
Author: Benjamin Otte <otte redhat com>
Date: Sat Mar 17 21:09:51 2012 +0100
syleprovider: Add a vfunc to get the changes
This way we can check what changes are even interesting for our matcher.
gtk/gtkcssprovider.c | 37 +++++++++++++++++++++++++++++++++++++
gtk/gtkmodifierstyle.c | 11 +++++++++++
gtk/gtksettings.c | 13 +++++++++++++
gtk/gtkstylecascade.c | 28 ++++++++++++++++++++++++++++
gtk/gtkstyleproperties.c | 8 ++++++++
gtk/gtkstyleproviderprivate.c | 17 +++++++++++++++++
gtk/gtkstyleproviderprivate.h | 4 ++++
7 files changed, 118 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 9320100..022d408 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 c16a051..2700250 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 75487b8..f1b03ee 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 f1bf516..a05d36d 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 5add14d..d63b659 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 43ae171..fc7e298 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 e055502..88b64a0 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]