#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
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);
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)
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;
}
/* 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);
}
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
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);
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;
}