mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-17 15:40:12 +00:00
syleprovider: Add a vfunc to get the changes
This way we can check what changes are even interesting for our matcher.
This commit is contained in:
parent
b0b6c8ad4b
commit
8dbe8c8349
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user