Mercurial > pidgin
comparison src/win32/wspell.c @ 4862:0fe2ffdb7906
[gaim-migrate @ 5189]
Win32 interface to gtkspell. If Aspell installation is found
Gaim will load and use gtkspell dll, if not dummy funcs are used.
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Sat, 22 Mar 2003 18:38:25 +0000 |
parents | |
children | a96653493416 |
comparison
equal
deleted
inserted
replaced
4861:6cb8b0686e46 | 4862:0fe2ffdb7906 |
---|---|
1 /* | |
2 * wspell.c | |
3 * | |
4 * Author: Herman Bloggs <hermanator12002@yahoo.com> | |
5 * Date: March, 2003 | |
6 * Description: Windows Gaim gtkspell interface. | |
7 */ | |
8 #include <windows.h> | |
9 #include <string.h> | |
10 #include <stdlib.h> | |
11 #include <glib.h> | |
12 #include <gtk/gtk.h> | |
13 #include <gtkspell/gtkspell.h> | |
14 #include "win32dep.h" | |
15 | |
16 extern void debug_printf(char * fmt, ...); | |
17 | |
18 /* GTKSPELL DUMMY FUNCS */ | |
19 GtkSpell* wgtkspell_new_attach(GtkTextView *view, | |
20 const gchar *lang, | |
21 GError **error) {return NULL;} | |
22 GtkSpell* wgtkspell_get_from_text_view(GtkTextView *view) {return NULL;} | |
23 void wgtkspell_detach(GtkSpell *spell) {} | |
24 gboolean wgtkspell_set_language(GtkSpell *spell, | |
25 const gchar *lang, | |
26 GError **error) {return 0;} | |
27 void wgtkspell_recheck_all(GtkSpell *spell) {} | |
28 | |
29 /* GTKSPELL PROTOS */ | |
30 GtkSpell* (*wgaim_gtkspell_new_attach) (GtkTextView *, | |
31 const gchar *, | |
32 GError **) = wgtkspell_new_attach; | |
33 | |
34 GtkSpell* (*wgaim_gtkspell_get_from_text_view) (GtkTextView*) = wgtkspell_get_from_text_view; | |
35 | |
36 void (*wgaim_gtkspell_detach) (GtkSpell*) = wgtkspell_detach; | |
37 | |
38 gboolean (*wgaim_gtkspell_set_language) (GtkSpell*, | |
39 const gchar*, | |
40 GError**) = wgtkspell_set_language; | |
41 | |
42 void (*wgaim_gtkspell_recheck_all) (GtkSpell*) = wgtkspell_recheck_all; | |
43 | |
44 static void load_gtkspell() { | |
45 wgaim_gtkspell_new_attach = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_new_attach" ); | |
46 wgaim_gtkspell_get_from_text_view = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_get_from_text_view"); | |
47 wgaim_gtkspell_detach = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_detach"); | |
48 wgaim_gtkspell_set_language = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_set_language"); | |
49 wgaim_gtkspell_recheck_all = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_recheck_all"); | |
50 } | |
51 | |
52 void wgaim_gtkspell_init() { | |
53 HKEY hKey; | |
54 const char buffer[1024] = ""; | |
55 DWORD size = sizeof(buffer); | |
56 DWORD type; | |
57 | |
58 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, | |
59 "Software\\Aspell", | |
60 0, | |
61 KEY_QUERY_VALUE, | |
62 &hKey)) { | |
63 /* Official aspell.net win32 installation or Gaim's aspell installation */ | |
64 if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Path", NULL, &type, (LPBYTE)buffer, &size) || | |
65 ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) { | |
66 int mark = strlen(buffer); | |
67 strcat(buffer, "\\aspell-15.dll"); | |
68 if(_access( buffer, 0 ) < 0) | |
69 debug_printf("Couldn't find aspell-15.dll\n"); | |
70 else { | |
71 char* tmp=NULL; | |
72 buffer[mark] = '\0'; | |
73 debug_printf("Found Aspell in %s\n", buffer); | |
74 /* Add path to Aspell dlls to PATH */ | |
75 tmp = g_malloc0(strlen(getenv("PATH")) + strlen(buffer) + 7); | |
76 sprintf(tmp, "PATH=%s;%s", getenv("PATH"), buffer); | |
77 putenv(tmp); | |
78 g_free(tmp); | |
79 load_gtkspell(); | |
80 } | |
81 } | |
82 else { | |
83 debug_printf("Couldn't find path for Aspell\n"); | |
84 } | |
85 RegCloseKey(hKey); | |
86 } | |
87 } |