[gspell/wip/expose-enchant: 2/3] Checker: expose EnchantDict



commit 11cc6182c5641b1a399046c3b9b716596523e984
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jul 15 10:52:51 2017 +0200

    Checker: expose EnchantDict
    
    I initially didn't want to expose the use of Enchant, because I thought
    that gspell could use directly hunspell instead. But I think this won't
    happen, Enchant provides a C API while hunspell is in C++, so it's
    simpler to use Enchant in gspell.
    
    So the use of Enchant is now part of the API, if it needs to change in
    the future, we can just bump the API/major version of gspell. This will
    anyway happen regularly to port gspell to new major versions of GTK+.
    
    This commit will normally permit to implement the following feature in
    gnome-builder (even if I would prefer that it's implemented in gspell,
    to make the feature available to all applications):
    https://bugzilla.gnome.org/show_bug.cgi?id=765616

 docs/reference/gspell-1.0-sections.txt |    1 +
 gspell/gspell-checker.c                |   32 ++++++++++++++++++++++++++------
 gspell/gspell-checker.h                |    4 ++++
 3 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/docs/reference/gspell-1.0-sections.txt b/docs/reference/gspell-1.0-sections.txt
index b18b53d..05d1cd8 100644
--- a/docs/reference/gspell-1.0-sections.txt
+++ b/docs/reference/gspell-1.0-sections.txt
@@ -14,6 +14,7 @@ gspell_checker_add_word_to_personal
 gspell_checker_add_word_to_session
 gspell_checker_clear_session
 gspell_checker_set_correction
+gspell_checker_get_enchant_dict
 <SUBSECTION Standard>
 GspellCheckerClass
 GSPELL_TYPE_CHECKER
diff --git a/gspell/gspell-checker.c b/gspell/gspell-checker.c
index aa2cb6f..e2e848f 100644
--- a/gspell/gspell-checker.c
+++ b/gspell/gspell-checker.c
@@ -24,7 +24,6 @@
 
 #include "gspell-checker.h"
 #include "gspell-checker-private.h"
-#include <enchant.h>
 #include <glib/gi18n-lib.h>
 #include <string.h>
 #include "gspell-utils.h"
@@ -46,11 +45,6 @@
  * “disabled” (but allowed) state.
  */
 
-/* Enchant is currently used under the hood, but it is an implementation detail,
- * it is *NOT* part of the gspell API. A future gspell version can be based on
- * another library (e.g. using directly hunspell).
- */
-
 typedef struct _GspellCheckerPrivate GspellCheckerPrivate;
 
 struct _GspellCheckerPrivate
@@ -640,4 +634,30 @@ gspell_checker_set_correction (GspellChecker *checker,
                                        replacement, replacement_length);
 }
 
+/**
+ * gspell_checker_get_enchant_dict:
+ * @checker: a #GspellChecker.
+ *
+ * Gets the EnchantDict currently used by @checker. It permits to extend
+ * #GspellChecker with more features. Note that by doing so, the other classes
+ * in gspell may no longer work well.
+ *
+ * #GspellChecker re-creates a new EnchantDict when the #GspellChecker:language
+ * is changed and when the session is cleared.
+ *
+ * Returns: (transfer none) (nullable): the EnchantDict currently used by
+ * @checker.
+ * Since: 1.6
+ */
+EnchantDict *
+gspell_checker_get_enchant_dict (GspellChecker *checker)
+{
+       GspellCheckerPrivate *priv;
+
+       g_return_val_if_fail (GSPELL_IS_CHECKER (checker), NULL);
+
+       priv = gspell_checker_get_instance_private (checker);
+       return priv->dict;
+}
+
 /* ex:set ts=8 noet: */
diff --git a/gspell/gspell-checker.h b/gspell/gspell-checker.h
index fc94a56..bab3617 100644
--- a/gspell/gspell-checker.h
+++ b/gspell/gspell-checker.h
@@ -26,6 +26,7 @@
 #endif
 
 #include <glib-object.h>
+#include <enchant.h>
 #include <gspell/gspell-language.h>
 #include <gspell/gspell-version.h>
 
@@ -123,6 +124,9 @@ void                gspell_checker_set_correction           (GspellChecker *checker,
                                                         const gchar   *replacement,
                                                         gssize         replacement_length);
 
+GSPELL_AVAILABLE_IN_1_6
+EnchantDict *  gspell_checker_get_enchant_dict         (GspellChecker *checker);
+
 G_END_DECLS
 
 #endif  /* GSPELL_CHECKER_H */


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