[gtk+] stylecontext: Store the scale value in the cascade
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] stylecontext: Store the scale value in the cascade
- Date: Fri, 6 Feb 2015 10:28:16 +0000 (UTC)
commit 9209c4ea411efc08a59eba12ff7898bd7be1aa05
Author: Benjamin Otte <otte redhat com>
Date: Sat Jan 31 11:01:25 2015 +0100
stylecontext: Store the scale value in the cascade
This is in preparation for the next commits.
gtk/gtkstylecascade.c | 23 +++++++++++++++++++++++
gtk/gtkstylecascadeprivate.h | 4 ++++
gtk/gtkstylecontext.c | 29 ++++++++++++++++++++---------
3 files changed, 47 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkstylecascade.c b/gtk/gtkstylecascade.c
index dd34aa1..9219d61 100644
--- a/gtk/gtkstylecascade.c
+++ b/gtk/gtkstylecascade.c
@@ -276,6 +276,8 @@ style_provider_data_clear (gpointer data_)
static void
_gtk_style_cascade_init (GtkStyleCascade *cascade)
{
+ cascade->scale = 1;
+
cascade->providers = g_array_new (FALSE, FALSE, sizeof (GtkStyleProviderData));
g_array_set_clear_func (cascade->providers, style_provider_data_clear);
}
@@ -373,3 +375,24 @@ _gtk_style_cascade_remove_provider (GtkStyleCascade *cascade,
}
}
+void
+_gtk_style_cascade_set_scale (GtkStyleCascade *cascade,
+ int scale)
+{
+ g_return_if_fail (GTK_IS_STYLE_CASCADE (cascade));
+
+ if (cascade->scale == scale)
+ return;
+
+ cascade->scale = scale;
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade));
+}
+
+int
+_gtk_style_cascade_get_scale (GtkStyleCascade *cascade)
+{
+ g_return_val_if_fail (GTK_IS_STYLE_CASCADE (cascade), 1);
+
+ return cascade->scale;
+}
diff --git a/gtk/gtkstylecascadeprivate.h b/gtk/gtkstylecascadeprivate.h
index 0bd0cb2..ad2f7e6 100644
--- a/gtk/gtkstylecascadeprivate.h
+++ b/gtk/gtkstylecascadeprivate.h
@@ -39,6 +39,7 @@ struct _GtkStyleCascade
GtkStyleCascade *parent;
GArray *providers;
+ int scale;
};
struct _GtkStyleCascadeClass
@@ -52,6 +53,9 @@ GtkStyleCascade * _gtk_style_cascade_new (void);
void _gtk_style_cascade_set_parent (GtkStyleCascade *cascade,
GtkStyleCascade *parent);
+void _gtk_style_cascade_set_scale (GtkStyleCascade *cascade,
+ int scale);
+int _gtk_style_cascade_get_scale (GtkStyleCascade *cascade);
void _gtk_style_cascade_add_provider (GtkStyleCascade *cascade,
GtkStyleProvider *provider,
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 959857d..a7f700a 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -165,7 +165,6 @@ struct _GtkStyleContextPrivate
GtkCssNode *cssnode;
GSList *saved_nodes;
GArray *property_cache;
- gint scale;
guint frame_clock_update_id;
GdkFrameClock *frame_clock;
@@ -819,7 +818,7 @@ update_properties (GtkStyleContext *context,
parent_changes,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
&matcher,
- priv->scale,
+ _gtk_style_cascade_get_scale (priv->cascade),
parent);
gtk_widget_path_free (path);
@@ -851,12 +850,12 @@ build_properties (GtkStyleContext *context,
if (_gtk_css_matcher_init (&matcher, path))
style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
&matcher,
- priv->scale,
+ _gtk_style_cascade_get_scale (priv->cascade),
parent);
else
style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
NULL,
- priv->scale,
+ _gtk_style_cascade_get_scale (priv->cascade),
parent);
gtk_widget_path_free (path);
@@ -1432,14 +1431,26 @@ void
gtk_style_context_set_scale (GtkStyleContext *context,
gint scale)
{
+ GtkStyleContextPrivate *priv;
+
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- if (context->priv->scale == scale)
+ priv = context->priv;
+
+ if (scale == _gtk_style_cascade_get_scale (priv->cascade))
return;
- context->priv->scale = scale;
+ if (priv->cascade == _gtk_settings_get_style_cascade (gtk_settings_get_for_screen (priv->screen)))
+ {
+ GtkStyleCascade *new_cascade;
+
+ new_cascade = _gtk_style_cascade_new ();
+ _gtk_style_cascade_set_parent (new_cascade, priv->cascade);
+ gtk_style_context_set_cascade (context, new_cascade);
+ g_object_unref (new_cascade);
+ }
- _gtk_style_context_queue_invalidate (context, GTK_CSS_CHANGE_SOURCE);
+ _gtk_style_cascade_set_scale (priv->cascade, scale);
}
/**
@@ -1457,7 +1468,7 @@ gtk_style_context_get_scale (GtkStyleContext *context)
{
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0);
- return context->priv->scale;
+ return _gtk_style_cascade_get_scale (context->priv->cascade);
}
/**
@@ -2990,7 +3001,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
priv->parent ? gtk_style_context_lookup_style (priv->parent) :
NULL,
timestamp,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
- priv->scale,
+ _gtk_style_cascade_get_scale (priv->cascade),
gtk_style_context_should_create_transitions (context, current) ?
current : NULL);
gtk_style_context_clear_cache (context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]