annotate plugins/spellchk.c @ 3563:e120097bbd72

[gaim-migrate @ 3658] I made my perl script unloading not suck (as much). Now you may port your perl scripts--use gaim.pl and PERL-HOWTO as references. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 28 Sep 2002 08:08:14 +0000
parents cd938f18f3f8
children 154c4a9d9b6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
1 /*
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
2 * A lot of this code (especially the config code) was taken directly
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
3 * or nearly directly from xchat, version 1.4.2 by Peter Zelezny and others.
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
4 *
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
5 * TODO:
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
6 * ? I think i did everything i want to with it.
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
7 *
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
8 * BUGS:
112
a57fd3390ee4 [gaim-migrate @ 122]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 111
diff changeset
9 * ? I think i fixed them all.
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
10 */
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 #define GAIM_PLUGINS
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 #include "gaim.h"
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 #include <string.h>
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 #include <ctype.h>
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 #include <stdlib.h>
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
17 #include <sys/stat.h>
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
18 #include <sys/types.h>
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
19 #include <unistd.h>
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
20 #include <fcntl.h>
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 struct replace_words {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 char *bad;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 char *good;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 };
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 GList *words = NULL;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
29 static int num_words(char *);
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
30 static int get_word(char *, int);
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
31 static char *have_word(char *, int);
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
32 static void substitute(char **, int, int, char *);
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
34 static void substitute_words(struct gaim_connection *gc, char *who, char **message, void *m) {
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 int i, l;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 int word;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 GList *w;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 char *tmp;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 if (message == NULL || *message == NULL)
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 return;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 l = num_words(*message);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 for (i = 0; i < l; i++) {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 word = get_word(*message, i);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 w = words;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 while (w) {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 struct replace_words *r;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 r = (struct replace_words *)(w->data);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 tmp = have_word(*message, word);
138
e8ea1e2fdf0c [gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 123
diff changeset
51 if (!strcmp(tmp, r->bad)) {
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 substitute(message, word, strlen(r->bad),
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 r->good);
112
a57fd3390ee4 [gaim-migrate @ 122]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 111
diff changeset
54 l += num_words(r->good) - num_words(r->bad);
a57fd3390ee4 [gaim-migrate @ 122]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 111
diff changeset
55 i += num_words(r->good) - num_words(r->bad);
a57fd3390ee4 [gaim-migrate @ 122]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 111
diff changeset
56 }
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 free(tmp);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 w = w->next;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
63 static int buf_get_line(char *ibuf, char **buf, int *position, int len) {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
64 int pos = *position, spos = pos;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
65
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
66 if (pos == len)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
67 return 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
68
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
69 while (ibuf[pos++] != '\n') {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
70 if (pos == len)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
71 return 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
72 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
73 pos--;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
74 ibuf[pos] = 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
75 *buf = &ibuf[spos];
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
76 pos++;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
77 *position = pos;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
78 return 1;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
79 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
80
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
81 static void load_conf() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
82 char *defaultconf = "BAD r\nGOOD are\n\n"
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
83 "BAD u\nGOOD you\n\n"
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
84 "BAD teh\nGOOD the\n\n";
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
85 char *buf, *ibuf;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
86 char name[82];
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
87 char cmd[256];
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
88 int fh, pnt = 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
89 struct stat st;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
90
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
91 if (words != NULL)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
92 g_list_free(words);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
93 words = NULL;
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
95 buf = malloc(1000);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
96 snprintf(buf, 1000, "%s/.gaim/dict", getenv("HOME"));
123
f7a5f376f54e [gaim-migrate @ 133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 113
diff changeset
97 fh = open(buf, O_RDONLY, 0600);
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
98 if (fh == -1) {
123
f7a5f376f54e [gaim-migrate @ 133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 113
diff changeset
99 fh = open(buf, O_TRUNC | O_WRONLY | O_CREAT, 0600);
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
100 if (fh != -1) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
101 write(fh, defaultconf, strlen(defaultconf));
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
102 close(fh);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
103 free(buf);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
104 load_conf();
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
105 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
106 return;
106
e05e6373ea5a [gaim-migrate @ 116]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 103
diff changeset
107 }
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
108 free(buf);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
109 if (fstat(fh, &st) != 0)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
110 return;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
111 ibuf = malloc(st.st_size);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
112 read(fh, ibuf, st.st_size);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
113 close(fh);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
114
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
115 cmd[0] = 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
116 name[0] = 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
117
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
118 while(buf_get_line(ibuf, &buf, &pnt, st.st_size)) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
119 if (*buf != '#') {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
120 if (!strncasecmp(buf, "BAD ", 4))
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
121 strncpy(name, buf + 4, 81);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
122 if (!strncasecmp(buf, "GOOD ", 5)) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
123 strncpy(cmd, buf + 5, 255);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
124 if (*name) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
125 struct replace_words *r;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
126 r = malloc(sizeof *r);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
127 r->bad = strdup(name);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
128 r->good = strdup(cmd);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
129 words = g_list_append(words, r);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
130 cmd[0] = 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
131 name[0] = 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
132 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
133 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
134 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
135 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
136 free(ibuf);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
137 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
138
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1000
diff changeset
139 char *gaim_plugin_init(GModule *handle) {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
140 load_conf();
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141
208
522e885485f0 [gaim-migrate @ 218]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 138
diff changeset
142 gaim_signal_connect(handle, event_im_send, substitute_words, NULL);
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 257
diff changeset
143 gaim_signal_connect(handle, event_chat_send, substitute_words, NULL);
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1000
diff changeset
144 return NULL;
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
147 void gaim_plugin_remove() {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
148 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
149
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
150 struct gaim_plugin_description desc;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
151 struct gaim_plugin_description *gaim_plugin_desc() {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
152 desc.api_version = PLUGIN_API_VERSION;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
153 desc.name = g_strdup("Text replacement");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
154 desc.version = g_strdup(VERSION);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
155 desc.description = g_strdup("Replaces text in outgoing messages according to user-defined rules.");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
156 desc.authors = g_strdup("Eric Warmehoven &lt;eric@warmenhoven.org>");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
157 desc.url = g_strdup(WEBSITE);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
158 return &desc;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
159 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 2906
diff changeset
160
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 char *name() {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 return "IM Spell Check";
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 char *description() {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 return "Watches outgoing IM text and corrects common spelling errors.";
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
169 static int num_words(char *m) {
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 int count = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 int pos;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 int state = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 for (pos = 0; pos < strlen(m); pos++) {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 switch (state) {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 case 0: /* expecting word */
1873
08ac51210d09 [gaim-migrate @ 1883]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1862
diff changeset
177 if (!isspace(m[pos]) && !ispunct(m[pos])) {
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 count++;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 state = 1;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 } else if (m[pos] == '<')
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 state = 2;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 break;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 case 1: /* inside word */
112
a57fd3390ee4 [gaim-migrate @ 122]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 111
diff changeset
184 if (m[pos] == '<')
a57fd3390ee4 [gaim-migrate @ 122]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 111
diff changeset
185 state = 2;
1873
08ac51210d09 [gaim-migrate @ 1883]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1862
diff changeset
186 else if (isspace(m[pos]) || ispunct(m[pos]))
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 state = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 break;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 case 2: /* inside HTML tag */
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 if (m[pos] == '>')
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 state = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 break;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 return count;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
198 static int get_word(char *m, int word) {
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 int count = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 int pos = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 int state = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 for (pos = 0; pos < strlen(m) && count <= word; pos++) {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 switch (state) {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 case 0:
1862
fd60aa357882 [gaim-migrate @ 1872]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1740
diff changeset
206 if (!isspace(m[pos]) && !ispunct(m[pos])) {
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 count++;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 state = 1;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 } else if (m[pos] == '<')
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 state = 2;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 break;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 case 1:
112
a57fd3390ee4 [gaim-migrate @ 122]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 111
diff changeset
213 if (m[pos] == '<')
a57fd3390ee4 [gaim-migrate @ 122]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 111
diff changeset
214 state = 2;
1862
fd60aa357882 [gaim-migrate @ 1872]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1740
diff changeset
215 else if (isspace(m[pos]) || ispunct(m[pos]))
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 state = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 break;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 case 2:
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 if (m[pos] == '>')
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 state = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 break;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 return pos - 1;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
227 static char *have_word(char *m, int pos) {
1740
72a30a73f689 [gaim-migrate @ 1750]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
228 char *tmp = strpbrk(&m[pos], "' \t\f\r\n\"><.?!-,");
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 int len = (int)(tmp - &m[pos]);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 if (tmp == NULL) {
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 tmp = strdup(&m[pos]);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 return tmp;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 tmp = malloc(len + 1);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 tmp[0] = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 strncat(tmp, &m[pos], len);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 return tmp;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 }
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
243 static void substitute(char **mes, int pos, int m, char *text) {
257
a93e273ca1d6 [gaim-migrate @ 267]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 208
diff changeset
244 char *new = g_malloc(strlen(*mes) + strlen(text) + 1);
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 char *tmp;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 new[0] = 0;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 strncat(new, *mes, pos);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 strcat(new, text);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 strcat(new, &(*mes)[pos + m]);
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 tmp = *mes;
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 *mes = new;
257
a93e273ca1d6 [gaim-migrate @ 267]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 208
diff changeset
254 g_free(tmp);
103
c5a1a1b05c26 [gaim-migrate @ 113]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 }
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
256
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
257 static GtkWidget *configwin = NULL;
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
258 static GtkWidget *list;
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
259 static GtkWidget *bad_entry;
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
260 static GtkWidget *good_entry;
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
261
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
262 static void row_unselect() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
263 gtk_entry_set_text(GTK_ENTRY(bad_entry), "");
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
264 gtk_entry_set_text(GTK_ENTRY(good_entry), "");
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
265 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
266
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
267 static void row_select() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
268 char *badwrd, *goodwrd;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
269 int row;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
270
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
271 if (GTK_CLIST(list)->selection)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
272 row = (int) GTK_CLIST (list)->selection->data;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
273 else
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
274 row = -1;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
275 if (row != -1) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
276 gtk_clist_get_text(GTK_CLIST(list), row, 0, &badwrd);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
277 gtk_clist_get_text(GTK_CLIST(list), row, 1, &goodwrd);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
278 gtk_entry_set_text(GTK_ENTRY(bad_entry), badwrd);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
279 gtk_entry_set_text(GTK_ENTRY(good_entry), goodwrd);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
280 } else {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
281 row_unselect();
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
282 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
283 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
284
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
285 static void list_add_new() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
286 int i;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
287 gchar *item[2] = {"*NEW*", "EDIT ME"};
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
288
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
289 i = gtk_clist_append(GTK_CLIST(list), item);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
290 gtk_clist_select_row(GTK_CLIST(list), i, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
291 gtk_clist_moveto(GTK_CLIST(list), i, 0, 0.5, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
292 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
293
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
294 static void list_delete() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
295 int row;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
296
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
297 if (GTK_CLIST(list)->selection)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
298 row = (int) GTK_CLIST (list)->selection->data;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
299 else
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
300 row = -1;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
301 if (row != -1) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
302 gtk_clist_unselect_all(GTK_CLIST(list));
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
303 gtk_clist_remove(GTK_CLIST(list), row);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
304 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
305 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
306
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
307 static void close_config() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
308 if (configwin)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
309 gtk_widget_destroy(configwin);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
310 configwin = NULL;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
311 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
312
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
313 static void save_list() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
314 int fh, i = 0;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
315 char buf[512];
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
316 char *a, *b;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
317
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
318 snprintf(buf, sizeof buf, "%s/.gaim/dict", getenv("HOME"));
123
f7a5f376f54e [gaim-migrate @ 133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 113
diff changeset
319 fh = open(buf, O_TRUNC | O_WRONLY | O_CREAT, 0600);
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
320 if (fh != 1) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
321 while (gtk_clist_get_text(GTK_CLIST(list), i, 0, &a)) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
322 gtk_clist_get_text(GTK_CLIST(list), i, 1, &b);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
323 snprintf(buf, sizeof buf, "BAD %s\nGOOD %s\n\n", a, b);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
324 write(fh, buf, strlen(buf));
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
325 i++;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
326 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
327 close (fh);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
328 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
329 close_config();
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
330 load_conf();
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
331 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
332
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
333 static void bad_changed() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
334 int row;
1940
8de58cd2892f [gaim-migrate @ 1950]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1873
diff changeset
335 const char *m;
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
336
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
337 if (GTK_CLIST(list)->selection)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
338 row = (int) GTK_CLIST (list)->selection->data;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
339 else
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
340 row = -1;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
341 if (row != -1) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
342 m = gtk_entry_get_text(GTK_ENTRY(bad_entry));
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
343 gtk_clist_set_text(GTK_CLIST(list), row, 0, m);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
344 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
345 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
346
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
347 static void good_changed() {
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
348 int row;
1940
8de58cd2892f [gaim-migrate @ 1950]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1873
diff changeset
349 const char *m;
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
350
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
351 if (GTK_CLIST(list)->selection)
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
352 row = (int) GTK_CLIST (list)->selection->data;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
353 else
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
354 row = -1;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
355 if (row != -1) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
356 m = gtk_entry_get_text(GTK_ENTRY(good_entry));
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
357 gtk_clist_set_text(GTK_CLIST(list), row, 1, m);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
358 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
359 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
360
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
361 void gaim_plugin_config() {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
362 GtkWidget *win;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
363 GtkWidget *vbox;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
364 GtkWidget *hbox;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
365 GtkWidget *button;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
366 GList *w = words;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
367 struct replace_words *r;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
368 char *pair[2] = {"Replace", "With"};
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
369
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
370 if (configwin) return;
2725
f3c094e78609 [gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1956
diff changeset
371 GAIM_DIALOG(configwin);
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
372 gtk_widget_set_usize(configwin, 450, 250);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
373 gtk_window_set_title(GTK_WINDOW(configwin), "Spell Check Config");
2906
538c58b43eff [gaim-migrate @ 2919]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
374 gtk_signal_connect(GTK_OBJECT(configwin), "destroy", GTK_SIGNAL_FUNC(close_config), NULL);
111
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
375
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
376 vbox = gtk_vbox_new(0, 2);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
377 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
378 gtk_container_add(GTK_CONTAINER(configwin), vbox);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
379 gtk_widget_show (vbox);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
380
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
381 win = gtk_scrolled_window_new(0, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
382 gtk_container_add(GTK_CONTAINER(vbox), win);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
383 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (win),
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
384 GTK_POLICY_AUTOMATIC,
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
385 GTK_POLICY_ALWAYS);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
386 gtk_widget_show(win);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
387 list = gtk_clist_new_with_titles(2, pair);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
388 gtk_clist_set_column_width(GTK_CLIST(list), 0, 90);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
389 gtk_clist_set_selection_mode(GTK_CLIST(list), GTK_SELECTION_BROWSE);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
390 gtk_clist_column_titles_passive(GTK_CLIST(list));
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
391 gtk_container_add(GTK_CONTAINER(win), list);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
392 gtk_signal_connect(GTK_OBJECT(list), "select_row",
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
393 GTK_SIGNAL_FUNC(row_select), NULL);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
394 gtk_signal_connect(GTK_OBJECT(list), "unselect_row",
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
395 GTK_SIGNAL_FUNC(row_unselect), NULL);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
396 gtk_widget_show(list);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
397
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
398 hbox = gtk_hbox_new(FALSE, 2);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
399 gtk_box_pack_end(GTK_BOX(vbox), hbox, 0, 0, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
400 gtk_widget_show(hbox);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
401
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
402 button = gtk_button_new_with_label("Add New");
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
403 gtk_signal_connect(GTK_OBJECT(button), "clicked",
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
404 GTK_SIGNAL_FUNC(list_add_new), NULL);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
405 gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
406 gtk_widget_set_usize(button, 100, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
407 gtk_widget_show(button);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
408
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
409 button = gtk_button_new_with_label("Delete");
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
410 gtk_signal_connect(GTK_OBJECT(button), "clicked",
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
411 GTK_SIGNAL_FUNC(list_delete), NULL);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
412 gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
413 gtk_widget_set_usize(button, 100, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
414 gtk_widget_show(button);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
415
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
416 button = gtk_button_new_with_label("Cancel");
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
417 gtk_signal_connect(GTK_OBJECT(button), "clicked",
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
418 GTK_SIGNAL_FUNC(close_config), NULL);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
419 gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
420 gtk_widget_set_usize(button, 100, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
421 gtk_widget_show(button);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
422
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
423 button = gtk_button_new_with_label("Save");
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
424 gtk_signal_connect(GTK_OBJECT(button), "clicked",
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
425 GTK_SIGNAL_FUNC(save_list), NULL);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
426 gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
427 gtk_widget_set_usize(button, 100, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
428 gtk_widget_show(button);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
429
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
430 hbox = gtk_hbox_new(FALSE, 2);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
431 gtk_box_pack_end(GTK_BOX(vbox), hbox, 0, 0, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
432 gtk_widget_show(hbox);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
433
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
434 bad_entry = gtk_entry_new_with_max_length(40);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
435 gtk_widget_set_usize(bad_entry, 96, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
436 gtk_signal_connect(GTK_OBJECT(bad_entry), "changed",
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
437 GTK_SIGNAL_FUNC(bad_changed), NULL);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
438 gtk_box_pack_start(GTK_BOX(hbox), bad_entry, 0, 0, 0);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
439 gtk_widget_show(bad_entry);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
440
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
441 good_entry = gtk_entry_new_with_max_length(255);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
442 gtk_signal_connect(GTK_OBJECT(good_entry), "changed",
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
443 GTK_SIGNAL_FUNC(good_changed), NULL);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
444 gtk_container_add(GTK_CONTAINER(hbox), good_entry);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
445 gtk_widget_show(good_entry);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
446
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
447 while (w) {
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
448 r = (struct replace_words *)(w->data);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
449 pair[0] = r->bad;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
450 pair[1] = r->good;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
451 gtk_clist_append(GTK_CLIST(list), pair);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
452 w = w->next;
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
453 }
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
454
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
455 gtk_widget_show(configwin);
d927bb34e2c6 [gaim-migrate @ 121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 106
diff changeset
456 }