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