Revision: 24 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=24&view=rev Author: eht16 Date: 2008-05-20 08:37:03 -0700 (Tue, 20 May 2008)
Log Message: ----------- Detect the Aspell installation prefix on Windows and use it to find installed dictionaries.
Modified Paths: -------------- trunk/spellcheck/ChangeLog trunk/spellcheck/src/spellcheck.c
Modified: trunk/spellcheck/ChangeLog =================================================================== --- trunk/spellcheck/ChangeLog 2008-05-20 14:45:24 UTC (rev 23) +++ trunk/spellcheck/ChangeLog 2008-05-20 15:37:03 UTC (rev 24) @@ -4,6 +4,8 @@ Add new GeanyFunctions API. Avoid crashes when LANG environment variable can't be read (e.g. on Windows). + Detect the Aspell installation prefix on Windows and use it to find + installed dictionaries.
2008-05-16 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/spellcheck/src/spellcheck.c =================================================================== --- trunk/spellcheck/src/spellcheck.c 2008-05-20 14:45:24 UTC (rev 23) +++ trunk/spellcheck/src/spellcheck.c 2008-05-20 15:37:03 UTC (rev 24) @@ -30,6 +30,10 @@ # include <locale.h> #endif
+#ifdef G_OS_WIN32 +# include <windows.h> +#endif + #include <aspell.h>
#include "plugindata.h" @@ -64,6 +68,28 @@ static gchar *config_file; static gchar *language;
+ +/* On Windows we need to find the Aspell installation prefix via the Windows Registry + * and then set the prefix in the Aspell config object. */ +static void set_up_aspell_prefix(AspellConfig *config) +{ +#ifdef G_OS_WIN32 + char sTemp[1024]; + HKEY hkey; + DWORD len = sizeof(sTemp); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\Aspell"), 0, + KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) + return; + + if (RegQueryValueEx(hkey, NULL, 0, NULL, (LPBYTE)sTemp, &len) == ERROR_SUCCESS) + aspell_config_replace(config, "prefix", sTemp); + + RegCloseKey(hkey); +#endif +} + + static void print_word_list(AspellSpeller *speller, GString *str, const AspellWordList *wl) { if (wl == NULL) @@ -188,6 +214,7 @@ config = new_aspell_config(); aspell_config_replace(config, "lang", language); aspell_config_replace(config, "encoding", "utf-8"); + set_up_aspell_prefix(config);
ret = new_aspell_speller(config); delete_aspell_config(config); @@ -270,6 +297,7 @@ guint i = 0;
config = new_aspell_config(); + set_up_aspell_prefix(config); dlist = get_aspell_dict_info_list(config); delete_aspell_config(config);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org