[mutter/gbsneto/silence-warnings: 14/15] theme: Drop gtk_css_provider_get_default()
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/silence-warnings: 14/15] theme: Drop gtk_css_provider_get_default()
- Date: Thu, 8 Nov 2018 18:09:44 +0000 (UTC)
commit e7d8332ba0d486dc3666a6e1d0ed9c7daee9bd3d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Nov 8 15:24:05 2018 -0200
theme: Drop gtk_css_provider_get_default()
Instead of using gtk_css_provider_get_default(), add a
static GtkCssProvider and fetch it instead. Creating
GtkCssProviders consume a bit more memory, so keeping
a single one alive is slightly more memory saving.
src/ui/theme.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 22951c24e..223bc04ae 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -1053,6 +1053,23 @@ create_style_context (GType widget_type,
return style;
}
+static inline GtkCssProvider *
+get_css_provider_for_theme_name (const gchar *theme_name,
+ const gchar *variant)
+{
+ static GtkCssProvider *default_provider = NULL;
+
+ if (!theme_name || *theme_name == '\0')
+ {
+ if (G_UNLIKELY (default_provider == NULL))
+ default_provider = gtk_css_provider_new ();
+
+ return default_provider;
+ }
+
+ return gtk_css_provider_get_named (theme_name, variant);
+}
+
MetaStyleInfo *
meta_theme_create_style_info (GdkScreen *screen,
const gchar *variant)
@@ -1065,10 +1082,7 @@ meta_theme_create_style_info (GdkScreen *screen,
"gtk-theme-name", &theme_name,
NULL);
- if (theme_name && *theme_name)
- provider = gtk_css_provider_get_named (theme_name, variant);
- else
- provider = gtk_css_provider_get_default ();
+ provider = get_css_provider_for_theme_name (theme_name, variant);
g_free (theme_name);
style_info = g_new0 (MetaStyleInfo, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]