diff options
author | Benjamin Otte <otte@redhat.com> | 2014-02-20 02:02:05 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2014-02-20 02:10:07 +0100 |
commit | 6de50aa7d9579ccf1bbf699eb0398aeff00e5689 (patch) | |
tree | 454abad70267e8389993fe98f1d20bda2822a250 | |
parent | 750eaf53d668c99bab227eb77db3c0d0b4367841 (diff) | |
download | gtk+-6de50aa7d9579ccf1bbf699eb0398aeff00e5689.tar.gz |
settings: Store style cascade in settings object
This ensures that the initialization for the CSS theme happens when the
style cascade gets queried.
https://bugzilla.redhat.com/show_bug.cgi?id=1064922
https://bugzilla.mozilla.org/show_bug.cgi?id=972382
-rw-r--r-- | gtk/gtksettings.c | 32 | ||||
-rw-r--r-- | gtk/gtksettingsprivate.h | 2 | ||||
-rw-r--r-- | gtk/gtkstylecascade.c | 16 |
3 files changed, 25 insertions, 25 deletions
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 0321047086..5bfb60c104 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -114,6 +114,7 @@ struct _GtkSettingsPrivate GData *queued_settings; /* of type GtkSettingsValue* */ GtkSettingsPropertyValue *property_values; GdkScreen *screen; + GtkStyleCascade *style_cascade; GtkCssProvider *theme_provider; GtkCssProvider *key_theme_provider; }; @@ -290,6 +291,7 @@ gtk_settings_init (GtkSettings *settings) g_datalist_init (&priv->queued_settings); object_list = g_slist_prepend (object_list, settings); + priv->style_cascade = _gtk_style_cascade_new (); priv->theme_provider = gtk_css_provider_new (); /* build up property array for all yet existing properties and queue @@ -1675,16 +1677,24 @@ gtk_settings_finalize (GObject *object) settings_update_provider (priv->screen, &priv->theme_provider, NULL); settings_update_provider (priv->screen, &priv->key_theme_provider, NULL); + g_clear_object (&priv->style_cascade); G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object); } +GtkStyleCascade * +_gtk_settings_get_style_cascade (GtkSettings *settings) +{ + g_return_val_if_fail (GTK_IS_SETTINGS (settings), NULL); + + return settings->priv->style_cascade; +} + static void settings_init_style (GtkSettings *settings) { static GtkCssProvider *css_provider = NULL; - - GdkScreen *screen = settings->priv->screen; + GtkSettingsPrivate *priv = settings->priv; /* Add provider for user file */ if (G_UNLIKELY (!css_provider)) @@ -1704,17 +1714,17 @@ settings_init_style (GtkSettings *settings) g_free (css_path); } - gtk_style_context_add_provider_for_screen (screen, - GTK_STYLE_PROVIDER (css_provider), - GTK_STYLE_PROVIDER_PRIORITY_USER); + _gtk_style_cascade_add_provider (priv->style_cascade, + GTK_STYLE_PROVIDER (css_provider), + GTK_STYLE_PROVIDER_PRIORITY_USER); - gtk_style_context_add_provider_for_screen (screen, - GTK_STYLE_PROVIDER (settings), - GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); + _gtk_style_cascade_add_provider (priv->style_cascade, + GTK_STYLE_PROVIDER (settings), + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); - gtk_style_context_add_provider_for_screen (screen, - GTK_STYLE_PROVIDER (settings->priv->theme_provider), - GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); + _gtk_style_cascade_add_provider (priv->style_cascade, + GTK_STYLE_PROVIDER (settings->priv->theme_provider), + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); settings_update_theme (settings); settings_update_key_theme (settings); diff --git a/gtk/gtksettingsprivate.h b/gtk/gtksettingsprivate.h index bb21d9d5ab..df42013ad8 100644 --- a/gtk/gtksettingsprivate.h +++ b/gtk/gtksettingsprivate.h @@ -19,6 +19,7 @@ #define __GTK_SETTINGS_PRIVATE_H__ #include <gtk/gtksettings.h> +#include "gtkstylecascadeprivate.h" G_BEGIN_DECLS @@ -36,6 +37,7 @@ gboolean _gtk_settings_parse_convert (GtkRcPropertyParse GParamSpec *pspec, GValue *dest_value); GdkScreen *_gtk_settings_get_screen (GtkSettings *settings); +GtkStyleCascade *_gtk_settings_get_style_cascade (GtkSettings *settings); G_END_DECLS diff --git a/gtk/gtkstylecascade.c b/gtk/gtkstylecascade.c index ea63fc86f6..7f281b399b 100644 --- a/gtk/gtkstylecascade.c +++ b/gtk/gtkstylecascade.c @@ -21,6 +21,7 @@ #include "gtkstyleprovider.h" #include "gtkstyleproviderprivate.h" +#include "gtksettingsprivate.h" typedef struct _GtkStyleCascadeIter GtkStyleCascadeIter; typedef struct _GtkStyleProviderData GtkStyleProviderData; @@ -312,22 +313,9 @@ _gtk_style_cascade_new (void) GtkStyleCascade * _gtk_style_cascade_get_for_screen (GdkScreen *screen) { - GtkStyleCascade *cascade; - static GQuark quark = 0; - g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("gtk-style-cascade"); - - cascade = g_object_get_qdata (G_OBJECT (screen), quark); - if (cascade == NULL) - { - cascade = _gtk_style_cascade_new (); - g_object_set_qdata_full (G_OBJECT (screen), quark, cascade, g_object_unref); - } - - return cascade; + return _gtk_settings_get_style_cascade (gtk_settings_get_for_screen (screen)); } void |