[gspell/wip/entry: 2/3] Checker: add force_set_language() private function
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/entry: 2/3] Checker: add force_set_language() private function
- Date: Sun, 30 Oct 2016 17:52:57 +0000 (UTC)
commit 7eb023b95ddbad2898e60e72a2cf38ca51d5e4c6
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Oct 30 18:19:08 2016 +0100
Checker: add force_set_language() private function
gspell/Makefile.am | 1 +
gspell/gspell-checker-private.h | 34 ++++++++++++++++++++++++++++++++++
gspell/gspell-checker.c | 31 +++++++++++++++++++++----------
3 files changed, 56 insertions(+), 10 deletions(-)
---
diff --git a/gspell/Makefile.am b/gspell/Makefile.am
index f0d0685..e8e87f1 100644
--- a/gspell/Makefile.am
+++ b/gspell/Makefile.am
@@ -45,6 +45,7 @@ gspell_public_c_files = \
gspell_private_headers = \
gconstructor.h \
gspellregion.h \
+ gspell-checker-private.h \
gspell-entry-private.h \
gspell-entry-utils.h \
gspell-init.h \
diff --git a/gspell/gspell-checker-private.h b/gspell/gspell-checker-private.h
new file mode 100644
index 0000000..c622876
--- /dev/null
+++ b/gspell/gspell-checker-private.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of gspell, a spell-checking library.
+ *
+ * Copyright 2016 - Sébastien Wilmet
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GSPELL_CHECKER_PRIVATE_H
+#define GSPELL_CHECKER_PRIVATE_H
+
+#include "gspell-checker.h"
+
+G_BEGIN_DECLS
+
+void _gspell_checker_force_set_language (GspellChecker *checker,
+ const GspellLanguage *language);
+
+G_END_DECLS
+
+#endif /* GSPELL_CHECKER_PRIVATE_H */
+
+/* ex:set ts=8 noet: */
diff --git a/gspell/gspell-checker.c b/gspell/gspell-checker.c
index 2fbf8db..d501d50 100644
--- a/gspell/gspell-checker.c
+++ b/gspell/gspell-checker.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "gspell-checker.h"
+#include "gspell-checker-private.h"
#include <enchant.h>
#include <glib/gi18n-lib.h>
#include <string.h>
@@ -284,6 +285,25 @@ create_new_dictionary (GspellChecker *checker)
gspell_checker_add_word_to_session (checker, app_name, -1);
}
+/* Used for unit tests. Useful to force a NULL language. */
+void
+_gspell_checker_force_set_language (GspellChecker *checker,
+ const GspellLanguage *language)
+{
+ GspellCheckerPrivate *priv;
+
+ g_return_if_fail (GSPELL_IS_CHECKER (checker));
+
+ priv = gspell_checker_get_instance_private (checker);
+
+ if (priv->active_lang != language)
+ {
+ priv->active_lang = language;
+ create_new_dictionary (checker);
+ g_object_notify (G_OBJECT (checker), "language");
+ }
+}
+
/**
* gspell_checker_set_language:
* @checker: a #GspellChecker.
@@ -296,23 +316,14 @@ void
gspell_checker_set_language (GspellChecker *checker,
const GspellLanguage *language)
{
- GspellCheckerPrivate *priv;
-
g_return_if_fail (GSPELL_IS_CHECKER (checker));
- priv = gspell_checker_get_instance_private (checker);
-
if (language == NULL)
{
language = gspell_language_get_default ();
}
- if (priv->active_lang != language)
- {
- priv->active_lang = language;
- create_new_dictionary (checker);
- g_object_notify (G_OBJECT (checker), "language");
- }
+ _gspell_checker_force_set_language (checker, language);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]