gtk/win32/wspell.c

branch
cpw.khc.msnp14
changeset 20472
6a6d2ef151e6
parent 11561
5ee24c739c7e
parent 14334
aec64dbd9564
child 20471
1966704b3e42
equal deleted inserted replaced
13912:463b4fa9f067 20472:6a6d2ef151e6
1 /*
2 * gaim
3 *
4 * File: wspell.c
5 * Date: March, 2003
6 * Description: Windows Gaim gtkspell interface.
7 *
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
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>
31 #include "debug.h"
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 static char* lookup_aspell_path() {
69 const char *tmp;
70
71 if ((tmp = g_getenv("GAIM_ASPELL_DIR")))
72 return g_strdup(tmp);
73
74 return wgaim_read_reg_string(HKEY_LOCAL_MACHINE, "Software\\Aspell", "Path");
75 }
76
77 void wgaim_gtkspell_init() {
78 char *aspell_path = lookup_aspell_path();
79
80 if (aspell_path != NULL) {
81 char *tmp = g_strconcat(aspell_path, "\\aspell-15.dll", NULL);
82 if (g_file_test(tmp, G_FILE_TEST_EXISTS)) {
83 const char *path = g_getenv("PATH");
84 gaim_debug_info("wspell", "Found Aspell in %s\n", aspell_path);
85
86 g_free(tmp);
87
88 tmp = g_strdup_printf("%s%s%s", (path ? path : ""),
89 (path ? G_SEARCHPATH_SEPARATOR_S : ""),
90 aspell_path);
91
92 g_setenv("PATH", tmp, TRUE);
93
94 load_gtkspell();
95 } else {
96 gaim_debug_warning("wspell", "Couldn't find aspell-15.dll\n");
97 }
98
99 g_free(tmp);
100 g_free(aspell_path);
101 } else {
102 gaim_debug_warning("wspell", "Couldn't find path for Aspell\n");
103 }
104 }

mercurial