[evolution/gnome-3-26] Bug 787646 - Replace deprecated and removed enchant API usage



commit cbe916e1c54a856b210ee77887e385ce9f476178
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 18 12:05:00 2017 +0200

    Bug 787646 - Replace deprecated and removed enchant API usage

 CMakeLists.txt                  |   10 ++++++++++
 config.h.in                     |    3 +++
 src/e-util/e-spell-dictionary.c |    8 ++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3a715a..ca2cc4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -291,6 +291,16 @@ pkg_check_modules(ENCHANT REQUIRED enchant>=${enchant_minimum_version})
 pkg_check_modules(LIBSOUP REQUIRED libsoup-2.4>=${soup_minimum_version})
 pkg_check_modules(WEB_EXTENSION REQUIRED webkit2gtk-4.0>=${webkit2gtk_minimum_version})
 
+set(CMAKE_REQUIRED_FLAGS ${ENCHANT_CFLAGS})
+set(CMAKE_REQUIRED_INCLUDES ${ENCHANT_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES ${ENCHANT_LDFLAGS})
+CHECK_C_SOURCE_COMPILES("#include <enchant/enchant.h>
+                       #include <stdio.h>
+                       int main(void) { enchant_dict_add (NULL, NULL, 0); enchant_dict_free_string_list 
(NULL, NULL); return 0; }" HAVE_ENCHANT_NEW_API)
+unset(CMAKE_REQUIRED_FLAGS)
+unset(CMAKE_REQUIRED_INCLUDES)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
 # ******************************
 # Canberra / Canberra-GTK Sound
 # ******************************
diff --git a/config.h.in b/config.h.in
index c39ccf8..9a76a06 100644
--- a/config.h.in
+++ b/config.h.in
@@ -134,3 +134,6 @@
 
 /* When defined contacts preview will contain maps */
 #cmakedefine ENABLE_CONTACT_MAPS 1
+
+/* Whether enchant contains new API */
+#cmakedefine HAVE_ENCHANT_NEW_API 1
diff --git a/src/e-util/e-spell-dictionary.c b/src/e-util/e-spell-dictionary.c
index ab89f55..54d3eff 100644
--- a/src/e-util/e-spell-dictionary.c
+++ b/src/e-util/e-spell-dictionary.c
@@ -671,7 +671,11 @@ e_spell_dictionary_learn_word (ESpellDictionary *dictionary,
                spell_checker, e_spell_dictionary_get_code (dictionary));
        g_return_if_fail (enchant_dict != NULL);
 
+       #ifdef HAVE_ENCHANT_NEW_API
+       enchant_dict_add (enchant_dict, word, length);
+       #else
        enchant_dict_add_to_personal (enchant_dict, word, length);
+       #endif
 
        g_object_unref (spell_checker);
 }
@@ -751,7 +755,11 @@ e_spell_dictionary_get_suggestions (ESpellDictionary *dictionary,
        suggestions = enchant_dict_suggest (enchant_dict, word, length, &count);
        for (ii = 0; ii < count; ii++)
                list = g_list_prepend (list, g_strdup (suggestions[ii]));
+       #ifdef HAVE_ENCHANT_NEW_API
+       enchant_dict_free_string_list (enchant_dict, suggestions);
+       #else
        enchant_dict_free_suggestions (enchant_dict, suggestions);
+       #endif
 
        g_object_unref (spell_checker);
 


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