pidgin/win32/wspell.c

Tue, 07 May 2013 05:04:46 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Tue, 07 May 2013 05:04:46 -0400
changeset 33923
0fcc5635daba
parent 33898
0f4b2e3ac978
child 35857
b7fc060d5c94
permissions
-rw-r--r--

Rewrite debug window filter in JS.

Note, this does cause a couple regressions, but they are probably not
that big a deal. First, the JS regular expression syntax is slightly
different. Second, the JS regex API lacks a way to reliably determine
the location of matched groups, so we can't highlight just the groups
and must highlight the entire expression.

I suspect that none of our users ever had to use any fancy regex in the
debug window, and that most of our developers didn't even know it could
be done. So I doubt these regressions will cause much pain.

4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
1 /*
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
2 * pidgin
5913
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
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
6 * Description: Windows Pidgin gtkspell interface.
5913
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
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
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
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 17072
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
5913
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5084
diff changeset
23 *
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
24 */
30794
89f6539d5de9 config.h is needed to determine USE_GTKSPELL here.
Daniel Atallah <datallah@pidgin.im>
parents: 30793
diff changeset
25
89f6539d5de9 config.h is needed to determine USE_GTKSPELL here.
Daniel Atallah <datallah@pidgin.im>
parents: 30793
diff changeset
26 #ifdef HAVE_CONFIG_H
89f6539d5de9 config.h is needed to determine USE_GTKSPELL here.
Daniel Atallah <datallah@pidgin.im>
parents: 30793
diff changeset
27 #include <config.h>
89f6539d5de9 config.h is needed to determine USE_GTKSPELL here.
Daniel Atallah <datallah@pidgin.im>
parents: 30793
diff changeset
28 #endif
30793
1f869064d3ee Make the win32 build possible to compile without GtkSpell if HAVE_GTKSPELL isn't defined.
Daniel Atallah <datallah@pidgin.im>
parents: 30739
diff changeset
29 #ifdef USE_GTKSPELL
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
30 #include <string.h>
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
31 #include <stdlib.h>
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
32 #include <glib.h>
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
33 #include <gtk/gtk.h>
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
34 #include <gtkspell/gtkspell.h>
6425
3e86c949c98a [gaim-migrate @ 6933]
Herman Bloggs <herman@bluedigits.com>
parents: 5913
diff changeset
35 #include "debug.h"
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
36 #include "win32dep.h"
15697
78ddac185d80 winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
37 #include "wspell.h"
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
38
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
39 /* Intermediate function so that we can eat Enchant error popups when it doesn't find a DLL
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
40 * This is fixed upstream, but not released */
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
41 GtkSpell* (*wpidginspell_new_attach_proxy) (GtkTextView *,
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
42 const gchar *,
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
43 GError **) = NULL;
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
44
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
45 /* GTKSPELL DUMMY FUNCS */
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
46 static GtkSpell* wgtkspell_new_attach(GtkTextView *view, const gchar *lang, GError **error) {
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
47 GtkSpell *ret = NULL;
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
48 if (wpidginspell_new_attach_proxy) {
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
49 UINT old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
50 ret = wpidginspell_new_attach_proxy(view, lang, error);
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
51 SetErrorMode(old_error_mode);
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
52 }
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
53 return ret;
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
54 }
15697
78ddac185d80 winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
55 static GtkSpell* wgtkspell_get_from_text_view(GtkTextView *view) {return NULL;}
78ddac185d80 winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
56 static void wgtkspell_detach(GtkSpell *spell) {}
78ddac185d80 winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
57 static gboolean wgtkspell_set_language(GtkSpell *spell, const gchar *lang, GError **error) {return FALSE;}
78ddac185d80 winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
58 static void wgtkspell_recheck_all(GtkSpell *spell) {}
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
59
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
60 /* GTKSPELL PROTOS */
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
61 GtkSpell* (*wpidginspell_new_attach) (GtkTextView *,
14334
aec64dbd9564 [gaim-migrate @ 16957]
Daniel Atallah <datallah@pidgin.im>
parents: 14253
diff changeset
62 const gchar *,
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
63 GError **) = wgtkspell_new_attach;
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
64
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
65 GtkSpell* (*wpidginspell_get_from_text_view) (GtkTextView*) = wgtkspell_get_from_text_view;
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
66
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
67 void (*wpidginspell_detach) (GtkSpell*) = wgtkspell_detach;
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
68
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
69 gboolean (*wpidginspell_set_language) (GtkSpell*,
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
70 const gchar*,
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
71 GError**) = wgtkspell_set_language;
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
72
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
73 void (*wpidginspell_recheck_all) (GtkSpell*) = wgtkspell_recheck_all;
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
74
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
75 #define GTKSPELL_DLL "libgtkspell-0.dll"
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
76
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
77 static void load_gtkspell() {
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
78 UINT old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
79 gchar *tmp, *tmp2;
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
80
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
81 const char *path = g_getenv("PATH");
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
82 tmp = g_build_filename(wpurple_install_dir(), "spellcheck", NULL);
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
83 tmp2 = g_strdup_printf("%s%s%s", tmp,
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
84 (path ? G_SEARCHPATH_SEPARATOR_S : ""),
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
85 (path ? path : ""));
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
86 g_free(tmp);
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
87 g_setenv("PATH", tmp2, TRUE);
30739
72613eff8b0e Use some fully qualified dll locations.
Daniel Atallah <datallah@pidgin.im>
parents: 29879
diff changeset
88 g_free(tmp2);
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
89
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
90 /* Suppress error popups */
33861
71533f0d5dc0 win32: switch to OBS, update and push to runtime-deps package - libenchant, gtkspell, meanwhile, tcl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 30794
diff changeset
91 wpidginspell_new_attach_proxy = (void*) wpurple_find_and_loadproc(GTKSPELL_DLL, "gtkspell_new_attach" );
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
92 if (wpidginspell_new_attach_proxy) {
33861
71533f0d5dc0 win32: switch to OBS, update and push to runtime-deps package - libenchant, gtkspell, meanwhile, tcl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 30794
diff changeset
93 wpidginspell_get_from_text_view = (void*) wpurple_find_and_loadproc(GTKSPELL_DLL, "gtkspell_get_from_text_view");
71533f0d5dc0 win32: switch to OBS, update and push to runtime-deps package - libenchant, gtkspell, meanwhile, tcl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 30794
diff changeset
94 wpidginspell_detach = (void*) wpurple_find_and_loadproc(GTKSPELL_DLL, "gtkspell_detach");
71533f0d5dc0 win32: switch to OBS, update and push to runtime-deps package - libenchant, gtkspell, meanwhile, tcl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 30794
diff changeset
95 wpidginspell_set_language = (void*) wpurple_find_and_loadproc(GTKSPELL_DLL, "gtkspell_set_language");
71533f0d5dc0 win32: switch to OBS, update and push to runtime-deps package - libenchant, gtkspell, meanwhile, tcl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 30794
diff changeset
96 wpidginspell_recheck_all = (void*) wpurple_find_and_loadproc(GTKSPELL_DLL, "gtkspell_recheck_all");
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
97 } else {
33861
71533f0d5dc0 win32: switch to OBS, update and push to runtime-deps package - libenchant, gtkspell, meanwhile, tcl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 30794
diff changeset
98 purple_debug_warning("wspell", "Couldn't load gtkspell (%s) \n", GTKSPELL_DLL);
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
99 /*wpidginspell_new_attach = wgtkspell_new_attach;*/
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
100 }
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
101 SetErrorMode(old_error_mode);
4862
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
102 }
002bcddc564f [gaim-migrate @ 5189]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
103
29807
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
104 void winpidgin_spell_init() {
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
105 load_gtkspell();
bda3933c6400 Upgrade GtkSpell to 2.0.16 on Windows. The installer needs a bunch more work, but that is for later
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
106 }
30793
1f869064d3ee Make the win32 build possible to compile without GtkSpell if HAVE_GTKSPELL isn't defined.
Daniel Atallah <datallah@pidgin.im>
parents: 30739
diff changeset
107 #endif

mercurial