diff options
author | Pablo Barciela <[email protected]> | 2018-05-09 17:19:05 +0200 |
---|---|---|
committer | Pablo Barciela <[email protected]> | 2018-05-09 17:19:05 +0200 |
commit | 310bfc249aac3dd80511d3dade14aa06f3d9769a (patch) | |
tree | 7e837c7bf7352df924eedbead36efeb82c58c002 | |
parent | a3dfb665d34094f15c72b967974490df4ddad31b (diff) | |
download | pluma-310bfc249aac3dd80511d3dade14aa06f3d9769a.tar.bz2 pluma-310bfc249aac3dd80511d3dade14aa06f3d9769a.tar.xz |
pluma-view.c: avoid deprecated 'gtk_widget_override_font'
-rw-r--r-- | pluma/pluma-view.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c index 5cc92512..c38bdac1 100644 --- a/pluma/pluma-view.c +++ b/pluma/pluma-view.c @@ -646,6 +646,35 @@ pluma_view_scroll_to_cursor (PlumaView *view) 0.0); } +static void +pluma_override_font (GtkWidget *widget, + const gchar *font) +{ + gchar *css; + GtkCssProvider *provider; + gchar *tempsize; + + provider = gtk_css_provider_new (); + tempsize = g_strdup (font); + + g_strreverse (tempsize); + g_strcanon (tempsize, "1234567890", '\0'); + g_strreverse (tempsize); + + gchar tempfont [strlen (font)]; + strcpy (tempfont, font); + tempfont [strlen (font) - strlen (tempsize)] = 0; + + css = g_strdup_printf ("textview { font-family: %s; font-size: %spt; }", tempfont, tempsize); + gtk_css_provider_load_from_data (provider, css, -1, NULL); + g_free (css); + + gtk_style_context_add_provider (gtk_widget_get_style_context (widget), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); +} + /* FIXME this is an issue for introspection */ /** * pluma_view_set_font: @@ -684,7 +713,7 @@ pluma_view_set_font (PlumaView *view, g_return_if_fail (font_desc != NULL); - gtk_widget_override_font (GTK_WIDGET (view), font_desc); + pluma_override_font (GTK_WIDGET (view), pango_font_description_to_string (font_desc)); pango_font_description_free (font_desc); } |