From 2542a150a5bdc8ac6527371814d44324a4beeef5 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 14 Aug 2016 14:51:59 +0200 Subject: [PATCH] Use modern method of setting font, instead of deprecated method --- src/ui/gui/psppire-data-editor.c | 14 +++++++++++++- src/ui/gui/psppire-dialog-action-comments.c | 20 +++++++++++++++----- src/ui/gui/psppire-window.c | 4 ++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 1c6143aaf4..4577d2dc51 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -682,6 +682,9 @@ psppire_data_editor_init (PsppireDataEditor *de) GtkWidget *hbox; gchar *fontname = NULL; + GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (de)); + gtk_style_context_add_class (context, "psppire-data-editor"); + de->font = NULL; de->old_vbox_widget = NULL; @@ -774,7 +777,16 @@ set_font_recursively (GtkWidget *w, gpointer data) { PangoFontDescription *font_desc = data; - gtk_widget_override_font (w, font_desc); + GtkCssProvider *cssp = gtk_css_provider_get_default (); + + gchar *str = pango_font_description_to_string (font_desc); + gchar *css = g_strdup_printf (".psppire-data-editor {font: %s }", str); + g_free (str); + + if (!gtk_css_provider_load_from_data (cssp, css, -1, NULL)) + g_warning ("Failed to load font css \"%s\"", css); + + g_free (css); if ( GTK_IS_CONTAINER (w)) gtk_container_foreach (GTK_CONTAINER (w), set_font_recursively, font_desc); diff --git a/src/ui/gui/psppire-dialog-action-comments.c b/src/ui/gui/psppire-dialog-action-comments.c index c500f1fad8..aa32ba0a42 100644 --- a/src/ui/gui/psppire-dialog-action-comments.c +++ b/src/ui/gui/psppire-dialog-action-comments.c @@ -199,8 +199,21 @@ psppire_dialog_action_comments_activate (PsppireDialogAction *pda) PangoFontDescription *font_desc = pango_font_description_from_string ("monospace"); - gtk_widget_override_font (act->textview, font_desc); - + GtkStyleContext *style = + gtk_widget_get_style_context (GTK_WIDGET (act->textview)); + gtk_style_context_add_class (style, "psppire-dialog-comment-pane"); + GtkCssProvider *cssp = gtk_css_provider_get_default (); + + gchar *str = pango_font_description_to_string (font_desc); + gchar *css = + g_strdup_printf (".psppire-dialog-comment-pane {font: %s }", str); + g_free (str); + + if (!gtk_css_provider_load_from_data (cssp, css, -1, NULL)) + g_warning ("Failed to load font css \"%s\"", css); + + g_free (css); + /* and let's just make sure that a complete line fits into the widget's width */ context = gtk_widget_create_pango_context (act->textview); @@ -233,9 +246,6 @@ psppire_dialog_action_comments_activate (PsppireDialogAction *pda) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - - - } static void diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index c268256bb0..97cfe6aed0 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -403,6 +403,10 @@ psppire_window_init (PsppireWindow *window) window->description = NULL; window->list_name = NULL; + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (gtk_css_provider_get_default ()), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + window->menuitem_table = g_hash_table_new (g_str_hash, g_str_equal); -- 2.30.2