annotate plugins/spellchk.c @ 4315:6e36a04209c0

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