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.
This commit is contained in:
parent
3d23ecc456
commit
c5ac3d6217
@ -1053,6 +1053,23 @@ create_style_context (GType widget_type,
|
|||||||
return style;
|
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 *
|
MetaStyleInfo *
|
||||||
meta_theme_create_style_info (GdkScreen *screen,
|
meta_theme_create_style_info (GdkScreen *screen,
|
||||||
const gchar *variant)
|
const gchar *variant)
|
||||||
@ -1065,10 +1082,7 @@ meta_theme_create_style_info (GdkScreen *screen,
|
|||||||
"gtk-theme-name", &theme_name,
|
"gtk-theme-name", &theme_name,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (theme_name && *theme_name)
|
provider = get_css_provider_for_theme_name (theme_name, variant);
|
||||||
provider = gtk_css_provider_get_named (theme_name, variant);
|
|
||||||
else
|
|
||||||
provider = gtk_css_provider_get_default ();
|
|
||||||
g_free (theme_name);
|
g_free (theme_name);
|
||||||
|
|
||||||
style_info = g_new0 (MetaStyleInfo, 1);
|
style_info = g_new0 (MetaStyleInfo, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user