[evolution/webkit-composer: 121/231] Add e_spell_checker_list_active_languages()
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 121/231] Add e_spell_checker_list_active_languages()
- Date: Fri, 13 Sep 2013 14:16:09 +0000 (UTC)
commit 96c1712f13e50411afec43c3141d0b7df7f4311e
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Jan 17 19:54:11 2013 -0500
Add e_spell_checker_list_active_languages()
Returns a NULL-terminated array of language codes actively being used
for spell checking.
.../evolution-util/evolution-util-sections.txt | 1 +
e-util/e-spell-checker.c | 47 ++++++++++++++++++++
e-util/e-spell-checker.h | 3 +
3 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt
b/doc/reference/evolution-util/evolution-util-sections.txt
index 108fc60..c4d867a 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -3808,6 +3808,7 @@ e_spell_checker_ref_dictionary
e_spell_checker_get_enchant_dict
e_spell_checker_get_language_active
e_spell_checker_set_language_active
+e_spell_checker_list_active_languages
e_spell_checker_learn_word
e_spell_checker_ignore_word
<SUBSECTION Standard>
diff --git a/e-util/e-spell-checker.c b/e-util/e-spell-checker.c
index 5f51685..67224c2 100644
--- a/e-util/e-spell-checker.c
+++ b/e-util/e-spell-checker.c
@@ -593,6 +593,53 @@ e_spell_checker_set_language_active (ESpellChecker *checker,
}
/**
+ * e_spell_checker_list_active_languages:
+ * @checker: an #ESpellChecker
+ * @n_languages: return location for the number of active languages, or %NULL
+ *
+ * Returns a %NULL-terminated array of language codes actively being used
+ * for spell checking. Free the returned array with g_strfreev().
+ *
+ * Returns: a %NULL-teriminated array of language codes
+ **/
+gchar **
+e_spell_checker_list_active_languages (ESpellChecker *checker,
+ guint *n_languages)
+{
+ GHashTable *active_dictionaries;
+ GList *list, *link;
+ gchar **active_languages;
+ guint size;
+ gint ii = 0;
+
+ g_return_val_if_fail (E_IS_SPELL_CHECKER (checker), NULL);
+
+ active_dictionaries = checker->priv->active_dictionaries;
+ list = g_hash_table_get_keys (active_dictionaries);
+ size = g_hash_table_size (active_dictionaries);
+
+ active_languages = g_new0 (gchar *, size + 1);
+
+ list = g_list_sort (list, (GCompareFunc) e_spell_dictionary_compare);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESpellDictionary *dictionary;
+ const gchar *language_code;
+
+ dictionary = E_SPELL_DICTIONARY (link->data);
+ language_code = e_spell_dictionary_get_code (dictionary);
+ active_languages[ii++] = g_strdup (language_code);
+ }
+
+ if (n_languages != NULL)
+ *n_languages = size;
+
+ g_list_free (list);
+
+ return active_languages;
+}
+
+/**
* e_spell_checker_ignore_word:
* @checker: an #ESpellChecker
* @word: word to ignore for the rest of session
diff --git a/e-util/e-spell-checker.h b/e-util/e-spell-checker.h
index 78dcb23..c39c530 100644
--- a/e-util/e-spell-checker.h
+++ b/e-util/e-spell-checker.h
@@ -77,6 +77,9 @@ void e_spell_checker_set_language_active
(ESpellChecker *checker,
const gchar *language_code,
gboolean active);
+gchar ** e_spell_checker_list_active_languages
+ (ESpellChecker *checker,
+ guint *n_languages);
void e_spell_checker_learn_word (ESpellChecker *checker,
const gchar *word);
void e_spell_checker_ignore_word (ESpellChecker *checker,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]