Commit 6de50aa7 authored by Benjamin Otte's avatar Benjamin Otte

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
parent 750eaf53
......@@ -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);
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment