commit 6efdeae6c0adc6d6109a1deb8ee5b506b7b6d1da from: Oliver Lowe date: Sat Aug 23 06:34:38 2025 UTC Drop spelling support Don't think this ever really worked for me anyway. "ok" and "I" were often labelled as incorrectly spelled? commit - 192a882eb735e9e441438161bcbd41189f5ff645 commit + 6efdeae6c0adc6d6109a1deb8ee5b506b7b6d1da blob - b9af385a3f828c7f0ee73c20dee8b8cf6d1aaf3b blob + 839d9967c71845e37e2d5d342eb7e24e1be029c3 --- Makefile.am +++ Makefile.am @@ -10,7 +10,7 @@ endif ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = dist-bzip2 dist-xz -SUBDIRS = po src tools config doc manual +SUBDIRS = po src config doc manual EXTRA_DIST = \ ChangeLog \ blob - fb29d77f6f683f038a124794ecdf2569000d7e0f blob + 26844585fef21a9f92929b8a894ca11ca7f0495d --- claws-features.h.in +++ claws-features.h.in @@ -1,4 +1,3 @@ #undef HAVE_VALGRIND -#undef USE_ENCHANT #undef USE_GNUTLS #undef USE_GPGME blob - c0c9572ac70c41db06a7d808acd4bf338e82b6a3 blob + 8f0e4d00f6566c18b7fdc7331f04a4e5ef0d2e9b --- claws-mail.pc.in +++ claws-mail.pc.in @@ -11,4 +11,4 @@ Name: Claws Mail Description: Claws Mail Version: @MAJOR_VERSION@.@MINOR_VERSION@.@MICRO_VERSION@.@EXTRA_VERSION@ -Cflags: -I${pkgincludedir}/common -I${pkgincludedir}/gtk @ENCHANT_CFLAGS@ @GPGME_CFLAGS@ -I${pkgincludedir} +Cflags: -I${pkgincludedir}/common -I${pkgincludedir}/gtk @GPGME_CFLAGS@ -I${pkgincludedir} blob - 88e721e4e92c8a0434cfc710d6844f7c66557f2a blob + a13b1d5ed1ceedc749cbfbc821922eba5db67335 --- configure.ac +++ configure.ac @@ -157,10 +157,6 @@ AC_ARG_ENABLE(oauth2, [ --disable-oauth2 Do not build OAuth2 support], [enable_oauth2=$enableval], [enable_oauth2=yes]) -AC_ARG_ENABLE(enchant, - [ --disable-enchant Do not build Enchant support for spell-checking], - [enable_enchant=$enableval], [enable_enchant=yes]) - AC_ARG_ENABLE(valgrind, [ --disable-valgrind Do not build valgrind support for debugging], [enable_valgrind=$enableval], [enable_valgrind=yes]) @@ -308,24 +304,6 @@ GTK_CFLAGS="$GTK_CFLAGS -DGTK_DISABLE_SINGLE_INCLUDES AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) -dnl enchant is used for spell checking -AC_MSG_CHECKING([whether to use enchant]) -AC_MSG_RESULT($enable_enchant) -if test $enable_enchant = yes; then - PKG_CHECK_MODULES(ENCHANT, enchant-2 >= 2.0.0, - [ - AC_DEFINE(USE_ENCHANT, 1, enchant-2) - echo "Building with enchant-2" - enable_enchant=yes - ], - [ - echo "Building without enchant-notification" - enable_enchant=no - ]) - AC_SUBST(ENCHANT_CFLAGS) - AC_SUBST(ENCHANT_LIBS) -fi - dnl dnl Check whether we need to pass -lresolv dnl @@ -437,7 +415,6 @@ echo "" echo "gnuTLS : $enable_gnutls" echo "OAuth2 : $enable_oauth2" echo "iconv : $am_cv_func_iconv" -echo "enchant : $enable_enchant" echo "Unit tests : $enable_tests" echo "Valgrind support : $enable_valgrind" blob - b9997bc67ed74160a3130b30c3d8e416a188e05e blob + d189d512e93ba449850e165adb7426551589a7f3 --- src/Makefile.am +++ src/Makefile.am @@ -104,7 +104,6 @@ claws_mail_SOURCES = \ prefs_quote.c \ prefs_receive.c \ prefs_send.c \ - prefs_spelling.c \ prefs_summaries.c \ prefs_summary_column.c \ prefs_summary_open.c \ @@ -207,7 +206,6 @@ claws_mailinclude_HEADERS = \ prefs_quote.h \ prefs_receive.h \ prefs_send.h \ - prefs_spelling.h \ prefs_summaries.h \ prefs_summary_column.h \ prefs_summary_open.h \ @@ -465,7 +463,6 @@ claws_mail_DEPENDENCIES = $(claws_mail_deps) \ claws_mail_LDADD = \ $(etpan_library) \ gtk/libclawsgtk.la \ - $(ENCHANT_LIBS) \ $(INTLLIBS) \ $(GTK_LIBS) \ $(GNUTLS_LIBS) \ @@ -487,7 +484,6 @@ AM_CPPFLAGS = \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ -DDATAROOTDIR=\""$(datarootdir)"\" \ $(IFLAGS) \ - $(ENCHANT_CFLAGS) \ $(GTK_CFLAGS) \ $(GNUTLS_CFLAGS) \ $(NETTLE_CFLAGS) \ blob - 055d47117ef1a68d764ea6cdd22a9272f8b9f91c blob + af58f6c2c5f2206a4df1ecb233462c6f7e85aa7e --- src/account.c +++ src/account.c @@ -1006,10 +1006,6 @@ static void account_clone(GtkWidget *widget, gpointer ACP_FDUP(auto_bcc); ACP_FASSIGN(set_autoreplyto); ACP_FDUP(auto_replyto); - ACP_FASSIGN(enable_default_dictionary); - ACP_FDUP(default_dictionary); - ACP_FASSIGN(enable_default_alt_dictionary); - ACP_FDUP(default_alt_dictionary); ACP_FASSIGN(compose_with_format); ACP_FDUP(compose_subject_format); ACP_FDUP(compose_body_format); blob - 9a4ae079537ce67af198faa6faebe6bc6e351e8b blob + 5517643560d91ec55837075ba7b34cfe75f4baa7 --- src/common/defs.h +++ src/common/defs.h @@ -79,7 +79,6 @@ #define HOMEPAGE_URI "https://www.claws-mail.org/" #define MANUAL_URI "https://www.claws-mail.org/documentation.php" #define FAQ_URI "https://www.claws-mail.org/faq/index.php" -#define DICTS_URI "https://www.claws-mail.org/win32/dictionaries.php" #define BUGZILLA_URI "https://www.thewildbeast.co.uk/claws-mail/bugzilla/enter_bug.cgi" #define THEMES_URI "https://www.claws-mail.org/themes.php" #define TOOLS_URI "https://www.claws-mail.org/tools.php" blob - ef28bb91721aa2eff56a238da38794d67023ad87 blob + ba3ffde4d7550344bc607b19f08a43cd34e03d57 --- src/compose.c +++ src/compose.c @@ -98,7 +98,6 @@ #include "hooks.h" #include "privacy.h" #include "autofaces.h" -#include "spell_entry.h" #include "headers.h" #include "file-utils.h" #include "fence.h" @@ -353,10 +352,6 @@ static void compose_add_header_entry (Compose *compose gchar *text, ComposePrefType pref_type); static void compose_remove_header_entries(Compose *compose); -#if USE_ENCHANT -static void compose_spell_menu_changed (void *data); -static void compose_dict_changed (void *data); -#endif static void compose_add_field_list ( Compose *compose, GList *listAddress ); @@ -524,21 +519,10 @@ static void compose_nothing_cb (GtkAction *action, } -#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); -static void compose_check_forwards_go (GtkAction *action, gpointer data); -#endif - static PrefsAccount *compose_find_account (MsgInfo *msginfo); static MsgInfo *compose_msginfo_new_from_compose(Compose *compose); -#ifdef USE_ENCHANT -static void compose_set_dictionaries_from_folder_prefs(Compose *compose, - FolderItem *folder_item); -#endif static void compose_attach_update_label(Compose *compose); static void compose_set_folder_prefs(Compose *compose, FolderItem *folder, gboolean respect_default_to); @@ -562,9 +546,6 @@ static GtkActionEntry compose_entries[] = /* menus */ {"Message", NULL, N_("_Message"), NULL, NULL, NULL }, {"Edit", NULL, N_("_Edit"), NULL, NULL, NULL }, -#if USE_ENCHANT - {"Spelling", NULL, N_("_Spelling"), NULL, NULL, NULL }, -#endif {"Options", NULL, N_("_Options"), NULL, NULL, NULL }, {"Tools", NULL, N_("_Tools"), NULL, NULL, NULL }, /* Message menu */ @@ -621,17 +602,7 @@ static GtkActionEntry compose_entries[] = {"Edit/WrapAllLines", NULL, N_("Wrap all long _lines"), "L", NULL, G_CALLBACK(compose_wrap_all_cb) }, /* 1 */ /* {"Edit/---", NULL, "---", NULL, NULL, NULL }, */ {"Edit/ExtEditor", NULL, N_("Edit with e_xternal editor"), "X", NULL, G_CALLBACK(compose_ext_editor_cb) }, -#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) }, - {"Spelling/CheckBackwards", NULL, N_("Check _backwards misspelled word"), NULL, NULL, G_CALLBACK(compose_check_backwards) }, - {"Spelling/ForwardNext", NULL, N_("_Forward to next misspelled word"), NULL, NULL, G_CALLBACK(compose_check_forwards_go) }, - {"Spelling/---", NULL, "---", NULL, NULL, NULL }, - {"Spelling/Options", NULL, N_("_Options"), NULL, NULL, NULL }, -#endif - {"Options/ReplyMode", NULL, N_("Reply _mode"), NULL, NULL, NULL }, {"Options/---", NULL, "---", NULL, NULL, NULL }, {"Options/PrivacySystem", NULL, N_("Privacy _System"), NULL, NULL, NULL }, @@ -941,13 +912,7 @@ Compose *compose_generic_new(PrefsAccount *account, co /* decode \-escape sequences in the internal representation of the quote format */ tmp = g_malloc(strlen(item->prefs->compose_override_from_format)+1); pref_get_unescaped_pref(tmp, item->prefs->compose_override_from_format); - -#ifdef USE_ENCHANT - quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE, - compose->gtkaspell); -#else quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE); -#endif quote_fmt_scan_string(tmp); quote_fmt_parse(); @@ -970,9 +935,6 @@ Compose *compose_generic_new(PrefsAccount *account, co compose_create_tags(textview, compose); undo_block(compose->undostruct); -#ifdef USE_ENCHANT - compose_set_dictionaries_from_folder_prefs(compose, item); -#endif if (account->auto_sig) compose_insert_sig(compose, FALSE); @@ -1016,12 +978,8 @@ Compose *compose_generic_new(PrefsAccount *account, co pref_get_unescaped_pref(tmp, subject_format); subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1); -#ifdef USE_ENCHANT - quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE, - compose->gtkaspell); -#else quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE); -#endif + quote_fmt_scan_string(tmp); quote_fmt_parse(); @@ -1062,10 +1020,6 @@ Compose *compose_generic_new(PrefsAccount *account, co quote_fmt_reset_vartable(); g_free(tmp); -#ifdef USE_ENCHANT - if (compose->gtkaspell && compose->gtkaspell->check_while_typing) - gtkaspell_highlight_all(compose->gtkaspell); -#endif mfield = BODY_FIELD_PRESENT; } @@ -1495,12 +1449,8 @@ static Compose *compose_generic_reply(MsgInfo *msginfo tmp = g_malloc(strlen(msginfo->folder->prefs->reply_override_from_format)+1); pref_get_unescaped_pref(tmp, msginfo->folder->prefs->reply_override_from_format); -#ifdef USE_ENCHANT - quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE, - compose->gtkaspell); -#else + quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE); -#endif quote_fmt_scan_string(tmp); quote_fmt_parse(); @@ -1520,10 +1470,6 @@ static Compose *compose_generic_reply(MsgInfo *msginfo compose_create_tags(textview, compose); undo_block(compose->undostruct); -#ifdef USE_ENCHANT - compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder); - gtkaspell_block_check(compose->gtkaspell); -#endif if (quote_mode == COMPOSE_QUOTE_FORCED || (quote_mode == COMPOSE_QUOTE_CHECK && prefs_common.reply_with_quote)) { @@ -1577,11 +1523,6 @@ static Compose *compose_generic_reply(MsgInfo *msginfo compose_wrap_all(compose); -#ifdef USE_ENCHANT - if (compose->gtkaspell && compose->gtkaspell->check_while_typing) - gtkaspell_highlight_all(compose->gtkaspell); - gtkaspell_unblock_check(compose->gtkaspell); -#endif SIGNAL_UNBLOCK(textbuf); gtk_widget_grab_focus(compose->text); @@ -1687,13 +1628,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInf tmp = g_malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1); pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format); -#ifdef USE_ENCHANT - gtkaspell_block_check(compose->gtkaspell); - quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE, - compose->gtkaspell); -#else quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE); -#endif quote_fmt_scan_string(tmp); quote_fmt_parse(); @@ -1768,11 +1703,6 @@ Compose *compose_forward(PrefsAccount *account, MsgInf compose_wrap_all(compose); -#ifdef USE_ENCHANT - if (compose->gtkaspell && compose->gtkaspell->check_while_typing) - gtkaspell_highlight_all(compose->gtkaspell); - gtkaspell_unblock_check(compose->gtkaspell); -#endif SIGNAL_UNBLOCK(textbuf); if (privacy_system_can_sign(compose->privacy_system) == FALSE && @@ -1881,13 +1811,7 @@ static Compose *compose_forward_multiple(PrefsAccount /* decode \-escape sequences in the internal representation of the quote format */ tmp = g_malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1); pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format); - -#ifdef USE_ENCHANT - quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, - compose->gtkaspell); -#else quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE); -#endif quote_fmt_scan_string(tmp); quote_fmt_parse(); @@ -2642,11 +2566,6 @@ void compose_toolbar_cb(gint action, gpointer data) case A_ADDRBOOK: compose_address_cb(NULL, compose); break; -#ifdef USE_ENCHANT - case A_CHECK_SPELLING: - compose_check_all(NULL, compose); - break; -#endif case A_PRIVACY_SIGN: break; case A_PRIVACY_ENCRYPT: @@ -2986,12 +2905,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgI } const char *qmark = "> "; -#ifdef USE_ENCHANT - quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, - compose->gtkaspell); -#else quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE); -#endif quote_fmt_scan_string(qmark); quote_fmt_parse(); @@ -3005,13 +2919,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgI if (trimmed_body) while (*trimmed_body == '\n') trimmed_body++; - -#ifdef USE_ENCHANT - quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE, - compose->gtkaspell); -#else quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE); -#endif if (need_unescape) { gchar *tmp = NULL; @@ -4854,35 +4762,9 @@ static void compose_select_account(Compose *compose, P header_entry->combo)), &iter, COMBOBOX_TEXT, &header, -1); if (header && !strlen(gtk_entry_get_text(GTK_ENTRY(header_entry->entry)))) { - if (account->protocol == A_NNTP) { - if (!strcmp(header, _("To:"))) - combobox_select_by_text( - GTK_COMBO_BOX(header_entry->combo), - _("Newsgroups:")); - } else { - if (!strcmp(header, _("Newsgroups:"))) - combobox_select_by_text( - GTK_COMBO_BOX(header_entry->combo), - _("To:")); - } - + combobox_select_by_text(GTK_COMBO_BOX(header_entry->combo), "To:"); } g_free(header); - -#ifdef USE_ENCHANT - /* use account's dict info if set */ - if (compose->gtkaspell) { - if (account->enable_default_dictionary) - gtkaspell_change_dict(compose->gtkaspell, - account->default_dictionary, FALSE); - if (account->enable_default_alt_dictionary) - gtkaspell_change_alt_dict(compose->gtkaspell, - account->default_alt_dictionary); - if (account->enable_default_dictionary - || account->enable_default_alt_dictionary) - compose_spell_menu_changed(compose); - } -#endif } gboolean compose_check_for_valid_recipient(Compose *compose) { @@ -7303,114 +7185,26 @@ static void entry_paste_clipboard(Compose *compose, Gt static gboolean text_clicked(GtkWidget *text, GdkEventButton *event, Compose *compose) { + if (event->button != 2) + return FALSE; + gint prev_autowrap; GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); -#if USE_ENCHANT - if (event->button == 3) { - GtkTextIter iter; - GtkTextIter sel_start, sel_end; - gboolean stuff_selected; - gint x, y; - /* move the cursor to allow GtkAspell to check the word - * under the mouse */ - if (event->x && event->y) { - gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text), - GTK_TEXT_WINDOW_TEXT, event->x, event->y, - &x, &y); - gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text), - &iter, x, y); - } else { - GtkTextMark *mark = gtk_text_buffer_get_insert(buffer); - gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); - } - /* get selection */ - stuff_selected = gtk_text_buffer_get_selection_bounds( - buffer, - &sel_start, &sel_end); + GtkTextIter iter; + gint x, y; + BLOCK_WRAP(); + /* get the middle-click position to paste at the correct place */ + gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text), + GTK_TEXT_WINDOW_TEXT, event->x, event->y, + &x, &y); + gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text), &iter, x, y); - gtk_text_buffer_place_cursor (buffer, &iter); - /* reselect stuff */ - if (stuff_selected - && gtk_text_iter_in_range(&iter, &sel_start, &sel_end)) { - gtk_text_buffer_select_range(buffer, - &sel_start, &sel_end); - } - return FALSE; /* pass the event so that the right-click goes through */ - } -#endif - if (event->button == 2) { - GtkTextIter iter; - gint x, y; - BLOCK_WRAP(); - /* get the middle-click position to paste at the correct place */ - gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text), - GTK_TEXT_WINDOW_TEXT, event->x, event->y, - &x, &y); - gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text), - &iter, x, y); - - entry_paste_clipboard(compose, text, GDK_SELECTION_PRIMARY, &iter); - UNBLOCK_WRAP(); - return TRUE; - } - return FALSE; + entry_paste_clipboard(compose, text, GDK_SELECTION_PRIMARY, &iter); + UNBLOCK_WRAP(); + return TRUE; } -#if USE_ENCHANT -static void compose_spell_menu_changed(void *data) -{ - Compose *compose = (Compose *)data; - GSList *items; - GtkWidget *menuitem; - GtkWidget *parent_item; - GtkMenu *menu = GTK_MENU(gtk_menu_new()); - GSList *spell_menu; - - if (compose->gtkaspell == NULL) - return; - - parent_item = gtk_ui_manager_get_widget(compose->ui_manager, - "/Menu/Spelling/Options"); - - /* setting the submenu removes '/Spelling/Options' from the factory - * so we need to save it */ - - if (parent_item == NULL) { - parent_item = compose->aspell_options_menu; - gtk_menu_item_set_submenu(GTK_MENU_ITEM(parent_item), NULL); - } else - compose->aspell_options_menu = parent_item; - - spell_menu = gtkaspell_make_config_menu(compose->gtkaspell); - - spell_menu = g_slist_reverse(spell_menu); - for (items = spell_menu; - items; items = items->next) { - menuitem = GTK_WIDGET(GTK_MENU_ITEM(items->data)); - gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), GTK_WIDGET(menuitem)); - gtk_widget_show(GTK_WIDGET(menuitem)); - } - g_slist_free(spell_menu); - - gtk_menu_item_set_submenu(GTK_MENU_ITEM(parent_item), GTK_WIDGET(menu)); - gtk_widget_show(parent_item); -} - -static void compose_dict_changed(void *data) -{ - Compose *compose = (Compose *) data; - - if(!compose->gtkaspell) - return; - if(compose->gtkaspell->recheck_when_changing_dict == FALSE) - return; - - gtkaspell_highlight_all(compose->gtkaspell); - claws_spell_entry_recheck_all(CLAWS_SPELL_ENTRY(compose->subject_entry)); -} -#endif - static gboolean compose_popup_menu(GtkWidget *widget, gpointer data) { Compose *compose = (Compose *)data; @@ -7462,10 +7256,6 @@ static Compose *compose_create(PrefsAccount *account, GtkWidget *popupmenu; GtkActionGroup *action_group = NULL; -#if USE_ENCHANT - GtkAspell * gtkaspell = NULL; -#endif - static GdkGeometry geometry; GdkRectangle workarea = {0}; @@ -7534,9 +7324,6 @@ 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_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) MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Tools", "Tools", GTK_UI_MANAGER_MENU) @@ -7596,16 +7383,6 @@ static Compose *compose_create(PrefsAccount *account, MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Edit", "Separator3", "Edit/---", GTK_UI_MANAGER_SEPARATOR) MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Edit", "ExtEditor", "Edit/ExtEditor", GTK_UI_MANAGER_MENUITEM) -#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) - MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "CheckBackwards", "Spelling/CheckBackwards", GTK_UI_MANAGER_MENUITEM) - MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "ForwardNext", "Spelling/ForwardNext", GTK_UI_MANAGER_MENUITEM) - MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "Separator1", "Spelling/---", GTK_UI_MANAGER_SEPARATOR) - MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "Options", "Spelling/Options", GTK_UI_MANAGER_MENU) -#endif - /* Options menu */ MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Options", "ReplyMode", "Options/ReplyMode", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Options/ReplyMode", "Normal", "Options/ReplyMode/Normal", GTK_UI_MANAGER_MENUITEM) @@ -7695,12 +7472,7 @@ static Compose *compose_create(PrefsAccount *account, label = gtk_label_new_with_mnemonic(_("S_ubject:")); gtk_box_pack_start(GTK_BOX(subject), label, FALSE, FALSE, HSPACING_NARROW); gtk_widget_show(label); - -#ifdef USE_ENCHANT - subject_entry = claws_spell_entry_new(); -#else subject_entry = gtk_entry_new(); -#endif gtk_box_pack_start(GTK_BOX(subject), subject_entry, TRUE, TRUE, HSPACING_NARROW); g_signal_connect_after(G_OBJECT(subject_entry), "grab_focus", G_CALLBACK(compose_grab_focus_cb), compose); @@ -7878,40 +7650,6 @@ static Compose *compose_create(PrefsAccount *account, hooks_register_hook(FOLDER_UPDATE_HOOKLIST, compose_update_folder_hook, (gpointer) compose); - -#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.dictionary, - prefs_common.alt_dictionary, - conv_get_locale_charset_str(), - prefs_common.color[COL_MISSPELLED], - prefs_common.check_while_typing, - prefs_common.recheck_when_changing_dict, - prefs_common.use_alternate, - prefs_common.use_both_dicts, - GTK_TEXT_VIEW(text), - GTK_WINDOW(compose->window), - compose_dict_changed, - compose_spell_menu_changed, - compose); - if (!gtkaspell) { - alertpanel_error(_("Spell checker could not " - "be started.\n%s"), - gtkaspell_checkers_strerror()); - gtkaspell_checkers_reset_error(); - } else { - cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", TRUE); - } - } - } - compose->gtkaspell = gtkaspell; - compose_spell_menu_changed(compose); - claws_spell_entry_set_gtkaspell(CLAWS_SPELL_ENTRY(subject_entry), gtkaspell); -#endif - compose_select_account(compose, account, TRUE); cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Edit/AutoWrap", prefs_common.autowrap); @@ -8373,12 +8111,6 @@ static void compose_destroy(Compose *compose) if (addressbook_get_target_compose() == compose) addressbook_set_target_compose(NULL); -#if USE_ENCHANT - if (compose->gtkaspell) { - gtkaspell_delete(compose->gtkaspell); - compose->gtkaspell = NULL; - } -#endif if (!compose->batch) { gtk_window_get_size(GTK_WINDOW(compose->window), @@ -9056,9 +8788,6 @@ static char *ext_editor_menu_entries[] = { "Menu/Message/Save", "Menu/Message/Print", "Menu/Edit", -#if USE_ENCHANT - "Menu/Spelling", -#endif "Menu/Tools/Actions", NULL }; @@ -9369,9 +9098,6 @@ static void compose_allow_user_actions (Compose *compo 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_ENCHANT - cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", allow); -#endif cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options", allow); cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Tools", allow); @@ -9805,12 +9531,6 @@ static void compose_insert_file_cb(GtkAction *action, } g_list_free(file_list); } - -#ifdef USE_ENCHANT - if (files_inserted > 0 && compose->gtkaspell && - compose->gtkaspell->check_while_typing) - gtkaspell_highlight_all(compose->gtkaspell); -#endif } static void compose_insert_sig_cb(GtkAction *action, gpointer data) @@ -10209,13 +9929,6 @@ static void compose_paste_cb(GtkAction *action, gpoint GtkTextBuffer *buffer; if (compose->focused_editable && gtk_widget_has_focus(compose->focused_editable)) entry_paste_clipboard(compose, compose->focused_editable, GDK_SELECTION_CLIPBOARD, NULL); - -#ifdef USE_ENCHANT - if (gtk_widget_has_focus(compose->text) && - compose->gtkaspell && - compose->gtkaspell->check_while_typing) - gtkaspell_highlight_all(compose->gtkaspell); -#endif } static void compose_paste_as_quote_cb(GtkAction *action, gpointer data) @@ -11072,61 +10785,6 @@ static void text_inserted(GtkTextBuffer *buffer, GtkTe (500, (GSourceFunc) compose_defer_auto_save_draft, compose); } -#if USE_ENCHANT -static void compose_check_all(GtkAction *action, gpointer data) -{ - Compose *compose = (Compose *)data; - if (!compose->gtkaspell) - return; - - if (gtk_widget_has_focus(compose->subject_entry)) - claws_spell_entry_check_all( - CLAWS_SPELL_ENTRY(compose->subject_entry)); - else - gtkaspell_check_all(compose->gtkaspell); -} - -static void compose_highlight_all(GtkAction *action, gpointer data) -{ - Compose *compose = (Compose *)data; - if (compose->gtkaspell) { - claws_spell_entry_recheck_all( - CLAWS_SPELL_ENTRY(compose->subject_entry)); - gtkaspell_highlight_all(compose->gtkaspell); - } -} - -static void compose_check_backwards(GtkAction *action, gpointer data) -{ - Compose *compose = (Compose *)data; - if (!compose->gtkaspell) { - cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", FALSE); - return; - } - - if (gtk_widget_has_focus(compose->subject_entry)) - claws_spell_entry_check_backwards( - CLAWS_SPELL_ENTRY(compose->subject_entry)); - else - gtkaspell_check_backwards(compose->gtkaspell); -} - -static void compose_check_forwards_go(GtkAction *action, gpointer data) -{ - Compose *compose = (Compose *)data; - if (!compose->gtkaspell) { - cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", FALSE); - return; - } - - if (gtk_widget_has_focus(compose->subject_entry)) - claws_spell_entry_check_forwards_go( - CLAWS_SPELL_ENTRY(compose->subject_entry)); - else - gtkaspell_check_forwards_go(compose->gtkaspell); -} -#endif - /*! *\brief Guess originating forward account from MsgInfo and several * "common preference" settings. Return NULL if no guess. @@ -11472,29 +11130,6 @@ static MsgInfo *compose_msginfo_new_from_compose(Compo return newmsginfo; } -#ifdef USE_ENCHANT -/* update compose's dictionaries from folder dict settings */ -static void compose_set_dictionaries_from_folder_prefs(Compose *compose, - FolderItem *folder_item) -{ - cm_return_if_fail(compose != NULL); - - if (compose->gtkaspell && folder_item && folder_item->prefs) { - FolderItemPrefs *prefs = folder_item->prefs; - - if (prefs->enable_default_dictionary) - gtkaspell_change_dict(compose->gtkaspell, - prefs->default_dictionary, FALSE); - if (folder_item->prefs->enable_default_alt_dictionary) - gtkaspell_change_alt_dict(compose->gtkaspell, - prefs->default_alt_dictionary); - if (prefs->enable_default_dictionary - || prefs->enable_default_alt_dictionary) - compose_spell_menu_changed(compose); - } -} -#endif - static void compose_subject_entry_activated(GtkWidget *widget, gpointer data) { Compose *compose = (Compose *)data; blob - 76f8ea48e54df71b3c7fe73f3b16c647c14f7ff3 blob + 6d9dad3b3ef91080050bfc713a91197500bb1333 --- src/compose.h +++ src/compose.h @@ -36,10 +36,6 @@ typedef struct _AttachInfo AttachInfo; #include "viewtypes.h" #include "folder.h" -#ifdef USE_ENCHANT -#include "gtkaspell.h" -#endif - #define COMPOSE_CHECK_BEFORE_SEND_HOOKLIST "compose_check_before_send" #define COMPOSE_CREATED_HOOKLIST "compose_created" @@ -253,11 +249,6 @@ struct _Compose GtkUIManager *ui_manager; gint folder_update_callback_id; -#if USE_ENCHANT - /* GNU/aspell spell checker */ - GtkAspell *gtkaspell; - GtkWidget *aspell_options_menu; -#endif }; struct _AttachInfo blob - 5a0a339b52006e573a1c76103bfc953c53c0fde0 blob + 24c720109cd9bd321c250caaee7bceb865bd43bd --- src/etpan/Makefile.am +++ src/etpan/Makefile.am @@ -25,13 +25,11 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/common \ -I$(top_srcdir)/src/gtk \ $(GTK_CFLAGS) \ - $(LIBETPAN_CFLAGS) \ - $(ENCHANT_CFLAGS) + $(LIBETPAN_CFLAGS) libclawsetpan_la_LIBADD = \ ../common/libclawscommon.la \ $(GTK_LIBS) \ - $(LIBETPAN_LIBS) \ - $(ENCHANT_LIBS) + $(LIBETPAN_LIBS) .PHONY: test blob - 09a3b9eabc4eefbe21584ecdf0f568b7049bf47a blob + 16905c1fff5db29bbb1998b7a41452f26e11b44e --- src/folder_item_prefs.c +++ src/folder_item_prefs.c @@ -71,16 +71,6 @@ static PrefParam param[] = { NULL, NULL, NULL}, {"default_account", NULL, &tmp_prefs.default_account, P_INT, NULL, NULL, NULL}, -#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, - NULL, NULL, NULL}, - {"enable_default_alt_dictionary", "", &tmp_prefs.enable_default_alt_dictionary, P_BOOL, - NULL, NULL, NULL}, - {"default_alt_dictionary", NULL, &tmp_prefs.default_alt_dictionary, P_STRING, - NULL, NULL, NULL}, -#endif {"always_sign", "0", &tmp_prefs.always_sign, P_ENUM, NULL, NULL, NULL}, {"always_encrypt", "0", &tmp_prefs.always_encrypt, P_ENUM, @@ -204,12 +194,6 @@ static FolderItemPrefs *folder_item_prefs_clear(Folder prefs->folder_chmod = 0; prefs->enable_default_account = FALSE; prefs->default_account = 0; -#if USE_ENCHANT - prefs->enable_default_dictionary = FALSE; - prefs->default_dictionary = NULL; - prefs->enable_default_alt_dictionary = FALSE; - prefs->default_alt_dictionary = NULL; -#endif prefs->always_sign = SIGN_OR_ENCRYPT_DEFAULT; prefs->always_encrypt = SIGN_OR_ENCRYPT_DEFAULT; prefs->save_copy_to_folder = FALSE; @@ -312,12 +296,6 @@ void folder_item_prefs_copy_prefs(FolderItem * src, Fo 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_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; - tmp_prefs.default_alt_dictionary = g_strdup(src->prefs->default_alt_dictionary); -#endif tmp_prefs.always_sign = src->prefs->always_sign; tmp_prefs.always_encrypt = src->prefs->always_encrypt; tmp_prefs.save_copy_to_folder = src->prefs->save_copy_to_folder; blob - 6998c48efc0eef7ae16f84de4a831b5aec123889 blob + cc9b7dc6cfa3fa2411acdd5216544a4a1dc59bba --- src/folder_item_prefs.h +++ src/folder_item_prefs.h @@ -80,10 +80,6 @@ struct _FolderItemPrefs { gboolean enable_default_account; gint default_account; - gboolean enable_default_dictionary; - gchar *default_dictionary; - gboolean enable_default_alt_dictionary; - gchar *default_alt_dictionary; SignOrEncryptType always_sign; SignOrEncryptType always_encrypt; gboolean save_copy_to_folder; blob - dc7ec56b1814f5895be45dac69f06be45b5b2c42 blob + 08b7a7a6437bd1c16090983d345af15a7237bfb6 --- src/gtk/Makefile.am +++ src/gtk/Makefile.am @@ -16,7 +16,6 @@ libclawsgtk_la_SOURCES = \ description_window.c \ filesel.c \ foldersort.c \ - gtkaspell.c \ gtkcmctree.c \ gtkcmclist.c \ gtksctree.c \ @@ -31,7 +30,6 @@ libclawsgtk_la_SOURCES = \ prefswindow.c \ progressdialog.c \ quicksearch.c \ - spell_entry.c \ sslcertwindow.c \ claws-marshal.c @@ -43,7 +41,6 @@ clawsgtkinclude_HEADERS = \ description_window.h \ filesel.h \ foldersort.h \ - gtkaspell.h \ gtkutils.h \ gtkunit.h \ gtkvscrollbutton.h \ @@ -56,7 +53,6 @@ clawsgtkinclude_HEADERS = \ prefswindow.h \ progressdialog.h \ quicksearch.h \ - spell_entry.h \ sslcertwindow.h \ claws-marshal.h \ gtkcmctree.h \ @@ -69,13 +65,11 @@ AM_CPPFLAGS = \ -I$(srcdir)/.. \ -I$(builddir)/.. \ $(GTK_CFLAGS) \ - $(ENCHANT_CFLAGS) \ -DDOCDIR=\"$(DOCDIR)\" libclawsgtk_la_LIBADD = \ ../common/libclawscommon.la \ - $(GTK_LIBS) \ - $(ENCHANT_LIBS) + $(GTK_LIBS) BUILT_SOURCES=claws-marshal.c claws-marshal.h blob - be2f8fcd6970e73a2aeb62c74c64f71f6b46dbdb blob + b8fdf2e2af67e6d60dff38dcacab72e04ca04eec --- src/gtk/about.c +++ src/gtk/about.c @@ -378,16 +378,6 @@ static GtkWidget *about_create_child_page_features(voi stock_pixbuf_gdk(STOCK_PIXMAP_CHECKBOX_ON, &active_pixbuf); stock_pixbuf_gdk(STOCK_PIXMAP_CHECKBOX_OFF, &inactive_pixbuf); -#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, (" Enchant "), -1, - "bold", NULL); - gtk_text_buffer_insert(buffer, &iter, - (gchar *)C_("Enchant", "adds support for spell checking\n"), -1); - #if USE_GNUTLS gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf); #else blob - 839230ea5f72240c55185a4a06dd72bcf3f68749 (mode 644) blob + /dev/null --- src/gtk/gtkaspell.c +++ /dev/null @@ -1,2351 +0,0 @@ -/* gtkaspell - a spell-checking addon for GtkText - * Copyright (c) 2000 Evan Martin (original code for ispell). - * Copyright (c) 2002 Melvin Hadasht. - * Copyright (C) 2001-2025 the Claws Mail Team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ -/* - * Stuphead: (C) 2000,2001 Grigroy Bakunov, Sergey Pinaev - * Adapted for Sylpheed (Claws) (c) 2001-2002 by Hiroyuki Yamamoto & - * The Claws Mail Team. - * Adapted for pspell (c) 2001-2002 Melvin Hadasht - * Adapted for GNU/aspell (c) 2002 Melvin Hadasht - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#include "claws-features.h" -#endif - -#ifdef USE_ENCHANT - -#include -#include -#include -#include -#if HAVE_SYS_WAIT_H -# include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include "utils.h" -#include "alertpanel.h" -#include "gtkaspell.h" -#include "gtk/gtkutils.h" -#include "gtk/combobox.h" - -#define ASPELL_FASTMODE 1 -#define ASPELL_NORMALMODE 2 -#define ASPELL_BADSPELLERMODE 3 - -/* size of the text buffer used in various word-processing routines. */ -#define BUFSIZE 1024 - -/* number of suggestions to display on each menu. */ -#define MENUCOUNT 15 - -enum { - SET_GTKASPELL_NAME = 0, - SET_GTKASPELL_FULLNAME = 1, - SET_GTKASPELL_SIZE -}; - -typedef struct _GtkAspellCheckers { - GSList *checkers; - GSList *dictionary_list; - gchar *error_message; -} GtkAspellCheckers; - -/******************************************************************************/ - -static GtkAspellCheckers *gtkaspellcheckers; - -/* Error message storage */ -static void gtkaspell_checkers_error_message (gchar *message); - -/* Callbacks */ -static gboolean key_press_cb (GtkWidget *text_view, - GdkEventKey *event, - GtkAspell *gtkaspell); -static void entry_insert_cb (GtkTextBuffer *textbuf, - GtkTextIter *iter, - gchar *newtext, - gint len, - GtkAspell *gtkaspell); -static void entry_delete_cb (GtkTextBuffer *textbuf, - GtkTextIter *startiter, - GtkTextIter *enditer, - GtkAspell *gtkaspell); -/*static gint button_press_intercept_cb (GtkTextView *gtktext, - GdkEvent *e, - GtkAspell *gtkaspell); -*/ -static void button_press_intercept_cb(GtkTextView *gtktext, - GtkMenu *menu, GtkAspell *gtkaspell); - -/* Checker creation */ -static GtkAspeller* gtkaspeller_new (Dictionary *dict); -static GtkAspeller* gtkaspeller_real_new (Dictionary *dict); -static void gtkaspeller_delete (GtkAspeller *gtkaspeller); -static GtkAspeller* gtkaspeller_real_delete (GtkAspeller *gtkaspeller); - -/* Checker configuration */ -static EnchantDict *set_dictionary (EnchantBroker *broker, - Dictionary *dict); -static void set_use_both_cb (GtkMenuItem *w, - GtkAspell *gtkaspell); - -/* Checker actions */ -static gboolean check_at (GtkAspell *gtkaspell, - int from_pos); -static gboolean check_at_cb (gpointer data); -static GList* misspelled_suggest (GtkAspell *gtkaspell, - gchar *word); -static gboolean find_misspelled_cb (gpointer data, - gboolean forward); -static void add_word_to_session_cb (GtkWidget *w, - gpointer data); -static void add_word_to_personal_cb (GtkWidget *w, - gpointer data); -static void replace_with_create_dialog_cb (GtkWidget *w, - gpointer data); -static void replace_with_supplied_word_cb (GtkWidget *w, - GtkAspell *gtkaspell); -static void replace_word_cb (GtkWidget *w, - gpointer data); -static void replace_real_word (GtkAspell *gtkaspell, - const gchar *newword); -static void replace_real_word_cb (gpointer data, - const gchar *newword); -static void check_with_alternate_cb (GtkWidget *w, - gpointer data); -static void toggle_check_while_typing_cb (GtkWidget *w, - gpointer data); - -/* Menu creation */ -static GSList* make_sug_menu (GtkAspell *gtkaspell); -static GSList * populate_submenu (GtkAspell *gtkaspell); -GSList* gtkaspell_make_config_menu (GtkAspell *gtkaspell); -static void set_menu_pos (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer data); -/* Other menu callbacks */ -static gboolean aspell_key_pressed (GtkWidget *widget, - GdkEventKey *event, - GtkAspell *gtkaspell); -static void change_dict_cb (GtkWidget *w, - GtkAspell *gtkaspell); -static void switch_to_alternate_cb (GtkWidget *w, - gpointer data); - -/* Misc. helper functions */ -static void set_point_continue (GtkAspell *gtkaspell); -static void continue_check (gpointer *gtkaspell); -static gboolean iswordsep (gunichar c); -static gunichar get_text_index_whar (GtkAspell *gtkaspell, - int pos); -static gboolean get_word_from_pos (GtkAspell *gtkaspell, - gint pos, - char* buf, - gint buflen, - gint *pstart, - gint *pend); -static void allocate_color (GtkAspell *gtkaspell, - GdkRGBA rgbvalue); -static void change_color (GtkAspell *gtkaspell, - gint start, - gint end, - gchar *newtext, - gboolean colorize); -static gint compare_dict (Dictionary *a, - Dictionary *b); -static void dictionary_delete (Dictionary *dict); -static Dictionary * dictionary_dup (const Dictionary *dict); -static void reset_theword_data (GtkAspell *gtkaspell); -static void free_checkers (gpointer elt, - gpointer data); - -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 (gint refresh); - -static void gtkaspell_uncheck_all (GtkAspell *gtkaspell); - -static gint get_textview_buffer_charcount(GtkTextView *view) -{ - GtkTextBuffer *buffer; - - cm_return_val_if_fail(view, 0); - - buffer = gtk_text_view_get_buffer(view); - cm_return_val_if_fail(buffer, 0); - - return gtk_text_buffer_get_char_count(buffer); -} -static gint get_textview_buffer_offset(GtkTextView *view) -{ - GtkTextBuffer * buffer; - GtkTextMark * mark; - GtkTextIter iter; - - cm_return_val_if_fail(view, 0); - - buffer = gtk_text_view_get_buffer(view); - cm_return_val_if_fail(buffer, 0); - - mark = gtk_text_buffer_get_insert(buffer); - cm_return_val_if_fail(mark, 0); - - gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); - - return gtk_text_iter_get_offset(&iter); -} -static void set_textview_buffer_offset(GtkTextView *view, gint offset) -{ - GtkTextBuffer *buffer; - GtkTextIter iter; - - cm_return_if_fail(view); - - buffer = gtk_text_view_get_buffer(view); - cm_return_if_fail(buffer); - - gtk_text_buffer_get_iter_at_offset(buffer, &iter, offset); - gtk_text_buffer_place_cursor(buffer, &iter); -} -/******************************************************************************/ - -void gtkaspell_checkers_init(void) -{ - gtkaspellcheckers = g_new(GtkAspellCheckers, 1); - gtkaspellcheckers->checkers = NULL; - gtkaspellcheckers->dictionary_list = NULL; - gtkaspellcheckers->error_message = NULL; -} - -void gtkaspell_checkers_quit(void) -{ - GSList *checkers; - GSList *dict_list; - - if (gtkaspellcheckers == NULL) - return; - - if ((checkers = gtkaspellcheckers->checkers)) { - debug_print("Aspell: number of running checkers to delete %d\n", - g_slist_length(checkers)); - - g_slist_foreach(checkers, free_checkers, NULL); - g_slist_free(checkers); - gtkaspellcheckers->checkers = NULL; - } - - if ((dict_list = gtkaspellcheckers->dictionary_list)) { - debug_print("Aspell: number of dictionaries to delete %d\n", - g_slist_length(dict_list)); - - gtkaspell_free_dictionary_list(dict_list); - gtkaspellcheckers->dictionary_list = NULL; - } - - g_free(gtkaspellcheckers->error_message); - gtkaspellcheckers->error_message = NULL; - return; -} - -static void gtkaspell_checkers_error_message (gchar *message) -{ - gchar *tmp; - if (gtkaspellcheckers->error_message) { - tmp = g_strdup_printf("%s\n%s", - gtkaspellcheckers->error_message, - message); - g_free(message); - g_free(gtkaspellcheckers->error_message); - gtkaspellcheckers->error_message = tmp; - } else - gtkaspellcheckers->error_message = message; - - -} - -const char *gtkaspell_checkers_strerror(void) -{ - cm_return_val_if_fail(gtkaspellcheckers, ""); - return gtkaspellcheckers->error_message; -} - -void gtkaspell_checkers_reset_error(void) -{ - cm_return_if_fail(gtkaspellcheckers); - - g_free(gtkaspellcheckers->error_message); - - gtkaspellcheckers->error_message = NULL; -} - -GtkAspell *gtkaspell_new(const gchar *dictionary, - const gchar *alt_dictionary, - const gchar *encoding, /* unused */ - GdkRGBA misspelled_color, - gboolean check_while_typing, - gboolean recheck_when_changing_dict, - gboolean use_alternate, - gboolean use_both_dicts, - GtkTextView *gtktext, - GtkWindow *parent_win, - void (dict_changed_cb)(void *data), - void (*spell_menu_cb)(void *data), - void *data) -{ - Dictionary *dict; - GtkAspell *gtkaspell; - GtkAspeller *gtkaspeller; - GtkTextBuffer *buffer; - - cm_return_val_if_fail(gtktext, 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); - 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); - } - - if (strchr(dict->fullname, '-')) { - *(strchr(dict->fullname, '-')) = '\0'; - *(strchr(dict->dictname, '-')) = '\0'; - } - gtkaspeller = gtkaspeller_new(dict); - dictionary_delete(dict); - - if (!gtkaspeller) { - gtkaspell_checkers_error_message( - g_strdup_printf(_("Couldn't initialize %s speller."), dictionary)); - return NULL; - } - - gtkaspell = g_new0(GtkAspell, 1); - - gtkaspell->gtkaspeller = gtkaspeller; - - if (use_alternate && alt_dictionary && *alt_dictionary) { - Dictionary *alt_dict; - GtkAspeller *alt_gtkaspeller; - - alt_dict = g_new0(Dictionary, 1); - 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); - } - if (strchr(alt_dict->fullname, '-')) { - *(strchr(alt_dict->fullname, '-')) = '\0'; - *(strchr(alt_dict->dictname, '-')) = '\0'; - } - - alt_gtkaspeller = gtkaspeller_new(alt_dict); - dictionary_delete(alt_dict); - - if (!alt_gtkaspeller) { - gtkaspell_checkers_error_message( - g_strdup_printf(_("Couldn't initialize %s speller."), dictionary)); - gtkaspeller_delete(gtkaspeller); - g_free(gtkaspell); - return NULL; - } - - gtkaspell->alternate_speller = alt_gtkaspeller; - } else { - gtkaspell->alternate_speller = NULL; - } - - gtkaspell->theword[0] = 0x00; - gtkaspell->start_pos = 0; - gtkaspell->end_pos = 0; - gtkaspell->orig_pos = -1; - gtkaspell->end_check_pos = -1; - gtkaspell->misspelled = -1; - gtkaspell->check_while_typing = check_while_typing; - gtkaspell->recheck_when_changing_dict = recheck_when_changing_dict; - gtkaspell->continue_check = NULL; - gtkaspell->replace_entry = NULL; - gtkaspell->gtktext = gtktext; - gtkaspell->max_sug = -1; - gtkaspell->suggestions_list = NULL; - gtkaspell->use_alternate = use_alternate; - gtkaspell->use_both_dicts = use_both_dicts; - gtkaspell->parent_window = GTK_WIDGET(parent_win); - gtkaspell->dict_changed_cb = dict_changed_cb; - gtkaspell->menu_changed_cb = spell_menu_cb; - gtkaspell->menu_changed_data = data; - - allocate_color(gtkaspell, misspelled_color); - - g_signal_connect(G_OBJECT(gtktext), "key_press_event", - G_CALLBACK(key_press_cb), gtkaspell); - g_signal_connect_after(G_OBJECT(buffer), "insert-text", - G_CALLBACK(entry_insert_cb), gtkaspell); - g_signal_connect_after(G_OBJECT(buffer), "delete-range", - G_CALLBACK(entry_delete_cb), gtkaspell); - /*g_signal_connect(G_OBJECT(gtktext), "button-press-event", - G_CALLBACK(button_press_intercept_cb), - gtkaspell);*/ - g_signal_connect(G_OBJECT(gtktext), "populate-popup", - G_CALLBACK(button_press_intercept_cb), gtkaspell); - - debug_print("Aspell: created gtkaspell %p\n", gtkaspell); - - return gtkaspell; -} - -void gtkaspell_delete(GtkAspell *gtkaspell) -{ - GtkTextView *gtktext = gtkaspell->gtktext; - - g_signal_handlers_disconnect_by_func(G_OBJECT(gtktext), - G_CALLBACK(key_press_cb), - gtkaspell); - g_signal_handlers_disconnect_by_func(G_OBJECT(gtktext), - G_CALLBACK(entry_insert_cb), - gtkaspell); - g_signal_handlers_disconnect_by_func(G_OBJECT(gtktext), - G_CALLBACK(entry_delete_cb), - gtkaspell); - g_signal_handlers_disconnect_by_func(G_OBJECT(gtktext), - G_CALLBACK(button_press_intercept_cb), - gtkaspell); - - gtkaspell_uncheck_all(gtkaspell); - - gtkaspeller_delete(gtkaspell->gtkaspeller); - - if (gtkaspell->alternate_speller) - gtkaspeller_delete(gtkaspell->alternate_speller); - - if (gtkaspell->suggestions_list) - gtkaspell_free_suggestions_list(gtkaspell); - - debug_print("Aspell: deleting gtkaspell %p\n", gtkaspell); - - g_free(gtkaspell); - - gtkaspell = NULL; -} - -void gtkaspell_dict_changed(GtkAspell *gtkaspell) -{ - if(!gtkaspell || !gtkaspell->dict_changed_cb || - !gtkaspell->menu_changed_data) - return; - - gtkaspell->dict_changed_cb(gtkaspell->menu_changed_data); -} - -static gboolean key_press_cb (GtkWidget *text_view, - GdkEventKey *event, - GtkAspell *gtkaspell) -{ - gint pos; - - cm_return_val_if_fail(gtkaspell->gtkaspeller->speller, FALSE); - - if (!gtkaspell->check_while_typing) - return FALSE; - - switch (event->keyval) { - case GDK_KEY_Home: - case GDK_KEY_Left: - case GDK_KEY_Up: - case GDK_KEY_Right: - case GDK_KEY_Down: - case GDK_KEY_Page_Up: - case GDK_KEY_Page_Down: - case GDK_KEY_End: - case GDK_KEY_Begin: - pos = get_textview_buffer_offset(GTK_TEXT_VIEW(text_view)); - if (pos > 0) - check_at(gtkaspell, pos - 1); - else - check_at(gtkaspell, pos); - break; - default: - break; - } - - return FALSE; -} - -static void entry_insert_cb(GtkTextBuffer *textbuf, - GtkTextIter *iter, - gchar *newtext, - gint len, - GtkAspell *gtkaspell) -{ - guint pos; - - cm_return_if_fail(gtkaspell->gtkaspeller->speller); - - if (!gtkaspell->check_while_typing) - return; - - pos = gtk_text_iter_get_offset(iter); - - if (iswordsep(g_utf8_get_char(newtext))) { - /* did we just end a word? */ - if (pos >= 2) - check_at(gtkaspell, pos - 2); - - /* did we just split a word? */ - if (pos < gtk_text_buffer_get_char_count(textbuf)) - check_at(gtkaspell, pos + 1); - } else { - /* check as they type, *except* if they're typing at the end (the most - * common case). - */ - if (pos < gtk_text_buffer_get_char_count(textbuf) && - !iswordsep(get_text_index_whar(gtkaspell, pos))) { - check_at(gtkaspell, pos - 1); - } - } -} - -static void entry_delete_cb(GtkTextBuffer *textbuf, - GtkTextIter *startiter, - GtkTextIter *enditer, - GtkAspell *gtkaspell) -{ - int origpos; - gint start; - - cm_return_if_fail(gtkaspell->gtkaspeller->speller); - - if (!gtkaspell->check_while_typing) - return; - - start = gtk_text_iter_get_offset(startiter); - origpos = get_textview_buffer_offset(gtkaspell->gtktext); - if (start) { - check_at(gtkaspell, start - 1); - check_at(gtkaspell, start); - } - - set_textview_buffer_offset(gtkaspell->gtktext, origpos); - /* this is to *UNDO* the selection, in case they were holding shift - * while hitting backspace. */ - /* needed with textview ??? */ - /* gtk_editable_select_region(GTK_EDITABLE(gtktext), origpos, origpos); */ -} - -void gtkaspell_make_context_menu(GtkMenu *menu, GtkAspell *gtkaspell) -{ - GtkMenuItem *menuitem; - GSList *spell_menu = NULL; - GSList *items; - gboolean suggest = FALSE; - - if (gtkaspell->misspelled && - misspelled_suggest(gtkaspell, gtkaspell->theword)) { - spell_menu = make_sug_menu(gtkaspell); - suggest = TRUE; - } - if (!spell_menu) - spell_menu = gtkaspell_make_config_menu(gtkaspell); - - menuitem = GTK_MENU_ITEM(gtk_separator_menu_item_new()); - gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), GTK_WIDGET(menuitem)); - gtk_widget_show(GTK_WIDGET(menuitem)); - - spell_menu = g_slist_reverse(spell_menu); - for (items = spell_menu; - items; items = items->next) { - menuitem = GTK_MENU_ITEM(items->data); - gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), GTK_WIDGET(menuitem)); - gtk_widget_show(GTK_WIDGET(menuitem)); - } - g_slist_free(spell_menu); - - g_signal_connect(G_OBJECT(menu), "deactivate", - G_CALLBACK(destroy_menu), - gtkaspell); - if (suggest) - g_signal_connect(G_OBJECT(menu), - "key_press_event", - G_CALLBACK(aspell_key_pressed), - gtkaspell); -} - -static void set_position_cb(gpointer data, gint pos) -{ - GtkAspell *gtkaspell = (GtkAspell *) data; - set_textview_buffer_offset(gtkaspell->gtktext, pos); -} - -void gtkaspell_context_set(GtkAspell *gtkaspell) -{ - gtkaspell->ctx.set_position = set_position_cb; - gtkaspell->ctx.set_menu_pos = set_menu_pos; - gtkaspell->ctx.find_misspelled = find_misspelled_cb; - gtkaspell->ctx.check_word = check_at_cb; - gtkaspell->ctx.replace_word = replace_real_word_cb; - gtkaspell->ctx.data = (gpointer) gtkaspell; -} - -static void button_press_intercept_cb(GtkTextView *gtktext, - GtkMenu *menu, GtkAspell *gtkaspell) -{ - gtktext = gtkaspell->gtktext; - gtkaspell->orig_pos = get_textview_buffer_offset(gtktext); - gtkaspell->misspelled = check_at(gtkaspell, gtkaspell->orig_pos); - - gtkaspell_context_set(gtkaspell); - gtkaspell_make_context_menu(menu, gtkaspell); -} -/* Checker creation */ -static GtkAspeller *gtkaspeller_new(Dictionary *dictionary) -{ - GtkAspeller *gtkaspeller = NULL; - Dictionary *dict; - - cm_return_val_if_fail(gtkaspellcheckers, NULL); - - cm_return_val_if_fail(dictionary, NULL); - - if (dictionary->dictname == NULL) - gtkaspell_checkers_error_message( - g_strdup(_("No dictionary selected."))); - - cm_return_val_if_fail(dictionary->fullname, NULL); - - dict = dictionary_dup(dictionary); - - if ((gtkaspeller = gtkaspeller_real_new(dict)) != NULL) { - gtkaspellcheckers->checkers = g_slist_append( - gtkaspellcheckers->checkers, - gtkaspeller); - - debug_print("Aspell: Created a new gtkaspeller %p\n", - gtkaspeller); - } else { - dictionary_delete(dict); - - debug_print("Aspell: Could not create spell checker.\n"); - } - - debug_print("Aspell: number of existing checkers %d\n", - g_slist_length(gtkaspellcheckers->checkers)); - - return gtkaspeller; -} - -static GtkAspeller *gtkaspeller_real_new(Dictionary *dict) -{ - GtkAspeller *gtkaspeller; - EnchantBroker *broker; - EnchantDict *speller; - - cm_return_val_if_fail(gtkaspellcheckers, NULL); - cm_return_val_if_fail(dict, NULL); - - gtkaspeller = g_new(GtkAspeller, 1); - - gtkaspeller->dictionary = dict; - - broker = enchant_broker_init(); - - if (!broker) { - gtkaspell_checkers_error_message( - g_strdup(_("Couldn't initialize Enchant broker."))); - g_free(gtkaspeller); - return NULL; - } - 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))); - g_free(gtkaspeller); - return NULL; - } - gtkaspeller->speller = speller; - gtkaspeller->broker = broker; - - return gtkaspeller; -} - -static void gtkaspeller_delete(GtkAspeller *gtkaspeller) -{ - cm_return_if_fail(gtkaspellcheckers); - - gtkaspellcheckers->checkers = - g_slist_remove(gtkaspellcheckers->checkers, - gtkaspeller); - - debug_print("Aspell: Deleting gtkaspeller %p.\n", - gtkaspeller); - - gtkaspeller_real_delete(gtkaspeller); - - debug_print("Aspell: number of existing checkers %d\n", - g_slist_length(gtkaspellcheckers->checkers)); -} - -static GtkAspeller *gtkaspeller_real_delete(GtkAspeller *gtkaspeller) -{ - cm_return_val_if_fail(gtkaspeller, NULL); - cm_return_val_if_fail(gtkaspeller->speller, NULL); - - enchant_broker_free_dict(gtkaspeller->broker, gtkaspeller->speller); - enchant_broker_free(gtkaspeller->broker); - - dictionary_delete(gtkaspeller->dictionary); - - debug_print("Aspell: gtkaspeller %p deleted.\n", - gtkaspeller); - - g_free(gtkaspeller); - - return NULL; -} - -/*****************************************************************************/ -/* Checker configuration */ - -static EnchantDict *set_dictionary(EnchantBroker *broker, Dictionary *dict) -{ - cm_return_val_if_fail(broker, FALSE); - cm_return_val_if_fail(dict, FALSE); - - return enchant_broker_request_dict(broker, dict->dictname ); -} - -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)); - gtkaspell_dict_changed(gtkaspell); - - if (gtkaspell->menu_changed_cb) - gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); -} - -/* misspelled_suggest() - Create a suggestion list for word */ -static GList *misspelled_suggest(GtkAspell *gtkaspell, gchar *word) -{ - GList *list = NULL; - char **suggestions; - size_t num_sug, i; - cm_return_val_if_fail(word, NULL); - - if (*word == 0) - return NULL; - - gtkaspell_free_suggestions_list(gtkaspell); - - suggestions = enchant_dict_suggest(gtkaspell->gtkaspeller->speller, word, strlen(word), &num_sug); - list = g_list_append(list, g_strdup(word)); - if (suggestions == NULL || num_sug == 0) { - gtkaspell->max_sug = -1; - gtkaspell->suggestions_list = list; - return list; - } - for (i = 0; i < num_sug; i++) - list = g_list_append(list, g_strdup((gchar *)suggestions[i])); - - 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 */ -int gtkaspell_misspelled_test(GtkAspell *gtkaspell, char *word) -{ - gint result = 0; - cm_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) { - gtkaspell_use_alternate_dict(gtkaspell); - result = enchant_dict_check(gtkaspell->gtkaspeller->speller, word, strlen(word)); - gtkaspell_use_alternate_dict(gtkaspell); - } - return (result && strcasecmp(word, "sylpheed") && - strcasecmp(word, "claws-mail")); -} - - -static gboolean iswordsep(gunichar c) -{ - return (g_unichar_isspace(c) || g_unichar_ispunct(c)) && c != (gunichar)'\''; -} - -static gunichar get_text_index_whar(GtkAspell *gtkaspell, int pos) -{ - GtkTextView *view = gtkaspell->gtktext; - GtkTextBuffer *buffer = gtk_text_view_get_buffer(view); - GtkTextIter start, end; - gchar *utf8chars; - gunichar a = '\0'; - - gtk_text_buffer_get_iter_at_offset(buffer, &start, pos); - gtk_text_buffer_get_iter_at_offset(buffer, &end, pos+1); - - utf8chars = gtk_text_iter_get_text(&start, &end); - a = g_utf8_get_char(utf8chars); - g_free(utf8chars); - - return a; -} - -/* get_word_from_pos () - return the word pointed to. */ -/* Handles correctly the quotes. */ -static gboolean get_word_from_pos(GtkAspell *gtkaspell, gint pos, - char* buf, gint buflen, - gint *pstart, gint *pend) -{ - - /* TODO : when correcting a word into quotes, change the color of */ - /* the quotes too, as may be they were highlighted before. To do */ - /* this, we can use two others pointers that points to the whole */ - /* word including quotes. */ - - gint start; - gint end; - - gunichar c; - GtkTextView *gtktext; - - gtktext = gtkaspell->gtktext; - if (iswordsep(get_text_index_whar(gtkaspell, pos))) - return FALSE; - - /* The apostrophe character is somtimes used for quotes - * So include it in the word only if it is not surrounded - * by other characters. - */ - - for (start = pos; start >= 0; --start) { - c = get_text_index_whar(gtkaspell, start); - if (c == (gunichar)'\'') { - if (start > 0) { - if (g_unichar_isspace(get_text_index_whar(gtkaspell, - start - 1)) - || g_unichar_ispunct(get_text_index_whar(gtkaspell, - start - 1)) - || g_unichar_isdigit(get_text_index_whar(gtkaspell, - start - 1))) { - /* start_quote = TRUE; */ - break; - } - } - else { - /* start_quote = TRUE; */ - break; - } - } - else if (g_unichar_isspace(c) || g_unichar_ispunct(c) || g_unichar_isdigit(c)) - break; - } - - start++; - - for (end = pos; end < get_textview_buffer_charcount(gtktext); end++) { - c = get_text_index_whar(gtkaspell, end); - if (c == (gunichar)'\'') { - if (end < get_textview_buffer_charcount(gtktext)) { - if (g_unichar_isspace(get_text_index_whar(gtkaspell, - end + 1)) - || g_unichar_ispunct(get_text_index_whar(gtkaspell, - end + 1)) - || g_unichar_isdigit(get_text_index_whar(gtkaspell, - end + 1))) { - /* end_quote = TRUE; */ - break; - } - } - else { - /* end_quote = TRUE; */ - break; - } - } - else if (g_unichar_isspace(c) || g_unichar_ispunct(c) || g_unichar_isdigit(c)) - break; - } - - if (pstart) - *pstart = start; - if (pend) - *pend = end; - - if (buf) { - if (end - start < buflen) { - GtkTextIter iterstart, iterend; - 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); - strncpy(buf, tmp, buflen-1); - buf[buflen-1]='\0'; - g_free(tmp); - } else - return FALSE; - } - - return TRUE; -} - -static gboolean check_at(GtkAspell *gtkaspell, gint from_pos) -{ - gint start, end; - char buf[GTKASPELLWORDSIZE]; - - cm_return_val_if_fail(from_pos >= 0, FALSE); - - if (!get_word_from_pos(gtkaspell, from_pos, buf, sizeof(buf), - &start, &end)) - return FALSE; - - if (gtkaspell_misspelled_test(gtkaspell, buf)) { - strncpy(gtkaspell->theword, (gchar *)buf, GTKASPELLWORDSIZE - 1); - gtkaspell->theword[GTKASPELLWORDSIZE - 1] = 0; - gtkaspell->start_pos = start; - gtkaspell->end_pos = end; - gtkaspell_free_suggestions_list(gtkaspell); - - change_color(gtkaspell, start, end, (gchar *)buf, TRUE); - return TRUE; - } else { - change_color(gtkaspell, start, end, (gchar *)buf, FALSE); - return FALSE; - } -} - -static gboolean check_at_cb(gpointer data) -{ - GtkAspell *gtkaspell = (GtkAspell *)data; - return check_at(gtkaspell, gtkaspell->start_pos); -} - -static gboolean find_misspelled_cb(gpointer data, gboolean forward) -{ - GtkAspell *gtkaspell = (GtkAspell *)data; - gboolean misspelled; - gint pos; - gint minpos; - gint maxpos; - gint direc = -1; - - minpos = 0; - maxpos = gtkaspell->end_check_pos; - - if (forward) { - minpos = -1; - direc = 1; - maxpos--; - } - - pos = get_textview_buffer_offset(gtkaspell->gtktext); - gtkaspell->orig_pos = pos; - while (iswordsep(get_text_index_whar(gtkaspell, pos)) && - pos > minpos && pos <= maxpos) - pos += direc; - while (!(misspelled = check_at(gtkaspell, pos)) && - pos > minpos && pos <= maxpos) { - - while (!iswordsep(get_text_index_whar(gtkaspell, pos)) && - pos > minpos && pos <= maxpos) - pos += direc; - - while (iswordsep(get_text_index_whar(gtkaspell, pos)) && - pos > minpos && pos <= maxpos) - pos += direc; - } - - return misspelled; -} - -gboolean gtkaspell_check_next_prev(GtkAspell *gtkaspell, gboolean forward) -{ - gboolean misspelled = gtkaspell->ctx.find_misspelled(gtkaspell->ctx.data, - forward); - if (misspelled) { - GSList *list, *cur; - GtkWidget *menu; - misspelled_suggest(gtkaspell, gtkaspell->theword); - - if (forward) - gtkaspell->orig_pos = gtkaspell->end_pos; - - gtkaspell->ctx.set_position(gtkaspell->ctx.data, gtkaspell->end_pos); - - /* only execute when in textview context */ - if (gtkaspell == (GtkAspell *)gtkaspell->ctx.data) { - /* scroll line to window center */ - gtk_text_view_scroll_to_mark(gtkaspell->gtktext, - gtk_text_buffer_get_insert( - gtk_text_view_get_buffer(gtkaspell->gtktext)), - 0.0, TRUE, 0.0, 0.5); - /* let textview recalculate coordinates (set_menu_pos) */ - while (gtk_events_pending ()) - gtk_main_iteration (); - } - - list = make_sug_menu(gtkaspell); - menu = gtk_menu_new(); - for (cur = list; cur; cur = cur->next) - gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(cur->data)); - g_slist_free(list); - gtk_menu_popup_at_pointer(GTK_MENU(menu), NULL); - g_signal_connect(G_OBJECT(menu), "deactivate", - G_CALLBACK(destroy_menu), - gtkaspell); - g_signal_connect(G_OBJECT(menu), - "key_press_event", - G_CALLBACK(aspell_key_pressed), - gtkaspell); - - - } else { - reset_theword_data(gtkaspell); - - alertpanel_notice(_("No misspelled word found.")); - gtkaspell->ctx.set_position(gtkaspell->ctx.data, - gtkaspell->orig_pos); - } - - return misspelled; -} - -void gtkaspell_check_backwards(GtkAspell *gtkaspell) -{ - gtkaspell->continue_check = NULL; - gtkaspell->end_check_pos = - get_textview_buffer_charcount(gtkaspell->gtktext); - gtkaspell_context_set(gtkaspell); - gtkaspell_check_next_prev(gtkaspell, FALSE); -} - -void gtkaspell_check_forwards_go(GtkAspell *gtkaspell) -{ - - gtkaspell->continue_check = NULL; - gtkaspell->end_check_pos = - get_textview_buffer_charcount(gtkaspell->gtktext); - gtkaspell_context_set(gtkaspell); - gtkaspell_check_next_prev(gtkaspell, TRUE); -} - -void gtkaspell_check_all(GtkAspell *gtkaspell) -{ - GtkTextView *gtktext; - gint start, end; - GtkTextBuffer *buffer; - GtkTextIter startiter, enditer; - - cm_return_if_fail(gtkaspell); - cm_return_if_fail(gtkaspell->gtktext); - - gtktext = gtkaspell->gtktext; - buffer = gtk_text_view_get_buffer(gtktext); - gtk_text_buffer_get_selection_bounds(buffer, &startiter, &enditer); - start = gtk_text_iter_get_offset(&startiter); - end = gtk_text_iter_get_offset(&enditer); - - if (start == end) { - start = 0; - end = gtk_text_buffer_get_char_count(buffer); - } else if (start > end) { - gint tmp; - - tmp = start; - start = end; - end = tmp; - } - - set_textview_buffer_offset(gtktext, start); - - gtkaspell->continue_check = continue_check; - gtkaspell->end_check_pos = end; - - gtkaspell_context_set(gtkaspell); - gtkaspell->misspelled = gtkaspell_check_next_prev(gtkaspell, TRUE); -} - -static void continue_check(gpointer *data) -{ - GtkAspell *gtkaspell = (GtkAspell *) data; - gint pos = get_textview_buffer_offset(gtkaspell->gtktext); - if (pos < gtkaspell->end_check_pos && gtkaspell->misspelled) - gtkaspell->misspelled = gtkaspell_check_next_prev(gtkaspell, TRUE); - else - gtkaspell->continue_check = NULL; -} - -void gtkaspell_highlight_all(GtkAspell *gtkaspell) -{ - guint origpos; - guint pos = 0; - guint len; - GtkTextView *gtktext; - - cm_return_if_fail(gtkaspell->gtkaspeller->speller); - - gtktext = gtkaspell->gtktext; - - len = get_textview_buffer_charcount(gtktext); - - origpos = get_textview_buffer_offset(gtktext); - - while (pos < len) { - while (pos < len && - iswordsep(get_text_index_whar(gtkaspell, pos))) - pos++; - while (pos < len && - !iswordsep(get_text_index_whar(gtkaspell, pos))) - pos++; - if (pos > 0) - check_at(gtkaspell, pos - 1); - } - set_textview_buffer_offset(gtktext, origpos); -} - -static void replace_with_supplied_word_cb(GtkWidget *w, GtkAspell *gtkaspell) -{ - char *newword; - GdkEvent *e= (GdkEvent *) gtk_get_current_event(); - - newword = gtk_editable_get_chars(GTK_EDITABLE(gtkaspell->replace_entry), - 0, -1); - - if (strcmp(newword, gtkaspell->theword)) { - gtkaspell->ctx.replace_word(gtkaspell->ctx.data, newword); - - if ((e->type == GDK_KEY_PRESS && - ((GdkEventKey *) e)->state & GDK_CONTROL_MASK)) { - enchant_dict_store_replacement(gtkaspell->gtkaspeller->speller, - gtkaspell->theword, strlen(gtkaspell->theword), - newword, strlen(newword)); - } - gtkaspell->replace_entry = NULL; - } - - g_free(newword); - - if (w && GTK_IS_DIALOG(w)) { - gtk_widget_destroy(w); - } - - set_point_continue(gtkaspell); -} - - -static void replace_word_cb(GtkWidget *w, gpointer data) -{ - const char *newword; - GtkAspell *gtkaspell = (GtkAspell *) data; - GdkEvent *e= (GdkEvent *) gtk_get_current_event(); - - newword = gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN((w))))); - - gtkaspell->ctx.replace_word(gtkaspell->ctx.data, newword); - - if ((e->type == GDK_KEY_PRESS && - ((GdkEventKey *) e)->state & GDK_CONTROL_MASK) || - (e->type == GDK_BUTTON_RELEASE && - ((GdkEventButton *) e)->state & GDK_CONTROL_MASK)) { - enchant_dict_store_replacement(gtkaspell->gtkaspeller->speller, - gtkaspell->theword, strlen(gtkaspell->theword), - newword, strlen(newword)); - } - - gtk_menu_shell_deactivate(GTK_MENU_SHELL(gtk_widget_get_parent(w))); - - set_point_continue(gtkaspell); -} - -void gtkaspell_block_check(GtkAspell *gtkaspell) -{ - GtkTextView *gtktext; - - if (gtkaspell == NULL) - return; - - gtktext = gtkaspell->gtktext; - g_signal_handlers_block_by_func(G_OBJECT(gtktext), - G_CALLBACK(key_press_cb), - gtkaspell); - g_signal_handlers_block_by_func(G_OBJECT(gtktext), - G_CALLBACK(entry_insert_cb), - gtkaspell); - g_signal_handlers_block_by_func(G_OBJECT(gtktext), - G_CALLBACK(entry_delete_cb), - gtkaspell); -} - -void gtkaspell_unblock_check(GtkAspell *gtkaspell) -{ - GtkTextView *gtktext; - - if (gtkaspell == NULL) - return; - - gtktext = gtkaspell->gtktext; - g_signal_handlers_unblock_by_func(G_OBJECT(gtktext), - G_CALLBACK(key_press_cb), - gtkaspell); - g_signal_handlers_unblock_by_func(G_OBJECT(gtktext), - G_CALLBACK(entry_insert_cb), - gtkaspell); - g_signal_handlers_unblock_by_func(G_OBJECT(gtktext), - G_CALLBACK(entry_delete_cb), - gtkaspell); -} - -static void replace_real_word(GtkAspell *gtkaspell, const gchar *newword) -{ - int oldlen, newlen; - gint origpos; - gint pos; - GtkTextView *gtktext; - GtkTextBuffer *textbuf; - GtkTextIter startiter, enditer; - - if (!newword) return; - - gtktext = gtkaspell->gtktext; - textbuf = gtk_text_view_get_buffer(gtktext); - - origpos = gtkaspell->orig_pos; - pos = origpos; - oldlen = gtkaspell->end_pos - gtkaspell->start_pos; - - newlen = strlen(newword); /* FIXME: multybyte characters? */ - - gtkaspell_block_check(gtkaspell); - - gtk_text_buffer_get_iter_at_offset(textbuf, &startiter, - gtkaspell->start_pos); - gtk_text_buffer_get_iter_at_offset(textbuf, &enditer, - gtkaspell->end_pos); - g_signal_emit_by_name(G_OBJECT(textbuf), "delete-range", - &startiter, &enditer, gtkaspell); - g_signal_emit_by_name(G_OBJECT(textbuf), "insert-text", - &startiter, newword, newlen, gtkaspell); - - gtkaspell_unblock_check(gtkaspell); - - /* Put the point and the position where we clicked with the mouse - * It seems to be a hack, as I must thaw,freeze,thaw the widget - * to let it update correctly the word insertion and then the - * point & position position. If not, SEGV after the first replacement - * If the new word ends before point, put the point at its end. - */ - - if (origpos - gtkaspell->start_pos < oldlen && - origpos - gtkaspell->start_pos >= 0) { - /* Original point was in the word. - * Let it there unless point is going to be outside of the word - */ - if (origpos - gtkaspell->start_pos >= newlen) { - pos = gtkaspell->start_pos + newlen; - } - } - else if (origpos >= gtkaspell->end_pos) { - /* move the position according to the change of length */ - pos = origpos + newlen - oldlen; - } - - gtkaspell->end_pos = gtkaspell->start_pos + strlen(newword); /* FIXME: multibyte characters? */ - - if (get_textview_buffer_charcount(gtktext) < pos) - pos = get_textview_buffer_charcount(gtktext); - gtkaspell->orig_pos = pos; - - set_textview_buffer_offset(gtktext, gtkaspell->orig_pos); -} - -static void replace_real_word_cb(gpointer data, const gchar *newword) -{ - replace_real_word((GtkAspell *)data, newword); -} - -/* Accept this word for this session */ -static void add_word_to_session_cb(GtkWidget *w, gpointer data) -{ - GtkAspell *gtkaspell = (GtkAspell *) data; - - enchant_dict_add_to_session(gtkaspell->gtkaspeller->speller, gtkaspell->theword, strlen(gtkaspell->theword)); - - gtkaspell->ctx.check_word(gtkaspell->ctx.data); - gtkaspell_dict_changed(gtkaspell); - - gtk_menu_shell_deactivate(GTK_MENU_SHELL(gtk_widget_get_parent(w))); - - set_point_continue(gtkaspell); -} - -/* add_word_to_personal_cb() - add word to personal dict. */ -static void add_word_to_personal_cb(GtkWidget *w, gpointer data) -{ - GtkAspell *gtkaspell = (GtkAspell *) data; - - enchant_dict_add(gtkaspell->gtkaspeller->speller, gtkaspell->theword, strlen(gtkaspell->theword)); - - gtkaspell->ctx.check_word(gtkaspell->ctx.data); - gtkaspell_dict_changed(gtkaspell); - - gtk_menu_shell_deactivate(GTK_MENU_SHELL(gtk_widget_get_parent(w))); - set_point_continue(gtkaspell); -} - -static void check_with_alternate_cb(GtkWidget *w, gpointer data) -{ - GtkAspell *gtkaspell = (GtkAspell *)data; - gint misspelled; - - gtk_menu_shell_deactivate(GTK_MENU_SHELL(gtk_widget_get_parent(w))); - - gtkaspell_use_alternate_dict(gtkaspell); - misspelled = gtkaspell->ctx.check_word(gtkaspell->ctx.data); - - if (!gtkaspell->continue_check) { - - gtkaspell->misspelled = misspelled; - - if (gtkaspell->misspelled) { - GtkWidget *menu; - GSList *list, *cur; - misspelled_suggest(gtkaspell, gtkaspell->theword); - - gtkaspell->ctx.set_position(gtkaspell->ctx.data, - gtkaspell->end_pos); - - list = make_sug_menu(gtkaspell); - menu = gtk_menu_new(); - for (cur = list; cur; cur = cur->next) - gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(cur->data)); - g_slist_free(list); - gtk_menu_popup_at_pointer(GTK_MENU(menu), NULL); - g_signal_connect(G_OBJECT(menu), "deactivate", - G_CALLBACK(destroy_menu), - gtkaspell); - g_signal_connect(G_OBJECT(menu), - "key_press_event", - G_CALLBACK(aspell_key_pressed), - gtkaspell); - return; - } - } else - gtkaspell->orig_pos = gtkaspell->start_pos; - - set_point_continue(gtkaspell); -} - -static gboolean replace_key_pressed(GtkWidget *widget, - GdkEventKey *event, - GtkAspell *gtkaspell) -{ - if (event && event->keyval == GDK_KEY_Escape) { - gtk_widget_destroy(widget); - return TRUE; - } else if (event && (event->keyval == GDK_KEY_KP_Enter || - event->keyval == GDK_KEY_Return)) { - replace_with_supplied_word_cb(widget, gtkaspell); - return TRUE; - } - return FALSE; -} - -static void replace_with_create_dialog_cb(GtkWidget *w, gpointer data) -{ - static PangoFontDescription *font_desc; - GtkWidget *dialog; - GtkWidget *label; - GtkWidget *hbox; - GtkWidget *vbox; - GtkWidget *entry; - GtkWidget *ok_button; - GtkWidget *cancel_button; - GtkWidget *icon; - GtkWidget *parent_window; - GtkWidget *content_area; - gchar *utf8buf, *thelabel, *format; - gint xx, yy; - GtkAspell *gtkaspell = (GtkAspell *) data; - - cm_return_if_fail(w != NULL); - parent_window = gtk_widget_get_parent(w); - cm_return_if_fail(parent_window != NULL); - gdk_window_get_origin(gtk_widget_get_window(parent_window), &xx, &yy); - - gtk_menu_shell_deactivate(GTK_MENU_SHELL(gtk_widget_get_parent(w))); - - dialog = gtk_dialog_new(); - content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - - gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); - gtk_window_set_title(GTK_WINDOW(dialog),_("Replace unknown word")); - gtk_window_move(GTK_WINDOW(dialog), xx, yy); - - g_signal_connect_swapped(G_OBJECT(dialog), "destroy", - G_CALLBACK(gtk_widget_destroy), - G_OBJECT(dialog)); - - gtk_box_set_spacing (GTK_BOX (content_area), 14); - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); - gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0); - - utf8buf = g_strdup(gtkaspell->theword); - - format = g_strconcat("", - _("Replace \"%s\" with: "), "", NULL); - thelabel = g_strdup_printf(format, utf8buf); - g_free(format); - - icon = gtk_image_new_from_icon_name("dialog-question-symbolic", - GTK_ICON_SIZE_DIALOG); - gtk_widget_set_halign(icon, GTK_ALIGN_CENTER); - gtk_widget_set_valign(icon, GTK_ALIGN_START); - gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0); - - vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12); - gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - label = gtk_label_new(thelabel); - gtk_label_set_xalign(GTK_LABEL(label), 0.0); - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - if (!font_desc) { - gint size; - - size = pango_font_description_get_size - (gtk_widget_get_style(label)->font_desc); - font_desc = pango_font_description_new(); - pango_font_description_set_weight - (font_desc, PANGO_WEIGHT_BOLD); - pango_font_description_set_size - (font_desc, size * PANGO_SCALE_LARGE); - } - if (font_desc) - gtk_widget_override_font(label, font_desc); - g_free(thelabel); - - entry = gtk_entry_new(); - gtkaspell->replace_entry = entry; - gtk_entry_set_text(GTK_ENTRY(entry), utf8buf); - gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1); - g_signal_connect(G_OBJECT(dialog), - "key_press_event", - G_CALLBACK(replace_key_pressed), gtkaspell); - gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0); - g_free(utf8buf); - - label = gtk_label_new(_("Holding down Control key while pressing " - "Enter\nwill learn from mistake.\n")); - gtk_label_set_xalign(GTK_LABEL(label), 0.0); - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_widget_show(label); - - cancel_button = gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Cancel"), - GTK_RESPONSE_NONE); - ok_button = gtk_dialog_add_button(GTK_DIALOG(dialog),_("_OK"), - GTK_RESPONSE_NONE); - g_signal_connect(G_OBJECT(ok_button), "clicked", - G_CALLBACK(replace_with_supplied_word_cb), - gtkaspell); - g_signal_connect_swapped(G_OBJECT(ok_button), "clicked", - G_CALLBACK(gtk_widget_destroy), - G_OBJECT(dialog)); - - g_signal_connect_swapped(G_OBJECT(cancel_button), "clicked", - G_CALLBACK(gtk_widget_destroy), - G_OBJECT(dialog)); - - gtk_widget_grab_focus(entry); - - gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); - - gtk_widget_show_all(dialog); -} - -static void gtkaspell_uncheck_all(GtkAspell * gtkaspell) -{ - GtkTextView *gtktext; - GtkTextBuffer *buffer; - GtkTextIter startiter, enditer; - - gtktext = gtkaspell->gtktext; - - buffer = gtk_text_view_get_buffer(gtktext); - gtk_text_buffer_get_iter_at_offset(buffer, &startiter, 0); - gtk_text_buffer_get_iter_at_offset(buffer, &enditer, - get_textview_buffer_charcount(gtktext)-1); - gtk_text_buffer_remove_tag_by_name(buffer, "misspelled", - &startiter, &enditer); -} - -static void toggle_check_while_typing_cb(GtkWidget *w, gpointer data) -{ - GtkAspell *gtkaspell = (GtkAspell *) data; - - gtkaspell->check_while_typing = gtkaspell->check_while_typing == FALSE; - - if (!gtkaspell->check_while_typing) - gtkaspell_uncheck_all(gtkaspell); - if (gtkaspell->menu_changed_cb) - gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); -} - -static GSList *create_empty_dictionary_list(void) -{ - GSList *list = NULL; - Dictionary *dict; - - dict = g_new0(Dictionary, 1); - dict->fullname = g_strdup(_("None")); - 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(gint refresh) -{ - GSList *list; - EnchantBroker *broker; - - if (!gtkaspellcheckers) - gtkaspell_checkers_init(); - - if (gtkaspellcheckers->dictionary_list && !refresh) - return gtkaspellcheckers->dictionary_list; - else - gtkaspell_free_dictionary_list( - gtkaspellcheckers->dictionary_list); - list = NULL; - - broker = enchant_broker_init(); - - enchant_broker_list_dicts(broker, list_dict_cb, &list); - - enchant_broker_free(broker); - - if (list == NULL){ - - debug_print("Aspell: error when searching for dictionaries: " - "No dictionary found.\n"); - list = create_empty_dictionary_list(); - } - - gtkaspellcheckers->dictionary_list = list; - - return list; -} - -static void gtkaspell_free_dictionary_list(GSList *list) -{ - Dictionary *dict; - GSList *walk; - for (walk = list; walk != NULL; walk = g_slist_next(walk)) - if (walk->data) { - dict = (Dictionary *) walk->data; - dictionary_delete(dict); - } - g_slist_free(list); -} - -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(refresh); - cm_return_val_if_fail(dict_list, NULL); - - store = gtk_list_store_new(SET_GTKASPELL_SIZE, - G_TYPE_STRING, - G_TYPE_STRING, - -1); - - for (tmp = dict_list; tmp != NULL; tmp = g_slist_next(tmp)) { - dict = (Dictionary *) tmp->data; - - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - SET_GTKASPELL_NAME, dict->dictname, - SET_GTKASPELL_FULLNAME, dict->fullname, - -1); - } - - return GTK_TREE_MODEL(store); -} - -GtkTreeModel *gtkaspell_dictionary_store_new(void) -{ - return gtkaspell_dictionary_store_new_with_refresh - (TRUE); -} - -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(refresh)); - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); - gtk_widget_show(combo); - - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo),renderer, - "text", SET_GTKASPELL_NAME, NULL); - - return combo; -} - -gchar *gtkaspell_get_dictionary_menu_active_item(GtkComboBox *combo) -{ - GtkTreeIter iter; - GtkTreeModel *model; - gchar *dict_fullname = NULL; - - cm_return_val_if_fail(GTK_IS_COMBO_BOX(combo), NULL); - cm_return_val_if_fail(gtk_combo_box_get_active_iter(combo, &iter), NULL); - - model = gtk_combo_box_get_model(combo); - if(model == NULL) - return NULL; - - gtk_tree_model_get(model, &iter, - SET_GTKASPELL_FULLNAME, &dict_fullname, - -1); - - return dict_fullname; -} - -gint gtkaspell_set_dictionary_menu_active_item(GtkComboBox *combo, - const gchar *dictionary) -{ - GtkTreeModel *model; - GtkTreeIter iter; - gchar *dict_name = NULL; - - cm_return_val_if_fail(combo != NULL, 0); - cm_return_val_if_fail(dictionary != NULL, 0); - cm_return_val_if_fail(GTK_IS_COMBO_BOX(combo), 0); - - if((model = gtk_combo_box_get_model(combo)) == NULL) - return 0; - if((gtk_tree_model_get_iter_first(model, &iter)) == FALSE) - return 0; - - do { - gtk_tree_model_get(model, &iter, - SET_GTKASPELL_FULLNAME, &dict_name, - -1); - - if ((dict_name != NULL) && !g_strcmp0(dict_name, dictionary)) { - gtk_combo_box_set_active_iter(combo, &iter); - g_free(dict_name); - return 1; - } - - g_free(dict_name); - - } while ((gtk_tree_model_iter_next(model, &iter)) == TRUE); - - return 0; -} - -void gtkaspell_use_alternate_dict(GtkAspell *gtkaspell) -{ - GtkAspeller *tmp; - - tmp = gtkaspell->gtkaspeller; - gtkaspell->gtkaspeller = gtkaspell->alternate_speller; - gtkaspell->alternate_speller = tmp; -} - -static void destroy_menu(GtkWidget *widget, - gpointer user_data) { - GtkAspell *gtkaspell = (GtkAspell *)user_data; - - if (gtkaspell->accel_group) { - gtk_window_remove_accel_group(GTK_WINDOW(gtkaspell->parent_window), - gtkaspell->accel_group); - gtkaspell->accel_group = NULL; - } -} - -static gboolean aspell_key_pressed(GtkWidget *widget, - GdkEventKey *event, - GtkAspell *gtkaspell) -{ - if (event && (isascii(event->keyval) || event->keyval == GDK_KEY_Return)) { - gtk_accel_groups_activate( - G_OBJECT(gtkaspell->parent_window), - event->keyval, event->state); - } else if (event && event->keyval == GDK_KEY_Escape) { - destroy_menu(NULL, gtkaspell); - } - return FALSE; -} - -/* Create a paged submenu with choice of available dictionaries */ -static GtkWidget *make_dictionary_list_submenu(GtkAspell *gtkaspell) -{ - GtkWidget *menu, *curmenu, *moremenu, *item; - int count = 2; - Dictionary *dict; - GSList *tmp; - - /* Dict list */ - if (gtkaspellcheckers->dictionary_list == NULL) - gtkaspell_get_dictionary_list(FALSE); - - menu = gtk_menu_new(); - curmenu = menu; - - for (tmp = gtkaspellcheckers->dictionary_list; tmp != NULL; - tmp = g_slist_next(tmp)) { - if (count == MENUCOUNT) { - - moremenu = gtk_menu_new(); - item = gtk_menu_item_new_with_label(_("More...")); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), - moremenu); - - gtk_menu_shell_append(GTK_MENU_SHELL(curmenu), item); - curmenu = moremenu; - count = 0; - } - dict = (Dictionary *) tmp->data; - item = gtk_check_menu_item_new_with_label(dict->fullname); - g_object_set_data(G_OBJECT(item), "dict_name", - dict->dictname); - if (g_strcmp0(dict->fullname, - gtkaspell->gtkaspeller->dictionary->fullname)) - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE); - else { - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(item), - FALSE); - } - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(change_dict_cb), - gtkaspell); - gtk_menu_shell_append(GTK_MENU_SHELL(curmenu), item); - - count++; - } - - gtk_widget_show_all(menu); - return menu; -} - -/* make_sug_menu() - Add menus to accept this word for this session - * and to add it to personal dictionary - */ -static GSList *make_sug_menu(GtkAspell *gtkaspell) -{ - GtkWidget *item, *submenu; - char *caption; - GtkAccelGroup *accel; - GList *l = gtkaspell->suggestions_list; - gchar *utf8buf; - GSList *list = NULL; - - if (l == NULL) - return NULL; - - accel = gtk_accel_group_new(); - - if (gtkaspell->accel_group) { - gtk_window_remove_accel_group(GTK_WINDOW(gtkaspell->parent_window), - gtkaspell->accel_group); - gtkaspell->accel_group = NULL; - } - - utf8buf = g_strdup(l->data); - caption = g_strdup_printf(_("\"%s\" unknown in dictionary '%s'"), - utf8buf, - gtkaspell->gtkaspeller->dictionary->dictname); - item = gtk_menu_item_new_with_label(caption); - submenu = make_dictionary_list_submenu(gtkaspell); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); - g_free(utf8buf); - gtk_widget_show(item); - list = g_slist_append(list, item); - g_free(caption); - - item = gtk_menu_item_new(); - gtk_widget_show(item); - list = g_slist_append(list, item); - - item = gtk_menu_item_new_with_label(_("Accept in this session")); - gtk_widget_show(item); - list = g_slist_append(list, item); - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(add_word_to_session_cb), - gtkaspell); - gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_space, - GDK_CONTROL_MASK, - GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE); - - item = gtk_menu_item_new_with_label(_("Add to personal dictionary")); - gtk_widget_show(item); - list = g_slist_append(list, item); - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(add_word_to_personal_cb), - gtkaspell); - gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_Return, - GDK_CONTROL_MASK, - GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE); - - item = gtk_menu_item_new_with_label(_("Replace with...")); - gtk_widget_show(item); - list = g_slist_append(list, item); - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(replace_with_create_dialog_cb), - gtkaspell); - gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_R, 0, - GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE); - gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_R, - GDK_CONTROL_MASK, - GTK_ACCEL_LOCKED); - - if (gtkaspell->use_alternate && gtkaspell->alternate_speller) { - caption = g_strdup_printf(_("Check with %s"), - gtkaspell->alternate_speller->dictionary->dictname); - item = gtk_menu_item_new_with_label(caption); - g_free(caption); - gtk_widget_show(item); - list = g_slist_append(list, item); - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(check_with_alternate_cb), - gtkaspell); - gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_X, 0, - GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE); - gtk_widget_add_accelerator(item, "activate", accel, GDK_KEY_X, - GDK_CONTROL_MASK, - GTK_ACCEL_LOCKED); - } - - item = gtk_menu_item_new(); - gtk_widget_show(item); - list = g_slist_append(list, item); - - l = l->next; - if (l == NULL) { - item = gtk_menu_item_new_with_label(_("(no suggestions)")); - gtk_widget_show(item); - list = g_slist_append(list, item); - } else { - GtkWidget *curmenu = NULL; - gint count = 0; - - do { - if (count == MENUCOUNT) { - count -= MENUCOUNT; - - item = gtk_menu_item_new_with_label(_("More...")); - gtk_widget_show(item); - if (curmenu) - gtk_menu_shell_append(GTK_MENU_SHELL(curmenu), item); - else - list = g_slist_append(list, item); - - curmenu = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), - curmenu); - } - - utf8buf = g_strdup(l->data); - - item = gtk_menu_item_new_with_label(utf8buf); - g_free(utf8buf); - gtk_widget_show(item); - if (curmenu == NULL) { - list = g_slist_append(list, item); - } else { - gtk_menu_shell_append(GTK_MENU_SHELL(curmenu), item); - } - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(replace_word_cb), - gtkaspell); - - if (curmenu == NULL && count < MENUCOUNT) { - gtk_widget_add_accelerator(item, "activate", - accel, - GDK_KEY_A + count, 0, - GTK_ACCEL_LOCKED | - GTK_ACCEL_VISIBLE); - gtk_widget_add_accelerator(item, "activate", - accel, - GDK_KEY_A + count, - GDK_CONTROL_MASK, - GTK_ACCEL_LOCKED); - } - - count++; - - } while ((l = l->next) != NULL); - } - - gtk_window_add_accel_group - (GTK_WINDOW(gtkaspell->parent_window), - accel); - gtkaspell->accel_group = accel; - - return list; -} - -static GSList *populate_submenu(GtkAspell *gtkaspell) -{ - GtkWidget *item, *submenu, *both_dicts_item; - gchar *dictname; - GtkAspeller *gtkaspeller = NULL; - GSList *list = NULL; - - if (!gtkaspell) - return NULL; - - gtkaspeller = gtkaspell->gtkaspeller; - dictname = g_strdup_printf(_("Dictionary: %s"), - gtkaspeller->dictionary->dictname); - item = gtk_menu_item_new_with_label(dictname); - g_free(dictname); - submenu = make_dictionary_list_submenu(gtkaspell); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); - gtk_widget_show(item); - list = g_slist_append(list, item); - - item = gtk_separator_menu_item_new(); - gtk_widget_show(item); - list = g_slist_append(list, item); - - if (gtkaspell->use_alternate && gtkaspell->alternate_speller) { - dictname = g_strdup_printf(_("Use alternate (%s)"), - gtkaspell->alternate_speller->dictionary->dictname); - item = gtk_menu_item_new_with_label(dictname); - g_free(dictname); - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(switch_to_alternate_cb), - gtkaspell); - gtk_widget_show(item); - list = g_slist_append(list, item); - } - - both_dicts_item = gtk_check_menu_item_new_with_label(_("Use both dictionaries")); - if (gtkaspell->use_both_dicts && gtkaspell->use_alternate) { - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(both_dicts_item), TRUE); - } - gtk_widget_set_sensitive(both_dicts_item, gtkaspell->use_alternate); - - g_signal_connect(G_OBJECT(both_dicts_item), "activate", - G_CALLBACK(set_use_both_cb), - gtkaspell); - gtk_widget_show(both_dicts_item); - list = g_slist_append(list, both_dicts_item); - - item = gtk_separator_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); - else - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE); - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(toggle_check_while_typing_cb), - gtkaspell); - gtk_widget_show(item); - list = g_slist_append(list, item); - - return list; -} - -GSList *gtkaspell_make_config_menu(GtkAspell *gtkaspell) -{ - return populate_submenu(gtkaspell); -} - -static void set_menu_pos(GtkMenu *menu, gint *x, gint *y, - gboolean *push_in, gpointer data) -{ - GtkAspell *gtkaspell = (GtkAspell *) data; - gint xx = 0, yy = 0; - GtkTextView *text = GTK_TEXT_VIEW(gtkaspell->gtktext); - GtkTextBuffer *textbuf; - GtkTextIter iter; - GdkRectangle rect; - - textbuf = gtk_text_view_get_buffer(gtkaspell->gtktext); - gtk_text_buffer_get_iter_at_mark(textbuf, &iter, - gtk_text_buffer_get_insert(textbuf)); - gtk_text_view_get_iter_location(gtkaspell->gtktext, &iter, &rect); - gtk_text_view_buffer_to_window_coords(text, GTK_TEXT_WINDOW_TEXT, - rect.x, rect.y, - &rect.x, &rect.y); - - gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(gtkaspell->gtktext)), - &xx, &yy); - - gtk_widget_get_preferred_size(GTK_WIDGET(menu), NULL, NULL); -} - -/* change the current dictionary of gtkaspell - - if always_set_alt_dict is set, the alternate dict is unconditionally set to the former - current dictionary (common use: from menu callbacks) - - if always_set_alt_dict is NOT set, the alternate dict will be set to the former - current dictionary only if there is no alternate dictionary already set - (this is when we need to set the current dictionary then the alternate one - when creating a compose window, from the account and folder settings) -*/ -gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary, - gboolean always_set_alt_dict) -{ - Dictionary *dict; - GtkAspeller *gtkaspeller; - - cm_return_val_if_fail(gtkaspell, FALSE); - cm_return_val_if_fail(dictionary, FALSE); - - dict = g_new0(Dictionary, 1); - - 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); - } - - if (dict->fullname && strchr(dict->fullname, '-')) { - *(strchr(dict->fullname, '-')) = '\0'; - *(strchr(dict->dictname, '-')) = '\0'; - } - - if (!dict->fullname || !(*dict->fullname)) { - dictionary_delete(dict); - return FALSE; - } - gtkaspeller = gtkaspeller_new(dict); - - if (!gtkaspeller) { - alertpanel_warning(_("The spell checker could not change dictionary.\n%s"), - gtkaspellcheckers->error_message); - } else { - if (gtkaspell->use_alternate) { - if (gtkaspell->alternate_speller) { - if (always_set_alt_dict) { - gtkaspeller_delete(gtkaspell->alternate_speller); - gtkaspell->alternate_speller = gtkaspell->gtkaspeller; - } else - gtkaspeller_delete(gtkaspell->gtkaspeller); - } else - /* should never be reached as the dicts are always set - to a default value */ - gtkaspell->alternate_speller = gtkaspell->gtkaspeller; - } else - gtkaspeller_delete(gtkaspell->gtkaspeller); - - gtkaspell->gtkaspeller = gtkaspeller; - } - - dictionary_delete(dict); - - return TRUE; -} - -/* change the alternate dictionary of gtkaspell (doesn't affect the default dictionary) */ -gboolean gtkaspell_change_alt_dict(GtkAspell *gtkaspell, const gchar *alt_dictionary) -{ - Dictionary *dict; - GtkAspeller *gtkaspeller; - - cm_return_val_if_fail(gtkaspell, FALSE); - cm_return_val_if_fail(alt_dictionary, FALSE); - - dict = g_new0(Dictionary, 1); - 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); - } - - if (dict->fullname && strchr(dict->fullname, '-')) { - *(strchr(dict->fullname, '-')) = '\0'; - *(strchr(dict->dictname, '-')) = '\0'; - } - - if (!dict->fullname || !(*dict->fullname)) { - dictionary_delete(dict); - return FALSE; - } - - gtkaspeller = gtkaspeller_new(dict); - - if (!gtkaspeller) { - alertpanel_warning(_("The spell checker could not change the alternate dictionary.\n%s"), - gtkaspellcheckers->error_message); - } else { - if (gtkaspell->alternate_speller) - gtkaspeller_delete(gtkaspell->alternate_speller); - gtkaspell->alternate_speller = gtkaspeller; - } - - dictionary_delete(dict); - - return TRUE; -} - -/* Menu call backs */ - -/* change_dict_cb() - Menu callback : change dict */ -static void change_dict_cb(GtkWidget *w, GtkAspell *gtkaspell) -{ - gchar *fullname; - - fullname = (gchar *) g_object_get_data(G_OBJECT(w), "dict_name"); - - if (!g_strcmp0(fullname, _("None"))) - return; - - gtkaspell_change_dict(gtkaspell, fullname, TRUE); - gtkaspell_dict_changed(gtkaspell); - - if (gtkaspell->menu_changed_cb) - gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); -} - -static void switch_to_alternate_cb(GtkWidget *w, - gpointer data) -{ - GtkAspell *gtkaspell = (GtkAspell *) data; - gtkaspell_use_alternate_dict(gtkaspell); - gtkaspell_dict_changed(gtkaspell); - - if (gtkaspell->menu_changed_cb) - gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); -} - -/* Misc. helper functions */ - -static void set_point_continue(GtkAspell *gtkaspell) -{ - gtkaspell->ctx.set_position(gtkaspell->ctx.data, gtkaspell->orig_pos); - - if (gtkaspell->continue_check) - gtkaspell->continue_check((gpointer *) gtkaspell->ctx.data); -} - -static void allocate_color(GtkAspell *gtkaspell, GdkRGBA rgba) -{ - GtkTextBuffer *buffer = gtk_text_view_get_buffer(gtkaspell->gtktext); - static const gchar *col = NULL; - - gtkaspell->highlight = rgba; - col = gtkut_gdk_rgba_to_string(&rgba); - - if (strcmp(col,"#000000") == 0) - gtk_text_buffer_create_tag(buffer, "misspelled", - "underline", PANGO_UNDERLINE_ERROR, NULL); - else - gtk_text_buffer_create_tag(buffer, "misspelled", - "foreground-rgba", &(gtkaspell->highlight), NULL); -} - -static void change_color(GtkAspell * gtkaspell, - gint start, gint end, - gchar *newtext, - gboolean colorize) -{ - GtkTextView *gtktext; - GtkTextBuffer *buffer; - GtkTextIter startiter, enditer; - - if (start > end) - return; - - gtktext = gtkaspell->gtktext; - - buffer = gtk_text_view_get_buffer(gtktext); - gtk_text_buffer_get_iter_at_offset(buffer, &startiter, start); - gtk_text_buffer_get_iter_at_offset(buffer, &enditer, end); - if (colorize) - gtk_text_buffer_apply_tag_by_name(buffer, "misspelled", - &startiter, &enditer); - else { - gtk_text_iter_forward_char(&enditer); - gtk_text_buffer_remove_tag_by_name(buffer, "misspelled", - &startiter, &enditer); - } -} - -/* compare_dict () - compare 2 dict names */ -static gint compare_dict(Dictionary *a, Dictionary *b) -{ - guint aparts = 0, bparts = 0; - guint i; - - for (i=0; i < strlen(a->dictname); i++) - if (a->dictname[i] == '-') - aparts++; - for (i=0; i < strlen(b->dictname); i++) - if (b->dictname[i] == '-') - bparts++; - - if (aparts != bparts) - return (aparts < bparts) ? -1 : +1; - else { - gint compare; - compare = g_strcmp0(a->dictname, b->dictname); - if (!compare) - compare = g_strcmp0(a->fullname, b->fullname); - return compare; - } -} - -static void dictionary_delete(Dictionary *dict) -{ - g_free(dict->fullname); - g_free(dict->dictname); - g_free(dict); -} - -static Dictionary *dictionary_dup(const Dictionary *dict) -{ - Dictionary *dict2; - - dict2 = g_new(Dictionary, 1); - - dict2->fullname = g_strdup(dict->fullname); - dict2->dictname = g_strdup(dict->dictname); - - return dict2; -} - -void gtkaspell_free_suggestions_list(GtkAspell *gtkaspell) -{ - GList *list; - - for (list = gtkaspell->suggestions_list; list != NULL; - list = list->next) - g_free(list->data); - - g_list_free(gtkaspell->suggestions_list); - - gtkaspell->max_sug = -1; - gtkaspell->suggestions_list = NULL; -} - -static void reset_theword_data(GtkAspell *gtkaspell) -{ - gtkaspell->start_pos = 0; - gtkaspell->end_pos = 0; - gtkaspell->theword[0] = 0; - gtkaspell->max_sug = -1; - - gtkaspell_free_suggestions_list(gtkaspell); -} - -static void free_checkers(gpointer elt, gpointer data) -{ - GtkAspeller *gtkaspeller = elt; - - cm_return_if_fail(gtkaspeller); - - gtkaspeller_real_delete(gtkaspeller); -} - -gchar *gtkaspell_get_default_dictionary(GtkAspell *gtkaspell) -{ - if (gtkaspell && gtkaspell->gtkaspeller && - gtkaspell->gtkaspeller->dictionary) - return gtkaspell->gtkaspeller->dictionary->dictname; - else - return NULL; -} -#endif blob - fef5d4f5a57929157ccc17ba1411e3d7b960b83c (mode 644) blob + /dev/null --- src/gtk/gtkaspell.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - Stuphead: (C) 2000,2001 Grigroy Bakunov, Sergey Pinaev - */ -/* gtkaspell - a spell-checking addon for GtkText - * Copyright (c) 2001-2002 Melvin Hadasht - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Adapted by the Claws Mail Team. - */ - -/* - * Adapted for pspell (c) 2001-2002 Melvin Hadasht - * Adapted for GNU/aspell (c) 2002 Melvin Hadasht - * - */ - -#ifndef __GTKENCHANT_H__ -#define __GTKENCHANT_H__ - -#ifdef HAVE_CONFIG_H -#include "claws-features.h" -#endif - -#ifdef USE_ENCHANT - -#include -#include - -#define GTKASPELLWORDSIZE 1024 - -typedef struct _Dictionary { - gchar *fullname; - gchar *dictname; -} Dictionary; - -typedef struct _GtkAspeller { - Dictionary *dictionary; - EnchantBroker *broker; - EnchantDict *speller; -} GtkAspeller; - -typedef void (*ContCheckFunc) (gpointer *gtkaspell); - -struct _WidgetContext -{ - void (*set_position)(gpointer data, gint pos); - void (*set_menu_pos)(GtkMenu *menu, gint *x, gint *y, - gboolean *push_in, gpointer user_data); - gboolean (*find_misspelled)(gpointer data, gboolean forward); - gboolean (*check_word)(gpointer data); - void (*replace_word)(gpointer data, const gchar *newword); - gpointer *data; -}; - -typedef struct _WidgetContext WidgetContext; - -struct _GtkAspell -{ - GtkAspeller *gtkaspeller; - GtkAspeller *alternate_speller; - gchar theword[GTKASPELLWORDSIZE]; - gint start_pos; - gint end_pos; - gint orig_pos; - gint end_check_pos; - gboolean misspelled; - gboolean check_while_typing; - gboolean recheck_when_changing_dict; - gboolean use_alternate; - gboolean use_both_dicts; - - ContCheckFunc continue_check; - - GtkWidget *replace_entry; - GtkWidget *parent_window; - - gint max_sug; - GList *suggestions_list; - - GtkTextView *gtktext; - GdkRGBA highlight; - GtkAccelGroup *accel_group; - void (*dict_changed_cb)(void *data); - void (*menu_changed_cb)(void *data); - void *menu_changed_data; - - WidgetContext ctx; -}; - -typedef struct _GtkAspell GtkAspell; - - -void gtkaspell_checkers_init (void); - -void gtkaspell_checkers_quit (void); - -const char * gtkaspell_checkers_strerror (void); - -void gtkaspell_checkers_reset_error (void); - -GtkAspell* gtkaspell_new (const gchar *dictionary, - const gchar *alt_dictionary, - const gchar *encoding, - GdkRGBA misspelled_color, - gboolean check_while_typing, - gboolean recheck_when_changing_dict, - gboolean use_alternate, - gboolean use_both_dicts, - GtkTextView *gtktext, - GtkWindow *parent_win, - void (*dict_changed_cd)(void *data), - void (*spell_menu_cb)(void *data), - void *data); - -void gtkaspell_delete (GtkAspell *gtkaspell); - - -gboolean gtkaspell_change_dict (GtkAspell *gtkaspell, - const gchar* dictionary, - gboolean always_set_alt_dict); - -gboolean gtkaspell_change_alt_dict (GtkAspell *gtkaspell, - const gchar* alt_dictionary); -void gtkaspell_use_alternate_dict (GtkAspell *gtkaspell); - -gboolean gtkaspell_check_next_prev (GtkAspell *gtkaspell, - gboolean forward); -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 gboolean refresh); - -GtkTreeModel* gtkaspell_dictionary_store_new (void); -GtkTreeModel* gtkaspell_dictionary_store_new_with_refresh - (gboolean refresh); - -gchar* gtkaspell_get_dictionary_menu_active_item - (GtkComboBox *combo); -gint gtkaspell_set_dictionary_menu_active_item - (GtkComboBox *combo, - const gchar *dictionary); - -GSList* gtkaspell_make_config_menu (GtkAspell *gtkaspell); - -gchar* gtkaspell_get_default_dictionary (GtkAspell *gtkaspell); - -void gtkaspell_make_context_menu (GtkMenu *menu, - GtkAspell *gtkaspell); - -int gtkaspell_misspelled_test (GtkAspell *gtkaspell, - char *word); -void gtkaspell_dict_changed (GtkAspell *gtkaspell); -void gtkaspell_context_set (GtkAspell *gtkaspell); -void gtkaspell_free_suggestions_list (GtkAspell *gtkaspell); -void gtkaspell_block_check (GtkAspell *gtkaspell); -void gtkaspell_unblock_check (GtkAspell *gtkaspell); - - -#endif /* USE_ENCHANT */ -#endif /* __GTKENCHANT_H__ */ blob - 8f677e80bc8bd1e28a756c8318c07e666fc61e43 (mode 644) blob + /dev/null --- src/gtk/spell_entry.c +++ /dev/null @@ -1,684 +0,0 @@ -/* - * @file libsexy/sexy-icon-entry.c Entry widget - * - * @Copyright (C) 2004-2006 Christian Hammond. - * Some of this code is from gtkspell, Copyright (C) 2002 Evan Martin. - * Adapted for Claws Mail (c) 2009-2012 Pawel Pekala and the Claws Mail team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#include "claws-features.h" -#endif - -#ifdef USE_ENCHANT - -#include -#include - -#include -#include - -#include -#include - -#include "spell_entry.h" -#include "prefs_common.h" -#include "codeconv.h" -#include "defs.h" -#include "gtkutils.h" - -static void claws_spell_entry_init (ClawsSpellEntry *entry); -static void claws_spell_entry_finalize (GObject *object); -static void claws_spell_entry_destroy (GtkWidget *object); -static gint claws_spell_entry_expose (GtkWidget *widget, - cairo_t *cr); -static gint claws_spell_entry_button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean claws_spell_entry_popup_menu (GtkWidget *widget, - ClawsSpellEntry *entry); -static void claws_spell_entry_populate_popup (ClawsSpellEntry *entry, - GtkMenu *menu, - gpointer data); -static void claws_spell_entry_changed (GtkEditable *editable, - gpointer data); -static void claws_spell_entry_preedit_changed (GtkEntry *entry, - gchar *preedit, - gpointer data); - -typedef struct _ClawsSpellEntryPriv -{ - PangoAttrList *attr_list; - gint mark_character; - gchar **words; - gint *word_starts; - gint *word_ends; - gint preedit_length; -} ClawsSpellEntryPrivate; - -static GtkEntryClass *parent_class = NULL; - - -G_DEFINE_TYPE_WITH_CODE(ClawsSpellEntry, claws_spell_entry, GTK_TYPE_ENTRY, - G_ADD_PRIVATE(ClawsSpellEntry)) - - -static void claws_spell_entry_class_init(ClawsSpellEntryClass *klass) -{ - GObjectClass *g_object_class; - GtkWidgetClass *widget_class; - - parent_class = g_type_class_peek_parent(klass); - - g_object_class = G_OBJECT_CLASS(klass); - g_object_class->finalize = claws_spell_entry_finalize; - - widget_class = GTK_WIDGET_CLASS(klass); - widget_class->button_press_event = claws_spell_entry_button_press; - widget_class->draw = claws_spell_entry_expose; - widget_class->destroy = claws_spell_entry_destroy; -} - -static void claws_spell_entry_init(ClawsSpellEntry *entry) -{ - entry->gtkaspell = NULL; - - entry->priv = g_new0(ClawsSpellEntryPriv, 1); - entry->priv->attr_list = pango_attr_list_new(); - entry->priv->preedit_length = 0; - - g_signal_connect(G_OBJECT(entry), "popup-menu", - G_CALLBACK(claws_spell_entry_popup_menu), entry); - g_signal_connect(G_OBJECT(entry), "populate-popup", - G_CALLBACK(claws_spell_entry_populate_popup), NULL); - g_signal_connect(G_OBJECT(entry), "changed", - G_CALLBACK(claws_spell_entry_changed), NULL); - g_signal_connect(G_OBJECT(entry), "preedit-changed", - G_CALLBACK(claws_spell_entry_preedit_changed), NULL); -} - -static void claws_spell_entry_finalize(GObject *object) -{ - ClawsSpellEntry *entry = CLAWS_SPELL_ENTRY(object); - - if (entry->priv->attr_list) - pango_attr_list_unref(entry->priv->attr_list); - if (entry->priv->words) - g_strfreev(entry->priv->words); - - g_free(entry->priv->word_starts); - g_free(entry->priv->word_ends); - g_free(entry->priv); - entry->priv = NULL; - - G_OBJECT_CLASS(parent_class)->finalize(object); -} - -static void claws_spell_entry_destroy(GtkWidget *object) -{ - GTK_WIDGET_CLASS(parent_class)->destroy(object); -} - -GtkWidget *claws_spell_entry_new(void) -{ - return GTK_WIDGET( g_object_new(CLAWS_TYPE_SPELL_ENTRY, NULL) ); -} - -void claws_spell_entry_set_gtkaspell(ClawsSpellEntry *entry, GtkAspell *gtkaspell) -{ - cm_return_if_fail(CLAWS_IS_SPELL_ENTRY(entry)); - - entry->gtkaspell = gtkaspell; -} - -static gint claws_spell_entry_find_position (ClawsSpellEntry *_entry, gint x) -{ - PangoLayout *layout; - PangoLayoutLine *line; - const gchar *text; - gint cursor_index; - gint index; - gint pos, current_pos; - gint scroll_offset; - gboolean trailing; - GtkEntry *entry = GTK_ENTRY(_entry); - - g_object_get(entry, "scroll-offset", &scroll_offset, NULL); - x = x + scroll_offset; - - layout = gtk_entry_get_layout(entry); - text = pango_layout_get_text(layout); - g_object_get(entry, "cursor-position", ¤t_pos, NULL); - cursor_index = g_utf8_offset_to_pointer(text, current_pos) - text; - - line = pango_layout_get_lines(layout)->data; - pango_layout_line_x_to_index(line, x * PANGO_SCALE, &index, &trailing); - - if (index >= cursor_index && _entry->priv->preedit_length) { - if (index >= cursor_index + _entry->priv->preedit_length) { - index -= _entry->priv->preedit_length; - } else { - index = cursor_index; - trailing = FALSE; - } - } - - pos = g_utf8_pointer_to_offset (text, text + index); - pos += trailing; - - return pos; -} - -static void get_word_extents_from_position(ClawsSpellEntry *entry, gint *start, - gint *end, guint position) -{ - const gchar *text; - gint i, bytes_pos; - - *start = -1; - *end = -1; - - if (entry->priv->words == NULL) - return; - - text = gtk_entry_get_text(GTK_ENTRY(entry)); - bytes_pos = (gint) (g_utf8_offset_to_pointer(text, position) - text); - - for (i = 0; entry->priv->words[i]; i++) { - if (bytes_pos >= entry->priv->word_starts[i] && - bytes_pos <= entry->priv->word_ends[i]) { - *start = entry->priv->word_starts[i]; - *end = entry->priv->word_ends[i]; - return; - } - } -} - -static gchar *get_word(ClawsSpellEntry *entry, const int start, const int end) -{ - const gchar *text; - gchar *word; - - if (start >= end) - return NULL; - - text = gtk_entry_get_text(GTK_ENTRY(entry)); - word = g_new0(gchar, end - start + 2); - g_strlcpy(word, text + start, end - start + 1); - - return word; -} - -static void replace_word(ClawsSpellEntry *entry, const gchar *newword) -{ - gint cursor, start_pos, end_pos; - const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); - - start_pos = entry->gtkaspell->start_pos; - end_pos = entry->gtkaspell->end_pos; - - cursor = gtk_editable_get_position(GTK_EDITABLE(entry)); - /* is the cursor at the end? If so, restore it there */ - if (g_utf8_strlen(text, -1) == cursor) - cursor = -1; - else if(cursor < entry->priv->mark_character || - cursor > entry->priv->mark_character) - cursor = entry->priv->mark_character; - - gtk_editable_delete_text(GTK_EDITABLE(entry), start_pos, end_pos); - gtk_editable_insert_text(GTK_EDITABLE(entry), newword, strlen(newword), - &start_pos); - gtk_editable_set_position(GTK_EDITABLE(entry), cursor); -} - - -static gboolean word_misspelled(ClawsSpellEntry *entry, int start, int end) -{ - gchar *word; - gboolean ret; - - word = get_word(entry, start, end); - if (word == NULL || g_unichar_isdigit(word[0])) { - if (word) - g_free(word); - return FALSE; - } - - ret = gtkaspell_misspelled_test(entry->gtkaspell, word); - - g_free(word); - return ret; -} - -static gboolean is_word_end (GtkEntry *entry, const int offset) -{ - gchar *p = gtk_editable_get_chars(GTK_EDITABLE(entry), offset, offset+1); - gunichar ch; - - ch = g_utf8_get_char(p); - g_free(p); - - if (ch == '\0') - return TRUE; - - if (ch == '\'') { - p = gtk_editable_get_chars(GTK_EDITABLE(entry), offset+1, offset+2); - ch = g_utf8_get_char(p); - g_free(p); - - return (g_unichar_isspace(ch) || g_unichar_ispunct(ch) - || g_unichar_isdigit(ch)); - } - - return (g_unichar_isspace(ch) || g_unichar_ispunct(ch)); -} - -static void entry_strsplit_utf8(GtkEntry *entry, gchar ***set, gint **starts, gint **ends) -{ - PangoLayout *layout; - PangoLogAttr *log_attrs; - const gchar *text; - gint n_attrs, n_strings, i, j; - - layout = gtk_entry_get_layout(GTK_ENTRY(entry)); - text = gtk_entry_get_text(GTK_ENTRY(entry)); - pango_layout_get_log_attrs(layout, &log_attrs, &n_attrs); - - /* Find how many words we have */ - n_strings = 0; - for (i = 0; i < n_attrs; i++) - if (log_attrs[i].is_word_start) - n_strings++; - - *set = g_new0(gchar *, n_strings + 1); - *starts = g_new0(gint, n_strings); - *ends = g_new0(gint, n_strings); - - /* Copy out strings */ - for (i = 0, j = 0; i < n_attrs; i++) { - if (log_attrs[i].is_word_start) { - gint cend, bytes; - gchar *start; - - /* Find the end of this string */ - cend = i; - while (!is_word_end(entry, cend)) - cend++; - - /* Copy sub-string */ - start = g_utf8_offset_to_pointer(text, i); - bytes = (gint) (g_utf8_offset_to_pointer(text, cend) - start); - (*set)[j] = g_new0(gchar, bytes + 1); - (*starts)[j] = (gint) (start - text); - (*ends)[j] = (gint) (start - text + bytes); - g_utf8_strncpy((*set)[j], start, cend - i); - - /* Move on to the next word */ - j++; - } - } - - g_free (log_attrs); -} - -static void insert_misspelled_marker(ClawsSpellEntry *entry, guint start, guint end) -{ - GdkRGBA *rgba = &prefs_common.color[COL_MISSPELLED]; - guint16 red = (guint16)(rgba->red * 65535); - guint16 green = (guint16)(rgba->green * 65535); - guint16 blue = (guint16)(rgba->blue * 65535); - PangoAttribute *fcolor; - - fcolor = pango_attr_foreground_new(red, green, blue); - fcolor->start_index = start; - fcolor->end_index = end; - - pango_attr_list_insert(entry->priv->attr_list, fcolor); -} - -static gboolean check_word(ClawsSpellEntry *entry, int start, int end) -{ - GtkAspell *gtkaspell = entry->gtkaspell; - PangoAttrIterator *it; - gint s, e; - gboolean misspelled; - gchar *text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); - gchar *word = NULL; - - /* Check to see if we've got any attributes at this position. - * If so, free them, since we'll readd it if the word is misspelled */ - it = pango_attr_list_get_iterator(entry->priv->attr_list); - if (it == NULL) - return FALSE; - do { - pango_attr_iterator_range(it, &s, &e); - if (s == start) { - GSList *attrs = pango_attr_iterator_get_attrs(it); - g_slist_foreach(attrs, (GFunc) pango_attribute_destroy, NULL); - g_slist_free(attrs); - } - } while (pango_attr_iterator_next(it)); - pango_attr_iterator_destroy(it); - - if ((misspelled = word_misspelled(entry, start, end))) { - insert_misspelled_marker(entry, start, end); - - word = get_word(entry, start, end); - strncpy(gtkaspell->theword, (gchar *)word, GTKASPELLWORDSIZE - 1); - gtkaspell->theword[GTKASPELLWORDSIZE - 1] = 0; - gtkaspell->start_pos = g_utf8_pointer_to_offset(text, (text+start)); - gtkaspell->end_pos = g_utf8_pointer_to_offset(text, (text+end)); - gtkaspell_free_suggestions_list(gtkaspell); - g_free(word); - } - - g_free(text); - - return misspelled; -} - -void claws_spell_entry_recheck_all(ClawsSpellEntry *entry) -{ - GtkAllocation allocation; - GdkRectangle rect; - PangoLayout *layout; - int length, i; - - cm_return_if_fail(CLAWS_IS_SPELL_ENTRY(entry)); - cm_return_if_fail(entry->gtkaspell != NULL); - - if (entry->priv->words == NULL) - return; - - /* Remove all existing pango attributes. These will get readded as we check */ - pango_attr_list_unref(entry->priv->attr_list); - entry->priv->attr_list = pango_attr_list_new(); - - /* Loop through words */ - for (i = 0; entry->priv->words[i]; i++) { - length = strlen(entry->priv->words[i]); - if (length == 0) - continue; - check_word(entry, entry->priv->word_starts[i], entry->priv->word_ends[i]); - } - - layout = gtk_entry_get_layout(GTK_ENTRY(entry)); - pango_layout_set_attributes(layout, entry->priv->attr_list); - - if (gtk_widget_get_realized(GTK_WIDGET(entry))) { - rect.x = 0; rect.y = 0; - gtk_widget_get_allocation(GTK_WIDGET(entry), &allocation); - rect.width = allocation.width; - rect.height = allocation.height; - gdk_window_invalidate_rect(gtk_widget_get_window(GTK_WIDGET(entry)), - &rect, TRUE); - } -} - -static gint claws_spell_entry_expose(GtkWidget *widget, cairo_t *cr) -{ - ClawsSpellEntry *entry = CLAWS_SPELL_ENTRY(widget); - GtkEntry *gtk_entry = GTK_ENTRY(widget); - PangoLayout *layout; - - if (entry->gtkaspell != NULL) { - layout = gtk_entry_get_layout(gtk_entry); - pango_layout_set_attributes(layout, entry->priv->attr_list); - } - - return GTK_WIDGET_CLASS(parent_class)->draw (widget, cr); -} - -static gint claws_spell_entry_button_press(GtkWidget *widget, GdkEventButton *event) -{ - ClawsSpellEntry *entry = CLAWS_SPELL_ENTRY(widget); - gint pos; - - pos = claws_spell_entry_find_position(entry, event->x); - entry->priv->mark_character = pos; - - return GTK_WIDGET_CLASS(parent_class)->button_press_event (widget, event); -} - -static gboolean claws_spell_entry_popup_menu(GtkWidget *widget, ClawsSpellEntry *entry) -{ - entry->priv->mark_character = gtk_editable_get_position (GTK_EDITABLE (entry)); - return FALSE; -} - -static void set_position(gpointer data, gint pos) -{ - gtk_editable_set_position(GTK_EDITABLE(data), pos); -} - -static gboolean find_misspelled_cb(gpointer data, gboolean forward) -{ - ClawsSpellEntry *entry = (ClawsSpellEntry *)data; - GtkAspell *gtkaspell = entry->gtkaspell; - gboolean misspelled = FALSE; - gint cursor, minpos, maxpos, i, words_len = 0; - gint start, end; - gchar *text; - - if (entry->priv->words == NULL) - return FALSE; - - gtkaspell->orig_pos = gtk_editable_get_position(GTK_EDITABLE(entry)); - text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); - cursor = g_utf8_offset_to_pointer(text, gtkaspell->orig_pos) - text; - - if (gtk_editable_get_selection_bounds(GTK_EDITABLE(entry), &start, &end)) { - minpos = g_utf8_offset_to_pointer(text, start) - text; - maxpos = g_utf8_offset_to_pointer(text, end) - text; - } else { - minpos = forward ? cursor : 0; - maxpos = forward ? strlen(text)-1 : cursor; - } - g_free(text); - - while(entry->priv->words[words_len]) - words_len++; - - if (forward) { - for(i=0; i < words_len; i++) - if (entry->priv->word_ends[i] > minpos && - (misspelled = check_word(entry, - entry->priv->word_starts[i], - entry->priv->word_ends[i]))) - break; - } else { - for(i=words_len-1; i >= 0; i--) - if (entry->priv->word_starts[i] < maxpos && - (misspelled = check_word(entry, - entry->priv->word_starts[i], - entry->priv->word_ends[i]))) - break; - } - - return misspelled; -} - -static gboolean check_word_cb(gpointer data) -{ - ClawsSpellEntry *entry = (ClawsSpellEntry *)data; - gint start, end; - - get_word_extents_from_position(entry, &start, &end, entry->priv->mark_character); - return check_word(entry, start, end); -} - -static void replace_word_cb(gpointer data, const gchar *newword) -{ - replace_word((ClawsSpellEntry *) data, newword); -} - -static void set_menu_pos(GtkMenu *menu, gint *x, gint *y, - gboolean *push_in, gpointer data) -{ - ClawsSpellEntry *entry = (ClawsSpellEntry *) data; - GtkAspell *gtkaspell = entry->gtkaspell; - gint pango_offset, win_x, win_y, scr_x, scr_y, text_index, entry_x; - gchar *text; - PangoLayout *layout = gtk_entry_get_layout(GTK_ENTRY(entry)); - PangoLayoutLine *line = pango_layout_get_lines(layout)->data; - - gtk_widget_get_preferred_size(GTK_WIDGET(entry), NULL, NULL); - - /* screen -> compose window coords */ - gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(gtkaspell->parent_window)), - &scr_x, &scr_y); - - /* compose window -> subject entry coords */ - gtk_widget_translate_coordinates(GTK_WIDGET(entry), - gtkaspell->parent_window, 0, 0, &win_x, &win_y); - - text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); - text_index = g_utf8_offset_to_pointer(text, gtkaspell->end_pos) - text; - g_free(text); - - pango_offset = gtk_entry_text_index_to_layout_index(GTK_ENTRY(entry), - text_index); - pango_layout_line_index_to_x(line, pango_offset, TRUE, &entry_x); -} - -void claws_spell_entry_context_set(ClawsSpellEntry *entry) -{ - cm_return_if_fail(CLAWS_IS_SPELL_ENTRY(entry)); - cm_return_if_fail(entry->gtkaspell != NULL); - - entry->gtkaspell->ctx.set_position = set_position; - entry->gtkaspell->ctx.set_menu_pos = set_menu_pos; - entry->gtkaspell->ctx.find_misspelled = find_misspelled_cb; - entry->gtkaspell->ctx.check_word = check_word_cb; - entry->gtkaspell->ctx.replace_word = replace_word_cb; - entry->gtkaspell->ctx.data = (gpointer) entry; -} - -static void claws_spell_entry_populate_popup(ClawsSpellEntry *entry, GtkMenu *menu, - gpointer data) -{ - GtkAspell *gtkaspell = entry->gtkaspell; - gint start, end; - gchar *word, *text; - - if (gtkaspell == NULL) - return; - - get_word_extents_from_position(entry, &start, &end, entry->priv->mark_character); - - if ((word = get_word(entry, start, end)) != NULL) { - strncpy(gtkaspell->theword, word, GTKASPELLWORDSIZE - 1); - g_free(word); - } - - gtkaspell->misspelled = word_misspelled(entry, start, end); - - text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); - gtkaspell->start_pos = g_utf8_pointer_to_offset(text, (text+start)); - gtkaspell->end_pos = g_utf8_pointer_to_offset(text, (text+end)); - g_free(text); - - claws_spell_entry_context_set(entry); - gtkaspell_make_context_menu(menu, gtkaspell); -} - -static void claws_spell_entry_changed(GtkEditable *editable, gpointer data) -{ - ClawsSpellEntry *entry = CLAWS_SPELL_ENTRY(editable); - - if (entry->gtkaspell == NULL) - return; - - if (entry->priv->words) { - g_strfreev(entry->priv->words); - g_free(entry->priv->word_starts); - g_free(entry->priv->word_ends); - } - entry_strsplit_utf8(GTK_ENTRY(entry), &entry->priv->words, - &entry->priv->word_starts, &entry->priv->word_ends); - if(entry->gtkaspell->check_while_typing == TRUE) - claws_spell_entry_recheck_all(entry); -} - -static void claws_spell_entry_preedit_changed (GtkEntry *_entry, - gchar *preedit, - gpointer data) -{ - ClawsSpellEntry *entry = CLAWS_SPELL_ENTRY(_entry); - - entry->priv->preedit_length = preedit != NULL ? strlen(preedit) : 0; -} - -static void continue_check(gpointer *data) -{ - ClawsSpellEntry *entry = (ClawsSpellEntry *)data; - GtkAspell *gtkaspell = entry->gtkaspell; - gint pos = gtk_editable_get_position(GTK_EDITABLE(entry)); - - if (gtkaspell->misspelled && pos < gtkaspell->end_check_pos) - gtkaspell->misspelled = gtkaspell_check_next_prev(gtkaspell, TRUE); - else - gtkaspell->continue_check = NULL; -} - -void claws_spell_entry_check_all(ClawsSpellEntry *entry) -{ - gint start, end; - gchar *text; - - cm_return_if_fail(CLAWS_IS_SPELL_ENTRY(entry)); - cm_return_if_fail(entry->gtkaspell != NULL); - - if (!gtk_editable_get_selection_bounds(GTK_EDITABLE(entry), &start, &end)) { - text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); - - start = 0; - end = g_utf8_strlen(text, -1) - 1; - - g_free(text); - } - - gtk_editable_set_position(GTK_EDITABLE(entry), start); - entry->gtkaspell->continue_check = continue_check; - entry->gtkaspell->end_check_pos = end; - - claws_spell_entry_context_set(entry); - entry->gtkaspell->misspelled = - gtkaspell_check_next_prev(entry->gtkaspell, TRUE); -} - -void claws_spell_entry_check_backwards(ClawsSpellEntry *entry) -{ - cm_return_if_fail(CLAWS_IS_SPELL_ENTRY(entry)); - cm_return_if_fail(entry->gtkaspell != NULL); - - entry->gtkaspell->continue_check = NULL; - claws_spell_entry_context_set(entry); - gtkaspell_check_next_prev(entry->gtkaspell, FALSE); -} - -void claws_spell_entry_check_forwards_go(ClawsSpellEntry *entry) -{ - cm_return_if_fail(CLAWS_IS_SPELL_ENTRY(entry)); - cm_return_if_fail(entry->gtkaspell != NULL); - - entry->gtkaspell->continue_check = NULL; - claws_spell_entry_context_set(entry); - gtkaspell_check_next_prev(entry->gtkaspell, TRUE); -} - -#endif /* USE_ENCHANT */ blob - aaa49da286f984acea09cdf53fcba2de8a060f83 (mode 644) blob + /dev/null --- src/gtk/spell_entry.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * @file libsexy/sexy-icon-entry.h Entry widget - * - * @Copyright (C) 2004-2006 Christian Hammond. - * Some of this code is from gtkspell, Copyright (C) 2002 Evan Martin. - * Adapted for Claws Mail (c) 2009-2012 Pawel Pekala and the Claws Mail team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef __SPELL_ENTRY_H__ -#define __SPELL_ENTRY_H__ - -#ifdef HAVE_CONFIG_H -#include "claws-features.h" -#endif - -#ifdef USE_ENCHANT - -G_BEGIN_DECLS - -typedef struct _ClawsSpellEntry ClawsSpellEntry; -typedef struct _ClawsSpellEntryClass ClawsSpellEntryClass; -typedef struct _ClawsSpellEntryPriv ClawsSpellEntryPriv; - -#include -#include "gtkaspell.h" - -#define CLAWS_TYPE_SPELL_ENTRY (claws_spell_entry_get_type()) -#define CLAWS_SPELL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CLAWS_TYPE_SPELL_ENTRY, ClawsSpellEntry)) -#define CLAWS_SPELL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CLAWS_TYPE_SPELL_ENTRY, ClawsSpellEntryClass)) -#define CLAWS_IS_SPELL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CLAWS_TYPE_SPELL_ENTRY)) - -struct _ClawsSpellEntry -{ - GtkEntry parent_object; - - ClawsSpellEntryPriv *priv; - GtkAspell *gtkaspell; - - void (*gtk_reserved1)(void); - void (*gtk_reserved2)(void); - void (*gtk_reserved3)(void); - void (*gtk_reserved4)(void); -}; - -struct _ClawsSpellEntryClass -{ - GtkEntryClass parent_class; - - void (*gtk_reserved1)(void); - void (*gtk_reserved2)(void); - void (*gtk_reserved3)(void); - void (*gtk_reserved4)(void); -}; - -GType claws_spell_entry_get_type (void); -GtkWidget * claws_spell_entry_new (void); -void claws_spell_entry_set_gtkaspell (ClawsSpellEntry *entry, - GtkAspell *gtkaspell); -void claws_spell_entry_recheck_all (ClawsSpellEntry *entry); -void claws_spell_entry_check_all (ClawsSpellEntry *entry); -void claws_spell_entry_context_set (ClawsSpellEntry *entry); -void claws_spell_entry_check_backwards (ClawsSpellEntry *entry); -void claws_spell_entry_check_forwards_go (ClawsSpellEntry *entry); - - -G_END_DECLS - -#endif /* USE_ENCHANT */ -#endif /* __SPELL_ENTRY_H__ */ blob - 2d8d9b4f3eb1aed9c9423d56be52f7696187e7ad blob + fb7db3a391ce209539c557df306211bd5cda597d --- src/main.c +++ src/main.c @@ -63,7 +63,6 @@ #include "prefs_message.h" #include "prefs_receive.h" #include "prefs_quote.h" -#include "prefs_spelling.h" #include "prefs_summaries.h" #include "prefs_themes.h" #include "prefs_other.h" @@ -375,12 +374,6 @@ static void main_dump_features_list(gboolean show_debu debug_print("Compiled-in features:\n"); else g_print("Compiled-in features:\n"); -#if USE_ENCHANT - if (show_debug_only) - debug_print(" Enchant\n"); - else - g_print(" Enchant\n"); -#endif #if USE_GNUTLS if (show_debug_only) debug_print(" GnuTLS\n"); @@ -517,10 +510,6 @@ int main(int argc, char *argv[]) prefs_receive_init(); prefs_send_init(); matcher_init(); -#ifdef USE_ENCHANT - gtkaspell_checkers_init(); - prefs_spelling_init(); -#endif codeconv_set_allow_jisx0201_kana(prefs_common.allow_jisx0201_kana); codeconv_set_broken_are_utf8(prefs_common.broken_are_utf8); @@ -830,10 +819,6 @@ static void exit_claws(MainWindow *mainwin) prefs_receive_done(); prefs_logging_done(); prefs_send_done(); -#ifdef USE_ENCHANT - prefs_spelling_done(); - gtkaspell_checkers_quit(); -#endif claws_done(); } blob - 9e3a8faf8b1f845c48186163d336ec2128f905a9 blob + b0fd474ec8d8602757138a80ecc7971bd76d5def --- src/prefs_account.c +++ src/prefs_account.c @@ -250,12 +250,6 @@ typedef struct ComposePage GtkWidget *autobcc_entry; GtkWidget *autoreplyto_checkbtn; GtkWidget *autoreplyto_entry; -#if USE_ENCHANT - GtkWidget *checkbtn_enable_default_dictionary; - GtkWidget *combo_default_dictionary; - GtkWidget *checkbtn_enable_default_alt_dictionary; - GtkWidget *combo_default_alt_dictionary; -#endif } ComposePage; typedef struct TemplatesPage @@ -448,11 +442,6 @@ static void prefs_account_mailcmd_toggled(GtkToggleBut static void prefs_account_showpwd_toggled(GtkEntry *entry, gpointer user_data); static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button, gpointer user_data); -#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 (PrefParam *pparam); -#endif - static gchar *privacy_prefs; static PrefParam basic_param[] = { @@ -722,38 +711,6 @@ static PrefParam compose_param[] = { &compose_page.autoreplyto_entry, prefs_set_data_from_entry, prefs_set_entry}, -#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}, - - {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING, - &compose_page.combo_default_dictionary, - prefs_account_compose_default_dictionary_set_string_from_optmenu, - prefs_account_compose_default_dictionary_set_optmenu_from_string}, - - {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL, - &compose_page.checkbtn_enable_default_alt_dictionary, - prefs_set_data_from_toggle, prefs_set_toggle}, - - {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING, - &compose_page.combo_default_alt_dictionary, - prefs_account_compose_default_dictionary_set_string_from_optmenu, - prefs_account_compose_default_dictionary_set_optmenu_from_string}, -#else - {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL, - NULL, NULL, NULL}, - - {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING, - NULL, NULL, NULL}, - - {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL, - NULL, NULL, NULL}, - - {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING, - NULL, NULL, NULL}, -#endif - {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} }; @@ -2368,14 +2325,6 @@ static void compose_create_widget_func(PrefsPage * _pa GtkWidget *autobcc_entry; GtkWidget *autoreplyto_checkbtn; GtkWidget *autoreplyto_entry; -#if USE_ENCHANT - GtkWidget *frame_dict; - GtkWidget *table_dict; - GtkWidget *checkbtn_enable_default_dictionary = NULL; - GtkWidget *combo_default_dictionary = NULL; - GtkWidget *checkbtn_enable_default_alt_dictionary = NULL; - GtkWidget *combo_default_alt_dictionary = NULL; -#endif vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING); gtk_widget_show (vbox1); @@ -2495,43 +2444,6 @@ static void compose_create_widget_func(PrefsPage * _pa SET_TOGGLE_SENSITIVITY (autoreplyto_checkbtn, autoreplyto_entry); -#if USE_ENCHANT - PACK_FRAME (vbox1, frame_dict, _("Spell check dictionaries")); - - table_dict = gtk_grid_new(); - gtk_widget_show (table_dict); - gtk_container_add (GTK_CONTAINER (frame_dict), table_dict); - gtk_container_set_border_width (GTK_CONTAINER (table_dict), 8); - gtk_grid_set_row_spacing(GTK_GRID(table_dict), VSPACING_NARROW_2); - gtk_grid_set_column_spacing(GTK_GRID(table_dict), 8); - - /* Default dictionary */ - checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary")); - gtk_grid_attach(GTK_GRID(table_dict), checkbtn_enable_default_dictionary, 0, 0, 1, 1); - - 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(TRUE); - gtk_grid_attach(GTK_GRID(table_dict), combo_default_dictionary, 1, 0, 1, 1); - - SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary); - - /* Default dictionary */ - checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary")); - gtk_grid_attach(GTK_GRID(table_dict), checkbtn_enable_default_alt_dictionary, 0, 1, 1, 1); - - 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(FALSE); - gtk_grid_attach(GTK_GRID(table_dict), combo_default_alt_dictionary, 1, 1, 1, 1); - - SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary); - - gtk_widget_show_all(table_dict); -#endif - page->sigfile_radiobtn = sigfile_radiobtn; page->entry_sigpath = entry_sigpath; page->checkbtn_autosig = checkbtn_autosig; @@ -2543,24 +2455,7 @@ static void compose_create_widget_func(PrefsPage * _pa page->autobcc_entry = autobcc_entry; page->autoreplyto_checkbtn = autoreplyto_checkbtn; page->autoreplyto_entry = autoreplyto_entry; -#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_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()); - gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_alt_dictionary), - gtkaspell_dictionary_store_new_with_refresh( - FALSE)); - } -#endif - tmp_ac_prefs = *ac_prefs; if (new_account) { @@ -5732,56 +5627,6 @@ static void prefs_account_filter_on_recv_toggled(GtkTo gtk_widget_set_sensitive(receive_page.filterhook_on_recv_checkbtn, do_filter); } -#if USE_ENCHANT -static void prefs_account_compose_default_dictionary_set_string_from_optmenu - (PrefParam *pparam) -{ - GtkWidget *combo; - gchar **str; - - cm_return_if_fail(*pparam->widget != NULL); - - combo = *pparam->widget; - str = (gchar **) pparam->data; - - g_free(*str); - *str = gtkaspell_get_dictionary_menu_active_item(GTK_COMBO_BOX(combo)); -} - -static void prefs_account_compose_default_dictionary_set_optmenu_from_string - (PrefParam *pparam) -{ - GtkWidget *combo; - gchar *dictionary; - - cm_return_if_fail(*pparam->widget != NULL); - - dictionary = *((gchar **) pparam->data); - if (dictionary != NULL) { - if (strrchr(dictionary, '/')) { - dictionary = g_strdup(strrchr(dictionary, '/')+1); - } - - if (strchr(dictionary, '-')) { - *(strchr(dictionary, '-')) = '\0'; - } - } - combo = *pparam->widget; - if (dictionary && *dictionary) - gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(combo), - dictionary); - else { - GtkTreeModel *model; - GtkTreeIter iter; - if((model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo))) == NULL) - return; - if((gtk_tree_model_get_iter_first(model, &iter)) == FALSE) - return; - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter); - } -} -#endif - gchar *prefs_account_generate_msgid(PrefsAccount *account) { gchar *addr, *tmbuf, *buf = NULL; blob - 0adc07be8725ec8e38d07b0d276a91f0bfd00876 blob + 3f387daccfb1dc39704d1705b28b6630aca6447e --- src/prefs_account.h +++ src/prefs_account.h @@ -153,10 +153,6 @@ struct _PrefsAccount gchar *auto_bcc; gboolean set_autoreplyto; gchar *auto_replyto; - gboolean enable_default_dictionary; - gchar *default_dictionary; - gboolean enable_default_alt_dictionary; - gchar *default_alt_dictionary; gboolean compose_with_format; gchar *compose_subject_format; gchar *compose_body_format; blob - b6962d0e6b32f998e80d6480e9464ff04281de16 blob + a45a7a66ce220dbf8281293bc52809c1733efa34 --- src/prefs_common.c +++ src/prefs_common.c @@ -189,23 +189,6 @@ static PrefParam param[] = { {"warn_large_insert_size", "500", &prefs_common.warn_large_insert_size, P_INT, NULL, NULL, NULL}, - {"enable_aspell", "TRUE", &prefs_common.enable_aspell, P_BOOL, - NULL, NULL, NULL}, - {"dictionary", "", &prefs_common.dictionary, P_STRING, - NULL, NULL, NULL}, - {"alt_dictionary", "", &prefs_common.alt_dictionary, P_STRING, - 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, - NULL, NULL, NULL}, - {"recheck_when_changing_dict", "TRUE", &prefs_common.recheck_when_changing_dict, - P_BOOL, NULL, NULL, NULL}, - {"misspelled_color", "#ff0000", &prefs_common.color[COL_MISSPELLED], - P_COLOR, NULL, NULL, NULL}, - {"use_both_dicts", "FALSE", &prefs_common.use_both_dicts, P_BOOL, - NULL, NULL, NULL}, - {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL, NULL, NULL, NULL}, {"compose_dnd_insert_or_attach", "0", &prefs_common.compose_dnd_mode, P_ENUM, blob - f92ea33d1b9a33763e03ec71553bd36c2da048f7 blob + 56629d83885da4da88e70235f08ddb3dcd38477d --- src/prefs_common.h +++ src/prefs_common.h @@ -213,15 +213,6 @@ struct _PrefsCommon gboolean redirect_keep_from; gchar *quote_chars; - gboolean enable_aspell; - gchar *dictionary; - gchar *alt_dictionary; - gboolean check_while_typing; - gboolean recheck_when_changing_dict; - gboolean use_alternate; - gboolean use_both_dicts; - - /* Display */ /* fonts */ gchar *textfont; gchar *printfont; blob - 49e6adeb4ef5e0ab7616511ad47e66571379078f blob + 619555d6bb7c123392dd6ca051f29f541533cfd6 --- src/prefs_folder_item.c +++ src/prefs_folder_item.c @@ -49,10 +49,6 @@ #include "stock_pixmap.h" #include "file-utils.h" -#if USE_ENCHANT -#include "gtkaspell.h" -#endif - #define ASSIGN_STRING(string, value) \ { \ g_free(string); \ @@ -132,12 +128,6 @@ struct _FolderItemComposePage GtkWidget *entry_default_replyto; GtkWidget *checkbtn_enable_default_account; GtkWidget *optmenu_default_account; -#if USE_ENCHANT - GtkWidget *checkbtn_enable_default_dictionary; - GtkWidget *checkbtn_enable_default_alt_dictionary; - GtkWidget *combo_default_dictionary; - GtkWidget *combo_default_alt_dictionary; -#endif GtkWidget *always_sign; GtkWidget *always_encrypt; @@ -151,10 +141,6 @@ struct _FolderItemComposePage GtkWidget *default_bcc_rec_checkbtn; GtkWidget *default_replyto_rec_checkbtn; GtkWidget *default_account_rec_checkbtn; -#if USE_ENCHANT - GtkWidget *default_dictionary_rec_checkbtn; - GtkWidget *default_alt_dictionary_rec_checkbtn; -#endif GtkWidget *always_sign_rec_checkbtn; GtkWidget *always_encrypt_rec_checkbtn; }; @@ -920,15 +906,6 @@ static void prefs_folder_item_compose_create_widget_fu GtkWidget *optmenu_default_account = NULL; GtkListStore *optmenu_default_account_menu = NULL; GtkTreeIter iter; -#if USE_ENCHANT - GtkWidget *checkbtn_enable_default_dictionary = NULL; - GtkWidget *combo_default_dictionary = NULL; - GtkWidget *checkbtn_enable_default_alt_dictionary = NULL; - GtkWidget *combo_default_alt_dictionary = NULL; - GtkWidget *default_dictionary_rec_checkbtn = NULL; - GtkWidget *default_alt_dictionary_rec_checkbtn = NULL; - gchar *dictionary; -#endif GtkWidget *always_sign; GtkListStore *always_sign_menu; GtkWidget *always_encrypt; @@ -953,11 +930,7 @@ static void prefs_folder_item_compose_create_widget_fu page->item = item; /* Table */ -#if USE_ENCHANT -# define TABLEHEIGHT 7 -#else -# define TABLEHEIGHT 6 -#endif +#define TABLEHEIGHT 6 table = gtk_grid_new(); gtk_container_set_border_width (GTK_CONTAINER (table), VBOX_BORDER); gtk_grid_set_row_spacing(GTK_GRID(table), 4); @@ -1184,70 +1157,6 @@ static void prefs_folder_item_compose_create_widget_fu gtk_grid_attach(GTK_GRID(table), default_account_rec_checkbtn, 2, rowcount, 1, 1); rowcount++; -#if USE_ENCHANT - /* Default dictionary */ - checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary")); - gtk_grid_attach(GTK_GRID(table), checkbtn_enable_default_dictionary, 0, rowcount, 1, 1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary), - item->prefs->enable_default_dictionary); - - combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE); - gtk_grid_attach(GTK_GRID(table), combo_default_dictionary, 1, rowcount, 1, 1); - - 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 (item->prefs->default_dictionary && - strchr(item->prefs->default_dictionary, '-')) { - *(strchr(item->prefs->default_dictionary, '-')) = '\0'; - } - if (dictionary) - gtkaspell_set_dictionary_menu_active_item( - GTK_COMBO_BOX(combo_default_dictionary), dictionary); - - SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary); - - default_dictionary_rec_checkbtn = gtk_check_button_new(); - gtk_grid_attach(GTK_GRID(table), default_dictionary_rec_checkbtn, 2, rowcount, 1, 1); - - rowcount++; - - /* Default alternate dictionary */ - checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary")); - gtk_grid_attach(GTK_GRID(table), checkbtn_enable_default_alt_dictionary, 0, rowcount, 1, 1); - 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(FALSE); - gtk_grid_attach(GTK_GRID(table), combo_default_alt_dictionary, 1, rowcount, 1, 1); - - 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 (item->prefs->default_alt_dictionary && - strchr(item->prefs->default_alt_dictionary, '-')) { - *(strchr(item->prefs->default_alt_dictionary, '-')) = '\0'; - } - if (dictionary) - gtkaspell_set_dictionary_menu_active_item( - GTK_COMBO_BOX(combo_default_alt_dictionary), dictionary); - - SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary); - - default_alt_dictionary_rec_checkbtn = gtk_check_button_new(); - gtk_grid_attach(GTK_GRID(table), default_alt_dictionary_rec_checkbtn, 2, rowcount, 1, 1); - - rowcount++; -#endif - /* PGP sign? */ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_spacing(GTK_BOX(hbox), 8); @@ -1331,12 +1240,6 @@ static void prefs_folder_item_compose_create_widget_fu page->entry_default_replyto = entry_default_replyto; page->checkbtn_enable_default_account = checkbtn_enable_default_account; page->optmenu_default_account = optmenu_default_account; -#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 page->always_sign = always_sign; page->always_encrypt = always_encrypt; @@ -1349,10 +1252,6 @@ static void prefs_folder_item_compose_create_widget_fu page->default_bcc_rec_checkbtn = default_bcc_rec_checkbtn; page->default_replyto_rec_checkbtn = default_replyto_rec_checkbtn; page->default_account_rec_checkbtn = default_account_rec_checkbtn; -#if USE_ENCHANT - page->default_dictionary_rec_checkbtn = default_dictionary_rec_checkbtn; - page->default_alt_dictionary_rec_checkbtn = default_alt_dictionary_rec_checkbtn; -#endif page->always_sign_rec_checkbtn = always_sign_rec_checkbtn; page->always_encrypt_rec_checkbtn = always_encrypt_rec_checkbtn; @@ -1474,22 +1373,6 @@ static void compose_save_folder_prefs(FolderItem *fold GTK_COMBO_BOX(page->optmenu_default_account)); } -#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)); - ASSIGN_STRING(prefs->default_dictionary, - gtkaspell_get_dictionary_menu_active_item( - GTK_COMBO_BOX(page->combo_default_dictionary))); - } - if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn))) { - prefs->enable_default_alt_dictionary = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_alt_dictionary)); - ASSIGN_STRING(prefs->default_alt_dictionary, - gtkaspell_get_dictionary_menu_active_item( - GTK_COMBO_BOX(page->combo_default_alt_dictionary))); - } -#endif if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_sign_rec_checkbtn))) { prefs->always_sign = combobox_get_active_data(GTK_COMBO_BOX(page->always_sign)); @@ -1524,10 +1407,6 @@ static gboolean compose_save_recurse_func(GNode *node, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_cc_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_bcc_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_replyto_rec_checkbtn)) || -#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 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_sign_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_encrypt_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_reply_to_rec_checkbtn)) @@ -1535,10 +1414,6 @@ static gboolean compose_save_recurse_func(GNode *node, 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_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 || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_sign_rec_checkbtn)) || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->always_encrypt_rec_checkbtn)) )) blob - 6dffb1a6cd9151485ef27d8a8c1c56ba99d0cd09 (mode 644) blob + /dev/null --- src/prefs_spelling.c +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2002-2025 the Claws Mail team and Hiroyuki Yamamoto - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#include "claws-features.h" -#endif - -#if USE_ENCHANT - -#include "defs.h" - -#include -#include - -#include -#include -#include - -#include "utils.h" -#include "prefs_common.h" -#include "prefs_gtk.h" - -#include "gtk/gtkutils.h" -#include "gtk/prefswindow.h" -#include "gtk/filesel.h" -#include "gtk/combobox.h" - -typedef struct _SpellingPage -{ - PrefsPage page; - - GtkWidget *window; /* do not modify */ - - GtkWidget *automatic_frame; - GtkWidget *dictionary_frame; - - GtkWidget *enable_aspell_checkbtn; - GtkWidget *recheck_when_changing_dict_checkbtn; - GtkWidget *check_while_typing_checkbtn; - GtkWidget *use_alternate_checkbtn; - - GtkWidget *default_dict_label; - GtkWidget *default_dict_combo; - - GtkWidget *default_alt_dict_label; - GtkWidget *default_alt_dict_combo; - - GtkWidget *both_dict_check; - - GtkWidget *misspelled_label; - GtkWidget *misspelled_colorbtn; - GtkWidget *misspelled_useblack_label; - - GdkRGBA misspell_col; -} SpellingPage; - -#define SAFE_STRING(str) \ - (str) ? (str) : "" - -static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gpointer data) -{ - SpellingPage *prefs_spelling = (SpellingPage *) _page; - - GtkWidget *vbox1, *vbox2; - - GtkWidget *enable_aspell_checkbtn; - GtkWidget *check_while_typing_checkbtn; - GtkWidget *recheck_when_changing_dict_checkbtn; - GtkWidget *use_alternate_checkbtn; - - GtkWidget *automatic_frame; - GtkWidget *dictionary_frame; - - GtkWidget *table; - - GtkWidget *default_dict_label; - GtkWidget *default_dict_combo; - - GtkWidget *default_alt_dict_label; - GtkWidget *default_alt_dict_combo; - GtkWidget *both_dict_check; - - GtkWidget *misspelled_label; - GtkWidget *misspelled_hbox; - GtkWidget *misspelled_colorbtn; - - vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING); - gtk_widget_show (vbox1); - gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER); - - vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - gtk_widget_show (vbox2); - gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0); - - enable_aspell_checkbtn = gtk_check_button_new_with_label( - _("Enable spell checker")); - gtk_widget_show(enable_aspell_checkbtn); - gtk_box_pack_start(GTK_BOX(vbox2), enable_aspell_checkbtn, TRUE, TRUE, 0); - - use_alternate_checkbtn = gtk_check_button_new_with_label( - _("Enable alternate dictionary")); - gtk_widget_show(use_alternate_checkbtn); - gtk_box_pack_start(GTK_BOX(vbox2), use_alternate_checkbtn, TRUE, TRUE, 0); - - CLAWS_SET_TIP(use_alternate_checkbtn, - _("Faster switching with last used dictionary")); - - vbox2 = gtkut_get_options_frame(vbox1, &automatic_frame, _("Automatic spell checking")); - - check_while_typing_checkbtn = gtk_check_button_new_with_label( - _("Check while typing")); - gtk_widget_show(check_while_typing_checkbtn); - gtk_box_pack_start(GTK_BOX(vbox2), check_while_typing_checkbtn, TRUE, TRUE, 0); - - recheck_when_changing_dict_checkbtn = gtk_check_button_new_with_label( - _("Re-check message when changing dictionary")); - gtk_widget_show(recheck_when_changing_dict_checkbtn); - gtk_box_pack_start(GTK_BOX(vbox2), recheck_when_changing_dict_checkbtn, TRUE, TRUE, 0); - - vbox2 = gtkut_get_options_frame(vbox1, &dictionary_frame, _("Dictionary")); - - table = gtk_grid_new(); - gtk_widget_show(table); - gtk_container_set_border_width(GTK_CONTAINER(table), 0); - gtk_grid_set_row_spacing(GTK_GRID(table), 4); - gtk_grid_set_column_spacing(GTK_GRID(table), 8); - - gtk_box_pack_start(GTK_BOX(vbox2), table, TRUE, TRUE, 0); - - default_dict_label = gtk_label_new(_("Default dictionary")); - gtk_widget_show(default_dict_label); - gtk_label_set_justify(GTK_LABEL(default_dict_label), GTK_JUSTIFY_RIGHT); - gtk_label_set_xalign(GTK_LABEL(default_dict_label), 1.0); - gtk_grid_attach(GTK_GRID(table), default_dict_label, 0, 0, 1, 1); - - default_dict_combo = gtkaspell_dictionary_combo_new(TRUE); - gtk_grid_attach(GTK_GRID(table), default_dict_combo, 1, 0, 1, 1); - - default_alt_dict_label = gtk_label_new(_("Default alternate dictionary")); - gtk_widget_show(default_alt_dict_label); - gtk_label_set_justify(GTK_LABEL(default_alt_dict_label), GTK_JUSTIFY_RIGHT); - gtk_label_set_xalign(GTK_LABEL(default_alt_dict_label), 1.0); - gtk_grid_attach(GTK_GRID(table), default_alt_dict_label, 0, 1, 1, 1); - - default_alt_dict_combo = gtkaspell_dictionary_combo_new(FALSE); - gtk_grid_attach(GTK_GRID(table), default_alt_dict_combo, 1, 1, 1, 1); - - both_dict_check = gtk_check_button_new_with_label( - _("Check with both dictionaries")); - gtk_widget_show(both_dict_check); - gtk_grid_attach(GTK_GRID(table), both_dict_check, 1, 2, 1, 1); - - misspelled_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); - gtk_widget_show(misspelled_hbox); - gtk_box_pack_start(GTK_BOX(vbox1), misspelled_hbox, FALSE, FALSE, 0); - - misspelled_label = gtk_label_new(_("Misspelled word color")); - gtk_widget_show(misspelled_label); - gtk_box_pack_start(GTK_BOX(misspelled_hbox), misspelled_label, - FALSE, FALSE, 0); - gtk_label_set_justify(GTK_LABEL(misspelled_label), GTK_JUSTIFY_RIGHT); - gtk_label_set_xalign(GTK_LABEL(misspelled_label), 1.0); - - misspelled_colorbtn = gtk_color_button_new_with_rgba( - &prefs_common.color[COL_MISSPELLED]); - gtk_color_button_set_title(GTK_COLOR_BUTTON(misspelled_colorbtn), - _("Pick color for misspelled word")); - gtk_widget_show(misspelled_colorbtn); - gtk_box_pack_start(GTK_BOX(misspelled_hbox), misspelled_colorbtn, - FALSE, FALSE, 0); - CLAWS_SET_TIP(misspelled_colorbtn, - _("Pick color for misspelled word. " - "Use black to underline")); - - SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, automatic_frame); - SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, dictionary_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); - SET_TOGGLE_SENSITIVITY(use_alternate_checkbtn, default_alt_dict_label); - SET_TOGGLE_SENSITIVITY(use_alternate_checkbtn, default_alt_dict_combo); - SET_TOGGLE_SENSITIVITY(use_alternate_checkbtn, both_dict_check); - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable_aspell_checkbtn), - prefs_common.enable_aspell); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(both_dict_check), - prefs_common.use_both_dicts); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_while_typing_checkbtn), - prefs_common.check_while_typing); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(recheck_when_changing_dict_checkbtn), - prefs_common.recheck_when_changing_dict); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_alternate_checkbtn), - prefs_common.use_alternate); - if (prefs_common.dictionary && - strrchr(prefs_common.dictionary, '/')) { - gchar *tmp = g_strdup(strrchr(prefs_common.dictionary, '/')+1); - g_free(prefs_common.dictionary); - prefs_common.dictionary = tmp; - } - if (prefs_common.alt_dictionary && - 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; - } - if (prefs_common.dictionary && - strchr(prefs_common.dictionary, '-')) { - *(strchr(prefs_common.dictionary, '-')) = '\0'; - } - if (prefs_common.alt_dictionary && - strchr(prefs_common.alt_dictionary, '-')) { - *(strchr(prefs_common.alt_dictionary, '-')) = '\0'; - } - gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(default_dict_combo), - prefs_common.dictionary); - - gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(default_alt_dict_combo), - prefs_common.alt_dictionary); - - prefs_spelling->window = GTK_WIDGET(window); - prefs_spelling->automatic_frame = automatic_frame; - prefs_spelling->dictionary_frame = dictionary_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->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->misspelled_label = misspelled_label; - prefs_spelling->misspelled_colorbtn = misspelled_colorbtn; - prefs_spelling->both_dict_check = both_dict_check; - - prefs_spelling->page.widget = vbox1; -} - -static void prefs_spelling_save(PrefsPage *_page) -{ - SpellingPage *spelling = (SpellingPage *) _page; - - prefs_common.enable_aspell = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->enable_aspell_checkbtn)); - prefs_common.check_while_typing = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->check_while_typing_checkbtn)); - prefs_common.recheck_when_changing_dict = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->recheck_when_changing_dict_checkbtn)); - prefs_common.use_alternate = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->use_alternate_checkbtn)); - prefs_common.use_both_dicts = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(spelling->both_dict_check)); - - g_free(prefs_common.dictionary); - prefs_common.dictionary = - gtkaspell_get_dictionary_menu_active_item( - GTK_COMBO_BOX(spelling->default_dict_combo)); - - g_free(prefs_common.alt_dictionary); - prefs_common.alt_dictionary = - gtkaspell_get_dictionary_menu_active_item( - GTK_COMBO_BOX(spelling->default_alt_dict_combo)); - - gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(spelling->misspelled_colorbtn), - &prefs_common.color[COL_MISSPELLED]); -} - -static void prefs_spelling_destroy_widget(PrefsPage *_page) -{ - /* SpellingPage *spelling = (SpellingPage *) _page; */ - -} - -SpellingPage *prefs_spelling; - -void prefs_spelling_init(void) -{ - SpellingPage *page; - static gchar *path[3]; - const gchar* language = NULL; - - path[0] = _("Write"); - path[1] = _("Spell Checking"); - path[2] = NULL; - - page = g_new0(SpellingPage, 1); - page->page.path = path; - page->page.create_widget = prefs_spelling_create_widget; - page->page.destroy_widget = prefs_spelling_destroy_widget; - page->page.save_page = prefs_spelling_save; - page->page.weight = 180.0; - - prefs_gtk_register_page((PrefsPage *) page); - prefs_spelling = page; - - language = g_getenv("LANG"); - if (language == NULL || !strcmp(language, "POSIX") || !strcmp(language, "C")) - language = "en"; - - if (!prefs_common.dictionary) - prefs_common.dictionary = g_strdup_printf("%s", language); - - if (!strlen(prefs_common.dictionary) || !strcmp(prefs_common.dictionary, _("None"))) { - g_free(prefs_common.dictionary); - prefs_common.dictionary = g_strdup_printf("%s", language); - } - - if (strcasestr(prefs_common.dictionary,".utf")) - *(strcasestr(prefs_common.dictionary,".utf")) = '\0'; - if (strstr(prefs_common.dictionary,"@")) - *(strstr(prefs_common.dictionary,"@")) = '\0'; -} - -void prefs_spelling_done(void) -{ - prefs_gtk_unregister_page((PrefsPage *) prefs_spelling); - g_free(prefs_spelling); -} - -#endif /* USE_ENCHANT */ blob - b40da474d98ae4c7565ac409de563bdc90d562ca (mode 644) blob + /dev/null --- src/prefs_spelling.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef PREFS_SPELLING_H -#define PREFS_SPELLING_H - -void prefs_spelling_init (void); -void prefs_spelling_done (void); - -#endif /* PREFS_SPELLING_H */ blob - a05bf8940e34b396c76a43ff8044a120ca68621b blob + 1373ce3370f7cf0c5cf1ea9e2020ab5405be6f13 --- src/prefs_template.c +++ src/prefs_template.c @@ -59,12 +59,7 @@ gboolean prefs_template_string_is_valid(gchar *string, dummyinfo.newsgroups="alt.test"; dummyinfo.subject="subject"; - -#ifdef USE_ENCHANT - quote_fmt_init(&dummyinfo, NULL, NULL, TRUE, account, FALSE, NULL); -#else quote_fmt_init(&dummyinfo, NULL, NULL, TRUE, account, FALSE); -#endif quote_fmt_scan_string(tmp); quote_fmt_parse(); g_free(tmp); blob - 5bdbe35e72a34ad434b9f34f8466746c5a59dda1 blob + 2e1ea8f2bf0e41e6edee30e5a1e4a73a540f3576 --- src/quote_fmt.c +++ src/quote_fmt.c @@ -63,7 +63,6 @@ static gchar *quote_desc_strings[] = { "%msg_no_sig (%m)", N_("message body without signature"), /* message with no signature */ "%quoted_msg_no_sig (%q)", N_("quoted message body without signature"), /* quoted message with no signature */ "%tags", N_("message tags"), /* message tags */ - "%dict (%T)", N_("current dictionary"), /* current dictionary */ "%cursor (%X)", N_("cursor position"), /* X marks the cursor spot */ "%account_fullname (%af)", N_("account property: your name"), /* full name in compose account */ "%account_email (%am)", N_("account property: your email address"), /* mail address in compose account */ @@ -71,7 +70,6 @@ static gchar *quote_desc_strings[] = { "%account_org (%ao)", N_("account property: organization"), /* organization in compose account */ "%account_sig (%as)", N_("account property: signature"), /* signature set in account prefs */ "%account_sigpath (%asp)", N_("account property: signature path"), /* signature path set in account prefs */ - "%account_dict (%aT)", N_("account property: default dictionary"), /* main dict (if enabled) in account */ "%addrbook_cc (%ABc)", N_("address book completion: Cc"), /* completion of 'Cc' from address book */ "%addrbook_from (%ABf)", N_("address book completion: From"), /* completion of 'From' from address book */ "%addrbook_to (%ABt)", N_("address book completion: To"), /* completion of 'To' from address book */ blob - f0a5ddbc318c7962f0c1dcdc93f071367f7fecd9 blob + 2900b947b1ccd756811c85a87e0ceba89ecc6fc9 --- src/quote_fmt.h +++ src/quote_fmt.h @@ -21,10 +21,6 @@ #define __QUOTE_FMT_H__ -#ifdef USE_ENCHANT -#include "gtkaspell.h" -#endif - #define quote_fmt_parse quote_fmtparse void quote_fmt_quote_description(GtkWidget *widget, GtkWidget *pref_window); @@ -32,18 +28,11 @@ void quote_fmt_quote_description(GtkWidget *widget, Gt gchar *quote_fmt_get_buffer(void); GList *quote_fmt_get_attachments_list(void); gint quote_fmt_get_line(void); -#ifdef USE_ENCHANT + void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, const gchar *my_body, gboolean my_dry_run, PrefsAccount *account, - gboolean escaped_string, - GtkAspell *gtkaspell); -#else -void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, - const gchar *my_body, gboolean my_dry_run, - PrefsAccount *account, gboolean escaped_string); -#endif gint quote_fmtparse(void); int quote_fmtlex_destroy(void); void quote_fmt_scan_string(const gchar *str); blob - 6d70a44fa3cf9e71ccc0ee497b35dffd3057e0a9 blob + 89d7346c89b95fac812fefbf331392c354e7dfbc --- src/quote_fmt_lex.l +++ src/quote_fmt_lex.l @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * */ #include "quote_fmt_lex.h" @@ -62,13 +62,13 @@ int escaped_string = 0; * always return to S_NORMAL after quote fmt parsing is * done. */ -%} +%} %{ if (quote_fmt_firsttime) { BEGIN S_NORMAL; quote_fmt_firsttime = 0; - } + } %} ("%X"|"%cursor") /* cursor pos */ return SET_CURSOR_POS; @@ -88,7 +88,6 @@ int escaped_string = 0; ("%r"|"%references") /* references */ return SHOW_REFERENCES; ("%s"|"%subject") /* subject */ return SHOW_SUBJECT; ("%t"|"%to") /* to */ return SHOW_TO; -("%T"|"%dict") /* current dictionary */ return SHOW_DICT; ("%tags") /* tags */ return SHOW_TAGS; ("%Q"|"%quoted_msg") /* quoted message */ return SHOW_QUOTED_MESSAGE; ("%q"|"%quoted_msg_no_sig") /* quoted message with no signature */ return SHOW_QUOTED_MESSAGE_NO_SIGNATURE; @@ -98,7 +97,6 @@ int escaped_string = 0; ("%ao"|"%account_org") /* organization in compose account */ return SHOW_ACCOUNT_ORGANIZATION; ("%as"|"%account_sig") /* signature in compose account */ return SHOW_ACCOUNT_SIG; ("%asp"|"%account_sigpath") /* signature path in compose account */ return SHOW_ACCOUNT_SIGPATH; -("%aT"|"%account_dict") /* main dict (if enabled) in compose account */ return SHOW_ACCOUNT_DICT; ("%ABc"|"%addrbook_cc") /* completion of 'Cc' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_CC; ("%ABf"|"%addrbook_from") /* completion of 'From' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM; ("%ABt"|"%addrbook_to") /* completion of 'To' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_TO; @@ -117,7 +115,6 @@ int escaped_string = 0; ("?N"|"?F"|"?L"|"?I"|"?fullname"|"?firstname"|"?lastname"|"?initials") /* query from name */ return QUERY_FULLNAME; ("?s"|"?subject") /* query subject */ return QUERY_SUBJECT; ("?t"|"?to") /* query to */ return QUERY_TO; -("?T"|"?dict") /* query current dictionary set and enabled */ return QUERY_DICT; ("?c"|"?cc") /* query cc */ return QUERY_CC; ("?n"|"?newsgroups") /* query newsgroups */ return QUERY_NEWSGROUPS; ("?i"|"?messageid") /* query message-id */ return QUERY_MESSAGEID; @@ -126,7 +123,6 @@ int escaped_string = 0; ("?ao"|"?account_org") /* query organization in compose account */ return QUERY_ACCOUNT_ORGANIZATION; ("?as"|"?account_sig") /* query signature */ return QUERY_ACCOUNT_SIG; ("?asp"|"?account_sigpath") /* query signature path */ return QUERY_ACCOUNT_SIGPATH; -("?aT"|"?account_dict") /* query account main dict enabled */ return QUERY_ACCOUNT_DICT; ("?ABc"|"?addrbook_cc") /* query completion for 'Cc' in address book */ return QUERY_CC_FOUND_IN_ADDRESSBOOK; ("?ABf"|"?addrbook_from") /* query completion for 'From' in address book */ return QUERY_FROM_FOUND_IN_ADDRESSBOOK; ("?ABt"|"?addrbook_to") /* query completion for 'To' in address book */ return QUERY_TO_FOUND_IN_ADDRESSBOOK; @@ -135,7 +131,6 @@ int escaped_string = 0; ("!N"|"!F"|"!L"|"!I"|"!fullname"|"!firstname"|"!lastname"|"!initials") /* query not(from name) */ return QUERY_NOT_FULLNAME; ("!s"|"!subject") /* query not(subject) */ return QUERY_NOT_SUBJECT; ("!t"|"!to") /* query not(to) */ return QUERY_NOT_TO; -("!T"|"!dict") /* query not(current dictionary set and enabled) */ return QUERY_NOT_DICT; ("!c"|"!cc") /* query not(cc) */ return QUERY_NOT_CC; ("!n"|"!newsgroups") /* query not(newsgroups) */ return QUERY_NOT_NEWSGROUPS; ("!i"|"!messageid") /* query not(message-id) */ return QUERY_NOT_MESSAGEID; @@ -144,7 +139,6 @@ int escaped_string = 0; ("!ao"|"!account_org") /* query not(organization in compose account) */ return QUERY_NOT_ACCOUNT_ORGANIZATION; ("!as"|"!account_sig") /* query not(signature) */ return QUERY_NOT_ACCOUNT_SIG; ("!asp"|"!account_sigpath") /* query not(signature path) */ return QUERY_NOT_ACCOUNT_SIGPATH; -("!aT"|"!account_dict") /* query not(account main dict enabled and set) */ return QUERY_NOT_ACCOUNT_DICT; ("!ABc"|"!addrbook_cc") /* query not(completion for 'Cc' in address book) */ return QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK; ("!ABf"|"!addrbook_from") /* query not(completion for 'From' in address book) */ return QUERY_NOT_FROM_FOUND_IN_ADDRESSBOOK; ("!ABt"|"!addrbook_to") /* query not(completion for 'To' in address book) */ return QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK; blob - d5364abe06a25342959c9ad31ba37452759129c0 blob + 7f7384991398b0e8fc37cfebfb40b8bfc830aba5 --- src/quote_fmt_parse.y +++ src/quote_fmt_parse.y @@ -49,9 +49,6 @@ int yylex(void); static MsgInfo *msginfo = NULL; static PrefsAccount *account = NULL; -#ifdef USE_ENCHANT -static gchar default_dictionary[BUFFSIZE]; -#endif static gboolean *visible = NULL; static gboolean dry_run = FALSE; static gint maxsize = 0; @@ -186,30 +183,16 @@ void quote_fmt_reset_vartable(void) } } -#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, - gboolean string_is_escaped, - GtkAspell *compose_gtkaspell) -#else -void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, - const gchar *my_body, gboolean my_dry_run, - PrefsAccount *compose_account, gboolean string_is_escaped) -#endif { quote_str = my_quote_str; body = my_body; msginfo = info; account = compose_account; -#ifdef USE_ENCHANT - gchar *dict = gtkaspell_get_default_dictionary(compose_gtkaspell); - if (dict) - strncpy2(default_dictionary, dict, sizeof(default_dictionary)); - else - *default_dictionary = '\0'; -#endif dry_run = my_dry_run; stacksize = 0; add_visibility(TRUE); @@ -637,8 +620,8 @@ static gchar *quote_fmt_complete_address(const gchar * %token SHOW_QUOTED_MESSAGE_NO_SIGNATURE SHOW_MESSAGE_NO_SIGNATURE %token SHOW_EOL SHOW_QUESTION_MARK SHOW_EXCLAMATION_MARK SHOW_PIPE SHOW_OPARENT SHOW_CPARENT %token SHOW_ACCOUNT_FULL_NAME SHOW_ACCOUNT_MAIL_ADDRESS SHOW_ACCOUNT_NAME SHOW_ACCOUNT_ORGANIZATION -%token SHOW_ACCOUNT_DICT SHOW_ACCOUNT_SIG SHOW_ACCOUNT_SIGPATH -%token SHOW_DICT SHOW_TAGS +%token SHOW_ACCOUNT_SIG SHOW_ACCOUNT_SIGPATH +%token SHOW_TAGS %token SHOW_ADDRESSBOOK_COMPLETION_FOR_CC %token SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM %token SHOW_ADDRESSBOOK_COMPLETION_FOR_TO @@ -646,9 +629,8 @@ static gchar *quote_fmt_complete_address(const gchar * %token QUERY_DATE QUERY_FROM %token QUERY_FULLNAME QUERY_SUBJECT QUERY_TO QUERY_NEWSGROUPS %token QUERY_MESSAGEID QUERY_CC QUERY_REFERENCES -%token QUERY_ACCOUNT_FULL_NAME QUERY_ACCOUNT_ORGANIZATION QUERY_ACCOUNT_DICT +%token QUERY_ACCOUNT_FULL_NAME QUERY_ACCOUNT_ORGANIZATION %token QUERY_ACCOUNT_SIG QUERY_ACCOUNT_SIGPATH -%token QUERY_DICT %token QUERY_CC_FOUND_IN_ADDRESSBOOK %token QUERY_FROM_FOUND_IN_ADDRESSBOOK %token QUERY_TO_FOUND_IN_ADDRESSBOOK @@ -656,9 +638,8 @@ static gchar *quote_fmt_complete_address(const gchar * %token QUERY_NOT_DATE QUERY_NOT_FROM %token QUERY_NOT_FULLNAME QUERY_NOT_SUBJECT QUERY_NOT_TO QUERY_NOT_NEWSGROUPS %token QUERY_NOT_MESSAGEID QUERY_NOT_CC QUERY_NOT_REFERENCES -%token QUERY_NOT_ACCOUNT_FULL_NAME QUERY_NOT_ACCOUNT_ORGANIZATION QUERY_NOT_ACCOUNT_DICT +%token QUERY_NOT_ACCOUNT_FULL_NAME QUERY_NOT_ACCOUNT_ORGANIZATION %token QUERY_NOT_ACCOUNT_SIG QUERY_NOT_ACCOUNT_SIGPATH -%token QUERY_NOT_DICT %token QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK %token QUERY_NOT_FROM_FOUND_IN_ADDRESSBOOK %token QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK @@ -855,22 +836,6 @@ special: if (account && account->sig_path) INSERT(account->sig_path); } - | SHOW_ACCOUNT_DICT - { -#ifdef USE_ENCHANT - if (account && account->enable_default_dictionary) { - gchar *dictname = g_path_get_basename(account->default_dictionary); - INSERT(dictname); - g_free(dictname); - } -#endif - } - | SHOW_DICT - { -#ifdef USE_ENCHANT - INSERT(default_dictionary); -#endif - } | SHOW_BACKSLASH { INSERT("\\"); @@ -1050,31 +1015,6 @@ query: { remove_visibility(); } - | QUERY_ACCOUNT_DICT - { -#ifdef USE_ENCHANT - add_visibility(account != NULL && account->enable_default_dictionary == TRUE && - account->default_dictionary != NULL && *account->default_dictionary != '\0'); -#else - add_visibility(FALSE); -#endif - } - OPARENT quote_fmt CPARENT - { - remove_visibility(); - } - | QUERY_DICT - { -#ifdef USE_ENCHANT - add_visibility(*default_dictionary != '\0'); -#else - add_visibility(FALSE); -#endif - } - OPARENT quote_fmt CPARENT - { - remove_visibility(); - } | QUERY_CC_FOUND_IN_ADDRESSBOOK { gchar *tmp = quote_fmt_complete_address(msginfo->cc); @@ -1221,31 +1161,6 @@ query_not: { remove_visibility(); } - | QUERY_NOT_ACCOUNT_DICT - { -#ifdef USE_ENCHANT - add_visibility(account == NULL || account->enable_default_dictionary == FALSE - || *account->default_dictionary == '\0'); -#else - add_visibility(FALSE); -#endif - } - OPARENT quote_fmt CPARENT - { - remove_visibility(); - } - | QUERY_NOT_DICT - { -#ifdef USE_ENCHANT - add_visibility(*default_dictionary == '\0'); -#else - add_visibility(FALSE); -#endif - } - OPARENT quote_fmt CPARENT - { - remove_visibility(); - } | QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK { gchar *tmp = quote_fmt_complete_address(msginfo->cc); blob - 0b80f948b19ef1a6204b36ef509636fef18d2a3c blob + c9bbc71430ed5c21d2fa620542cf2454bb59faac --- src/toolbar.c +++ src/toolbar.c @@ -201,10 +201,6 @@ static void toolbar_linewrap_all_cb (GtkWidget *widge gpointer data); static void toolbar_addrbook_cb (GtkWidget *widget, gpointer data); -#ifdef USE_ENCHANT -static void toolbar_check_spelling_cb (GtkWidget *widget, - gpointer data); -#endif static void toolbar_cancel_inc_cb (GtkWidget *widget, gpointer data); static void toolbar_cancel_send_cb (GtkWidget *widget, @@ -262,9 +258,6 @@ 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_ENCHANT - { "A_CHECK_SPELLING", N_("Check spelling") }, -#endif { "A_PRIVACY_SIGN", N_("Sign") }, { "A_PRIVACY_ENCRYPT", N_("Encrypt") }, { "A_CLAWS_ACTIONS", N_("Claws Mail Actions Feature") }, @@ -388,9 +381,6 @@ GList *toolbar_get_action_items(ToolbarType source) A_INSERT, A_ATTACH, A_SIG, A_REP_SIG, A_EXTEDITOR, A_LINEWRAP_CURRENT, A_LINEWRAP_ALL, A_ADDRBOOK, -#ifdef USE_ENCHANT - A_CHECK_SPELLING, -#endif A_PRIVACY_SIGN, A_PRIVACY_ENCRYPT, A_CLOSE }; @@ -529,9 +519,6 @@ const gchar *toolbar_get_short_text(int action) { case A_LINEWRAP_CURRENT:return _("Wrap para."); case A_LINEWRAP_ALL: return _("Wrap all"); case A_ADDRBOOK: return _("Address"); - #ifdef USE_ENCHANT - case A_CHECK_SPELLING: return _("Check spelling"); - #endif case A_PRIVACY_SIGN: return _("Sign"); case A_PRIVACY_ENCRYPT: return _("Encrypt"); @@ -591,9 +578,6 @@ gint toolbar_get_icon(int action) { case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT; case A_LINEWRAP_ALL: return STOCK_PIXMAP_LINEWRAP_ALL; case A_ADDRBOOK: return STOCK_PIXMAP_ADDRESS_BOOK; - #ifdef USE_ENCHANT - case A_CHECK_SPELLING: return STOCK_PIXMAP_CHECK_SPELLING; - #endif case A_PRIVACY_SIGN: return STOCK_PIXMAP_MAIL_PRIVACY_SIGNED; case A_PRIVACY_ENCRYPT: return STOCK_PIXMAP_MAIL_PRIVACY_ENCRYPTED; @@ -1876,13 +1860,6 @@ static void toolbar_linewrap_all_cb(GtkWidget *widget, compose_toolbar_cb(A_LINEWRAP_ALL, data); } -#ifdef USE_ENCHANT -static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data) -{ - compose_toolbar_cb(A_CHECK_SPELLING, data); -} -#endif - static void toolbar_privacy_sign_cb(GtkWidget *widget, gpointer data) { ToolbarItem *toolbar_item = (ToolbarItem*)data; @@ -2060,9 +2037,6 @@ 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_ENCHANT - { A_CHECK_SPELLING, toolbar_check_spelling_cb }, -#endif { A_PRIVACY_SIGN, toolbar_privacy_sign_cb }, { A_PRIVACY_ENCRYPT, toolbar_privacy_encrypt_cb }, { A_CLAWS_ACTIONS, toolbar_actions_execute_cb }, @@ -2412,12 +2386,6 @@ Toolbar *toolbar_create(ToolbarType type, TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book")); toolbar_data->addrbook_btn = item; break; -#ifdef USE_ENCHANT - case A_CHECK_SPELLING: - TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling")); - toolbar_data->spellcheck_btn = item; - break; -#endif case A_PRIVACY_SIGN: TOOLBAR_TOGGLE_ITEM(item,icon_wid,toolbar_item->text,_("Sign")); g_signal_connect (G_OBJECT(item), "toggled", @@ -2759,10 +2727,6 @@ void toolbar_comp_set_sensitive(gpointer data, gboolea 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_ENCHANT - if (compose->toolbar->spellcheck_btn) - GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive); -#endif for (; items != NULL; items = g_slist_next(items)) { ToolbarClawsActions *item = (ToolbarClawsActions *)items->data; GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive); @@ -2819,9 +2783,6 @@ static void toolbar_init(Toolbar * toolbar) toolbar->preferences_btn = NULL; toolbar->action_list = NULL; toolbar->item_list = NULL; -#ifdef USE_ENCHANT - toolbar->spellcheck_btn = NULL; -#endif toolbar->privacy_sign_btn = NULL; toolbar->privacy_encrypt_btn = NULL; blob - a244068685879f912cf7f10afa7b1321d3ce7c3d blob + 34288a516095628eb8300bb2cc2dc1fd98a83413 --- src/toolbar.h +++ src/toolbar.h @@ -105,10 +105,6 @@ struct _Toolbar { GSList *action_list; GSList *item_list; -#ifdef USE_ENCHANT - GtkWidget *spellcheck_btn; -#endif - GtkWidget *privacy_sign_btn; GtkWidget *privacy_encrypt_btn; }; @@ -201,9 +197,6 @@ enum { A_LINEWRAP_CURRENT, A_LINEWRAP_ALL, A_ADDRBOOK, -#ifdef USE_ENCHANT - A_CHECK_SPELLING, -#endif A_PRIVACY_SIGN, A_PRIVACY_ENCRYPT,