annotate src/win32/wspell.c @ 5913:9657e243d001

[gaim-migrate @ 6345] win32 adjustments for header re-org, and GPL header insertions where missing committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Tue, 17 Jun 2003 18:56:53 +0000
parents a96653493416
children 26b739bc9f1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
1 /*
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
2 * gaim
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
3 *
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
4 * File: wspell.c
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
5 * Date: March, 2003
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
6 * Description: Windows Gaim gtkspell interface.
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
7 *
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
9 *
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
10 * This program is free software; you can redistribute it and/or modify
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
11 * it under the terms of the GNU General Public License as published by
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
13 * (at your option) any later version.
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
14 *
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
15 * This program is distributed in the hope that it will be useful,
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
18 * GNU General Public License for more details.
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
19 *
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
20 * You should have received a copy of the GNU General Public License
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
21 * along with this program; if not, write to the Free Software
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
23 *
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
24 */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
25 #include <windows.h>
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
26 #include <string.h>
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
27 #include <stdlib.h>
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
28 #include <glib.h>
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
29 #include <gtk/gtk.h>
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
30 #include <gtkspell/gtkspell.h>
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
31 #include "win32dep.h"
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
32
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
33 extern void debug_printf(char * fmt, ...);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
34
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
35 /* GTKSPELL DUMMY FUNCS */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
36 GtkSpell* wgtkspell_new_attach(GtkTextView *view,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
37 const gchar *lang,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
38 GError **error) {return NULL;}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
39 GtkSpell* wgtkspell_get_from_text_view(GtkTextView *view) {return NULL;}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
40 void wgtkspell_detach(GtkSpell *spell) {}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
41 gboolean wgtkspell_set_language(GtkSpell *spell,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
42 const gchar *lang,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
43 GError **error) {return 0;}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
44 void wgtkspell_recheck_all(GtkSpell *spell) {}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
45
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
46 /* GTKSPELL PROTOS */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
47 GtkSpell* (*wgaim_gtkspell_new_attach) (GtkTextView *,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
48 const gchar *,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
49 GError **) = wgtkspell_new_attach;
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 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
52
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
53 void (*wgaim_gtkspell_detach) (GtkSpell*) = wgtkspell_detach;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
54
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
55 gboolean (*wgaim_gtkspell_set_language) (GtkSpell*,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
56 const gchar*,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
57 GError**) = wgtkspell_set_language;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
58
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
59 void (*wgaim_gtkspell_recheck_all) (GtkSpell*) = wgtkspell_recheck_all;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
60
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
61 static void load_gtkspell() {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
62 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
63 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
64 wgaim_gtkspell_detach = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_detach");
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
65 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
66 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
67 }
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
68
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
69 void wgaim_gtkspell_init() {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
70 HKEY hKey;
5084
a96653493416 [gaim-migrate @ 5439]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4862
diff changeset
71 char buffer[1024] = "";
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
72 DWORD size = sizeof(buffer);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
73 DWORD type;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
74
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
75 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
76 "Software\\Aspell",
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
77 0,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
78 KEY_QUERY_VALUE,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
79 &hKey)) {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
80 /* Official aspell.net win32 installation or Gaim's aspell installation */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
81 if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Path", NULL, &type, (LPBYTE)buffer, &size) ||
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
82 ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
83 int mark = strlen(buffer);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
84 strcat(buffer, "\\aspell-15.dll");
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
85 if(_access( buffer, 0 ) < 0)
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
86 debug_printf("Couldn't find aspell-15.dll\n");
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
87 else {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
88 char* tmp=NULL;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
89 buffer[mark] = '\0';
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
90 debug_printf("Found Aspell in %s\n", buffer);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
91 /* Add path to Aspell dlls to PATH */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
92 tmp = g_malloc0(strlen(getenv("PATH")) + strlen(buffer) + 7);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
93 sprintf(tmp, "PATH=%s;%s", getenv("PATH"), buffer);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
94 putenv(tmp);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
95 g_free(tmp);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
96 load_gtkspell();
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
97 }
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
98 }
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
99 else {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
100 debug_printf("Couldn't find path for Aspell\n");
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
101 }
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
102 RegCloseKey(hKey);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
103 }
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
104 }