[balsa/gtk3] Deprecation cleanup



commit eba30b47988dc5ebfee31fd540df9ba6b3237b57
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Feb 10 20:56:42 2015 -0500

    Deprecation cleanup
    
        * src/balsa-mime-widget-text.c (bm_modify_font_from_string):
        gtk_widget_override_font is deprecated, use CSS instead.

 ChangeLog                    |    7 +++++++
 src/balsa-mime-widget-text.c |   19 +++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7747d6a..2508802 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2015-02-10  Peter Bloomfield  <pbloomfield bellsouth net>
 
+       Deprecation cleanup
+
+       * src/balsa-mime-widget-text.c (bm_modify_font_from_string):
+       gtk_widget_override_font is deprecated, use CSS instead.
+
+2015-02-10  Peter Bloomfield  <pbloomfield bellsouth net>
+
        * src/balsa-mime-widget-image.c
        (balsa_mime_widget_image_dispose): fix typo.
 
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 50c90f7..9ce2f05 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -334,14 +334,25 @@ create_text_widget(const char * content_type)
 #endif
 }
 
+#define BALSA_MESSAGE_TEXT_HEADER "balsa-message-text-header"
+
 static void
 bm_modify_font_from_string(GtkWidget * widget, const char *font)
 {
-    PangoFontDescription *desc;
+    gchar *css;
+    GtkCssProvider *css_provider;
+
+    gtk_widget_set_name(widget, BALSA_MESSAGE_TEXT_HEADER);
+    css = g_strconcat("#" BALSA_MESSAGE_TEXT_HEADER " {font:", font, "}", NULL);
+
+    css_provider = gtk_css_provider_new();
+    gtk_css_provider_load_from_data(css_provider, css, -1, NULL);
+    g_free(css);
 
-    desc = pango_font_description_from_string(font);
-    gtk_widget_override_font(widget, desc);
-    pango_font_description_free(desc);
+    gtk_style_context_add_provider(gtk_widget_get_style_context(widget) ,
+                                   GTK_STYLE_PROVIDER(css_provider),
+                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    g_object_unref(css_provider);
 }
 
 /* quote_tag:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]