From: Ilia Maslakov Date: Tue, 23 Oct 2012 14:06:00 +0000 (+0400) Subject: Ticket #2914 (disable annoying aspell warnings about spelling language) X-Git-Tag: 4.8.7~4^2~1 X-Git-Url: https://repo.or.cz/w/midnight-commander.git/commitdiff_plain/4861d060734d8326c9bef2981408fa286ba3a394 Ticket #2914 (disable annoying aspell warnings about spelling language) Added the aspell param 'spell_language' in ini-file. This allow set spelling language. spell_language=NONE - disable aspell support. Signed-off-by: Ilia Maslakov --- diff --git a/src/editor/editmenu.c b/src/editor/editmenu.c index 1624c9366..b9c9592a4 100644 --- a/src/editor/editmenu.c +++ b/src/editor/editmenu.c @@ -176,14 +176,17 @@ create_command_menu (void) menu_entry_create (_("Record/Repeat &actions"), CK_RepeatStartStopRecord)); entries = g_list_prepend (entries, menu_separator_create ()); #ifdef HAVE_ASPELL - entries = g_list_prepend (entries, menu_entry_create (_("S&pell check"), CK_SpellCheck)); - entries = - g_list_prepend (entries, menu_entry_create (_("C&heck word"), CK_SpellCheckCurrentWord)); - entries = - g_list_prepend (entries, - menu_entry_create (_("Change spelling &language..."), - CK_SpellCheckSelectLang)); - entries = g_list_prepend (entries, menu_separator_create ()); + if (strcmp (spell_language, "NONE") != 0) + { + entries = g_list_prepend (entries, menu_entry_create (_("S&pell check"), CK_SpellCheck)); + entries = + g_list_prepend (entries, menu_entry_create (_("C&heck word"), CK_SpellCheckCurrentWord)); + entries = + g_list_prepend (entries, + menu_entry_create (_("Change spelling &language..."), + CK_SpellCheckSelectLang)); + entries = g_list_prepend (entries, menu_separator_create ()); + } #endif /* HAVE_ASPELL */ entries = g_list_prepend (entries, menu_entry_create (_("&Mail..."), CK_Mail)); diff --git a/src/editor/spell.c b/src/editor/spell.c index 85afaecc5..4ca18b9c6 100644 --- a/src/editor/spell.c +++ b/src/editor/spell.c @@ -35,6 +35,8 @@ #endif #include "lib/strutil.h" +#include "src/setup.h" + #include "edit-impl.h" #include "spell.h" @@ -284,6 +286,9 @@ aspell_init (void) { AspellCanHaveError *error = NULL; + if (strcmp (spell_language, "NONE") == 0) + return; + if (global_speller != NULL) return; @@ -301,6 +306,13 @@ aspell_init (void) global_speller->config = mc_new_aspell_config (); global_speller->speller = NULL; + if (spell_language != NULL) + { + int res; + + res = mc_aspell_config_replace (global_speller->config, "lang", spell_language); + } + error = mc_new_aspell_speller (global_speller->config); if (mc_aspell_error_number (error) == 0) @@ -435,6 +447,9 @@ aspell_set_lang (const char *lang) AspellCanHaveError *error; const char *spell_codeset; + g_free (spell_language); + spell_language = g_strdup (lang); + #ifdef HAVE_CHARSET if (mc_global.source_codepage > 0) spell_codeset = get_codepage_id (mc_global.source_codepage); diff --git a/src/setup.c b/src/setup.c index 49b837d28..69e5823b1 100644 --- a/src/setup.c +++ b/src/setup.c @@ -187,6 +187,10 @@ char *autodetect_codeset = NULL; gboolean is_autodetect_codeset_enabled = FALSE; #endif /* !HAVE_CHARSET */ +#ifdef HAVE_ASPELL +char *spell_language = NULL; +#endif + /* If set, then print to the given file the last directory we were at */ char *last_wd_string = NULL; @@ -1049,6 +1053,11 @@ load_setup (void) mc_global.utf8_display = str_isutf8 (buffer); #endif /* HAVE_CHARSET */ +#ifdef HAVE_ASPELL + spell_language = + mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language", "en"); +#endif /* HAVE_ASPELL */ + clipboard_store_path = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store", ""); clipboard_paste_path = @@ -1095,6 +1104,12 @@ save_setup (gboolean save_options, gboolean save_panel_options) mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "autodetect_codeset", autodetect_codeset); #endif /* HAVE_CHARSET */ + +#ifdef HAVE_ASPELL + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language", + spell_language); +#endif /* HAVE_ASPELL */ + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store", clipboard_store_path); mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_paste", @@ -1142,6 +1157,10 @@ done_setup (void) g_free (autodetect_codeset); free_codepages_list (); #endif + +#ifdef HAVE_ASPELL + g_free (spell_language); +#endif /* HAVE_ASPELL */ } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/setup.h b/src/setup.h index 4ec473ddd..a4a4c1600 100644 --- a/src/setup.h +++ b/src/setup.h @@ -113,6 +113,10 @@ extern char *autodetect_codeset; extern gboolean is_autodetect_codeset_enabled; #endif /* !HAVE_CHARSET */ +#ifdef HAVE_ASPELL +extern char *spell_language; +#endif + /* If set, then print to the given file the last directory we were at */ extern char *last_wd_string;