[balsa] Use Enchant API to check languages



commit d9d60a9b0174206906d350fbbdfb249814d2064b
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Dec 30 10:12:30 2009 -0500

    Use Enchant API to check languages

 ChangeLog            |    5 +++++
 src/sendmsg-window.c |   19 ++++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e9a579c..a89a795 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-30  Peter Bloomfield
+
+	* src/sendmsg-window.c (create_lang_menu): use
+	enchant_broker_dict_exists() to check languages.
+
 2009-12-29  Pawel Salek
 
 	* libbalsa/rfc3156.c:
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 401c82c..26a2206 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -74,6 +74,7 @@
 
 #if HAVE_GTKSPELL
 #include "gtkspell/gtkspell.h"
+#include <enchant/enchant.h>
 #else                           /* HAVE_GTKSPELL */
 #include "spell-check.h"
 #endif                          /* HAVE_GTKSPELL */
@@ -4324,6 +4325,9 @@ create_lang_menu(GtkWidget * parent, BalsaSendmsg * bsmsg)
     GtkWidget *langs = gtk_menu_new();
     static gboolean locales_sorted = FALSE;
     GSList *group = NULL;
+#if HAVE_GTKSPELL
+    EnchantBroker *broker;
+#endif                          /* HAVE_GTKSPELL */
 
     if (!locales_sorted) {
         for (i = 0; i < ELEMENTS(locales); i++)
@@ -4343,26 +4347,24 @@ create_lang_menu(GtkWidget * parent, BalsaSendmsg * bsmsg)
     selected_pos = find_locale_index_by_locale(setlocale(LC_CTYPE, NULL));
 #endif                          /* HAVE_GTKSPELL */
 
-    for (i = 0; i < ELEMENTS(locales); i++) {
 #if HAVE_GTKSPELL
-        GtkSpell *spell;
+    broker = enchant_broker_init();
+#endif                          /* HAVE_GTKSPELL */
 
+    for (i = 0; i < ELEMENTS(locales); i++) {
+#if HAVE_GTKSPELL
         if (locales[i].locale == NULL || locales[i].locale[0] == '\0')
             /* GtkSpell handles NULL lang, but complains about empty
              * lang; in either case, it does not go in the langs menu. */
             continue;
 
-        spell = gtkspell_new_attach(GTK_TEXT_VIEW(bsmsg->text),
-                                    locales[i].locale, NULL);
-        if (spell) {
+        if (enchant_broker_dict_exists(broker, locales[i].locale)) {
             GtkWidget *w;
 
             if (selected_pos < 0)
                 /* We did not find balsa_app.spell_check_lang. */
                 selected_pos = i;
 
-            gtkspell_detach(spell);
-
             w = gtk_radio_menu_item_new_with_mnemonic(group,
                                                       locales[i].
                                                       lang_name);
@@ -4394,6 +4396,9 @@ create_lang_menu(GtkWidget * parent, BalsaSendmsg * bsmsg)
         gtk_menu_shell_append(GTK_MENU_SHELL(langs), w);
 #endif                          /* HAVE_GTKSPELL */
     }
+#if HAVE_GTKSPELL
+    enchant_broker_free(broker);
+#endif                          /* HAVE_GTKSPELL */
     if (selected_pos >= 0)
         set_locale(bsmsg, selected_pos);
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(parent), langs);



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