Mercurial > pidgin
annotate src/win32/wspell.c @ 5248:d635e8fe2fba
[gaim-migrate @ 5620]
Just cleaning up some loose ends. This should fix compilation on Windows
oxen. How do you peeps feel about the TOMBSTONE thing? I just like
using that word. "TOBMSTONE."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 28 Apr 2003 06:11:49 +0000 |
parents | a96653493416 |
children | 9657e243d001 |
rev | line source |
---|---|
4862
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
1 /* |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
2 * wspell.c |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
3 * |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
4 * Author: Herman Bloggs <hermanator12002@yahoo.com> |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
5 * Date: March, 2003 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
6 * Description: Windows Gaim gtkspell interface. |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
7 */ |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
8 #include <windows.h> |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
9 #include <string.h> |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
10 #include <stdlib.h> |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
11 #include <glib.h> |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
12 #include <gtk/gtk.h> |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
13 #include <gtkspell/gtkspell.h> |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
14 #include "win32dep.h" |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
15 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
16 extern void debug_printf(char * fmt, ...); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
17 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
18 /* GTKSPELL DUMMY FUNCS */ |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
19 GtkSpell* wgtkspell_new_attach(GtkTextView *view, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
20 const gchar *lang, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
21 GError **error) {return NULL;} |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
22 GtkSpell* wgtkspell_get_from_text_view(GtkTextView *view) {return NULL;} |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
23 void wgtkspell_detach(GtkSpell *spell) {} |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
24 gboolean wgtkspell_set_language(GtkSpell *spell, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
25 const gchar *lang, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
26 GError **error) {return 0;} |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
27 void wgtkspell_recheck_all(GtkSpell *spell) {} |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
28 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
29 /* GTKSPELL PROTOS */ |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
30 GtkSpell* (*wgaim_gtkspell_new_attach) (GtkTextView *, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
31 const gchar *, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
32 GError **) = wgtkspell_new_attach; |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
33 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
34 GtkSpell* (*wgaim_gtkspell_get_from_text_view) (GtkTextView*) = wgtkspell_get_from_text_view; |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
35 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
36 void (*wgaim_gtkspell_detach) (GtkSpell*) = wgtkspell_detach; |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
37 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
38 gboolean (*wgaim_gtkspell_set_language) (GtkSpell*, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
39 const gchar*, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
40 GError**) = wgtkspell_set_language; |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
41 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
42 void (*wgaim_gtkspell_recheck_all) (GtkSpell*) = wgtkspell_recheck_all; |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
43 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
44 static void load_gtkspell() { |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
45 wgaim_gtkspell_new_attach = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_new_attach" ); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
46 wgaim_gtkspell_get_from_text_view = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_get_from_text_view"); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
47 wgaim_gtkspell_detach = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_detach"); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
48 wgaim_gtkspell_set_language = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_set_language"); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
49 wgaim_gtkspell_recheck_all = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_recheck_all"); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
50 } |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
51 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
52 void wgaim_gtkspell_init() { |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
53 HKEY hKey; |
5084
a96653493416
[gaim-migrate @ 5439]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4862
diff
changeset
|
54 char buffer[1024] = ""; |
4862
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
55 DWORD size = sizeof(buffer); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
56 DWORD type; |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
57 |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
58 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
59 "Software\\Aspell", |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
60 0, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
61 KEY_QUERY_VALUE, |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
62 &hKey)) { |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
63 /* Official aspell.net win32 installation or Gaim's aspell installation */ |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
64 if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Path", NULL, &type, (LPBYTE)buffer, &size) || |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
65 ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) { |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
66 int mark = strlen(buffer); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
67 strcat(buffer, "\\aspell-15.dll"); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
68 if(_access( buffer, 0 ) < 0) |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
69 debug_printf("Couldn't find aspell-15.dll\n"); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
70 else { |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
71 char* tmp=NULL; |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
72 buffer[mark] = '\0'; |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
73 debug_printf("Found Aspell in %s\n", buffer); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
74 /* Add path to Aspell dlls to PATH */ |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
75 tmp = g_malloc0(strlen(getenv("PATH")) + strlen(buffer) + 7); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
76 sprintf(tmp, "PATH=%s;%s", getenv("PATH"), buffer); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
77 putenv(tmp); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
78 g_free(tmp); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
79 load_gtkspell(); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
80 } |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
81 } |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
82 else { |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
83 debug_printf("Couldn't find path for Aspell\n"); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
84 } |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
85 RegCloseKey(hKey); |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
86 } |
0fe2ffdb7906
[gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
87 } |