From: Colin Leroy Date: Fri, 12 Sep 2008 16:11:51 +0000 (+0000) Subject: 2008-09-12 [colin] 3.5.0cvs103 X-Git-Tag: rel_3_6_0~49 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=daee52fe5a0c832ee25b19e2d3d9346a8b711eb1;ds=sidebyside 2008-09-12 [colin] 3.5.0cvs103 * claws-mail.pc.in * src/Makefile.am * src/compose.c * src/compose.h * src/crash.c * src/folder_item_prefs.c * src/folder_item_prefs.h * src/main.c * src/prefs_account.c * src/prefs_common.c * src/prefs_common.h * src/prefs_folder_item.c * src/prefs_spelling.c * src/prefs_template.c * src/quote_fmt.h * src/quote_fmt_parse.y * src/toolbar.c * src/toolbar.h * src/gtk/Makefile.am * src/gtk/about.c * src/gtk/filesel.c * src/gtk/gtkaspell.c * src/gtk/gtkaspell.h * src/plugins/bogofilter/Makefile.am * src/plugins/dillo_viewer/Makefile.am * src/plugins/spamassassin/Makefile.am * src/plugins/trayicon/Makefile.am Switch spellchecker to Enchant --- diff --git a/ChangeLog b/ChangeLog index 8823b124b..967e0d7b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2008-09-12 [colin] 3.5.0cvs103 + + * claws-mail.pc.in + * src/Makefile.am + * src/compose.c + * src/compose.h + * src/crash.c + * src/folder_item_prefs.c + * src/folder_item_prefs.h + * src/main.c + * src/prefs_account.c + * src/prefs_common.c + * src/prefs_common.h + * src/prefs_folder_item.c + * src/prefs_spelling.c + * src/prefs_template.c + * src/quote_fmt.h + * src/quote_fmt_parse.y + * src/toolbar.c + * src/toolbar.h + * src/gtk/Makefile.am + * src/gtk/about.c + * src/gtk/filesel.c + * src/gtk/gtkaspell.c + * src/gtk/gtkaspell.h + * src/plugins/bogofilter/Makefile.am + * src/plugins/dillo_viewer/Makefile.am + * src/plugins/spamassassin/Makefile.am + * src/plugins/trayicon/Makefile.am + Switch spellchecker to Enchant + 2008-09-12 [paul] 3.5.0cvs102 * tools/README diff --git a/PATCHSETS b/PATCHSETS index 146761ab5..6c685b0ef 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -3514,3 +3514,4 @@ ( cvs diff -u -r 1.654.2.3573 -r 1.654.2.3574 configure.ac; ) > 3.5.0cvs100.patchset ( cvs diff -u -r 1.382.2.473 -r 1.382.2.474 src/compose.c; cvs diff -u -r 1.1.2.17 -r 1.1.2.18 src/prefs_wrapping.c; ) > 3.5.0cvs101.patchset ( cvs diff -u -r 1.30.2.31 -r 1.30.2.32 tools/README; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 tools/csv2addressbook.pl; ) > 3.5.0cvs102.patchset +( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 claws-mail.pc.in; cvs diff -u -r 1.155.2.90 -r 1.155.2.91 src/Makefile.am; cvs diff -u -r 1.382.2.474 -r 1.382.2.475 src/compose.c; cvs diff -u -r 1.50.2.50 -r 1.50.2.51 src/compose.h; cvs diff -u -r 1.23.2.29 -r 1.23.2.30 src/crash.c; cvs diff -u -r 1.2.2.30 -r 1.2.2.31 src/folder_item_prefs.c; cvs diff -u -r 1.2.2.17 -r 1.2.2.18 src/folder_item_prefs.h; cvs diff -u -r 1.115.2.204 -r 1.115.2.205 src/main.c; cvs diff -u -r 1.105.2.144 -r 1.105.2.145 src/prefs_account.c; cvs diff -u -r 1.204.2.177 -r 1.204.2.178 src/prefs_common.c; cvs diff -u -r 1.103.2.112 -r 1.103.2.113 src/prefs_common.h; cvs diff -u -r 1.52.2.66 -r 1.52.2.67 src/prefs_folder_item.c; cvs diff -u -r 1.5.2.36 -r 1.5.2.37 src/prefs_spelling.c; cvs diff -u -r 1.12.2.66 -r 1.12.2.67 src/prefs_template.c; cvs diff -u -r 1.5.12.18 -r 1.5.12.19 src/quote_fmt.h; cvs diff -u -r 1.22.2.39 -r 1.22.2.40 src/quote_fmt_parse.y; cvs diff -u -r 1.43.2.104 -r 1.43.2.105 src/toolbar.c; cvs diff -u -r 1.19.2.28 -r 1.19.2.29 src/toolbar.h; cvs diff -u -r 1.20.2.17 -r 1.20.2.18 src/gtk/Makefile.am; cvs diff -u -r 1.4.2.66 -r 1.4.2.67 src/gtk/about.c; cvs diff -u -r 1.2.2.37 -r 1.2.2.38 src/gtk/filesel.c; cvs diff -u -r 1.9.2.60 -r 1.9.2.61 src/gtk/gtkaspell.c; cvs diff -u -r 1.5.2.15 -r 1.5.2.16 src/gtk/gtkaspell.h; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/bogofilter/Makefile.am; cvs diff -u -r 1.4.2.7 -r 1.4.2.8 src/plugins/dillo_viewer/Makefile.am; cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/plugins/spamassassin/Makefile.am; cvs diff -u -r 1.4.2.11 -r 1.4.2.12 src/plugins/trayicon/Makefile.am; ) > 3.5.0cvs103.patchset diff --git a/claws-mail.pc.in b/claws-mail.pc.in index 64a25e667..62125e8a0 100644 --- a/claws-mail.pc.in +++ b/claws-mail.pc.in @@ -11,4 +11,4 @@ Name: Claws Mail Description: Claws Mail Version: @MAJOR_VERSION@.@MINOR_VERSION@.@MICRO_VERSION@.@EXTRA_VERSION@ -Cflags: @ASPELL_CFLAGS@ @GPGME_CFLAGS@ @OPENSSL_CFLAGS@ -I${pkgincludedir} -I${pkgincludedir}/common -I${pkgincludedir}/gtk +Cflags: @ENCHANT_CFLAGS@ @GPGME_CFLAGS@ @OPENSSL_CFLAGS@ -I${pkgincludedir} -I${pkgincludedir}/common -I${pkgincludedir}/gtk diff --git a/configure.ac b/configure.ac index 1d2a9db05..1acfe2577 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=5 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=102 +EXTRA_VERSION=103 EXTRA_RELEASE= EXTRA_GTK2_VERSION= @@ -460,17 +460,24 @@ AC_ARG_ENABLE(deprecated, [ --disable-deprecated disable deprecated GTK functi AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) -dnl GNU/Aspell is used for spell checking -AC_ARG_ENABLE(aspell, - [ --disable-aspell disable GNU/aspell support], - [ac_cv_enable_aspell=$enableval], [ac_cv_enable_aspell=yes]) -AC_MSG_CHECKING([whether to use GNU/aspell]) -if test $ac_cv_enable_aspell = yes; then - AC_MSG_RESULT(yes) - AM_PATH_ASPELL(0.50, AC_DEFINE(USE_ASPELL, 1, Define if you use ASPELL to support spell checking), - [use_aspell=no ac_cv_enable_aspell=no]) -else - AC_MSG_RESULT(no) +dnl enchant is used for spell checking +AC_ARG_ENABLE(enchant, + [ --disable-enchant disable enchant support], + [ac_cv_enable_enchant=$enableval], [ac_cv_enable_enchant=yes]) +AC_MSG_CHECKING([whether to use enchant]) +if test $ac_cv_enable_enchant = yes; then + PKG_CHECK_MODULES(ENCHANT, enchant >= 1.0.0, + [ + AC_DEFINE(USE_ENCHANT, 1, enchant) + echo "Building with enchant" + ac_cv_enable_enchant=yes + ], + [ + echo "Building without enchant-notification" + ac_cv_enable_enchant=no + ]) + AC_SUBST(ENCHANT_CFLAGS) + AC_SUBST(ENCHANT_LIBS) fi dnl want crash dialog @@ -1065,7 +1072,7 @@ echo "gnuTLS : $ac_cv_enable_gnutls" echo "iconv : $am_cv_func_iconv" echo "compface : $ac_cv_enable_compface" echo "IPv6 : $ac_cv_enable_ipv6" -echo "GNU/aspell : $ac_cv_enable_aspell" +echo "enchant : $ac_cv_enable_enchant" echo "IMAP4 : $ac_cv_enable_libetpan" echo "NNTP : $ac_cv_enable_libetpan" echo "Crash dialog : $ac_cv_enable_crash_dialog" diff --git a/src/Makefile.am b/src/Makefile.am index 2caaf250a..a7fb69cf2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -514,7 +514,7 @@ claws_mail_DEPENDENCIES = $(claws_mail_deps) \ claws_mail_LDADD = \ $(etpan_library) \ gtk/libclawsgtk.la \ - $(ASPELL_LIBS) \ + $(ENCHANT_LIBS) \ $(INTLLIBS) \ $(GTK_LIBS) \ $(GPGME_LIBS) \ @@ -544,7 +544,7 @@ AM_CPPFLAGS = \ -DTARGET_ALIAS=\""$(target_triplet)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ -DDATAROOTDIR=\""$(datarootdir)"\" \ - $(ASPELL_CFLAGS) \ + $(ENCHANT_CFLAGS) \ $(GTK_CFLAGS) \ $(GPGME_CFLAGS) \ $(OPENSSL_CFLAGS) \ diff --git a/src/compose.c b/src/compose.c index 5832075f5..22ca6682f 100644 --- a/src/compose.c +++ b/src/compose.c @@ -332,7 +332,7 @@ static void compose_add_header_entry (Compose *compose, const gchar *header, gch static void compose_remove_header_entries(Compose *compose); static void compose_update_priority_menu_item(Compose * compose); -#if USE_ASPELL +#if USE_ENCHANT static void compose_spell_menu_changed (void *data); #endif static void compose_add_field_list ( Compose *compose, @@ -505,7 +505,7 @@ static void compose_nothing_cb (GtkAction *action, gpointer data) } -#if USE_ASPELL +#if USE_ENCHANT static void compose_check_all (GtkAction *action, gpointer data); static void compose_highlight_all (GtkAction *action, gpointer data); static void compose_check_backwards (GtkAction *action, gpointer data); @@ -517,7 +517,7 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo (MsgInfo *msginf static MsgInfo *compose_msginfo_new_from_compose(Compose *compose); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT static void compose_set_dictionaries_from_folder_prefs(Compose *compose, FolderItem *folder_item); #endif @@ -540,7 +540,7 @@ static GtkActionEntry compose_entries[] = /* menus */ {"Message", NULL, N_("_Message") }, {"Edit", NULL, N_("_Edit") }, -#if USE_ASPELL +#if USE_ENCHANT {"Spelling", NULL, N_("_Spelling") }, #endif {"Options", NULL, N_("_Options") }, @@ -599,7 +599,7 @@ static GtkActionEntry compose_entries[] = {"Edit/WrapAllLines", NULL, N_("Wrap all long _lines"), "L", NULL, G_CALLBACK(compose_wrap_all_cb) }, /* 1 */ /* {"Edit/---", NULL, "---" }, */ {"Edit/ExtEditor", NULL, N_("Edit with e_xternal editor"), "X", NULL, G_CALLBACK(compose_ext_editor_cb) }, -#if USE_ASPELL +#if USE_ENCHANT /* Spelling menu */ {"Spelling/CheckAllSel", NULL, N_("_Check all or check selection"), NULL, NULL, G_CALLBACK(compose_check_all) }, {"Spelling/HighlightAll", NULL, N_("_Highlight all misspelled words"), NULL, NULL, G_CALLBACK(compose_highlight_all) }, @@ -942,7 +942,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI tmp = malloc(strlen(item->prefs->compose_override_from_format)+1); pref_get_unescaped_pref(tmp, item->prefs->compose_override_from_format); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -969,7 +969,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI compose_create_tags(textview, compose); undo_block(compose->undostruct); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT compose_set_dictionaries_from_folder_prefs(compose, item); #endif @@ -1034,7 +1034,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI pref_get_unescaped_pref(tmp, subject_format); subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -1437,7 +1437,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, tmp = malloc(strlen(msginfo->folder->prefs->reply_override_from_format)+1); pref_get_unescaped_pref(tmp, msginfo->folder->prefs->reply_override_from_format); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -1461,7 +1461,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, compose_create_tags(textview, compose); undo_block(compose->undostruct); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder); #endif @@ -1607,7 +1607,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo, tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1); pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -1789,7 +1789,7 @@ static Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_ tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1); pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -2451,7 +2451,7 @@ void compose_toolbar_cb(gint action, gpointer data) case A_ADDRBOOK: compose_address_cb(NULL, compose); break; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT case A_CHECK_SPELLING: compose_check_all(NULL, compose); break; @@ -2766,7 +2766,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo, } if (qmark != NULL) { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -2788,7 +2788,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo, while (*trimmed_body == '\n') trimmed_body++; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -4552,7 +4552,7 @@ static void compose_select_account(Compose *compose, PrefsAccount *account, undo_unblock(compose->undostruct); } -#ifdef USE_ASPELL +#ifdef USE_ENCHANT /* use account's dict info if set */ if (compose->gtkaspell) { if (account->enable_default_dictionary) @@ -6574,7 +6574,7 @@ static gboolean text_clicked(GtkWidget *text, GdkEventButton *event, { gint prev_autowrap; GtkTextBuffer *buffer = GTK_TEXT_VIEW(text)->buffer; -#if USE_ASPELL +#if USE_ENCHANT if (event->button == 3) { GtkTextIter iter; GtkTextIter sel_start, sel_end; @@ -6628,7 +6628,7 @@ static gboolean text_clicked(GtkWidget *text, GdkEventButton *event, return FALSE; } -#if USE_ASPELL +#if USE_ENCHANT static void compose_spell_menu_changed(void *data) { Compose *compose = (Compose *)data; @@ -6725,7 +6725,7 @@ static Compose *compose_create(PrefsAccount *account, GtkWidget *tmpl_menu; GtkActionGroup *action_group = NULL; -#if USE_ASPELL +#if USE_ENCHANT GtkAspell * gtkaspell = NULL; #endif @@ -6805,7 +6805,7 @@ static Compose *compose_create(PrefsAccount *account, MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Message", "Message", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU) -#ifdef USE_ASPELL +#ifdef USE_ENCHANT MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Spelling", "Spelling", GTK_UI_MANAGER_MENU) #endif MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Options", "Options", GTK_UI_MANAGER_MENU) @@ -6868,7 +6868,7 @@ static Compose *compose_create(PrefsAccount *account, MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Edit", "ExtEditor", "Edit/ExtEditor", GTK_UI_MANAGER_MENUITEM) -#if USE_ASPELL +#if USE_ENCHANT /* Spelling menu */ MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "CheckAllSel", "Spelling/CheckAllSel", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "HighlightAll", "Spelling/HighlightAll", GTK_UI_MANAGER_MENUITEM) @@ -7239,13 +7239,12 @@ static Compose *compose_create(PrefsAccount *account, compose->exteditor_tag = -1; compose->draft_timeout_tag = -2; /* inhibit auto-drafting while loading */ -#if USE_ASPELL +#if USE_ENCHANT cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", FALSE); if (mode != COMPOSE_REDIRECT) { if (prefs_common.enable_aspell && prefs_common.dictionary && strcmp(prefs_common.dictionary, "")) { - gtkaspell = gtkaspell_new(prefs_common.aspell_path, - prefs_common.dictionary, + gtkaspell = gtkaspell_new(prefs_common.dictionary, prefs_common.alt_dictionary, conv_get_locale_charset_str(), prefs_common.misspelled_col, @@ -7263,14 +7262,6 @@ static Compose *compose_create(PrefsAccount *account, gtkaspell_checkers_strerror()); gtkaspell_checkers_reset_error(); } else { - if (!gtkaspell_set_sug_mode(gtkaspell, - prefs_common.aspell_sugmode)) { - debug_print("Aspell: could not set " - "suggestion mode %s\n", - gtkaspell_checkers_strerror()); - gtkaspell_checkers_reset_error(); - } - cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", TRUE); } } @@ -7876,7 +7867,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl) } if (tmpl->from && *tmpl->from != '\0') { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -7894,7 +7885,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl) } if (tmpl->to && *tmpl->to != '\0') { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -7912,7 +7903,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl) } if (tmpl->cc && *tmpl->cc != '\0') { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -7930,7 +7921,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl) } if (tmpl->bcc && *tmpl->bcc != '\0') { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -7949,7 +7940,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl) /* process the subject */ if (tmpl->subject && *tmpl->subject != '\0') { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, compose->gtkaspell); #else @@ -8024,7 +8015,7 @@ static void compose_destroy(Compose *compose) if (addressbook_get_target_compose() == compose) addressbook_set_target_compose(NULL); -#if USE_ASPELL +#if USE_ENCHANT if (compose->gtkaspell) { gtkaspell_delete(compose->gtkaspell); compose->gtkaspell = NULL; @@ -8847,7 +8838,7 @@ static void compose_allow_user_actions (Compose *compose, gboolean allow) toolbar_comp_set_sensitive(compose, allow); cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Message", allow); cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Edit", allow); -#if USE_ASPELL +#if USE_ENCHANT cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", allow); #endif cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options", allow); @@ -10444,7 +10435,7 @@ static gint compose_defer_auto_save_draft(Compose *compose) return FALSE; } -#if USE_ASPELL +#if USE_ENCHANT static void compose_check_all(GtkAction *action, gpointer data) { Compose *compose = (Compose *)data; @@ -10755,7 +10746,7 @@ static MsgInfo *compose_msginfo_new_from_compose(Compose *compose) return newmsginfo; } -#ifdef USE_ASPELL +#ifdef USE_ENCHANT /* update compose's dictionaries from folder dict settings */ static void compose_set_dictionaries_from_folder_prefs(Compose *compose, FolderItem *folder_item) diff --git a/src/compose.h b/src/compose.h index 3a26db9d7..9a51ad6c8 100644 --- a/src/compose.h +++ b/src/compose.h @@ -38,7 +38,7 @@ typedef struct _AttachInfo AttachInfo; #include "textview.h" #include "folder.h" -#ifdef USE_ASPELL +#ifdef USE_ENCHANT #include "gtkaspell.h" #endif @@ -200,7 +200,7 @@ struct _Compose GIOChannel *exteditor_ch; gint exteditor_tag; -#if USE_ASPELL +#if USE_ENCHANT /* GNU/aspell spell checker */ GtkAspell *gtkaspell; GtkWidget *aspell_options_menu; diff --git a/src/crash.c b/src/crash.c index a9e8546c3..70705b310 100644 --- a/src/crash.c +++ b/src/crash.c @@ -427,7 +427,7 @@ static const gchar *get_compiled_in_features(void) #if USE_JPILOT " JPilot" #endif -#if USE_ASPELL +#if USE_ENCHANT " GNU/aspell" #endif #if HAVE_LIBETPAN diff --git a/src/folder_item_prefs.c b/src/folder_item_prefs.c index 880f9832d..1d5e4e7fe 100644 --- a/src/folder_item_prefs.c +++ b/src/folder_item_prefs.c @@ -54,7 +54,7 @@ static PrefParam param[] = { NULL, NULL, NULL}, {"default_account", NULL, &tmp_prefs.default_account, P_INT, NULL, NULL, NULL}, -#if USE_ASPELL +#if USE_ENCHANT {"enable_default_dictionary", "", &tmp_prefs.enable_default_dictionary, P_BOOL, NULL, NULL, NULL}, {"default_dictionary", NULL, &tmp_prefs.default_dictionary, P_STRING, @@ -162,7 +162,7 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs) prefs->folder_chmod = 0; prefs->enable_default_account = FALSE; prefs->default_account = 0; -#if USE_ASPELL +#if USE_ENCHANT prefs->enable_default_dictionary = FALSE; prefs->default_dictionary = NULL; prefs->enable_default_alt_dictionary = FALSE; @@ -258,7 +258,7 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest) tmp_prefs.folder_chmod = src->prefs->folder_chmod; tmp_prefs.enable_default_account = src->prefs->enable_default_account; tmp_prefs.default_account = src->prefs->default_account; -#if USE_ASPELL +#if USE_ENCHANT tmp_prefs.enable_default_dictionary = src->prefs->enable_default_dictionary; tmp_prefs.default_dictionary = g_strdup(src->prefs->default_dictionary); tmp_prefs.enable_default_alt_dictionary = src->prefs->enable_default_alt_dictionary; diff --git a/src/folder_item_prefs.h b/src/folder_item_prefs.h index f07f2596d..bc90ee4e8 100644 --- a/src/folder_item_prefs.h +++ b/src/folder_item_prefs.h @@ -50,7 +50,7 @@ struct _FolderItemPrefs { gint folder_chmod; gboolean enable_default_account; gint default_account; -#if USE_ASPELL +#if USE_ENCHANT gboolean enable_default_dictionary; gchar *default_dictionary; gboolean enable_default_alt_dictionary; diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am index dc14e2d12..f2f10a102 100644 --- a/src/gtk/Makefile.am +++ b/src/gtk/Makefile.am @@ -75,16 +75,16 @@ AM_CPPFLAGS = \ -I$(builddir)/.. \ $(GTK_CFLAGS) \ $(OPENSSL_CFLAGS) \ - $(ASPELL_CFLAGS) \ $(GNOMEPRINT_CFLAGS) \ $(MAEMO_CFLAGS) \ + $(ENCHANT_CFLAGS) \ -DPLUGINDIR=\"$(PLUGINDIR)\" \ -DDOCDIR=\"$(DOCDIR)\" libclawsgtk_la_LIBADD = \ ../common/libclawscommon.la \ $(GTK_LIBS) \ - $(ASPELL_LIBS) \ + $(ENCHANT_LIBS) \ $(GNOMEPRINT_LIBS) \ $(MAEMO_LIBS) diff --git a/src/gtk/about.c b/src/gtk/about.c index cce0b6f51..6f71aeb3a 100644 --- a/src/gtk/about.c +++ b/src/gtk/about.c @@ -405,15 +405,15 @@ static GtkWidget *about_create_child_page_features(void) gtk_text_buffer_insert(buffer, &iter, (gchar *)Q_("compface|adds support for the X-Face header\n"), -1); -#if USE_ASPELL +#if USE_ENCHANT gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf); #else gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf); #endif - gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" GNU/aspell "), -1, + gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" Enchant "), -1, "bold", NULL); gtk_text_buffer_insert(buffer, &iter, - (gchar *)Q_("GNU/aspell|adds support for spell checking\n"), -1); + (gchar *)Q_("Enchant|adds support for spell checking\n"), -1); #if USE_GNUTLS gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf); diff --git a/src/gtk/filesel.c b/src/gtk/filesel.c index 9ad0f4847..ca69a598e 100644 --- a/src/gtk/filesel.c +++ b/src/gtk/filesel.c @@ -110,11 +110,19 @@ static GList *filesel_create(const gchar *title, const gchar *path, chooser = hildon_file_chooser_dialog_new (NULL, action); } #else +#if !GTK_CHECK_VERSION(2,14,0) GtkWidget *chooser = gtk_file_chooser_dialog_new_with_backend (title, NULL, action, "gtk+", GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, action_btn, GTK_RESPONSE_ACCEPT, NULL); +#else + GtkWidget *chooser = gtk_file_chooser_dialog_new + (title, NULL, action, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + action_btn, GTK_RESPONSE_ACCEPT, + NULL); +#endif #endif if (filter != NULL) { GtkFileFilter *file_filter = gtk_file_filter_new(); diff --git a/src/gtk/gtkaspell.c b/src/gtk/gtkaspell.c index 566d9f67f..2c9fea598 100644 --- a/src/gtk/gtkaspell.c +++ b/src/gtk/gtkaspell.c @@ -27,7 +27,7 @@ # include "config.h" #endif -#ifdef USE_ASPELL +#ifdef USE_ENCHANT #include #include @@ -50,10 +50,9 @@ #include #include -#include +#include #include "utils.h" -#include "codeconv.h" #include "alertpanel.h" #include "gtkaspell.h" #include "gtk/gtkutils.h" @@ -71,20 +70,6 @@ /* number of suggestions to display on each menu. */ #define MENUCOUNT 15 -/* 'config' must be defined as a 'AspellConfig *' */ -#define RETURN_FALSE_IF_CONFIG_ERROR() \ -{ \ - if (aspell_config_error_number(config) != 0) { \ - gtkaspellcheckers->error_message = g_strdup(aspell_config_error_message(config)); \ - return FALSE; \ - } \ -} - -#define CONFIG_REPLACE_RETURN_FALSE_IF_FAIL(option, value) { \ - aspell_config_replace(config, option, value); \ - RETURN_FALSE_IF_CONFIG_ERROR(); \ - } - enum { SET_GTKASPELL_NAME = 0, SET_GTKASPELL_FULLNAME = 1, @@ -100,14 +85,12 @@ typedef struct _GtkAspellCheckers { typedef struct _Dictionary { gchar *fullname; gchar *dictname; - gchar *encoding; } Dictionary; typedef struct _GtkAspeller { Dictionary *dictionary; - gint sug_mode; - AspellConfig *config; - AspellSpeller *checker; + EnchantBroker *broker; + EnchantDict *speller; } GtkAspeller; typedef void (*ContCheckFunc) (gpointer *gtkaspell); @@ -116,7 +99,6 @@ struct _GtkAspell { GtkAspeller *gtkaspeller; GtkAspeller *alternate_speller; - gchar *dictionary_path; gchar theword[GTKASPELLWORDSIZE]; gint start_pos; gint end_pos; @@ -133,7 +115,6 @@ struct _GtkAspell GtkWidget *replace_entry; GtkWidget *parent_window; - gint default_sug_mode; gint max_sug; GList *suggestions_list; @@ -144,14 +125,12 @@ struct _GtkAspell void *menu_changed_data; }; -typedef AspellConfig GtkAspellConfig; - /******************************************************************************/ static GtkAspellCheckers *gtkaspellcheckers; /* Error message storage */ -static void gtkaspell_checkers_error_message (gchar *message); +static void gtkaspell_checkers_error_message (gchar *message); /* Callbacks */ static void entry_insert_cb (GtkTextBuffer *textbuf, @@ -177,14 +156,10 @@ static GtkAspeller* gtkaspeller_delete (GtkAspeller *gtkaspeller); static GtkAspeller* gtkaspeller_real_delete (GtkAspeller *gtkaspeller); /* Checker configuration */ -static gint set_dictionary (AspellConfig *config, +static EnchantDict *set_dictionary (EnchantBroker *broker, Dictionary *dict); -static void set_sug_mode_cb (GtkMenuItem *w, - GtkAspell *gtkaspell); static void set_use_both_cb (GtkMenuItem *w, GtkAspell *gtkaspell); -static void set_real_sug_mode (GtkAspell *gtkaspell, - const char *themode); /* Checker actions */ static gboolean check_at (GtkAspell *gtkaspell, @@ -204,7 +179,7 @@ static void replace_with_supplied_word_cb (GtkWidget *w, static void replace_word_cb (GtkWidget *w, gpointer data); static void replace_real_word (GtkAspell *gtkaspell, - gchar *newword); + const gchar *newword); static void check_with_alternate_cb (GtkWidget *w, gpointer data); static void use_alternate_dict (GtkAspell *gtkaspell); @@ -237,7 +212,7 @@ static gunichar get_text_index_whar (GtkAspell *gtkaspell, int pos); static gboolean get_word_from_pos (GtkAspell *gtkaspell, gint pos, - unsigned char* buf, + char* buf, gint buflen, gint *pstart, gint *pend); @@ -248,7 +223,6 @@ static void change_color (GtkAspell *gtkaspell, gint end, gchar *newtext, GdkColor *color); -static gchar* convert_to_aspell_encoding (const gchar *encoding); static gint compare_dict (Dictionary *a, Dictionary *b); static void dictionary_delete (Dictionary *dict); @@ -259,16 +233,14 @@ static void free_checkers (gpointer elt, gpointer data); static gint find_gtkaspeller (gconstpointer aa, gconstpointer bb); -/* gtkspellconfig - only one config per session */ -GtkAspellConfig * gtkaspellconfig; + static void destroy_menu(GtkWidget *widget, gpointer user_data); /******************************************************************************/ static gint get_textview_buffer_charcount(GtkTextView *view); static void gtkaspell_free_dictionary_list (GSList *list); -static GSList* gtkaspell_get_dictionary_list (const char *aspell_path, - gint refresh); +static GSList* gtkaspell_get_dictionary_list (gint refresh); static void gtkaspell_uncheck_all (GtkAspell *gtkaspell); @@ -366,6 +338,8 @@ static void gtkaspell_checkers_error_message (gchar *message) gtkaspellcheckers->error_message = tmp; } else gtkaspellcheckers->error_message = message; + + } const char *gtkaspell_checkers_strerror(void) @@ -383,10 +357,9 @@ void gtkaspell_checkers_reset_error(void) gtkaspellcheckers->error_message = NULL; } -GtkAspell *gtkaspell_new(const gchar *dictionary_path, - const gchar *dictionary, +GtkAspell *gtkaspell_new(const gchar *dictionary, const gchar *alt_dictionary, - const gchar *encoding, + const gchar *encoding, /* unused */ gint misspelled_color, gboolean check_while_typing, gboolean recheck_when_changing_dict, @@ -403,28 +376,34 @@ GtkAspell *gtkaspell_new(const gchar *dictionary_path, GtkTextBuffer *buffer; g_return_val_if_fail(gtktext, NULL); - g_return_val_if_fail(dictionary && strlen(dictionary) > 0, - NULL); - - g_return_val_if_fail(dictionary_path && strlen(dictionary_path) > 0, - NULL); + if (!dictionary || !*dictionary) { + gtkaspell_checkers_error_message( + g_strdup(_("No dictionary selected."))); + return NULL; + } buffer = gtk_text_view_get_buffer(gtktext); dict = g_new0(Dictionary, 1); - dict->fullname = g_strdup(dictionary); - dict->encoding = g_strdup(encoding); + if (strrchr(dictionary, '/')) { + dict->fullname = g_strdup(strrchr(dictionary, '/')+1); + dict->dictname = g_strdup(strrchr(dictionary, '/')+1); + } else { + dict->fullname = g_strdup(dictionary); + dict->dictname = g_strdup(dictionary); + } gtkaspeller = gtkaspeller_new(dict); dictionary_delete(dict); - if (!gtkaspeller) + if (!gtkaspeller) { + gtkaspell_checkers_error_message( + g_strdup_printf(_("Couldn't initialize %s speller."), dictionary)); return NULL; + } gtkaspell = g_new0(GtkAspell, 1); - gtkaspell->dictionary_path = g_strdup(dictionary_path); - gtkaspell->gtkaspeller = gtkaspeller; if (use_alternate && alt_dictionary && *alt_dictionary) { @@ -432,14 +411,22 @@ GtkAspell *gtkaspell_new(const gchar *dictionary_path, GtkAspeller *alt_gtkaspeller; alt_dict = g_new0(Dictionary, 1); - alt_dict->fullname = g_strdup(alt_dictionary); - alt_dict->encoding = g_strdup(encoding); + if (strrchr(alt_dictionary, '/')) { + alt_dict->fullname = g_strdup(strrchr(alt_dictionary, '/')+1); + alt_dict->dictname = g_strdup(strrchr(alt_dictionary, '/')+1); + } else { + alt_dict->fullname = g_strdup(alt_dictionary); + alt_dict->dictname = g_strdup(alt_dictionary); + } alt_gtkaspeller = gtkaspeller_new(alt_dict); dictionary_delete(alt_dict); - if (!alt_gtkaspeller) + if (!alt_gtkaspeller) { + gtkaspell_checkers_error_message( + g_strdup_printf(_("Couldn't initialize %s speller."), dictionary)); return NULL; + } gtkaspell->alternate_speller = alt_gtkaspeller; } else { @@ -457,7 +444,6 @@ GtkAspell *gtkaspell_new(const gchar *dictionary_path, gtkaspell->continue_check = NULL; gtkaspell->replace_entry = NULL; gtkaspell->gtktext = gtktext; - gtkaspell->default_sug_mode = ASPELL_FASTMODE; gtkaspell->max_sug = -1; gtkaspell->suggestions_list = NULL; gtkaspell->use_alternate = use_alternate; @@ -507,9 +493,6 @@ void gtkaspell_delete(GtkAspell *gtkaspell) if (gtkaspell->suggestions_list) free_suggestions_list(gtkaspell); - g_free((gchar *)gtkaspell->dictionary_path); - gtkaspell->dictionary_path = NULL; - debug_print("Aspell: deleting gtkaspell %p\n", gtkaspell); g_free(gtkaspell); @@ -525,7 +508,7 @@ static void entry_insert_cb(GtkTextBuffer *textbuf, { guint pos; - g_return_if_fail(gtkaspell->gtkaspeller->checker); + g_return_if_fail(gtkaspell->gtkaspeller->speller); if (!gtkaspell->check_while_typing) return; @@ -559,7 +542,7 @@ static void entry_delete_cb(GtkTextBuffer *textbuf, int origpos; gint start, end; - g_return_if_fail(gtkaspell->gtkaspeller->checker); + g_return_if_fail(gtkaspell->gtkaspeller->speller); if (!gtkaspell->check_while_typing) return; @@ -636,22 +619,11 @@ static GtkAspeller *gtkaspeller_new(Dictionary *dictionary) g_return_val_if_fail(dictionary, NULL); - if (dictionary->fullname == NULL) + if (dictionary->dictname == NULL) gtkaspell_checkers_error_message( g_strdup(_("No dictionary selected."))); g_return_val_if_fail(dictionary->fullname, NULL); - - if (dictionary->dictname == NULL) { - gchar *tmp; - - tmp = strrchr(dictionary->fullname, G_DIR_SEPARATOR); - - if (tmp == NULL) - dictionary->dictname = dictionary->fullname; - else - dictionary->dictname = tmp + 1; - } dict = dictionary_dup(dictionary); @@ -685,8 +657,8 @@ static GtkAspeller *gtkaspeller_new(Dictionary *dictionary) static GtkAspeller *gtkaspeller_real_new(Dictionary *dict) { GtkAspeller *gtkaspeller; - AspellConfig *config; - AspellCanHaveError *ret; + EnchantBroker *broker; + EnchantDict *speller; g_return_val_if_fail(gtkaspellcheckers, NULL); g_return_val_if_fail(dict, NULL); @@ -694,27 +666,23 @@ static GtkAspeller *gtkaspeller_real_new(Dictionary *dict) gtkaspeller = g_new(GtkAspeller, 1); gtkaspeller->dictionary = dict; - gtkaspeller->sug_mode = ASPELL_FASTMODE; - config = new_aspell_config(); + broker = enchant_broker_init(); - if (!set_dictionary(config, dict)) + if (!broker) { + gtkaspell_checkers_error_message( + g_strdup(_("Couldn't initialize Enchant broker."))); return NULL; - - ret = new_aspell_speller(config); - delete_aspell_config(config); - - if (aspell_error_number(ret) != 0) { - gtkaspellcheckers->error_message - = g_strdup(aspell_error_message(ret)); - - delete_aspell_can_have_error(ret); - + } + if ((speller = set_dictionary(broker, dict)) == NULL) { + gtkaspell_checkers_error_message( + g_strdup_printf(_("Couldn't initialize %s dictionary:"), dict->fullname)); + gtkaspell_checkers_error_message( + g_strdup(enchant_broker_get_error(broker))); return NULL; } - - gtkaspeller->checker = to_aspell_speller(ret); - gtkaspeller->config = aspell_speller_config(gtkaspeller->checker); + gtkaspeller->speller = speller; + gtkaspeller->broker = broker; return gtkaspeller; } @@ -741,11 +709,10 @@ static GtkAspeller *gtkaspeller_delete(GtkAspeller *gtkaspeller) static GtkAspeller *gtkaspeller_real_delete(GtkAspeller *gtkaspeller) { g_return_val_if_fail(gtkaspeller, NULL); - g_return_val_if_fail(gtkaspeller->checker, NULL); + g_return_val_if_fail(gtkaspeller->speller, NULL); - aspell_speller_save_all_word_lists(gtkaspeller->checker); - - delete_aspell_speller(gtkaspeller->checker); + enchant_broker_free_dict(gtkaspeller->broker, gtkaspeller->speller); + enchant_broker_free(gtkaspeller->broker); dictionary_delete(gtkaspeller->dictionary); @@ -760,77 +727,14 @@ static GtkAspeller *gtkaspeller_real_delete(GtkAspeller *gtkaspeller) /*****************************************************************************/ /* Checker configuration */ -static gboolean set_dictionary(AspellConfig *config, Dictionary *dict) +static EnchantDict *set_dictionary(EnchantBroker *broker, Dictionary *dict) { - gchar *language = NULL; - gchar *jargon = NULL; - gchar *size = NULL; - gchar buf[BUFSIZE]; - - g_return_val_if_fail(config, FALSE); + g_return_val_if_fail(broker, FALSE); g_return_val_if_fail(dict, FALSE); - strncpy(buf, dict->fullname, BUFSIZE-1); - buf[BUFSIZE-1] = 0x00; - - buf[dict->dictname - dict->fullname] = 0x00; - - CONFIG_REPLACE_RETURN_FALSE_IF_FAIL("dict-dir", buf); - debug_print("Aspell: looking for dictionaries in path %s.\n", buf); - - strncpy(buf, dict->dictname, BUFSIZE-1); - language = buf; - - if ((size = strrchr(buf, '-')) && isdigit((int) size[1])) - *size++ = 0x00; - else - size = NULL; - - if ((jargon = strchr(language, '-')) != NULL) - *jargon++ = 0x00; - - if (size != NULL && jargon == size) - jargon = NULL; - - debug_print("Aspell: language: %s, jargon: %s, size: %s\n", - language, jargon ? jargon : "", - size ? size : ""); - - if (language) - CONFIG_REPLACE_RETURN_FALSE_IF_FAIL("lang", language); - if (jargon) - CONFIG_REPLACE_RETURN_FALSE_IF_FAIL("jargon", jargon); - if (size) - CONFIG_REPLACE_RETURN_FALSE_IF_FAIL("size", size); - if (dict->encoding) { - gchar *aspell_enc; - - aspell_enc = convert_to_aspell_encoding (dict->encoding); - aspell_config_replace(config, "encoding", - (const char *) aspell_enc); - g_free(aspell_enc); - - RETURN_FALSE_IF_CONFIG_ERROR(); - } - - return TRUE; + return enchant_broker_request_dict(broker, dict->dictname ); } -/* set_sug_mode_cb() - Menu callback: Set the suggestion mode */ -static void set_sug_mode_cb(GtkMenuItem *w, GtkAspell *gtkaspell) -{ - char *themode; - - themode = (char *) gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN((w))))); - themode = g_strdup(themode); - - set_real_sug_mode(gtkaspell, themode); - g_free(themode); - if (gtkaspell->menu_changed_cb) - gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); -} - -/* set_sug_mode_cb() - Menu callback: Set the suggestion mode */ static void set_use_both_cb(GtkMenuItem *w, GtkAspell *gtkaspell) { gtkaspell->use_both_dicts = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); @@ -842,108 +746,50 @@ static void set_use_both_cb(GtkMenuItem *w, GtkAspell *gtkaspell) if (gtkaspell->menu_changed_cb) gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); } - -static void set_real_sug_mode(GtkAspell *gtkaspell, const char *themode) -{ - gint result; - gint mode = ASPELL_FASTMODE; - g_return_if_fail(gtkaspell); - g_return_if_fail(gtkaspell->gtkaspeller); - g_return_if_fail(themode); - - if (!strcmp(themode,_("Normal Mode"))) - mode = ASPELL_NORMALMODE; - else if (!strcmp( themode,_("Bad Spellers Mode"))) - mode = ASPELL_BADSPELLERMODE; - - result = gtkaspell_set_sug_mode(gtkaspell, mode); - - if(!result) { - debug_print("Aspell: error while changing suggestion mode:%s\n", - gtkaspellcheckers->error_message); - gtkaspell_checkers_reset_error(); - } -} -/* gtkaspell_set_sug_mode() - Set the suggestion mode */ -gboolean gtkaspell_set_sug_mode(GtkAspell *gtkaspell, gint themode) -{ - AspellConfig *config; - - g_return_val_if_fail(gtkaspell, FALSE); - g_return_val_if_fail(gtkaspell->gtkaspeller, FALSE); - g_return_val_if_fail(gtkaspell->gtkaspeller->config, FALSE); - - debug_print("Aspell: setting sug mode of gtkaspeller %p to %d\n", - gtkaspell->gtkaspeller, themode); - - config = gtkaspell->gtkaspeller->config; - - switch (themode) { - case ASPELL_FASTMODE: - CONFIG_REPLACE_RETURN_FALSE_IF_FAIL("sug-mode", "fast"); - break; - case ASPELL_NORMALMODE: - CONFIG_REPLACE_RETURN_FALSE_IF_FAIL("sug-mode", "normal"); - break; - case ASPELL_BADSPELLERMODE: - CONFIG_REPLACE_RETURN_FALSE_IF_FAIL("sug-mode", - "bad-spellers"); - break; - default: - gtkaspellcheckers->error_message = - g_strdup(_("Unknown suggestion mode.")); - return FALSE; - } - - gtkaspell->gtkaspeller->sug_mode = themode; - gtkaspell->default_sug_mode = themode; - - return TRUE; -} - /* misspelled_suggest() - Create a suggestion list for word */ static GList *misspelled_suggest(GtkAspell *gtkaspell, gchar *word) { - const guchar *newword; GList *list = NULL; - const AspellWordList *suggestions; - AspellStringEnumeration *elements; - + char **suggestions; + size_t num_sug, i; g_return_val_if_fail(word, NULL); - if (!aspell_speller_check(gtkaspell->gtkaspeller->checker, word, -1)) { - free_suggestions_list(gtkaspell); - - suggestions = aspell_speller_suggest( - gtkaspell->gtkaspeller->checker, - (const char *)word, -1); - elements = aspell_word_list_elements(suggestions); - list = g_list_append(list, g_strdup(word)); - - while ((newword = (guchar *)aspell_string_enumeration_next(elements)) != NULL) - list = g_list_append(list, g_strdup((gchar *)newword)); + if (*word == 0) + return NULL; - gtkaspell->max_sug = g_list_length(list) - 1; - gtkaspell->suggestions_list = list; + free_suggestions_list(gtkaspell); - return list; + suggestions = enchant_dict_suggest(gtkaspell->gtkaspeller->speller, word, strlen(word), &num_sug); + if (suggestions == NULL || num_sug == 0) { + gtkaspell->max_sug = - 1; + gtkaspell->suggestions_list = NULL; + return NULL; } + list = g_list_append(list, g_strdup(word)); + for (i = 0; i < num_sug; i++) + list = g_list_append(list, g_strdup((gchar *)suggestions[i])); - free_suggestions_list(gtkaspell); - - return NULL; + gtkaspell->max_sug = num_sug - 1; + gtkaspell->suggestions_list = list; + enchant_dict_free_string_list(gtkaspell->gtkaspeller->speller, suggestions); + return list; } /* misspelled_test() - Just test if word is correctly spelled */ -static int misspelled_test(GtkAspell *gtkaspell, unsigned char *word) +static int misspelled_test(GtkAspell *gtkaspell, char *word) { - gint result = aspell_speller_check(gtkaspell->gtkaspeller->checker, (char *)word, -1) - ? 0 : 1; + gint result = 0; + g_return_val_if_fail(word, 0); + + if (*word == 0) + return 0; + + result = enchant_dict_check(gtkaspell->gtkaspeller->speller, word, strlen(word)); + if (result && gtkaspell->use_both_dicts && gtkaspell->alternate_speller) { use_alternate_dict(gtkaspell); - result = aspell_speller_check(gtkaspell->gtkaspeller->checker, (char *)word, -1) - ? 0 : 1; + result = enchant_dict_check(gtkaspell->gtkaspeller->speller, word, strlen(word)); use_alternate_dict(gtkaspell); } return result; @@ -967,16 +813,7 @@ static gunichar get_text_index_whar(GtkAspell *gtkaspell, int pos) gtk_text_buffer_get_iter_at_offset(buffer, &end, pos+1); utf8chars = gtk_text_iter_get_text(&start, &end); - if (is_ascii_str(utf8chars)) { - a = utf8chars ? (gunichar)utf8chars[0] : '\0' ; - } else { - gchar *tr = conv_iconv_strdup(utf8chars, CS_UTF_8, - gtkaspell->gtkaspeller->dictionary->encoding); - if (tr) { - a = g_utf8_get_char(tr); - g_free(tr); - } - } + a = g_utf8_get_char(utf8chars); g_free(utf8chars); return a; @@ -985,7 +822,7 @@ static gunichar get_text_index_whar(GtkAspell *gtkaspell, int pos) /* get_word_from_pos () - return the word pointed to. */ /* Handles correctly the quotes. */ static gboolean get_word_from_pos(GtkAspell *gtkaspell, gint pos, - unsigned char* buf, gint buflen, + char* buf, gint buflen, gint *pstart, gint *pend) { @@ -1065,17 +902,14 @@ static gboolean get_word_from_pos(GtkAspell *gtkaspell, gint pos, if (buf) { if (end - start < buflen) { GtkTextIter iterstart, iterend; - gchar *tmp, *conv; + gchar *tmp; GtkTextBuffer *buffer = gtk_text_view_get_buffer(gtktext); gtk_text_buffer_get_iter_at_offset(buffer, &iterstart, start); gtk_text_buffer_get_iter_at_offset(buffer, &iterend, end); tmp = gtk_text_buffer_get_text(buffer, &iterstart, &iterend, FALSE); - conv = conv_iconv_strdup(tmp, CS_UTF_8, - gtkaspell->gtkaspeller->dictionary->encoding); - g_free(tmp); - strncpy((char *)buf, conv, buflen-1); + strncpy(buf, tmp, buflen-1); buf[buflen-1]='\0'; - g_free(conv); + g_free(tmp); } else return FALSE; } @@ -1086,7 +920,7 @@ static gboolean get_word_from_pos(GtkAspell *gtkaspell, gint pos, static gboolean check_at(GtkAspell *gtkaspell, gint from_pos) { gint start, end; - unsigned char buf[GTKASPELLWORDSIZE]; + char buf[GTKASPELLWORDSIZE]; GtkTextView *gtktext; g_return_val_if_fail(from_pos >= 0, FALSE); @@ -1098,7 +932,7 @@ static gboolean check_at(GtkAspell *gtkaspell, gint from_pos) return FALSE; if (misspelled_test(gtkaspell, buf) - && strcasecmp((char *)buf, "sylpheed") && strcasecmp((char *)buf, "claws-mail")) { + && strcasecmp(buf, "sylpheed") && strcasecmp(buf, "claws-mail")) { strncpy(gtkaspell->theword, (gchar *)buf, GTKASPELLWORDSIZE - 1); gtkaspell->theword[GTKASPELLWORDSIZE - 1] = 0; gtkaspell->start_pos = start; @@ -1260,7 +1094,7 @@ void gtkaspell_highlight_all(GtkAspell *gtkaspell) guint len; GtkTextView *gtktext; - g_return_if_fail(gtkaspell->gtkaspeller->checker); + g_return_if_fail(gtkaspell->gtkaspeller->speller); gtktext = gtkaspell->gtktext; @@ -1283,21 +1117,20 @@ void gtkaspell_highlight_all(GtkAspell *gtkaspell) static void replace_with_supplied_word_cb(GtkWidget *w, GtkAspell *gtkaspell) { - unsigned char *newword; + char *newword; GdkEvent *e= (GdkEvent *) gtk_get_current_event(); - newword = (unsigned char *)gtk_editable_get_chars(GTK_EDITABLE(gtkaspell->replace_entry), + newword = gtk_editable_get_chars(GTK_EDITABLE(gtkaspell->replace_entry), 0, -1); - if (strcmp((char *)newword, gtkaspell->theword)) { - replace_real_word(gtkaspell, (char *)newword); + if (strcmp(newword, gtkaspell->theword)) { + replace_real_word(gtkaspell, newword); if ((e->type == GDK_KEY_PRESS && ((GdkEventKey *) e)->state & GDK_CONTROL_MASK)) { - aspell_speller_store_replacement( - gtkaspell->gtkaspeller->checker, - gtkaspell->theword, -1, - (char *)newword, -1); + enchant_dict_store_replacement(gtkaspell->gtkaspeller->speller, + gtkaspell->theword, strlen(gtkaspell->theword), + newword, strlen(newword)); } gtkaspell->replace_entry = NULL; } @@ -1314,32 +1147,29 @@ static void replace_with_supplied_word_cb(GtkWidget *w, GtkAspell *gtkaspell) static void replace_word_cb(GtkWidget *w, gpointer data) { - unsigned char *newword; + const char *newword; GtkAspell *gtkaspell = (GtkAspell *) data; GdkEvent *e= (GdkEvent *) gtk_get_current_event(); - newword = (unsigned char *) gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN((w))))); - newword = (unsigned char *)g_strdup((char *)newword); + newword = gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN((w))))); - replace_real_word(gtkaspell, (char *)newword); + replace_real_word(gtkaspell, newword); if ((e->type == GDK_KEY_PRESS && ((GdkEventKey *) e)->state & GDK_CONTROL_MASK) || (e->type == GDK_BUTTON_RELEASE && ((GdkEventButton *) e)->state & GDK_CONTROL_MASK)) { - aspell_speller_store_replacement( - gtkaspell->gtkaspeller->checker, - gtkaspell->theword, -1, - (char *)newword, -1); + enchant_dict_store_replacement(gtkaspell->gtkaspeller->speller, + gtkaspell->theword, strlen(gtkaspell->theword), + newword, strlen(newword)); } gtk_menu_shell_deactivate(GTK_MENU_SHELL(w->parent)); set_point_continue(gtkaspell); - g_free(newword); } -static void replace_real_word(GtkAspell *gtkaspell, gchar *newword) +static void replace_real_word(GtkAspell *gtkaspell, const gchar *newword) { int oldlen, newlen, wordlen; gint origpos; @@ -1423,9 +1253,7 @@ static void add_word_to_session_cb(GtkWidget *w, gpointer data) pos = get_textview_buffer_offset(gtktext); - aspell_speller_add_to_session(gtkaspell->gtkaspeller->checker, - gtkaspell->theword, - strlen(gtkaspell->theword)); + enchant_dict_add_to_session(gtkaspell->gtkaspeller->speller, gtkaspell->theword, strlen(gtkaspell->theword)); check_at(gtkaspell, gtkaspell->start_pos); @@ -1439,9 +1267,7 @@ static void add_word_to_personal_cb(GtkWidget *w, gpointer data) { GtkAspell *gtkaspell = (GtkAspell *) data; - aspell_speller_add_to_personal(gtkaspell->gtkaspeller->checker, - gtkaspell->theword, - strlen(gtkaspell->theword)); + enchant_dict_add_to_pwl(gtkaspell->gtkaspeller->speller, gtkaspell->theword, strlen(gtkaspell->theword)); check_at(gtkaspell, gtkaspell->start_pos); @@ -1546,9 +1372,7 @@ static void replace_with_create_dialog_cb(GtkWidget *w, gpointer data) gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); - utf8buf = conv_codeset_strdup(gtkaspell->theword, - conv_get_locale_charset_str(), - CS_UTF_8); + utf8buf = g_strdup(gtkaspell->theword); thelabel = g_strdup_printf(_("Replace \"%s\" with: "), @@ -1667,21 +1491,38 @@ static GSList *create_empty_dictionary_list(void) dict = g_new0(Dictionary, 1); dict->fullname = g_strdup(_("None")); - dict->dictname = dict->fullname; - dict->encoding = NULL; + dict->dictname = NULL; return g_slist_append(list, dict); } +static void list_dict_cb(const char * const lang_tag, + const char * const provider_name, + const char * const provider_desc, + const char * const provider_file, + void * data) +{ + GSList **list = (GSList **)data; + Dictionary *dict = g_new0(Dictionary, 1); + dict->fullname = g_strdup(lang_tag); + dict->dictname = g_strdup(lang_tag); + + if (g_slist_find_custom(*list, dict, + (GCompareFunc) compare_dict) == NULL) { + debug_print("Aspell: found dictionary %s %s\n", dict->fullname, + dict->dictname); + *list = g_slist_insert_sorted(*list, dict, + (GCompareFunc) compare_dict); + } else { + dictionary_delete(dict); + } +} + /* gtkaspell_get_dictionary_list() - returns list of dictionary names */ -static GSList *gtkaspell_get_dictionary_list(const gchar *aspell_path, gint refresh) +static GSList *gtkaspell_get_dictionary_list(gint refresh) { GSList *list; - Dictionary *dict; - AspellConfig *config; - AspellDictInfoList *dlist; - AspellDictInfoEnumeration *dels; - const AspellDictInfo *entry; + EnchantBroker *broker; if (!gtkaspellcheckers) gtkaspell_checkers_init(); @@ -1693,46 +1534,13 @@ static GSList *gtkaspell_get_dictionary_list(const gchar *aspell_path, gint refr gtkaspellcheckers->dictionary_list); list = NULL; - config = new_aspell_config(); + broker = enchant_broker_init(); - aspell_config_replace(config, "dict-dir", aspell_path); - if (aspell_config_error_number(config) != 0) { - gtkaspellcheckers->error_message = g_strdup( - aspell_config_error_message(config)); - gtkaspellcheckers->dictionary_list = - create_empty_dictionary_list(); + enchant_broker_list_dicts(broker, list_dict_cb, &list); - return gtkaspellcheckers->dictionary_list; - } + enchant_broker_free(broker); - dlist = get_aspell_dict_info_list(config); - delete_aspell_config(config); - - debug_print("Aspell: checking for dictionaries in %s\n", aspell_path?aspell_path:"(null)"); - dels = aspell_dict_info_list_elements(dlist); - while ( (entry = aspell_dict_info_enumeration_next(dels)) != 0) - { - dict = g_new0(Dictionary, 1); - dict->fullname = g_strdup_printf("%s%s", aspell_path, - entry->name); - dict->dictname = dict->fullname + strlen(aspell_path); - dict->encoding = g_strdup(entry->code); - - if (g_slist_find_custom(list, dict, - (GCompareFunc) compare_dict) != NULL) { - dictionary_delete(dict); - continue; - } - - debug_print("Aspell: found dictionary %s %s %s\n", dict->fullname, - dict->dictname, dict->encoding); - list = g_slist_insert_sorted(list, dict, - (GCompareFunc) compare_dict); - } - - delete_aspell_dict_info_enumeration(dels); - - if(list==NULL){ + if (list == NULL){ debug_print("Aspell: error when searching for dictionaries: " "No dictionary found.\n"); @@ -1756,15 +1564,14 @@ static void gtkaspell_free_dictionary_list(GSList *list) g_slist_free(list); } -GtkTreeModel *gtkaspell_dictionary_store_new_with_refresh(const gchar *aspell_path, - gboolean refresh) +GtkTreeModel *gtkaspell_dictionary_store_new_with_refresh(gboolean refresh) { GSList *dict_list, *tmp; GtkListStore *store; GtkTreeIter iter; Dictionary *dict; - dict_list = gtkaspell_get_dictionary_list(aspell_path, refresh); + dict_list = gtkaspell_get_dictionary_list(refresh); g_return_val_if_fail(dict_list, NULL); store = gtk_list_store_new(SET_GTKASPELL_SIZE, @@ -1785,20 +1592,19 @@ GtkTreeModel *gtkaspell_dictionary_store_new_with_refresh(const gchar *aspell_pa return GTK_TREE_MODEL(store); } -GtkTreeModel *gtkaspell_dictionary_store_new(const gchar *aspell_path) +GtkTreeModel *gtkaspell_dictionary_store_new(void) { return gtkaspell_dictionary_store_new_with_refresh - (aspell_path, TRUE); + (TRUE); } -GtkWidget *gtkaspell_dictionary_combo_new(const gchar *aspell_path, - const gboolean refresh) +GtkWidget *gtkaspell_dictionary_combo_new(const gboolean refresh) { GtkWidget *combo; GtkCellRenderer *renderer; combo = gtk_combo_box_new_with_model( - gtkaspell_dictionary_store_new_with_refresh(aspell_path, refresh)); + gtkaspell_dictionary_store_new_with_refresh(refresh)); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); gtk_widget_show(combo); @@ -1864,25 +1670,6 @@ gint gtkaspell_set_dictionary_menu_active_item(GtkComboBox *combo, return 0; } -GtkWidget *gtkaspell_sugmode_combo_new(gint sugmode) -{ - GtkWidget *combo = gtkut_sc_combobox_create(NULL, FALSE); - GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model( - GTK_COMBO_BOX(combo))); - GtkTreeIter iter; - - g_return_val_if_fail(store != NULL, NULL); - - COMBOBOX_ADD(store, _("Fast Mode"), ASPELL_FASTMODE); - COMBOBOX_ADD(store, _("Normal Mode"), ASPELL_NORMALMODE); - COMBOBOX_ADD(store, _("Bad Spellers Mode"), ASPELL_BADSPELLERMODE); - - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), sugmode - 1); - gtk_widget_show(combo); - - return combo; -} - static void use_alternate_dict(GtkAspell *gtkaspell) { GtkAspeller *tmp; @@ -1932,6 +1719,9 @@ static GSList *make_sug_menu(GtkAspell *gtkaspell) GSList *list = NULL; gtktext = gtkaspell->gtktext; + if (l == NULL) + return NULL; + accel = gtk_accel_group_new(); if (gtkaspell->accel_group) { @@ -1940,9 +1730,7 @@ static GSList *make_sug_menu(GtkAspell *gtkaspell) gtkaspell->accel_group = NULL; } - utf8buf = conv_codeset_strdup((char*)l->data, - conv_get_locale_charset_str(), - CS_UTF_8); + utf8buf = g_strdup(l->data); caption = g_strdup_printf(_("\"%s\" unknown in %s"), utf8buf, gtkaspell->gtkaspeller->dictionary->dictname); @@ -2035,9 +1823,8 @@ static GSList *make_sug_menu(GtkAspell *gtkaspell) curmenu); } - utf8buf = conv_codeset_strdup((char*)l->data, - conv_get_locale_charset_str(), - CS_UTF_8); + utf8buf = g_strdup(l->data); + item = gtk_menu_item_new_with_label(utf8buf); g_free(utf8buf); gtk_widget_show(item); @@ -2125,46 +1912,6 @@ static GSList *populate_submenu(GtkAspell *gtkaspell) gtk_widget_show(item); list = g_slist_append(list, item); - item = gtk_check_menu_item_new_with_label(_("Fast Mode")); - gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), TRUE); - if (gtkaspell->gtkaspeller->sug_mode == ASPELL_FASTMODE) { - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(item),FALSE); - } else - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(set_sug_mode_cb), - gtkaspell); - gtk_widget_show(item); - list = g_slist_append(list, item); - - item = gtk_check_menu_item_new_with_label(_("Normal Mode")); - gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), TRUE); - if (gtkaspell->gtkaspeller->sug_mode == ASPELL_NORMALMODE) { - gtk_widget_set_sensitive(GTK_WIDGET(item), FALSE); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); - } else - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(set_sug_mode_cb), - gtkaspell); - gtk_widget_show(item); - list = g_slist_append(list, item); - - item = gtk_check_menu_item_new_with_label(_("Bad Spellers Mode")); - gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), TRUE); - if (gtkaspell->gtkaspeller->sug_mode == ASPELL_BADSPELLERMODE) { - gtk_widget_set_sensitive(GTK_WIDGET(item), FALSE); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); - } else - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(set_sug_mode_cb), - gtkaspell); - gtk_widget_show(item); - list = g_slist_append(list, item); - - item = gtk_menu_item_new(); - gtk_widget_show(item); - list = g_slist_append(list, item); - item = gtk_check_menu_item_new_with_label(_("Check while typing")); if (gtkaspell->check_while_typing) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); @@ -2188,7 +1935,7 @@ static GSList *populate_submenu(GtkAspell *gtkaspell) /* Dict list */ if (gtkaspellcheckers->dictionary_list == NULL) - gtkaspell_get_dictionary_list(gtkaspell->dictionary_path, FALSE); + gtkaspell_get_dictionary_list(FALSE); { GtkWidget * curmenu = submenu; int count = 0; @@ -2294,16 +2041,19 @@ gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary, { Dictionary *dict; GtkAspeller *gtkaspeller; - gint sug_mode; g_return_val_if_fail(gtkaspell, FALSE); g_return_val_if_fail(dictionary, FALSE); - sug_mode = gtkaspell->default_sug_mode; - dict = g_new0(Dictionary, 1); - dict->fullname = g_strdup(dictionary); - dict->encoding = g_strdup(gtkaspell->gtkaspeller->dictionary->encoding); + + if (strrchr(dictionary, '/')) { + dict->fullname = g_strdup(strrchr(dictionary, '/')+1); + dict->dictname = g_strdup(strrchr(dictionary, '/')+1); + } else { + dict->fullname = g_strdup(dictionary); + dict->dictname = g_strdup(dictionary); + } gtkaspeller = gtkaspeller_new(dict); @@ -2326,7 +2076,6 @@ gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary, gtkaspeller_delete(gtkaspell->gtkaspeller); gtkaspell->gtkaspeller = gtkaspeller; - gtkaspell_set_sug_mode(gtkaspell, sug_mode); } dictionary_delete(dict); @@ -2344,8 +2093,13 @@ gboolean gtkaspell_change_alt_dict(GtkAspell *gtkaspell, const gchar *alt_dictio g_return_val_if_fail(alt_dictionary, FALSE); dict = g_new0(Dictionary, 1); - dict->fullname = g_strdup(alt_dictionary); - dict->encoding = g_strdup(gtkaspell->gtkaspeller->dictionary->encoding); + if (strrchr(alt_dictionary, '/')) { + dict->fullname = g_strdup(strrchr(alt_dictionary, '/')+1); + dict->dictname = g_strdup(strrchr(alt_dictionary, '/')+1); + } else { + dict->fullname = g_strdup(alt_dictionary); + dict->dictname = g_strdup(alt_dictionary); + } gtkaspeller = gtkaspeller_new(dict); @@ -2459,27 +2213,6 @@ static void change_color(GtkAspell * gtkaspell, } } -/* convert_to_aspell_encoding () - converts ISO-8859-* strings to iso8859-* - * as needed by aspell. Returns an allocated string. - */ - -static gchar *convert_to_aspell_encoding (const gchar *encoding) -{ - gchar * aspell_encoding; - - if (strstr2(encoding, "ISO-8859-")) { - aspell_encoding = g_strdup_printf("iso8859%s", encoding+8); - } - else { - if (!strcmp2(encoding, "US-ASCII")) - aspell_encoding = g_strdup("iso8859-1"); - else - aspell_encoding = g_strdup(encoding); - } - - return aspell_encoding; -} - /* compare_dict () - compare 2 dict names */ static gint compare_dict(Dictionary *a, Dictionary *b) { @@ -2507,7 +2240,7 @@ static gint compare_dict(Dictionary *a, Dictionary *b) static void dictionary_delete(Dictionary *dict) { g_free(dict->fullname); - g_free(dict->encoding); + g_free(dict->dictname); g_free(dict); } @@ -2518,8 +2251,7 @@ static Dictionary *dictionary_dup(const Dictionary *dict) dict2 = g_new(Dictionary, 1); dict2->fullname = g_strdup(dict->fullname); - dict2->dictname = dict->dictname - dict->fullname + dict2->fullname; - dict2->encoding = g_strdup(dict->encoding); + dict2->dictname = g_strdup(dict->dictname); return dict2; } @@ -2562,10 +2294,8 @@ static gint find_gtkaspeller(gconstpointer aa, gconstpointer bb) Dictionary *a = ((GtkAspeller *) aa)->dictionary; Dictionary *b = ((GtkAspeller *) bb)->dictionary; - if (a && b && a->fullname && b->fullname && - strcmp(a->fullname, b->fullname) == 0 && - a->encoding && b->encoding) - return strcmp(a->encoding, b->encoding); + if (a && b && a->fullname && b->fullname) + return strcmp(a->fullname, b->fullname); return 1; } diff --git a/src/gtk/gtkaspell.h b/src/gtk/gtkaspell.h index 20dce2607..419e48812 100644 --- a/src/gtk/gtkaspell.h +++ b/src/gtk/gtkaspell.h @@ -28,14 +28,14 @@ * */ -#ifndef __GTKASPELL_H__ -#define __GTKASPELL_H__ +#ifndef __GTKENCHANT_H__ +#define __GTKENCHANT_H__ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#ifdef USE_ASPELL +#ifdef USE_ENCHANT #include @@ -49,8 +49,7 @@ const char * gtkaspell_checkers_strerror (void); void gtkaspell_checkers_reset_error (void); -GtkAspell* gtkaspell_new (const gchar *dictionary_path, - const gchar *dictionary, +GtkAspell* gtkaspell_new (const gchar *dictionary, const gchar *alt_dictionary, const gchar *encoding, gint misspelled_color, @@ -74,22 +73,17 @@ gboolean gtkaspell_change_alt_dict (GtkAspell *gtkaspell, const gchar* alt_dictionary); -gboolean gtkaspell_set_sug_mode (GtkAspell *gtkaspell, - gint themode); - void gtkaspell_check_forwards_go (GtkAspell *gtkaspell); void gtkaspell_check_backwards (GtkAspell *gtkaspell); void gtkaspell_check_all (GtkAspell *gtkaspell); void gtkaspell_highlight_all (GtkAspell *gtkaspell); -GtkWidget* gtkaspell_dictionary_combo_new (const gchar *aspell_path, - const gboolean refresh); +GtkWidget* gtkaspell_dictionary_combo_new (const gboolean refresh); -GtkTreeModel* gtkaspell_dictionary_store_new (const gchar *aspell_path); +GtkTreeModel* gtkaspell_dictionary_store_new (void); GtkTreeModel* gtkaspell_dictionary_store_new_with_refresh - (const gchar *aspell_path, - gboolean refresh); + (gboolean refresh); gchar* gtkaspell_get_dictionary_menu_active_item (GtkComboBox *combo); @@ -97,11 +91,9 @@ gint gtkaspell_set_dictionary_menu_active_item (GtkComboBox *combo, const gchar *dictionary); -GtkWidget* gtkaspell_sugmode_combo_new (gint sugmode); - GSList* gtkaspell_make_config_menu (GtkAspell *gtkaspell); gchar *gtkaspell_get_default_dictionary(GtkAspell *gtkaspell); -#endif /* USE_ASPELL */ -#endif /* __GTKASPELL_H__ */ +#endif /* USE_ENCHANT */ +#endif /* __GTKENCHANT_H__ */ diff --git a/src/main.c b/src/main.c index 4685bdd96..cfccbf495 100644 --- a/src/main.c +++ b/src/main.c @@ -862,7 +862,7 @@ static void main_dump_features_list(gboolean show_debug_only) else g_print(" compface\n"); #endif -#if USE_ASPELL +#if USE_ENCHANT if (show_debug_only) debug_print(" aspell\n"); else @@ -974,7 +974,7 @@ static void dbus_update(FolderItem *removed_item) "claws-mail", G_TYPE_INVALID, G_TYPE_INVALID); } if (error) { - debug_print(error->message); + debug_print("%s", error->message); g_error_free(error); } } @@ -1052,7 +1052,8 @@ int main(int argc, char *argv[]) gboolean asked_for_migration = FALSE; gboolean start_done = TRUE; GtkUIManager *gui_manager = NULL; - + GSList *plug_list = NULL; + START_TIMING("startup"); sc_starting = TRUE; @@ -1313,7 +1314,7 @@ int main(int argc, char *argv[]) prefs_receive_init(); prefs_send_init(); tags_read_tags(); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT gtkaspell_checkers_init(); prefs_spelling_init(); #endif @@ -1504,12 +1505,32 @@ int main(int argc, char *argv[]) prefs_matcher_read_config(); } - if (plugin_get_unloaded_list() != NULL) { + if ((plug_list = plugin_get_unloaded_list()) != NULL) { + GSList *cur; + gchar *list = NULL; + gint num_plugins = 0; + for (cur = plug_list; cur; cur = cur->next) { + Plugin *plugin = (Plugin *)cur->data; + gchar *tmp = g_strdup_printf("%s\n%s", + list? list:"", + plugin_get_name(plugin)); + g_free(list); + list = tmp; + num_plugins++; + } main_window_cursor_normal(mainwin); - alertpanel_warning(_("Some plugin(s) failed to load. " + alertpanel_warning(ngettext( + "The following plugin failed to load. " + "Check the Plugins configuration " + "for more information:\n%s", + "The following plugins failed to load. " "Check the Plugins configuration " - "for more information.")); + "for more information:\n%s", + num_plugins), + list); main_window_cursor_wait(mainwin); + g_free(list); + g_slist_free(plug_list); } plugin_load_standard_plugins (); @@ -1758,7 +1779,7 @@ static void exit_claws(MainWindow *mainwin) prefs_logging_done(); prefs_send_done(); tags_write_tags(); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT prefs_spelling_done(); gtkaspell_checkers_quit(); #endif diff --git a/src/plugins/bogofilter/Makefile.am b/src/plugins/bogofilter/Makefile.am index 32e209243..85609fa0a 100644 --- a/src/plugins/bogofilter/Makefile.am +++ b/src/plugins/bogofilter/Makefile.am @@ -25,7 +25,7 @@ INCLUDES = \ -I$(top_srcdir)/src/gtk AM_CPPFLAGS = \ - $(ASPELL_CFLAGS) \ + $(ENCHANT_CFLAGS) \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(OPENSSL_CFLAGS) \ diff --git a/src/plugins/dillo_viewer/Makefile.am b/src/plugins/dillo_viewer/Makefile.am index 9629a1eea..3153235ff 100644 --- a/src/plugins/dillo_viewer/Makefile.am +++ b/src/plugins/dillo_viewer/Makefile.am @@ -24,7 +24,7 @@ INCLUDES = \ -I$(top_srcdir)/src/gtk AM_CPPFLAGS = \ - $(ASPELL_CFLAGS) \ + $(ENCHANT_CFLAGS) \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(OPENSSL_CFLAGS) \ diff --git a/src/plugins/spamassassin/Makefile.am b/src/plugins/spamassassin/Makefile.am index 335f73210..59a0aece7 100644 --- a/src/plugins/spamassassin/Makefile.am +++ b/src/plugins/spamassassin/Makefile.am @@ -27,7 +27,7 @@ INCLUDES = \ -I$(top_srcdir)/src/gtk AM_CPPFLAGS = \ - $(ASPELL_CFLAGS) \ + $(ENCHANT_CFLAGS) \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(OPENSSL_CFLAGS) \ diff --git a/src/plugins/trayicon/Makefile.am b/src/plugins/trayicon/Makefile.am index 76201cab0..927f0c2b8 100644 --- a/src/plugins/trayicon/Makefile.am +++ b/src/plugins/trayicon/Makefile.am @@ -33,7 +33,7 @@ INCLUDES = \ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ - $(ASPELL_CFLAGS) \ + $(ENCHANT_CFLAGS) \ $(OPENSSL_CFLAGS) \ $(MAEMO_CFLAGS) diff --git a/src/prefs_account.c b/src/prefs_account.c index 742eda8f4..25a01ba49 100644 --- a/src/prefs_account.c +++ b/src/prefs_account.c @@ -189,7 +189,7 @@ typedef struct ComposePage GtkWidget *autobcc_entry; GtkWidget *autoreplyto_checkbtn; GtkWidget *autoreplyto_entry; -#if USE_ASPELL +#if USE_ENCHANT GtkWidget *checkbtn_enable_default_dictionary; GtkWidget *combo_default_dictionary; GtkWidget *checkbtn_enable_default_alt_dictionary; @@ -357,7 +357,7 @@ static void prefs_account_mailcmd_toggled(GtkToggleButton *button, static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button, gpointer user_data); -#if USE_ASPELL +#if USE_ENCHANT static void prefs_account_compose_default_dictionary_set_string_from_optmenu (PrefParam *pparam); static void prefs_account_compose_default_dictionary_set_optmenu_from_string @@ -568,7 +568,7 @@ static PrefParam compose_param[] = { &compose_page.autoreplyto_entry, prefs_set_data_from_entry, prefs_set_entry}, -#if USE_ASPELL +#if USE_ENCHANT {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL, &compose_page.checkbtn_enable_default_dictionary, prefs_set_data_from_toggle, prefs_set_toggle}, @@ -1864,7 +1864,7 @@ static void compose_create_widget_func(PrefsPage * _page, GtkWidget *autobcc_entry; GtkWidget *autoreplyto_checkbtn; GtkWidget *autoreplyto_entry; -#if USE_ASPELL +#if USE_ENCHANT GtkWidget *frame_dict; GtkWidget *table_dict; GtkWidget *checkbtn_enable_default_dictionary = NULL; @@ -1991,7 +1991,7 @@ static void compose_create_widget_func(PrefsPage * _page, SET_TOGGLE_SENSITIVITY (autoreplyto_checkbtn, autoreplyto_entry); -#if USE_ASPELL +#if USE_ENCHANT PACK_FRAME (vbox1, frame_dict, _("Spell check dictionaries")); table_dict = gtk_table_new (2, 2, FALSE); @@ -2008,8 +2008,7 @@ static void compose_create_widget_func(PrefsPage * _page, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary), tmp_ac_prefs.enable_default_dictionary); - combo_default_dictionary = gtkaspell_dictionary_combo_new( - prefs_common.aspell_path, TRUE); + combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE); gtk_table_attach(GTK_TABLE(table_dict), combo_default_dictionary, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); @@ -2022,8 +2021,7 @@ static void compose_create_widget_func(PrefsPage * _page, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary), tmp_ac_prefs.enable_default_alt_dictionary); - combo_default_alt_dictionary = gtkaspell_dictionary_combo_new( - prefs_common.aspell_path, FALSE); + combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(FALSE); gtk_table_attach(GTK_TABLE(table_dict), combo_default_alt_dictionary, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); @@ -2043,21 +2041,21 @@ static void compose_create_widget_func(PrefsPage * _page, page->autobcc_entry = autobcc_entry; page->autoreplyto_checkbtn = autoreplyto_checkbtn; page->autoreplyto_entry = autoreplyto_entry; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary; page->combo_default_dictionary = combo_default_dictionary; page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary; page->combo_default_alt_dictionary = combo_default_alt_dictionary; #endif -#ifdef USE_ASPELL +#ifdef USE_ENCHANT /* reset gtkaspell menus */ if (compose_page.combo_default_dictionary != NULL) { gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_dictionary), - gtkaspell_dictionary_store_new(prefs_common.aspell_path)); + gtkaspell_dictionary_store_new()); gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_alt_dictionary), gtkaspell_dictionary_store_new_with_refresh( - prefs_common.aspell_path, FALSE)); + FALSE)); } #endif @@ -4508,7 +4506,7 @@ static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button, gtk_widget_set_sensitive(receive_page.filterhook_on_recv_checkbtn, do_filter); } -#if USE_ASPELL +#if USE_ENCHANT static void prefs_account_compose_default_dictionary_set_string_from_optmenu (PrefParam *pparam) { @@ -4536,6 +4534,10 @@ static void prefs_account_compose_default_dictionary_set_optmenu_from_string if (dictionary == NULL) return; + if (strrchr(dictionary, '/')) { + dictionary = g_strdup(strrchr(dictionary, '/')+1); + } + combo = *pparam->widget; if (dictionary) gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(combo), diff --git a/src/prefs_common.c b/src/prefs_common.c index eb8a5890f..d9c859e98 100644 --- a/src/prefs_common.c +++ b/src/prefs_common.c @@ -245,17 +245,13 @@ static PrefParam param[] = { P_BOOL, NULL, NULL, NULL}, {"autosave_length", "50", &prefs_common.autosave_length, P_INT, NULL, NULL, NULL}, -#if USE_ASPELL +#if USE_ENCHANT {"enable_aspell", "TRUE", &prefs_common.enable_aspell, P_BOOL, NULL, NULL, NULL}, - {"aspell_path", ASPELL_PATH, &prefs_common.aspell_path, P_STRING, - NULL, NULL, NULL}, {"dictionary", "", &prefs_common.dictionary, P_STRING, NULL, NULL, NULL}, {"alt_dictionary", "", &prefs_common.alt_dictionary, P_STRING, NULL, NULL, NULL}, - {"aspell_sugmode", "1", &prefs_common.aspell_sugmode, P_INT, - NULL, NULL, NULL}, {"use_alternate_dict", "FALSE", &prefs_common.use_alternate, P_BOOL, NULL, NULL, NULL}, {"check_while_typing", "TRUE", &prefs_common.check_while_typing, P_BOOL, diff --git a/src/prefs_common.h b/src/prefs_common.h index d607ab767..8387d7589 100644 --- a/src/prefs_common.h +++ b/src/prefs_common.h @@ -166,13 +166,11 @@ struct _PrefsCommon gboolean block_cursor; gchar *quote_chars; -#if USE_ASPELL +#if USE_ENCHANT gboolean enable_aspell; - gchar *aspell_path; gchar *dictionary; gchar *alt_dictionary; gulong misspelled_col; - gint aspell_sugmode; gboolean check_while_typing; gboolean recheck_when_changing_dict; gboolean use_alternate; diff --git a/src/prefs_folder_item.c b/src/prefs_folder_item.c index 3586d50da..5d66a8935 100644 --- a/src/prefs_folder_item.c +++ b/src/prefs_folder_item.c @@ -50,7 +50,7 @@ #include "quote_fmt.h" #include "combobox.h" -#if USE_ASPELL +#if USE_ENCHANT #include "gtkaspell.h" #endif @@ -122,7 +122,7 @@ struct _FolderItemComposePage GtkWidget *entry_default_reply_to; GtkWidget *checkbtn_enable_default_account; GtkWidget *optmenu_default_account; -#if USE_ASPELL +#if USE_ENCHANT GtkWidget *checkbtn_enable_default_dictionary; GtkWidget *checkbtn_enable_default_alt_dictionary; GtkWidget *combo_default_dictionary; @@ -135,7 +135,7 @@ struct _FolderItemComposePage GtkWidget *default_to_rec_checkbtn; GtkWidget *default_reply_to_rec_checkbtn; GtkWidget *default_account_rec_checkbtn; -#if USE_ASPELL +#if USE_ENCHANT GtkWidget *default_dictionary_rec_checkbtn; GtkWidget *default_alt_dictionary_rec_checkbtn; #endif @@ -744,7 +744,7 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, GtkWidget *optmenu_default_account = NULL; GtkListStore *optmenu_default_account_menu = NULL; GtkTreeIter iter; -#if USE_ASPELL +#if USE_ENCHANT GtkWidget *checkbtn_enable_default_dictionary = NULL; GtkWidget *combo_default_dictionary = NULL; GtkWidget *checkbtn_enable_default_alt_dictionary = NULL; @@ -767,7 +767,7 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, page->item = item; /* Table */ -#if USE_ASPELL +#if USE_ENCHANT # define TABLEHEIGHT 7 #else # define TABLEHEIGHT 6 @@ -920,7 +920,7 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0); rowcount++; -#if USE_ASPELL +#if USE_ENCHANT /* Default dictionary */ checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary")); gtk_table_attach(GTK_TABLE(table), checkbtn_enable_default_dictionary, 0, 1, @@ -928,12 +928,17 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary), item->prefs->enable_default_dictionary); - combo_default_dictionary = gtkaspell_dictionary_combo_new( - prefs_common.aspell_path, TRUE); + combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE); gtk_table_attach(GTK_TABLE(table), combo_default_dictionary, 1, 2, rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); dictionary = item->prefs->default_dictionary; + if (dictionary && strrchr(dictionary, '/')) { + gchar *tmp = g_strdup(strrchr(dictionary, '/')+1); + g_free(item->prefs->default_dictionary); + item->prefs->default_dictionary = tmp; + dictionary = item->prefs->default_dictionary; + } if (dictionary) gtkaspell_set_dictionary_menu_active_item( GTK_COMBO_BOX(combo_default_dictionary), dictionary); @@ -953,12 +958,17 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary), item->prefs->enable_default_alt_dictionary); - combo_default_alt_dictionary = gtkaspell_dictionary_combo_new( - prefs_common.aspell_path, FALSE); + combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(FALSE); gtk_table_attach(GTK_TABLE(table), combo_default_alt_dictionary, 1, 2, rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); dictionary = item->prefs->default_alt_dictionary; + if (dictionary && strrchr(dictionary, '/')) { + gchar *tmp = g_strdup(strrchr(dictionary, '/')+1); + g_free(item->prefs->default_alt_dictionary); + item->prefs->default_alt_dictionary = tmp; + dictionary = item->prefs->default_alt_dictionary; + } if (dictionary) gtkaspell_set_dictionary_menu_active_item( GTK_COMBO_BOX(combo_default_alt_dictionary), dictionary); @@ -985,7 +995,7 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, page->entry_default_reply_to = entry_default_reply_to; page->checkbtn_enable_default_account = checkbtn_enable_default_account; page->optmenu_default_account = optmenu_default_account; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary; page->combo_default_dictionary = combo_default_dictionary; page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary; @@ -997,7 +1007,7 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, page->default_to_rec_checkbtn = default_to_rec_checkbtn; page->default_reply_to_rec_checkbtn = default_reply_to_rec_checkbtn; page->default_account_rec_checkbtn = default_account_rec_checkbtn; -#if USE_ASPELL +#if USE_ENCHANT page->default_dictionary_rec_checkbtn = default_dictionary_rec_checkbtn; page->default_alt_dictionary_rec_checkbtn = default_alt_dictionary_rec_checkbtn; #endif @@ -1077,7 +1087,7 @@ static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage GTK_COMBO_BOX(page->optmenu_default_account)); } -#if USE_ASPELL +#if USE_ENCHANT if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn))) { prefs->enable_default_dictionary = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_dictionary)); @@ -1115,7 +1125,7 @@ static gboolean compose_save_recurse_func(GNode *node, gpointer data) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->save_copy_to_folder_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_to_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn)) || -#if USE_ASPELL +#if USE_ENCHANT gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn)) || #endif @@ -1123,7 +1133,7 @@ static gboolean compose_save_recurse_func(GNode *node, gpointer data) return TRUE; else if ((node == page->item->node) && item_protocol(item) == A_NNTP && !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn)) -#if USE_ASPELL +#if USE_ENCHANT || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn)) #endif diff --git a/src/prefs_spelling.c b/src/prefs_spelling.c index 125390229..6c8f9bb9c 100644 --- a/src/prefs_spelling.c +++ b/src/prefs_spelling.c @@ -21,7 +21,7 @@ # include "config.h" #endif -#if USE_ASPELL +#if USE_ENCHANT #include "defs.h" @@ -50,16 +50,12 @@ typedef struct _SpellingPage GtkWidget *automatic_frame; GtkWidget *dictionary_frame; - GtkWidget *path_frame; GtkWidget *enable_aspell_checkbtn; GtkWidget *recheck_when_changing_dict_checkbtn; GtkWidget *check_while_typing_checkbtn; GtkWidget *use_alternate_checkbtn; - GtkWidget *aspell_path_entry; - GtkWidget *aspell_path_select; - GtkWidget *default_dict_label; GtkWidget *default_dict_combo; @@ -68,9 +64,6 @@ typedef struct _SpellingPage GtkWidget *both_dict_check; - GtkWidget *sugmode_label; - GtkWidget *sugmode_combo; - GtkWidget *misspelled_label; GtkWidget *misspelled_colorbtn; GtkWidget *misspelled_useblack_label; @@ -78,39 +71,6 @@ typedef struct _SpellingPage gint misspell_col; } SpellingPage; -static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget, - gpointer data) -{ - SpellingPage *spelling = (SpellingPage *) data; - gchar *file_path; - - file_path = filesel_select_file_open(_("Select dictionaries location"), - prefs_common.aspell_path); - if (file_path != NULL) { - gchar *tmp_path, *tmp; - - tmp_path = g_path_get_dirname(file_path); - tmp = g_strdup_printf("%s%s", tmp_path, G_DIR_SEPARATOR_S); - g_free(tmp_path); - - gtk_combo_box_set_model(GTK_COMBO_BOX(spelling->default_dict_combo), - gtkaspell_dictionary_store_new(tmp)); - - gtk_combo_box_set_model(GTK_COMBO_BOX(spelling->default_alt_dict_combo), - gtkaspell_dictionary_store_new_with_refresh(tmp, FALSE)); - - gtk_entry_set_text(GTK_ENTRY(spelling->aspell_path_entry), tmp); - /* select first one */ - gtk_combo_box_set_active(GTK_COMBO_BOX( - spelling->default_dict_combo), 0); - gtk_combo_box_set_active(GTK_COMBO_BOX( - spelling->default_alt_dict_combo), 0); - - g_free(tmp); - - } -} - static void prefs_spelling_colorsel(GtkWidget *widget, gpointer data) { @@ -139,11 +99,6 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp GtkWidget *automatic_frame; GtkWidget *dictionary_frame; - GtkWidget *path_frame; - - GtkWidget *aspell_path_hbox; - GtkWidget *aspell_path_entry; - GtkWidget *aspell_path_select; GtkWidget *table; @@ -153,9 +108,6 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp GtkWidget *default_alt_dict_label; GtkWidget *default_alt_dict_combo; - GtkWidget *sugmode_label; - GtkWidget *sugmode_combo; - GtkWidget *both_dict_check; GtkWidget *misspelled_label; GtkWidget *misspelled_hbox; @@ -183,21 +135,6 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp CLAWS_SET_TIP(use_alternate_checkbtn, _("Faster switching with last used dictionary")); - PACK_FRAME(vbox1, path_frame, _("Path to dictionaries")); - aspell_path_hbox = gtk_hbox_new(FALSE, 8); - gtk_widget_show(aspell_path_hbox); - gtk_container_add(GTK_CONTAINER(path_frame), aspell_path_hbox); - gtk_container_set_border_width(GTK_CONTAINER(aspell_path_hbox), 8); - - aspell_path_entry = gtk_entry_new(); - gtk_widget_show(aspell_path_entry); - gtk_box_pack_start(GTK_BOX(aspell_path_hbox), aspell_path_entry, TRUE, TRUE, 0); - gtk_widget_set_size_request(aspell_path_entry, 30, 20); - - aspell_path_select = gtkut_get_browse_directory_btn(_("_Browse")); - gtk_widget_show(aspell_path_select); - gtk_box_pack_start(GTK_BOX(aspell_path_hbox), aspell_path_select, FALSE, FALSE, 0); - vbox2 = gtkut_get_options_frame(vbox1, &automatic_frame, _("Automatic spell checking")); check_while_typing_checkbtn = gtk_check_button_new_with_label( @@ -228,8 +165,7 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp gtk_label_set_justify(GTK_LABEL(default_dict_label), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(default_dict_label), 1, 0.5); - default_dict_combo = gtkaspell_dictionary_combo_new( - prefs_common.aspell_path, TRUE); + default_dict_combo = gtkaspell_dictionary_combo_new(TRUE); gtk_widget_set_size_request(default_dict_combo, 180, -1); gtk_table_attach (GTK_TABLE (table), default_dict_combo, 1, 2, 0, 1, GTK_SHRINK, 0, 0, 0); @@ -242,8 +178,7 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp gtk_label_set_justify(GTK_LABEL(default_alt_dict_label), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(default_alt_dict_label), 1, 0.5); - default_alt_dict_combo = gtkaspell_dictionary_combo_new( - prefs_common.aspell_path, FALSE); + default_alt_dict_combo = gtkaspell_dictionary_combo_new(FALSE); gtk_widget_set_size_request(default_alt_dict_combo, 180, -1); gtk_table_attach (GTK_TABLE (table), default_alt_dict_combo, 1, 2, 1, 2, GTK_SHRINK, 0, 0, 0); @@ -254,19 +189,6 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp gtk_table_attach (GTK_TABLE (table), both_dict_check, 1, 2, 2, 3, GTK_SHRINK, 0, 0, 0); - sugmode_label = gtk_label_new(_("Default suggestion mode")); - gtk_widget_show(sugmode_label); - gtk_table_attach(GTK_TABLE (table), sugmode_label, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 2); - gtk_label_set_justify(GTK_LABEL(sugmode_label), GTK_JUSTIFY_RIGHT); - gtk_misc_set_alignment(GTK_MISC(sugmode_label), 1, 0.5); - - sugmode_combo = gtkaspell_sugmode_combo_new(prefs_common.aspell_sugmode); - gtk_widget_set_size_request(sugmode_combo, 180, -1); - gtk_table_attach (GTK_TABLE (table), sugmode_combo, 1, 2, 3, 4, - GTK_SHRINK, 0, 0, 0); - misspelled_hbox = gtk_hbox_new(FALSE, 10); gtk_widget_show(misspelled_hbox); gtk_box_pack_start(GTK_BOX(vbox1), misspelled_hbox, FALSE, FALSE, 0); @@ -289,7 +211,6 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, automatic_frame); SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, dictionary_frame); - SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, path_frame); SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, misspelled_label); SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, misspelled_colorbtn); SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, use_alternate_checkbtn); @@ -307,11 +228,16 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp prefs_common.recheck_when_changing_dict); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_alternate_checkbtn), prefs_common.use_alternate); - gtk_entry_set_text(GTK_ENTRY(aspell_path_entry), - SAFE_STRING(prefs_common.aspell_path)); - g_signal_connect(G_OBJECT(aspell_path_select), "clicked", - G_CALLBACK(prefs_spelling_btn_aspell_path_clicked_cb), - prefs_spelling); + if (strrchr(prefs_common.dictionary, '/')) { + gchar *tmp = g_strdup(strrchr(prefs_common.dictionary, '/')+1); + g_free(prefs_common.dictionary); + prefs_common.dictionary = tmp; + } + if (strrchr(prefs_common.alt_dictionary, '/')) { + gchar *tmp = g_strdup(strrchr(prefs_common.alt_dictionary, '/')+1); + g_free(prefs_common.alt_dictionary); + prefs_common.alt_dictionary = tmp; + } gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(default_dict_combo), prefs_common.dictionary); @@ -327,21 +253,16 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp prefs_spelling->window = GTK_WIDGET(window); prefs_spelling->automatic_frame = automatic_frame; prefs_spelling->dictionary_frame = dictionary_frame; - prefs_spelling->path_frame = path_frame; prefs_spelling->enable_aspell_checkbtn = enable_aspell_checkbtn; prefs_spelling->check_while_typing_checkbtn = check_while_typing_checkbtn; prefs_spelling->recheck_when_changing_dict_checkbtn = recheck_when_changing_dict_checkbtn; prefs_spelling->use_alternate_checkbtn = use_alternate_checkbtn; - prefs_spelling->aspell_path_entry = aspell_path_entry; - prefs_spelling->aspell_path_select = aspell_path_select; prefs_spelling->default_dict_label = default_dict_label; prefs_spelling->default_dict_combo = default_dict_combo; prefs_spelling->default_alt_dict_label = default_alt_dict_label; prefs_spelling->default_alt_dict_combo = default_alt_dict_combo; - prefs_spelling->sugmode_label = sugmode_label; - prefs_spelling->sugmode_combo = sugmode_combo; prefs_spelling->misspelled_label = misspelled_label; prefs_spelling->misspelled_colorbtn = misspelled_colorbtn; prefs_spelling->both_dict_check = both_dict_check; @@ -364,10 +285,6 @@ static void prefs_spelling_save(PrefsPage *_page) prefs_common.use_both_dicts = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->both_dict_check)); - g_free(prefs_common.aspell_path); - prefs_common.aspell_path = - gtk_editable_get_chars(GTK_EDITABLE(spelling->aspell_path_entry), 0, -1); - g_free(prefs_common.dictionary); prefs_common.dictionary = gtkaspell_get_dictionary_menu_active_item( @@ -378,9 +295,6 @@ static void prefs_spelling_save(PrefsPage *_page) gtkaspell_get_dictionary_menu_active_item( GTK_COMBO_BOX(spelling->default_alt_dict_combo)); - prefs_common.aspell_sugmode = - combobox_get_active_data(GTK_COMBO_BOX(spelling->sugmode_combo)); - prefs_common.misspelled_col = spelling->misspell_col; } @@ -419,13 +333,11 @@ void prefs_spelling_init(void) language = "en"; if (!prefs_common.dictionary) - prefs_common.dictionary = g_strdup_printf("%s%s", - prefs_common.aspell_path, + prefs_common.dictionary = g_strdup_printf("%s", language); if (!strlen(prefs_common.dictionary) || !strcmp(prefs_common.dictionary,"(None")) - prefs_common.dictionary = g_strdup_printf("%s%s", - prefs_common.aspell_path, + prefs_common.dictionary = g_strdup_printf("%s", language); if (strcasestr(prefs_common.dictionary,".utf")) *(strcasestr(prefs_common.dictionary,".utf")) = '\0'; @@ -439,4 +351,4 @@ void prefs_spelling_done(void) g_free(prefs_spelling); } -#endif /* USE_ASPELL */ +#endif /* USE_ENCHANT */ diff --git a/src/prefs_template.c b/src/prefs_template.c index 3c3ccf871..dc2ff11ff 100644 --- a/src/prefs_template.c +++ b/src/prefs_template.c @@ -681,7 +681,7 @@ gboolean prefs_template_string_is_valid(gchar *string, gint *line, gboolean esca tmp = g_strdup(string); } memset(&dummyinfo, 0, sizeof(MsgInfo)); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT quote_fmt_init(&dummyinfo, NULL, NULL, TRUE, account, FALSE, NULL); #else quote_fmt_init(&dummyinfo, NULL, NULL, TRUE, account, FALSE); diff --git a/src/quote_fmt.h b/src/quote_fmt.h index 52d9a5cf8..9d3e958b7 100644 --- a/src/quote_fmt.h +++ b/src/quote_fmt.h @@ -2,7 +2,7 @@ #define __QUOTE_FMT_H__ -#ifdef USE_ASPELL +#ifdef USE_ENCHANT #include "gtkaspell.h" #endif @@ -13,7 +13,7 @@ void quote_fmt_quote_description(GtkWidget *widget, GtkWidget *pref_window); gchar *quote_fmt_get_buffer(void); GList *quote_fmt_get_attachments_list(void); gint quote_fmt_get_line(void); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, const gchar *my_body, gboolean my_dry_run, PrefsAccount *account, diff --git a/src/quote_fmt_parse.y b/src/quote_fmt_parse.y index e666e9108..762120c23 100644 --- a/src/quote_fmt_parse.y +++ b/src/quote_fmt_parse.y @@ -47,7 +47,7 @@ int yylex(void); static MsgInfo *msginfo = NULL; static PrefsAccount *account = NULL; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT static gchar default_dictionary[BUFFSIZE]; #endif static gboolean *visible = NULL; @@ -184,7 +184,7 @@ void quote_fmt_reset_vartable(void) } } -#ifdef USE_ASPELL +#ifdef USE_ENCHANT void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, const gchar *my_body, gboolean my_dry_run, PrefsAccount *compose_account, @@ -201,7 +201,7 @@ void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, body = my_body; msginfo = info; account = compose_account; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT gchar *dict = gtkaspell_get_default_dictionary(compose_gtkaspell); if (dict) strncpy2(default_dictionary, dict, sizeof(default_dictionary)); @@ -788,7 +788,7 @@ special: } | SHOW_ACCOUNT_DICT { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT if (account && account->enable_default_dictionary) { gchar *dictname = g_path_get_basename(account->default_dictionary); INSERT(dictname); @@ -798,7 +798,7 @@ special: } | SHOW_DICT { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT INSERT(default_dictionary); #endif } @@ -972,7 +972,7 @@ query: } | QUERY_ACCOUNT_DICT { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT add_visibility(account != NULL && account->enable_default_dictionary == TRUE && account->default_dictionary != NULL && *account->default_dictionary != '\0'); #else @@ -985,7 +985,7 @@ query: } | QUERY_DICT { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT add_visibility(*default_dictionary != '\0'); #else add_visibility(FALSE); @@ -1124,7 +1124,7 @@ query_not: } | QUERY_NOT_ACCOUNT_DICT { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT add_visibility(account == NULL || account->enable_default_dictionary == FALSE || *account->default_dictionary == '\0'); #else @@ -1137,7 +1137,7 @@ query_not: } | QUERY_NOT_DICT { -#ifdef USE_ASPELL +#ifdef USE_ENCHANT add_visibility(*default_dictionary == '\0'); #else add_visibility(FALSE); diff --git a/src/toolbar.c b/src/toolbar.c index 2ffc2a4ab..469c4d6e5 100644 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -164,7 +164,7 @@ static void toolbar_linewrap_all_cb (GtkWidget *widget, gpointer data); static void toolbar_addrbook_cb (GtkWidget *widget, gpointer data); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT static void toolbar_check_spelling_cb (GtkWidget *widget, gpointer data); #endif @@ -208,7 +208,7 @@ struct { { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") }, { "A_LINEWRAP_ALL", N_("Wrap all long lines") }, { "A_ADDRBOOK", N_("Address book") }, -#ifdef USE_ASPELL +#ifdef USE_ENCHANT { "A_CHECK_SPELLING", N_("Check spelling") }, #endif { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") }, @@ -312,7 +312,7 @@ GList *toolbar_get_action_items(ToolbarType source) A_INSERT, A_ATTACH, A_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT, A_LINEWRAP_ALL, A_ADDRBOOK, -#ifdef USE_ASPELL +#ifdef USE_ENCHANT A_CHECK_SPELLING, #endif A_CLOSE }; @@ -415,7 +415,7 @@ const gchar *toolbar_get_short_text(int action) { case A_ADDRBOOK: return _("Address"); case A_CANCEL_INC: return _("Stop"); case A_EXECUTE: return _("Execute"); - #ifdef USE_ASPELL + #ifdef USE_ENCHANT case A_CHECK_SPELLING: return _("Check spelling"); #endif default: return ""; @@ -458,7 +458,7 @@ gint toolbar_get_icon(int action) { case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK; case A_CANCEL_INC: return STOCK_PIXMAP_CANCEL; case A_EXECUTE: return STOCK_PIXMAP_EXEC; - #ifdef USE_ASPELL + #ifdef USE_ENCHANT case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING; #endif default: return -1; @@ -1575,7 +1575,7 @@ static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data) compose_toolbar_cb(A_LINEWRAP_ALL, data); } -#ifdef USE_ASPELL +#ifdef USE_ENCHANT static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data) { compose_toolbar_cb(A_CHECK_SPELLING, data); @@ -1705,7 +1705,7 @@ static void toolbar_buttons_cb(GtkWidget *widget, { A_LINEWRAP_CURRENT, toolbar_linewrap_current_cb }, { A_LINEWRAP_ALL, toolbar_linewrap_all_cb }, { A_ADDRBOOK, toolbar_addrbook_cb }, -#ifdef USE_ASPELL +#ifdef USE_ENCHANT { A_CHECK_SPELLING, toolbar_check_spelling_cb }, #endif { A_CLAWS_ACTIONS, toolbar_actions_execute_cb }, @@ -2084,7 +2084,7 @@ Toolbar *toolbar_create(ToolbarType type, TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book")); toolbar_data->addrbook_btn = item; break; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT case A_CHECK_SPELLING: TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling")); toolbar_data->spellcheck_btn = item; @@ -2451,7 +2451,7 @@ void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive) GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive); if (compose->toolbar->addrbook_btn) GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive); -#ifdef USE_ASPELL +#ifdef USE_ENCHANT if (compose->toolbar->spellcheck_btn) GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive); #endif @@ -2497,7 +2497,7 @@ static void toolbar_init(Toolbar * toolbar) toolbar->linewrap_current_btn = NULL; toolbar->linewrap_all_btn = NULL; toolbar->addrbook_btn = NULL; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT toolbar->spellcheck_btn = NULL; #endif diff --git a/src/toolbar.h b/src/toolbar.h index e2a95b601..98bd87bdb 100644 --- a/src/toolbar.h +++ b/src/toolbar.h @@ -91,7 +91,7 @@ struct _Toolbar { GtkWidget *linewrap_current_btn; GtkWidget *linewrap_all_btn; GtkWidget *addrbook_btn; -#ifdef USE_ASPELL +#ifdef USE_ENCHANT GtkWidget *spellcheck_btn; #endif @@ -187,7 +187,7 @@ enum { A_LINEWRAP_CURRENT, A_LINEWRAP_ALL, A_ADDRBOOK, -#ifdef USE_ASPELL +#ifdef USE_ENCHANT A_CHECK_SPELLING, #endif