Skip to content

Commit e451bfe

Browse files
committed
pluma-view: pluma_override_font: add the provider only one time
1 parent 8f3b1d6 commit e451bfe

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎pluma/pluma-view.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ static void
650650
pluma_override_font (GtkWidget *widget,
651651
PangoFontDescription *font)
652652
{
653+
static gboolean provider_added = FALSE;
653654
GtkCssProvider *provider;
654655
gchar *css;
655656
gchar *family;
@@ -672,14 +673,18 @@ pluma_override_font (GtkWidget *widget,
672673
pango_font_description_get_size (font) / PANGO_SCALE,
673674
pango_font_description_get_size_is_absolute (font) ? "px" : "pt");
674675

675-
provider = gtk_css_provider_new ();
676+
provider = gtk_css_provider_get_default ();
677+
676678
css = g_strdup_printf ("textview { %s %s %s %s }", family, weight, style, size);
677679
gtk_css_provider_load_from_data (provider, css, -1, NULL);
678680

679-
gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
680-
GTK_STYLE_PROVIDER (provider),
681-
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
682-
g_object_unref (provider);
681+
if (!provider_added) {
682+
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (widget),
683+
GTK_STYLE_PROVIDER (provider),
684+
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
685+
provider_added = TRUE;
686+
}
687+
683688
g_free (css);
684689
g_free (family);
685690
g_free (weight);

0 commit comments

Comments
 (0)