summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2018-07-17 23:13:18 +0200
committerPablo Barciela <[email protected]>2018-07-17 23:13:18 +0200
commite451bfe61952156ba6bdb63700f1089c2c52f766 (patch)
treecb5cb6366df66b68dd3e6d5bd41f5c54224c80cf
parent8f3b1d625c86cc57b51c8acb3b1ab4e5f59d4d4d (diff)
downloadpluma-e451bfe61952156ba6bdb63700f1089c2c52f766.tar.bz2
pluma-e451bfe61952156ba6bdb63700f1089c2c52f766.tar.xz
pluma-view: pluma_override_font: add the provider only one time
-rw-r--r--pluma/pluma-view.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c
index a4fe6026..b4e27a00 100644
--- a/pluma/pluma-view.c
+++ b/pluma/pluma-view.c
@@ -650,6 +650,7 @@ static void
pluma_override_font (GtkWidget *widget,
PangoFontDescription *font)
{
+ static gboolean provider_added = FALSE;
GtkCssProvider *provider;
gchar *css;
gchar *family;
@@ -672,14 +673,18 @@ pluma_override_font (GtkWidget *widget,
pango_font_description_get_size (font) / PANGO_SCALE,
pango_font_description_get_size_is_absolute (font) ? "px" : "pt");
- provider = gtk_css_provider_new ();
+ provider = gtk_css_provider_get_default ();
+
css = g_strdup_printf ("textview { %s %s %s %s }", family, weight, style, size);
gtk_css_provider_load_from_data (provider, css, -1, NULL);
- gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (provider);
+ if (!provider_added) {
+ gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (widget),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ provider_added = TRUE;
+ }
+
g_free (css);
g_free (family);
g_free (weight);