annotate src/win32/wspell.c @ 10311:b7566fc34c6c

[gaim-migrate @ 11505] Hitting the enter key when you're cursor is in the alias field of the Add Chat dialog now activates the dialogs default action. Closes bug 1075200 and patch 1078079. Thanks to Andrew Hart for taking a stab at this and wounding, but not killing. Killing is wrong! committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 03 Dec 2004 04:02:10 +0000
parents 26b739bc9f1a
children da36acb8442c
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>
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
31 #include "debug.h"
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
32 #include "win32dep.h"
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 DUMMY FUNCS */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
35 GtkSpell* wgtkspell_new_attach(GtkTextView *view,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
36 const gchar *lang,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
37 GError **error) {return NULL;}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
38 GtkSpell* wgtkspell_get_from_text_view(GtkTextView *view) {return NULL;}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
39 void wgtkspell_detach(GtkSpell *spell) {}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
40 gboolean wgtkspell_set_language(GtkSpell *spell,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
41 const gchar *lang,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
42 GError **error) {return 0;}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
43 void wgtkspell_recheck_all(GtkSpell *spell) {}
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
44
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
45 /* GTKSPELL PROTOS */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
46 GtkSpell* (*wgaim_gtkspell_new_attach) (GtkTextView *,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
47 const gchar *,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
48 GError **) = wgtkspell_new_attach;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
49
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
50 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
51
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
52 void (*wgaim_gtkspell_detach) (GtkSpell*) = wgtkspell_detach;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
53
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
54 gboolean (*wgaim_gtkspell_set_language) (GtkSpell*,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
55 const gchar*,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
56 GError**) = wgtkspell_set_language;
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 void (*wgaim_gtkspell_recheck_all) (GtkSpell*) = wgtkspell_recheck_all;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
59
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
60 static void load_gtkspell() {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
61 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
62 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
63 wgaim_gtkspell_detach = (void*)wgaim_find_and_loadproc("libgtkspell.dll", "gtkspell_detach");
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
64 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
65 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
66 }
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 void wgaim_gtkspell_init() {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
69 HKEY hKey;
5084
a96653493416 [gaim-migrate @ 5439]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4862
diff changeset
70 char buffer[1024] = "";
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
71 DWORD size = sizeof(buffer);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
72 DWORD type;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
73
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
74 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
75 "Software\\Aspell",
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
76 0,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
77 KEY_QUERY_VALUE,
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
78 &hKey)) {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
79 /* Official aspell.net win32 installation or Gaim's aspell installation */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
80 if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Path", NULL, &type, (LPBYTE)buffer, &size) ||
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
81 ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
82 int mark = strlen(buffer);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
83 strcat(buffer, "\\aspell-15.dll");
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
84 if(_access( buffer, 0 ) < 0)
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
85 gaim_debug(GAIM_DEBUG_WARNING, "wspell", "Couldn't find aspell-15.dll\n");
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
86 else {
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
87 char* tmp=NULL;
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
88 buffer[mark] = '\0';
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
89 gaim_debug(GAIM_DEBUG_INFO, "wspell", "Found Aspell in %s\n", buffer);
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
90 /* Add path to Aspell dlls to PATH */
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
91 tmp = g_malloc0(strlen(getenv("PATH")) + strlen(buffer) + 7);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
92 sprintf(tmp, "PATH=%s;%s", getenv("PATH"), buffer);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
93 putenv(tmp);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
94 g_free(tmp);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
95 load_gtkspell();
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
96 }
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 else {
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
99 gaim_debug(GAIM_DEBUG_WARNING, "wspell", "Couldn't find path for Aspell\n");
4862
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
100 }
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
101 RegCloseKey(hKey);
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
102 }
0fe2ffdb7906 [gaim-migrate @ 5189]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
103 }