made search for accounts by email address not case sensitive
[claws.git] / src / gtkspell.c
index 0d9fb7be84dd55701398c81cdd2f06e459320272..9d5594caace719cbf5800885c6f51aff9a0d9af8 100644 (file)
@@ -58,7 +58,7 @@
 #include "gtkspell.h"
 
 #include <pspell/pspell.h>
-
+#include <pspell/string_list.h>
 /* size of the text buffer used in various word-processing routines. */
 #define BUFSIZE 1024
 
@@ -191,11 +191,11 @@ GtkPspell *gtkpspell_new_with_config(GtkPspellConfig *gtkpspellconfig,
        if (encoding) {
                char *pspell_encoding;
                pspell_encoding = convert_to_pspell_encoding (encoding);
-               debug_print(_("Pspell encoding: %s\n"), pspell_encoding);
+               debug_print(_("Pspell encoding: asked: %s changed to: %s\n"), encoding, pspell_encoding);
                pspell_config_replace(gtkpspell->config, "encoding", (const char *)pspell_encoding);
                if (pspell_config_error_number(gtkpspell->config) !=0 ) {
-                       debug_print(_("Pspell encoding: %s\n"), pspell_config_error_message(gtkpspell->config));
-                       debug_print(_("Pspell encoding: setting error. Switching to iso8859-1 (sorry)\n"));
+                       debug_print(_("Pspell encoding error: %s\nSwitching to iso8859-1 (sorry)\n"), 
+                                   pspell_config_error_message(gtkpspell->config));
                        pspell_config_replace(gtkpspell->config, "encoding", "iso8859-1");
                }
                g_free(pspell_encoding);
@@ -322,6 +322,14 @@ int set_path_and_dict(GtkPspell *gtkpspell, PspellConfig *config,
        debug_print(_("Language : %s\nSpelling: %s\nJargon: %s\nModule: %s\n"),
                    language, spelling, jargon, module);
        
+       if (temppath[strlen(temppath)-1] == G_DIR_SEPARATOR) 
+               temppath[strlen(temppath)-1]= 0;
+       if (temppath) {
+               pspell_config_replace(config, "add-word-list-path", temppath);
+               debug_print(_("Pspell config: added path %s\n"), pspell_config_retrieve(config, "word-list-path"));
+               if (pspell_config_error_number(config))
+                       debug_print(_("Pspell config: %s\n"), pspell_config_error_message(config));
+       }
        if (language) 
                pspell_config_replace(config, "language-tag", language);
        if (spelling) 
@@ -330,18 +338,16 @@ int set_path_and_dict(GtkPspell *gtkpspell, PspellConfig *config,
                pspell_config_replace(config, "jargon", jargon);
        if (module)
                pspell_config_replace(config, "module", module);
-       if (temppath)
-               pspell_config_replace(config, "word-list-path", temppath);
 
        switch(gtkpspell->mode) {
        case PSPELL_FASTMODE: 
-               pspell_config_replace(config, "sug_mode", "fast");
+               pspell_config_replace(config, "sug-mode", "fast");
                break;
        case PSPELL_NORMALMODE: 
-               pspell_config_replace(config, "sug_mode", "normal");
+               pspell_config_replace(config, "sug-mode", "normal");
                break;
        case PSPELL_BADSPELLERMODE: 
-               pspell_config_replace(config, "sug_mode", "bad-spellers");
+               pspell_config_replace(config, "sug-mode", "bad-spellers");
                break;
        }
   
@@ -458,10 +464,19 @@ static void menu_change_dict(GtkWidget *w, GtkPspell *gtkpspell)
        /* Dict is simply the menu label */
 
        gtk_label_get(GTK_LABEL(GTK_BIN(w)->child), (gchar **) &thelabel);
+
+       if (!strcmp2(thelabel, _("None")))
+                       return;
+
        thedict = g_strdup(thelabel);
 
        /* Set path, dict, (and sug_mode ?) */
-       gtkpspell_set_path_and_dict(gtkpspell, gtkpspell->path, thedict);
+       if(!gtkpspell_set_path_and_dict(gtkpspell, gtkpspell->path, thedict)) {
+               /* FIXME : try to handle this very special case */
+               debug_print("Pspell: Attempt to change to a non existant dict. I will crash after closing compose window.\n");
+               gtkpspell_detach(gtkpspell);
+               gtkpspell = gtkpspell_delete(gtkpspell);
+       }
        g_free(thedict);
 }
 
@@ -808,8 +823,11 @@ static void entry_delete_cb(GtkXText *gtktext, gint start, gint end,
                return;
 
        origpos = gtk_editable_get_position(GTK_EDITABLE(gtktext));
-       if (start)
+       if (start) {
                check_at(gtkpspell, start - 1);
+               check_at(gtkpspell, start);
+       }
+
        gtk_editable_set_position(GTK_EDITABLE(gtktext), origpos);
        gtk_editable_select_region(GTK_EDITABLE(gtktext), origpos, origpos);
        /* this is to *UNDO* the selection, in case they were holding shift
@@ -1295,7 +1313,7 @@ GSList *gtkpspell_get_dictionary_list(const gchar *pspell_path)
                list = create_empty_dictionary_list();
        }
         if(list==NULL){
-          debug_print(_("No dictionary found"));
+          debug_print(_("No dictionary found\n"));
           list = create_empty_dictionary_list();
         }
        chdir(prevdir);
@@ -1400,12 +1418,15 @@ gchar *gtkpspell_get_dictionary_menu_active_item(GtkWidget *menu)
 guchar *convert_to_pspell_encoding (const guchar *encoding)
 {
        guchar * pspell_encoding;
-       /* Beware, strstr2 returns 0 if string is found -1 if not */
-       if (!strstr2(encoding, "ISO-8859-")) {
+
+       if (strstr2(encoding, "ISO-8859-")) {
                pspell_encoding = g_strdup_printf("iso8859%s", encoding+8);
        }
        else
-               pspell_encoding = g_strdup(encoding);
+               if (!strcmp2(encoding, "US-ASCII"))
+                       pspell_encoding = g_strdup("iso8859-1");
+               else
+                       pspell_encoding = g_strdup(encoding);
        return pspell_encoding;
        
 }