summaryrefslogtreecommitdiffstats
path: root/src/widgets/spw-utilities.cpp
diff options
context:
space:
mode:
authorAlex Valavanis <valavanisalex@gmail.com>2016-04-13 10:19:33 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2016-04-13 10:19:33 +0000
commit1eacfbf37731e918de1690b1e614440c4e3d9afe (patch)
tree4b650d30efff35d62c35ea5d784b66c01917ea7a /src/widgets/spw-utilities.cpp
parentFix cmake build (diff)
downloadinkscape-1eacfbf37731e918de1690b1e614440c4e3d9afe.tar.gz
inkscape-1eacfbf37731e918de1690b1e614440c4e3d9afe.zip
spw-utilities: Fix deprecated gtk_widget_override_font #Hackfest2016
(bzr r14819)
Diffstat (limited to 'src/widgets/spw-utilities.cpp')
-rw-r--r--src/widgets/spw-utilities.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp
index 2cad395e7..89ab76585 100644
--- a/src/widgets/spw-utilities.cpp
+++ b/src/widgets/spw-utilities.cpp
@@ -255,12 +255,26 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font)
{
guint size = GPOINTER_TO_UINT (font);
- PangoFontDescription* pan = pango_font_description_new ();
- pango_font_description_set_size (pan, size);
-
#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_override_font (w, pan);
+ GtkCssProvider *css_provider = gtk_css_provider_new();
+
+ const double pt_size = size / static_cast<double>(PANGO_SCALE);
+ std::ostringstream css_data;
+ css_data << "GtkWidget {\n"
+ << " font-size: " << pt_size << "pt;\n"
+ << "}\n";
+
+ gtk_css_provider_load_from_data(css_provider,
+ css_data.str().c_str(),
+ -1, NULL);
+
+ GtkStyleContext *style_context = gtk_widget_get_style_context(w);
+ gtk_style_context_add_provider(style_context,
+ GTK_STYLE_PROVIDER(css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
#else
+ PangoFontDescription* pan = pango_font_description_new ();
+ pango_font_description_set_size (pan, size);
gtk_widget_modify_font (w, pan);
#endif
@@ -268,7 +282,11 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font)
gtk_container_foreach (GTK_CONTAINER(w), (GtkCallback) sp_set_font_size_recursive, font);
}
+#if GTK_CHECK_VERSION(3,0,0)
+ g_object_unref(css_provider);
+#else
pango_font_description_free (pan);
+#endif
}
void