[balsa] Deprecation cleanup



commit 08f3f24413c3af61d0117435742b0cacbf2e13be
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Dec 4 10:53:07 2018 -0500

    Deprecation cleanup
    
    * libbalsa/mime.c (libbalsa_text_to_html):
      pango_unichar_direction() is deprecated in Pango 1.44; a commit
    vvmessage suggests using fribidi directly.
    * configure.ac: add direct fribidi dependency; it is already an
      indirect dependency through Pango.
    * meson.build: ditto.

 ChangeLog       | 11 +++++++++++
 configure.ac    |  1 +
 libbalsa/mime.c | 20 ++++++++++++++++----
 meson.build     |  4 +++-
 4 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e0ac9958f..e3ce8070e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2018-12-04  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Deprecation cleanup
+
+       * libbalsa/mime.c (libbalsa_text_to_html):
+       pango_unichar_direction() is deprecated in Pango 1.44; a commit
+       message suggests using fribidi directly.
+       * configure.ac: add direct fribidi dependency; it is already an
+       indirect dependency through Pango.
+       * meson.build: ditto.
+
 2018-12-03  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Do not include no-longer-existing libbalsa/libbalsa-marshal.h
diff --git a/configure.ac b/configure.ac
index 67ea061af..2db4559f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,6 +230,7 @@ gmime-2.6
 gio-2.0
 gthread-2.0
 gnutls
+fribidi
 ])
 
 PKG_CHECK_MODULES(BALSA_AB, [
diff --git a/libbalsa/mime.c b/libbalsa/mime.c
index b4a7fe014..e6784dc8b 100644
--- a/libbalsa/mime.c
+++ b/libbalsa/mime.c
@@ -24,6 +24,7 @@
 
 #include <string.h>
 #include <ctype.h>
+#include <fribidi.h>
 
 #include "libbalsa.h"
 #include "misc.h"
@@ -1243,7 +1244,7 @@ libbalsa_text_to_html(const gchar * title, const gchar * body, const gchar * lan
     while (*start) {
         const gchar * eol = strchr(start, '\n');
         const gchar * p = start;
-        PangoDirection direction = PANGO_DIRECTION_NEUTRAL;
+        gboolean is_rtl = FALSE;
         GString * html;
         gsize idx;
 
@@ -1251,8 +1252,19 @@ libbalsa_text_to_html(const gchar * title, const gchar * body, const gchar * lan
             eol = start + strlen(start);
 
         /* find the first real char to determine the paragraph direction */
-        while (p < eol && direction == PANGO_DIRECTION_NEUTRAL) {
-            direction = pango_unichar_direction(g_utf8_get_char(p));
+        /* Use the same logic as fribidi_get_par_direction(), but
+         * without allocating memory for all the gunichars and
+         * FriBidiCharTypes: */
+        while (p < eol) {
+            FriBidiCharType char_type;
+
+            char_type = fribidi_get_bidi_type(g_utf8_get_char(p));
+
+            if (FRIBIDI_IS_LETTER(char_type)) {
+                is_rtl = FRIBIDI_IS_RTL(char_type);
+                break;
+            }
+
             p = g_utf8_next_char(p);
         }
 
@@ -1275,7 +1287,7 @@ libbalsa_text_to_html(const gchar * title, const gchar * body, const gchar * lan
 
         /* append the paragraph, always stating the proper direction */
         g_string_append_printf(html_body, "<p dir=\"%s\">%s</p>\n",
-                               direction == PANGO_DIRECTION_RTL ? "rtl" : "ltr",
+                               is_rtl ? "rtl" : "ltr",
                                *html->str ? html->str : "&nbsp;");
         g_string_free(html, TRUE);
 
diff --git a/meson.build b/meson.build
index dab90d89d..ad9f7a9c3 100644
--- a/meson.build
+++ b/meson.build
@@ -133,6 +133,7 @@ gmime_dep   = dependency('gmime-2.6')
 gio_dep     = dependency('gio-2.0')
 gthread_dep = dependency('gthread-2.0')
 gnutls_dep  = dependency('gnutls')
+fribidi_dep = dependency('fribidi')
 
 # Dependencies for balsa
 balsa_deps = [glib_dep,
@@ -140,7 +141,8 @@ balsa_deps = [glib_dep,
               gmime_dep,
               gio_dep,
               gthread_dep,
-              gnutls_dep]
+              gnutls_dep,
+              fribidi_dep]
 
 # Dependencies for balsa_ab:
 balsa_ab_deps = [glib_dep,


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