[gtk+] settings: Store style cascade in settings object
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] settings: Store style cascade in settings object
- Date: Thu, 20 Feb 2014 01:19:41 +0000 (UTC)
commit 6de50aa7d9579ccf1bbf699eb0398aeff00e5689
Author: Benjamin Otte <otte redhat com>
Date: Thu Feb 20 02:02:05 2014 +0100
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
gtk/gtksettings.c | 32 +++++++++++++++++++++-----------
gtk/gtksettingsprivate.h | 2 ++
gtk/gtkstylecascade.c | 16 ++--------------
3 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 0321047..5bfb60c 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 bb21d9d..df42013 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 ea63fc8..7f281b3 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]