Mercurial > pidgin.yaz
annotate src/conversation.c @ 502:4d1e39112cbd
[gaim-migrate @ 512]
smile! you've got french's
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 18 Jul 2000 05:23:25 +0000 |
parents | 6e8019420c1e |
children | 3133ab511d92 |
rev | line source |
---|---|
66 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
344
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
344
diff
changeset
|
23 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
344
diff
changeset
|
24 #endif |
66 | 25 #include <string.h> |
26 #include <sys/time.h> | |
27 #include <sys/types.h> | |
28 #include <sys/stat.h> | |
29 #include <unistd.h> | |
30 #include <stdio.h> | |
31 #include <stdlib.h> | |
210
ec0686b3b03f
[gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
209
diff
changeset
|
32 #include <ctype.h> |
66 | 33 #include <gtk/gtk.h> |
34 #include "gtkhtml.h" | |
35 #include <gdk/gdkkeysyms.h> | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
36 #include "convo.h" |
337 | 37 |
66 | 38 int state_lock=0; |
39 | |
40 GdkPixmap *dark_icon_pm = NULL; | |
41 GdkBitmap *dark_icon_bm = NULL; | |
42 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
43 char *fontface; |
66 | 44 |
45 void check_everything(GtkWidget *entry); | |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
46 char *get_tag_by_prefix(GtkWidget *entry, const char *prefix); |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
47 gboolean keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c); |
66 | 48 |
49 /*------------------------------------------------------------------------*/ | |
50 /* Helpers */ | |
51 /*------------------------------------------------------------------------*/ | |
52 | |
53 | |
54 void quiet_set(GtkWidget *tb, int state) | |
55 { | |
56 state_lock=1; | |
57 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(tb), state); | |
58 state_lock=0; | |
59 } | |
60 | |
61 | |
62 void set_state_lock(int i) | |
63 { | |
64 state_lock = i; | |
65 } | |
66 | |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
67 void toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
68 { |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
69 gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(to_toggle)); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
70 |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
71 if (sensitivity == TRUE) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
72 gtk_widget_set_sensitive(GTK_WIDGET(to_toggle), FALSE); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
73 else |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
74 gtk_widget_set_sensitive(GTK_WIDGET(to_toggle), TRUE); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
75 |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
76 return; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
77 } |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
78 |
66 | 79 struct conversation *new_conversation(char *name) |
80 { | |
81 struct conversation *c; | |
82 | |
83 c = find_conversation(name); | |
84 | |
85 if (c != NULL) | |
86 return c; | |
87 | |
88 c = (struct conversation *)g_new0(struct conversation, 1); | |
89 g_snprintf(c->name, sizeof(c->name), "%s", name); | |
90 | |
91 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
92 FILE *fd; | |
70 | 93 |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
363
diff
changeset
|
94 fd = open_log_file(c->name); |
66 | 95 if (!(general_options & OPT_GEN_STRIP_HTML)) |
70 | 96 fprintf(fd, "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n", full_date()); |
66 | 97 else |
70 | 98 fprintf(fd, " ---- New Conversation @ %s ----\n", full_date()); |
99 | |
66 | 100 fclose(fd); |
101 } | |
102 | |
103 show_conv(c); | |
104 conversations = g_list_append(conversations, c); | |
105 return c; | |
106 } | |
107 | |
108 | |
109 struct conversation *find_conversation(char *name) | |
110 { | |
111 char *cuser = g_malloc(64); | |
112 struct conversation *c; | |
113 GList *cnv = conversations; | |
114 | |
115 strcpy(cuser, normalize(name)); | |
116 | |
117 while(cnv) { | |
118 c = (struct conversation *)cnv->data; | |
119 if(!strcasecmp(cuser, normalize(c->name))) { | |
120 g_free(cuser); | |
121 return c; | |
122 } | |
123 cnv = cnv->next; | |
124 } | |
125 g_free(cuser); | |
126 return NULL; | |
127 } | |
128 | |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
129 /* given the first part of a tag, returns the length up to the final '>'; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
130 useful for 'remove_tags' calls on variable data, such as <font face> |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
131 tags */ |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
132 char *get_tag_by_prefix(GtkWidget *entry, const char *prefix) |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
133 { |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
134 char *s, *t; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
135 int i = 0; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
136 |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
137 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
138 t = s; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
139 |
411
a330017b3aa4
[gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
391
diff
changeset
|
140 if ((t = strstr(s, prefix)) != NULL) |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
141 { |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
142 for (i = 1; t[i] != '\0'; i++) |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
143 { |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
144 |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
145 if (t[i] == '>') |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
146 break; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
147 } |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
148 |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
149 t = gtk_editable_get_chars(GTK_EDITABLE(entry), (t-s), (t-s) + i + 1); |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
150 } |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
151 return t; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
152 } |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
153 |
66 | 154 /* --------------------------------------------------- |
155 * Function to remove a log file entry | |
156 * --------------------------------------------------- | |
157 */ | |
158 | |
159 void rm_log(struct log_conversation *a) | |
160 { | |
161 struct conversation *cnv = find_conversation(a->name); | |
162 char buf[128]; | |
163 | |
164 log_conversations = g_list_remove(log_conversations, a); | |
165 | |
166 save_prefs(); | |
167 | |
168 if (cnv) { | |
169 if (!(general_options & OPT_GEN_LOG_ALL)) | |
170 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, cnv->name); | |
171 else | |
172 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, cnv->name); | |
173 gtk_window_set_title(GTK_WINDOW(cnv->window), buf); | |
174 } | |
175 } | |
176 | |
177 struct log_conversation *find_log_info(char *name) | |
178 { | |
179 char *pname = g_malloc(64); | |
180 GList *lc = log_conversations; | |
181 struct log_conversation *l; | |
182 | |
183 | |
184 strcpy(pname, normalize(name)); | |
185 | |
186 while(lc) { | |
187 l = (struct log_conversation *)lc->data; | |
188 if (!strcasecmp(pname, normalize(l->name))) { | |
189 g_free(pname); | |
190 return l; | |
191 } | |
192 lc = lc->next; | |
193 } | |
194 g_free(pname); | |
195 return NULL; | |
196 } | |
197 | |
198 void delete_conversation(struct conversation *cnv) | |
199 { | |
200 conversations = g_list_remove(conversations, cnv); | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
201 if (cnv->color_dialog) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
202 gtk_widget_destroy(cnv->color_dialog); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
203 if (cnv->font_dialog) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
204 gtk_widget_destroy(cnv->font_dialog); |
66 | 205 g_free(cnv); |
206 } | |
207 | |
208 void update_log_convs() | |
209 { | |
210 GList *cnv = conversations; | |
211 struct conversation *c; | |
212 | |
213 while(cnv) { | |
214 c = (struct conversation *)cnv->data; | |
215 | |
216 if (c->log_button) | |
217 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); | |
218 | |
219 cnv = cnv->next; | |
220 } | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
221 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
222 cnv = buddy_chats; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
223 while(cnv) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
224 c = (struct conversation *)cnv->data; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
225 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
226 if (c->log_button) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
227 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
228 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
229 cnv = cnv->next; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
230 } |
66 | 231 } |
232 | |
233 void update_font_buttons() | |
234 { | |
235 GList *cnv = conversations; | |
236 struct conversation *c; | |
237 | |
238 while (cnv) { | |
239 c = (struct conversation *)cnv->data; | |
240 | |
241 if (c->bold) | |
242 gtk_widget_set_sensitive(c->bold, ((font_options & OPT_FONT_BOLD)) ? FALSE : TRUE); | |
243 | |
244 if (c->italic) | |
245 gtk_widget_set_sensitive(c->italic, ((font_options & OPT_FONT_ITALIC)) ? FALSE : TRUE); | |
246 | |
247 if (c->underline) | |
248 gtk_widget_set_sensitive(c->underline, ((font_options & OPT_FONT_UNDERLINE)) ? FALSE : TRUE); | |
249 | |
250 if (c->strike) | |
251 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); | |
252 | |
488
0fcb7e7a263c
[gaim-migrate @ 498]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
474
diff
changeset
|
253 if (c->font) |
0fcb7e7a263c
[gaim-migrate @ 498]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
474
diff
changeset
|
254 gtk_widget_set_sensitive(c->font, ((font_options & OPT_FONT_FACE)) ? TRUE : FALSE); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
255 |
66 | 256 cnv = cnv->next; |
257 } | |
258 } | |
259 | |
260 /* | |
261 void update_transparency() | |
262 { | |
263 GList *cnv = conversations; | |
264 struct conversation *c; | |
265 | |
266 This func should be uncalled! | |
267 | |
268 while(cnv) { | |
269 c = (struct conversation *)cnv->data; | |
270 | |
271 if (c->text) | |
272 gtk_html_set_transparent(GTK_HTML(c->text), | |
273 (transparent) ? TRUE : FALSE); | |
274 | |
275 cnv = cnv->next; | |
276 } | |
277 } | |
278 */ | |
279 | |
280 | |
281 /*------------------------------------------------------------------------*/ | |
282 /* Callbacks */ | |
283 /*------------------------------------------------------------------------*/ | |
284 | |
285 void toggle_loggle(GtkWidget *w, struct conversation *p) | |
286 { | |
287 if (state_lock) | |
288 return; | |
289 | |
290 if (find_log_info(p->name)) | |
291 rm_log(find_log_info(p->name)); | |
292 else | |
293 show_log_dialog(p->name); | |
294 } | |
295 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
296 int close_callback(GtkWidget *widget, struct conversation *c) |
66 | 297 { |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
298 if (c->window) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
299 gtk_widget_destroy(c->window); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
300 c->window = NULL; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
301 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
302 if (c->is_chat) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
303 serv_chat_leave(c->id); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
304 else |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
305 delete_conversation(c); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
306 |
66 | 307 return TRUE; |
308 } | |
309 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
310 void set_font_face(GtkWidget *widget, struct conversation *c) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
311 { |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
312 char *pre_fontface, *old_font_face; |
411
a330017b3aa4
[gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
391
diff
changeset
|
313 int alloc = 0; |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
314 |
308
e5fa88351dc8
[gaim-migrate @ 318]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
315 if (c->current_fontface[0] && strcmp(c->current_fontface, "(null)")) |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
316 { |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
317 pre_fontface = g_strconcat("<FONT FACE=\"", c->current_fontface, "\">", '\0'); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
318 alloc++; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
319 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
320 else |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
321 pre_fontface = "<FONT FACE=\"Helvetica\">"; |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
322 |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
323 if (!strcmp(pre_fontface, "<FONT FACE=\"\">")) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
324 { |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
325 g_free(pre_fontface); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
326 alloc--; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
327 pre_fontface = "<FONT FACE=\"Helvetica\">"; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
328 } |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
329 |
411
a330017b3aa4
[gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
391
diff
changeset
|
330 if ((old_font_face = get_tag_by_prefix(c->entry, "<FONT FACE")) != NULL) |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
331 { |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
332 remove_tags(c->entry, old_font_face); |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
333 remove_tags(c->entry, "</FONT>"); |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
334 } |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
335 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
336 surround(c->entry, pre_fontface, "</FONT>"); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
337 gtk_widget_grab_focus(c->entry); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
338 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
339 if (alloc) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
340 g_free(pre_fontface); |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
341 |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
342 g_free(old_font_face); /* mem allocated in get_tag_by_prefix() */ |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
343 return; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
344 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
345 |
66 | 346 static gint delete_event_convo(GtkWidget *w, GdkEventAny *e, struct conversation *c) |
347 { | |
348 delete_conversation(c); | |
349 return FALSE; | |
350 } | |
351 | |
352 static void color_callback(GtkWidget *widget, struct conversation *c) | |
353 { | |
354 /* show_color_dialog(c); */ | |
355 gtk_widget_grab_focus(c->entry); | |
356 } | |
357 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
358 void add_callback(GtkWidget *widget, struct conversation *c) |
66 | 359 { |
360 if (find_buddy(c->name) != NULL) { | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
361 sprintf(debug_buff,_("Removing '%s' from buddylist.\n"), c->name); |
66 | 362 debug_print(debug_buff); |
363 remove_buddy(find_group_by_buddy(c->name), find_buddy(c->name)); | |
364 build_edit_tree(); | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
365 gtk_label_set_text(GTK_LABEL(GTK_BIN(c->add_button)->child), _("Add")); |
66 | 366 } |
367 else | |
368 { | |
369 show_add_buddy(c->name, NULL); | |
370 } | |
371 | |
372 gtk_widget_grab_focus(c->entry); | |
373 } | |
374 | |
375 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
376 void block_callback(GtkWidget *widget, struct conversation *c) |
66 | 377 { |
378 show_add_perm(c->name); | |
379 gtk_widget_grab_focus(c->entry); | |
380 } | |
381 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
382 void warn_callback(GtkWidget *widget, struct conversation *c) |
66 | 383 { |
384 show_warn_dialog(c->name); | |
385 gtk_widget_grab_focus(c->entry); | |
386 } | |
387 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
388 void info_callback(GtkWidget *w, struct conversation *c) |
66 | 389 { |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
390 if (c->is_chat) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
391 char *name; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
392 GList *i; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
393 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
394 i = GTK_LIST(c->list)->selection; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
395 if (i) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
396 name = (char *)gtk_object_get_user_data(GTK_OBJECT(i->data)); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
397 else |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
398 return; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
399 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
400 serv_get_info(name); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
401 } else { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
402 serv_get_info(c->name); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
403 gtk_widget_grab_focus(c->entry); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
404 } |
66 | 405 } |
406 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
407 gboolean keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c) |
66 | 408 { |
409 int pos; | |
410 if(event->keyval==GDK_Return) { | |
363
1c4ce1da3946
[gaim-migrate @ 373]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
411 if(!(event->state & GDK_SHIFT_MASK) |
1c4ce1da3946
[gaim-migrate @ 373]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
412 && (general_options & OPT_GEN_ENTER_SENDS)) { |
66 | 413 gtk_signal_emit_by_name(GTK_OBJECT(entry), "activate", c); |
414 //to stop the putting in of the enter character | |
415 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); | |
416 } else { | |
417 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); | |
418 pos=gtk_editable_get_position(GTK_EDITABLE(entry)); | |
419 gtk_editable_insert_text(GTK_EDITABLE(entry), "\n", 1, &pos); | |
420 } | |
421 } | |
422 | |
423 return TRUE; | |
424 | |
425 } | |
426 | |
427 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
428 void send_callback(GtkWidget *widget, struct conversation *c) |
66 | 429 { |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
430 char *buf = g_malloc(BUF_LEN * 4); |
66 | 431 char *buf2; |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
432 char *buf3; |
66 | 433 gchar *buf4; |
434 int hdrlen; | |
435 | |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
275
diff
changeset
|
436 /* FIXME : for USE_OSCAR, libfaim can send messages much longer |
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
275
diff
changeset
|
437 * than this (I think it's about 7K rather than 4K. So we need |
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
275
diff
changeset
|
438 * to do these checks a little bit differently here */ |
66 | 439 buf4 = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1); |
440 g_snprintf(buf, BUF_LONG, "%s", buf4); | |
441 g_free(buf4); | |
442 | |
443 if (!strlen(buf)) { | |
444 return; | |
445 } | |
446 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
447 gtk_editable_delete_text(GTK_EDITABLE(c->entry), 0, -1); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
448 |
66 | 449 if (general_options & OPT_GEN_SEND_LINKS) { |
450 linkify_text(buf); | |
451 } | |
452 | |
453 /* Let us determine how long the message CAN be. | |
454 * toc_send_im is 11 chars long + 2 quotes. | |
455 * + 2 spaces + 6 for the header + 2 for good | |
456 * measure = 23 bytes + the length of normalize c->name */ | |
457 | |
458 buf2 = g_malloc(BUF_LONG); | |
459 | |
460 hdrlen = 23 + strlen(normalize(c->name)); | |
461 | |
462 /* printf("%d %d %d\n", strlen(buf), hdrlen, BUF_LONG);*/ | |
463 | |
464 if (font_options & OPT_FONT_BOLD) { | |
465 g_snprintf(buf2, BUF_LONG, "<B>%s</B>", buf); | |
466 strcpy(buf, buf2); | |
467 } | |
468 | |
469 if (font_options & OPT_FONT_ITALIC) { | |
470 g_snprintf(buf2, BUF_LONG, "<I>%s</I>", buf); | |
471 strcpy(buf, buf2); | |
472 } | |
473 | |
474 if (font_options & OPT_FONT_UNDERLINE) { | |
475 g_snprintf(buf2, BUF_LONG, "<U>%s</U>", buf); | |
476 strcpy(buf, buf2); | |
477 } | |
478 | |
479 if (font_options & OPT_FONT_STRIKE) { | |
480 g_snprintf(buf2, BUF_LONG, "<STRIKE>%s</STRIKE>", buf); | |
481 strcpy(buf, buf2); | |
482 } | |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
483 |
488
0fcb7e7a263c
[gaim-migrate @ 498]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
474
diff
changeset
|
484 if (font_options & OPT_FONT_FACE) { |
0fcb7e7a263c
[gaim-migrate @ 498]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
474
diff
changeset
|
485 g_snprintf(buf2, BUF_LONG, "<FONT FACE=\"%s\">%s</FONT>", c->current_fontface, buf); |
0fcb7e7a263c
[gaim-migrate @ 498]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
474
diff
changeset
|
486 strcpy(buf, buf2); |
0fcb7e7a263c
[gaim-migrate @ 498]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
474
diff
changeset
|
487 } |
0fcb7e7a263c
[gaim-migrate @ 498]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
474
diff
changeset
|
488 |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
489 #ifdef GAIM_PLUGINS |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
490 { |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
491 GList *ca = callbacks; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
492 struct gaim_callback *g; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
493 void (*function)(char *, char **, void *); |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
389
diff
changeset
|
494 char *buffy = g_strdup(buf); |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
495 enum gaim_event evnt = c->is_chat ? event_chat_send : event_im_send; |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
496 while (ca) { |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
497 g = (struct gaim_callback *)(ca->data); |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
498 if (g->event == evnt && g->function != NULL) { |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
499 function = g->function; |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
389
diff
changeset
|
500 (*function)(c->name, &buffy, g->data); |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
501 } |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
502 ca = ca->next; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
503 } |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
389
diff
changeset
|
504 if (!buffy) { |
102
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
505 g_free(buf2); |
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
506 return; |
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
507 } |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
389
diff
changeset
|
508 g_snprintf(buf, BUF_LONG, "%s", buffy); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
389
diff
changeset
|
509 g_free(buffy); |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
510 } |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
511 #endif |
66 | 512 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
513 if (!c->is_chat) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
514 buf3 = g_strdup(buf); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
515 write_to_conv(c, buf3, WFLAG_SEND, NULL); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
516 g_free(buf3); |
502
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
517 escape_text(buf); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
518 if (escape_message(buf) > MSG_LEN - hdrlen) |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
519 do_error_dialog(_("Message too long, some data truncated."), _("Error")); |
66 | 520 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
521 serv_send_im(c->name, buf, 0); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
522 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
523 if (c->makesound && (sound_options & OPT_SOUND_SEND)) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
524 play_sound(SEND); |
502
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
525 } else { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
526 serv_chat_send(c->id, buf); /* this does escape_text for us */ |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
527 |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
528 /* no sound because we do that when we receive our message */ |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
529 } |
66 | 530 |
531 quiet_set(c->bold, FALSE); | |
532 quiet_set(c->strike, FALSE); | |
533 quiet_set(c->italic, FALSE); | |
534 quiet_set(c->underline, FALSE); | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
535 quiet_set(c->font, FALSE); |
66 | 536 quiet_set(c->palette, FALSE); |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
537 quiet_set(c->link, FALSE); |
66 | 538 |
375
1eae69f076d2
[gaim-migrate @ 385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
373
diff
changeset
|
539 if ((general_options & OPT_GEN_BACK_ON_IM) && awaymessage != NULL) { |
66 | 540 do_im_back(); |
541 } | |
542 | |
543 gtk_widget_grab_focus(c->entry); | |
544 | |
488
0fcb7e7a263c
[gaim-migrate @ 498]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
474
diff
changeset
|
545 g_free(buf2); |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
546 g_free(buf); |
66 | 547 } |
548 | |
549 static int | |
550 entry_key_pressed(GtkWidget *w, GtkWidget *entry) | |
551 { | |
552 check_everything(w); | |
553 return TRUE; | |
554 } | |
555 | |
556 /*------------------------------------------------------------------------*/ | |
557 /* HTML-type stuff */ | |
558 /*------------------------------------------------------------------------*/ | |
559 | |
560 int count_tag(GtkWidget *entry, char *s1, char *s2) | |
561 { | |
562 char *p1, *p2; | |
563 int res=0; | |
564 char *tmp, *tmpo, h; | |
565 tmpo = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
566 h = tmpo[GTK_EDITABLE(entry)->current_pos]; | |
567 tmpo[GTK_EDITABLE(entry)->current_pos]='\0'; | |
568 tmp=tmpo; | |
569 do { | |
570 p1 = strstr(tmp, s1); | |
571 p2 = strstr(tmp, s2); | |
572 if (p1 && p2) { | |
573 if (p1 < p2) { | |
574 res=1; | |
575 tmp = p1 +strlen(s1); | |
576 } else if (p2 < p1) { | |
577 res = 0; | |
578 tmp = p2 + strlen(s2); | |
579 } | |
580 } else { | |
581 if (p1) { | |
582 res = 1; | |
583 tmp = p1 + strlen(s1); | |
584 } else if (p2) { | |
585 res = 0; | |
586 tmp = p2 + strlen(s2); | |
587 } | |
588 } | |
589 } while (p1 || p2); | |
590 tmpo[GTK_EDITABLE(entry)->current_pos]=h; | |
591 g_free(tmpo); | |
592 return res; | |
593 } | |
594 | |
595 | |
596 int invert_tags(GtkWidget *entry, char *s1, char *s2, int really) | |
597 { | |
598 int start = GTK_EDITABLE(entry)->selection_start_pos; | |
599 int finish = GTK_EDITABLE(entry)->selection_end_pos; | |
600 char *s; | |
601 | |
602 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
603 if (!strncasecmp(&s[start], s1, strlen(s1)) && | |
604 !strncasecmp(&s[finish - strlen(s2)], s2, strlen(s2))) { | |
605 if (really) { | |
606 gtk_editable_delete_text(GTK_EDITABLE(entry), start, start + strlen(s1)); | |
607 gtk_editable_delete_text(GTK_EDITABLE(entry), finish - strlen(s2) - strlen(s1), finish - strlen(s1)); | |
608 } | |
609 g_free(s); | |
610 return 1; | |
611 } | |
612 g_free(s); | |
613 return 0; | |
614 } | |
615 | |
616 | |
617 void remove_tags(GtkWidget *entry, char *tag) | |
618 { | |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
619 char *s, *t; |
66 | 620 int start = GTK_EDITABLE(entry)->selection_start_pos; |
621 int finish = GTK_EDITABLE(entry)->selection_end_pos; | |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
622 int temp; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
623 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
66 | 624 t = s; |
275
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
625 |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
626 if (start > finish) |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
627 { |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
628 temp = start; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
629 start = finish; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
630 finish = temp; |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
631 } |
f9eb3eb9ffde
[gaim-migrate @ 285]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
234
diff
changeset
|
632 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
633 if (strstr(tag, "<FONT SIZE=")) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
634 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
635 while((t = strstr(t, "<FONT SIZE="))) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
636 if (((t-s) < finish) && ((t-s) >= start)) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
637 gtk_editable_delete_text(GTK_EDITABLE(entry), (t-s), (t-s) + strlen(tag)); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
638 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
639 t = s; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
640 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
641 else t++; |
68 | 642 } |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
643 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
644 else |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
645 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
646 while((t = strstr(t, tag))) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
647 if (((t-s) < finish) && ((t-s) >= start)) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
648 gtk_editable_delete_text(GTK_EDITABLE(entry), (t-s), (t-s) + strlen(tag)); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
649 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
650 t = s; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
651 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
652 else t++; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
653 } |
66 | 654 } |
655 g_free(s); | |
656 } | |
657 | |
658 void surround(GtkWidget *entry, char *pre, char *post) | |
659 { | |
660 int pos = GTK_EDITABLE(entry)->current_pos; | |
661 int dummy; | |
662 int start, finish; | |
663 if (GTK_EDITABLE(entry)->has_selection) { | |
664 remove_tags(entry, pre); | |
665 remove_tags(entry, post); | |
666 start = GTK_EDITABLE(entry)->selection_start_pos; | |
667 finish = GTK_EDITABLE(entry)->selection_end_pos; | |
668 if (start > finish) { | |
669 dummy = finish; | |
670 finish = start; | |
671 start = dummy; | |
672 } | |
673 dummy = start; | |
674 gtk_editable_insert_text(GTK_EDITABLE(entry), pre, strlen(pre), &dummy); | |
675 dummy = finish + strlen(pre); | |
676 gtk_editable_insert_text(GTK_EDITABLE(entry), post, strlen(post), &dummy); | |
677 gtk_editable_select_region(GTK_EDITABLE(entry), start, finish + strlen(pre) + strlen(post)); | |
678 } else { | |
679 gtk_editable_insert_text(GTK_EDITABLE(entry), pre, strlen(pre), &pos); | |
680 dummy = pos; | |
681 gtk_editable_insert_text(GTK_EDITABLE(entry), post, strlen(post), &dummy); | |
682 gtk_editable_set_position(GTK_EDITABLE(entry), pos); | |
683 } | |
684 gtk_widget_grab_focus(entry); | |
685 } | |
686 | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
687 void advance_past(GtkWidget *entry, char *pre, char *post) |
66 | 688 { |
689 char *s, *s2; | |
690 int pos; | |
691 if (invert_tags(entry, pre, post, 1)) | |
692 return; | |
693 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
694 pos = GTK_EDITABLE(entry)->current_pos; | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
695 sprintf(debug_buff,_("Currently at %d\n"),pos); |
66 | 696 debug_print(debug_buff); |
697 s2= strstr(&s[pos], post); | |
698 if (s2) | |
699 pos = s2 - s + strlen(post); | |
700 else | |
187 | 701 pos=strlen(s); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
702 sprintf(debug_buff,_("Setting position to %d\n"),pos); |
66 | 703 debug_print(debug_buff); |
704 gtk_editable_set_position(GTK_EDITABLE(entry), pos); | |
705 gtk_widget_grab_focus(entry); | |
706 } | |
707 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
708 void toggle_color(GtkWidget *color, struct conversation *c) |
66 | 709 { |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
710 if (state_lock) |
66 | 711 return; |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
712 if (GTK_TOGGLE_BUTTON(color)->active) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
713 show_color_dialog(c, color); |
189
50dc3db25513
[gaim-migrate @ 199]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
187
diff
changeset
|
714 else |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
715 advance_past(c->entry, "<FONT COLOR>", "</FONT>" ); |
66 | 716 } |
717 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
718 void toggle_font(GtkWidget *font, struct conversation *c) |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
719 { |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
720 if (state_lock) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
721 return; |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
722 if (GTK_TOGGLE_BUTTON(font)->active) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
723 show_font_dialog(c, font); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
724 else |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
725 advance_past(c->entry, "<FONT FACE>", "</FONT>"); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
726 |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
727 return; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
728 } |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
729 |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
730 void do_link(GtkWidget *linky, GtkWidget *entry) |
66 | 731 { |
732 if (state_lock) | |
733 return; | |
734 if (GTK_TOGGLE_BUTTON(linky)->active) | |
735 show_add_link(entry, linky); | |
736 else | |
737 advance_past(entry, "<A HREF>", "</A>" ); | |
738 } | |
739 | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
740 void do_strike(GtkWidget *strike, GtkWidget *entry) |
66 | 741 { |
742 if (state_lock) | |
743 return; | |
744 if (GTK_TOGGLE_BUTTON(strike)->active) | |
745 surround(entry, "<STRIKE>","</STRIKE>"); | |
746 else | |
747 advance_past(entry, "<STRIKE>", "</STRIKE>"); | |
748 } | |
749 | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
750 void do_bold(GtkWidget *bold, GtkWidget *entry) |
66 | 751 { |
752 if (state_lock) | |
753 return; | |
754 if (GTK_TOGGLE_BUTTON(bold)->active) | |
755 surround(entry, "<B>","</B>"); | |
756 else | |
757 advance_past(entry, "<B>", "</B>"); | |
758 } | |
759 | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
760 void do_underline(GtkWidget *underline, GtkWidget *entry) |
66 | 761 { |
762 if (state_lock) | |
763 return; | |
764 if (GTK_TOGGLE_BUTTON(underline)->active) | |
765 surround(entry, "<U>","</U>"); | |
766 else | |
767 advance_past(entry, "<U>", "</U>"); | |
768 } | |
769 | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
770 void do_italic(GtkWidget *italic, GtkWidget *entry) |
66 | 771 { |
772 if (state_lock) | |
773 return; | |
774 if (GTK_TOGGLE_BUTTON(italic)->active) | |
775 surround(entry, "<I>","</I>"); | |
776 else | |
777 advance_past(entry, "<I>", "</I>"); | |
778 } | |
779 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
780 /* html code to modify font sizes must all be the same length, */ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
781 /* currently set to 15 chars */ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
782 |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
783 void do_small(GtkWidget *small, GtkWidget *entry) |
66 | 784 { |
785 if (state_lock) | |
786 return; | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
787 surround(entry, "<FONT SIZE=\"1\">","</FONT>"); |
66 | 788 } |
789 | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
790 void do_normal(GtkWidget *normal, GtkWidget *entry) |
66 | 791 { |
792 if (state_lock) | |
793 return; | |
88 | 794 surround(entry, "<FONT SIZE=\"3\">","</FONT>"); |
66 | 795 } |
796 | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
797 void do_big(GtkWidget *big, GtkWidget *entry) |
66 | 798 { |
799 if (state_lock) | |
800 return; | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
801 surround(entry, "<FONT SIZE=\"5\">","</FONT>"); |
66 | 802 } |
803 | |
804 void check_everything(GtkWidget *entry) | |
805 { | |
806 struct conversation *c; | |
206 | 807 |
66 | 808 c = (struct conversation *)gtk_object_get_user_data(GTK_OBJECT(entry)); |
809 if (!c) return; | |
810 if (invert_tags(entry, "<B>", "</B>", 0)) | |
811 quiet_set(c->bold, TRUE); | |
812 else if (count_tag(entry, "<B>", "</B>")) | |
813 quiet_set(c->bold, TRUE); | |
814 else | |
815 quiet_set(c->bold,FALSE); | |
816 if (invert_tags(entry, "<I>", "</I>", 0)) | |
817 quiet_set(c->italic, TRUE); | |
818 else if (count_tag(entry, "<I>", "</I>")) | |
819 quiet_set(c->italic, TRUE); | |
820 else | |
821 quiet_set(c->italic, FALSE); | |
822 | |
823 if (invert_tags(entry, "<FONT COLOR", "</FONT>", 0)) | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
824 quiet_set(c->palette, TRUE); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
825 else if (count_tag(entry, "<FONT COLOR", "</FONT>")) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
826 quiet_set(c->palette, TRUE); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
827 else |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
828 quiet_set(c->palette, FALSE); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
829 |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
830 if (invert_tags(entry, "<FONT FACE", "</FONT>", 0)) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
831 quiet_set(c->font, TRUE); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
832 else if (count_tag(entry, "<FONT FACE", "</FONT>")) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
833 quiet_set(c->font, TRUE); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
834 else |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
835 quiet_set(c->font, FALSE); |
66 | 836 |
837 if (invert_tags(entry, "<A HREF", "</A>", 0)) | |
838 quiet_set(c->link, TRUE); | |
839 else if (count_tag(entry, "<A HREF", "</A>")) | |
840 quiet_set(c->link, TRUE); | |
841 else | |
842 quiet_set(c->link, FALSE); | |
843 | |
844 if (invert_tags(entry, "<U>", "</U>", 0)) | |
845 quiet_set(c->underline, TRUE); | |
846 else if (count_tag(entry, "<U>", "</U>")) | |
847 quiet_set(c->underline, TRUE); | |
848 else | |
849 quiet_set(c->underline, FALSE); | |
850 | |
851 if (invert_tags(entry, "<STRIKE>", "</STRIKE>", 0)) | |
852 quiet_set(c->strike, TRUE); | |
853 else if (count_tag(entry, "<STRIKE>", "</STRIKE>")) | |
854 quiet_set(c->strike, TRUE); | |
855 else | |
856 quiet_set(c->strike, FALSE); | |
857 } | |
858 | |
859 | |
860 /*------------------------------------------------------------------------*/ | |
861 /* Takin care of the window.. */ | |
862 /*------------------------------------------------------------------------*/ | |
863 | |
864 | |
502
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
865 GdkPixmap *is_smiley(struct conversation *c, char *m, int *len) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
866 GdkBitmap *mask; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
867 GdkPixmap *face = NULL; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
868 |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
869 if (strlen(m) < 2) return face; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
870 *len = 2; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
871 if ( !strncmp(m, ":)", 2) || |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
872 !strncmp(m, "=)", 2)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
873 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
874 } else if (!strncmp(m, ":(", 2) || |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
875 !strncmp(m, "=(", 2)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
876 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, sad_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
877 } else if (!strncmp(m, ";)", 2)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
878 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, wink_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
879 } |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
880 |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
881 if (face || strlen(m) < 3) return face; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
882 *len = 3; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
883 if ( !strncmp(m, ":-)", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
884 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
885 } else if (!strncmp(m, ":-(", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
886 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, sad_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
887 } else if (!strncmp(m, ";-)", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
888 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, wink_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
889 } else if (!strncmp(m, ":-p", 3) || |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
890 !strncmp(m, ":-P", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
891 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, tongue_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
892 } else if (!strncmp(m, "=-O", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
893 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, scream_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
894 } else if (!strncmp(m, ":-*", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
895 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, kiss_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
896 } else if (!strncmp(m, ">:o", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
897 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, yell_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
898 } else if (!strncmp(m, "8-)", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
899 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile8_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
900 } else if (!strncmp(m, ":-$", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
901 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, moneymouth_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
902 } else if (!strncmp(m, ":-!", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
903 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, burp_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
904 } else if (!strncmp(m, ":-[", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
905 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, embarrassed_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
906 } else if (!strncmp(m, ":'(", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
907 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, cry_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
908 } else if (!strncmp(m, ":-\\", 3) || |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
909 !strncmp(m, ":-/", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
910 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, think_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
911 } else if (!strncmp(m, ":-X", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
912 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, crossedlips_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
913 } else if (!strncmp(m, ":-D", 3)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
914 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, bigsmile_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
915 } |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
916 |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
917 if (face || strlen(m) < 4) return face; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
918 *len = 4; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
919 if ( !strncmp(m, "O:-)", 4)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
920 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, angel_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
921 } |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
922 |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
923 if (face || strlen(m) < 6) return face; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
924 *len = 6; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
925 if ( !strncmp(m, ">:o", 6)) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
926 face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, yell_xpm); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
927 } |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
928 |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
929 return face; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
930 } |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
931 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
932 /* this is going to be interesting since the conversation could either be a |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
933 * normal IM conversation or a chat window. but hopefully it won't matter */ |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
934 void write_to_conv(struct conversation *c, char *what, int flags, char *who) |
66 | 935 { |
936 char *buf = g_malloc(BUF_LONG); | |
937 char *buf2 = g_malloc(BUF_LONG); | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
938 char *str; |
66 | 939 FILE *fd; |
940 char colour[10]; | |
337 | 941 GdkPixmap *face; |
942 int state; | |
943 int y; | |
944 int i; | |
389 | 945 char *smiley = g_malloc(7); |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
946 |
474
7720d0f9da8e
[gaim-migrate @ 484]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
473
diff
changeset
|
947 if (!who) { |
7720d0f9da8e
[gaim-migrate @ 484]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
473
diff
changeset
|
948 if (flags & WFLAG_SEND) |
7720d0f9da8e
[gaim-migrate @ 484]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
473
diff
changeset
|
949 who = current_user->username; |
7720d0f9da8e
[gaim-migrate @ 484]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
473
diff
changeset
|
950 else |
7720d0f9da8e
[gaim-migrate @ 484]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
473
diff
changeset
|
951 who = c->name; |
7720d0f9da8e
[gaim-migrate @ 484]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
473
diff
changeset
|
952 } |
337 | 953 |
66 | 954 if (flags & WFLAG_SYSTEM) { |
955 | |
956 gtk_html_freeze(GTK_HTML(c->text)); | |
957 | |
958 gtk_html_append_text(GTK_HTML(c->text), what, 0); | |
337 | 959 |
960 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0); | |
66 | 961 |
962 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
963 char *t1; | |
964 | |
965 if (general_options & OPT_GEN_STRIP_HTML) { | |
966 t1 = strip_html(what); | |
967 } else { | |
968 t1 = what; | |
969 } | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
363
diff
changeset
|
970 fd = open_log_file(c->name); |
66 | 971 fprintf(fd, "%s\n", t1); |
972 fclose(fd); | |
973 if (general_options & OPT_GEN_STRIP_HTML) { | |
974 g_free(t1); | |
975 } | |
976 } | |
977 | |
978 } else { | |
979 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
980 if (flags & WFLAG_WHISPER) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
981 /* if we're whispering, it's not an autoresponse */ |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
982 if (meify(what)) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
983 str = g_malloc(64); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
984 g_snprintf(str, 62, "***%s", who); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
985 strcpy(colour, "#6C2585\0"); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
986 } else { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
987 str = g_malloc(64); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
988 g_snprintf(str, 62, "*%s*:", who); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
989 strcpy(colour, "#00ff00\0"); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
990 } |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
991 } else { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
992 if (meify(what)) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
993 str = g_malloc(64); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
994 if (flags & WFLAG_AUTO) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
995 g_snprintf(str, 62, "%s ***%s", AUTO_RESPONSE, who); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
996 else |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
997 g_snprintf(str, 62, "***%s", who); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
998 strcpy(colour, "#062585\0"); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
999 } else { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1000 str = g_malloc(64); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1001 if (flags & WFLAG_AUTO) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1002 g_snprintf(str, 62, "%s %s", who, AUTO_RESPONSE); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1003 else |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1004 g_snprintf(str, 62, "%s:", who); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1005 if (flags & WFLAG_RECV) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1006 strcpy(colour, "#ff0000"); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1007 else if (flags & WFLAG_SEND) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1008 strcpy(colour, "#0000ff"); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1009 } |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1010 } |
66 | 1011 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1012 if (display_options & OPT_DISP_SHOW_TIME) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1013 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s %s</B></FONT> ", colour, date(), str); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1014 else |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1015 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s</B></FONT>", colour, str); |
66 | 1016 |
473
f9bb7761c52b
[gaim-migrate @ 483]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
472
diff
changeset
|
1017 g_free(str); |
f9bb7761c52b
[gaim-migrate @ 483]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
472
diff
changeset
|
1018 |
66 | 1019 gtk_html_freeze(GTK_HTML(c->text)); |
1020 | |
337 | 1021 y = 0; |
1022 state = 0; | |
1023 buf2[0] = 0; | |
1024 | |
1025 | |
1026 gtk_html_append_text(GTK_HTML(c->text), buf, 0); | |
1027 | |
1028 if (display_options & OPT_DISP_SHOW_SMILEY) | |
1029 { | |
1030 for (i = 0; i < strlen(what); i++) | |
1031 { | |
502
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1032 int len; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1033 if ((face = is_smiley(c, &what[i], &len)) != NULL) { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1034 buf2[y] = 0; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1035 gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1036 gtk_html_add_pixmap(GTK_HTML(c->text), face, 0); |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1037 y = 0; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1038 i += len - 1; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1039 } else { |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1040 buf2[y] = what[i]; |
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1041 y++; |
337 | 1042 |
502
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1043 } |
337 | 1044 } |
1045 | |
502
4d1e39112cbd
[gaim-migrate @ 512]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
494
diff
changeset
|
1046 if (y) |
337 | 1047 { |
1048 buf2[y] = 0; | |
1049 gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); | |
1050 } | |
1051 } | |
1052 else | |
1053 { | |
1054 gtk_html_append_text(GTK_HTML(c->text), what, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); | |
1055 } | |
66 | 1056 |
1057 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0); | |
1058 | |
1059 | |
1060 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
1061 char *t1, *t2; | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1062 char *nm = g_malloc(256); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1063 if (c->is_chat) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1064 g_snprintf(nm, 256, "%s.chat", c->name); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1065 else |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1066 g_snprintf(nm, 256, "%s", c->name); |
66 | 1067 |
1068 if (general_options & OPT_GEN_STRIP_HTML) { | |
1069 t1 = strip_html(buf); | |
1070 t2 = strip_html(what); | |
1071 } else { | |
1072 t1 = buf; | |
1073 t2 = what; | |
1074 } | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1075 fd = open_log_file(nm); |
66 | 1076 fprintf(fd, "%s%s\n", t1, t2); |
1077 fclose(fd); | |
1078 if (general_options & OPT_GEN_STRIP_HTML) { | |
1079 g_free(t1); | |
1080 g_free(t2); | |
1081 } | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1082 g_free(nm); |
66 | 1083 } |
1084 } | |
1085 | |
1086 /* if (!GTK_WIDGET_MAPPED(c->window)) { | |
1087 | |
1088 if (dark_icon_pm == NULL) | |
1089 dark_icon_pm = gdk_pixmap_create_from_xpm_d(c->window->window, &dark_icon_bm, | |
1090 NULL, (gchar **)aimicon2_xpm); | |
1091 gdk_window_set_icon(c->window->window, NULL, dark_icon_pm, dark_icon_bm); | |
1092 } | |
1093 */ | |
1094 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1095 if ((c->is_chat && (general_options & OPT_GEN_POPUP_CHAT)) || |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1096 (!c->is_chat && (general_options & OPT_GEN_POPUP_WINDOWS))) |
81 | 1097 gdk_window_show(c->window->window); |
66 | 1098 |
491
dcf5fe44396a
[gaim-migrate @ 501]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
488
diff
changeset
|
1099 gtk_html_thaw(GTK_HTML(c->text)); |
dcf5fe44396a
[gaim-migrate @ 501]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
488
diff
changeset
|
1100 |
337 | 1101 g_free(smiley); |
66 | 1102 g_free(buf); |
1103 g_free(buf2); | |
1104 } | |
1105 | |
1106 | |
1107 | |
206 | 1108 static void check_spelling( GtkEditable * editable, gchar * new_text, |
1109 gint length, gint * position, | |
1110 gpointer data ) | |
1111 { | |
207 | 1112 if (general_options & OPT_GEN_CHECK_SPELLING) |
1113 { | |
1114 gtk_signal_handler_block_by_func(GTK_OBJECT(editable), | |
1115 GTK_SIGNAL_FUNC(check_spelling), data); | |
1116 gtk_text_set_point(GTK_TEXT(editable), *position); | |
1117 gtk_text_insert(GTK_TEXT(editable), NULL, &(GTK_WIDGET(editable)->style->fg[0]), NULL, new_text, length ); | |
1118 if(isspace(new_text[0])) | |
1119 { | |
1120 gtk_text_freeze(GTK_TEXT(editable)); | |
209 | 1121 spell_checker(GTK_WIDGET(editable)); |
207 | 1122 gtk_text_thaw(GTK_TEXT(editable)); |
1123 } | |
1124 gtk_signal_handler_unblock_by_func(GTK_OBJECT(editable), | |
1125 GTK_SIGNAL_FUNC(check_spelling), data); | |
1126 gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert-text"); | |
1127 } | |
206 | 1128 } |
66 | 1129 |
1130 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1131 GtkWidget *build_conv_toolbar(struct conversation *c) { |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1132 GdkPixmap *strike_i, *small_i, *normal_i, *big_i, *bold_i, *italic_i, *underline_i, *speaker_i, *wood_i, *palette_i, *link_i, *font_i; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1133 GtkWidget *strike_p, *small_p, *normal_p, *big_p, *bold_p, *italic_p, *underline_p, *speaker_p, *wood_p, *palette_p, *link_p, *font_p; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1134 GtkWidget *strike, *small, *normal, *big, *bold, *italic, *underline, *speaker, *wood, *palette, *link, *font; |
66 | 1135 GdkBitmap *mask; |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1136 GtkWidget *toolbar; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1137 GtkWidget *win; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1138 GtkWidget *entry; |
66 | 1139 |
1140 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1141 win = c->window; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1142 entry = c->entry; |
66 | 1143 |
1144 link_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, | |
1145 &win->style->white, link_xpm ); | |
1146 link_p = gtk_pixmap_new(link_i, mask); | |
1147 gtk_widget_show(link_p); | |
1148 | |
1149 palette_i = gdk_pixmap_create_from_xpm_d (win->window, &mask, | |
1150 &win->style->white, palette_xpm ); | |
1151 palette_p = gtk_pixmap_new(palette_i, mask); | |
1152 gtk_widget_show(palette_p); | |
1153 | |
1154 wood_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1155 &win->style->white, wood_xpm ); | |
1156 wood_p = gtk_pixmap_new(wood_i, mask); | |
1157 gtk_widget_show(wood_p); | |
1158 speaker_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1159 &win->style->white, speaker_xpm ); | |
1160 speaker_p = gtk_pixmap_new(speaker_i, mask); | |
1161 gtk_widget_show(speaker_p); | |
1162 c->makesound=1; | |
1163 strike_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1164 &win->style->white, strike_xpm ); | |
1165 strike_p = gtk_pixmap_new(strike_i, mask); | |
1166 gtk_widget_show(strike_p); | |
1167 bold_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1168 &win->style->white, bold_xpm ); | |
1169 bold_p = gtk_pixmap_new(bold_i, mask); | |
1170 gtk_widget_show(bold_p); | |
1171 italic_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1172 &win->style->white, italic_xpm ); | |
1173 italic_p = gtk_pixmap_new(italic_i, mask); | |
1174 gtk_widget_show(italic_p); | |
1175 underline_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1176 &win->style->white, underline_xpm ); | |
1177 underline_p = gtk_pixmap_new(underline_i, mask); | |
1178 gtk_widget_show(underline_p); | |
1179 small_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1180 &win->style->white, small_xpm ); | |
1181 small_p = gtk_pixmap_new(small_i, mask); | |
1182 gtk_widget_show(small_p); | |
1183 normal_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1184 &win->style->white, normal_xpm ); | |
1185 normal_p = gtk_pixmap_new(normal_i, mask); | |
1186 gtk_widget_show(normal_p); | |
1187 big_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
1188 &win->style->white, big_xpm ); | |
1189 big_p = gtk_pixmap_new(big_i, mask); | |
1190 gtk_widget_show(big_p); | |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1191 font_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1192 &win->style->white, fontface_xpm ); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1193 font_p = gtk_pixmap_new(font_i, mask); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1194 gtk_widget_show(font_p); |
66 | 1195 |
1196 bold = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
1197 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1198 _("Bold"), _("Bold Text"), _("Bold"), bold_p, |
66 | 1199 GTK_SIGNAL_FUNC(do_bold), entry); |
1200 italic = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
1201 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1202 NULL, _("Italics"), _("Italics Text"), |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1203 _("Italics"), italic_p, GTK_SIGNAL_FUNC(do_italic), entry); |
66 | 1204 underline = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
1205 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1206 NULL, _("Underline"), _("Underline Text"), |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1207 _("Underline"), underline_p, GTK_SIGNAL_FUNC(do_underline), entry); |
66 | 1208 strike = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
1209 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1210 NULL, _("Strike"), _("Strike through Text"), |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1211 _("Strike"), strike_p, GTK_SIGNAL_FUNC(do_strike), entry); |
66 | 1212 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1213 small = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), _("Small"), _("Decrease font size"), _("Small"), small_p, GTK_SIGNAL_FUNC(do_small), entry); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1214 normal = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), _("Normal"), _("Normal font size"), _("Normal"), normal_p, GTK_SIGNAL_FUNC(do_normal), entry); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1215 big = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), _("Big"), _("Increase font size"), _("Big"), big_p, GTK_SIGNAL_FUNC(do_big), entry); |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
1216 font = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
1217 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1218 NULL, _("Font"), _("Select Font"), |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1219 _("Font"), font_p, GTK_SIGNAL_FUNC(toggle_font), c); |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
1220 |
66 | 1221 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); |
1222 link = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1223 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, _("Link"), _("Insert Link"), |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1224 _("Link"), link_p, GTK_SIGNAL_FUNC(do_link), entry); |
66 | 1225 palette = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
1226 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1227 NULL, _("Color"), _("Text Color"), |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1228 _("Color"), palette_p, GTK_SIGNAL_FUNC(toggle_color), c); |
66 | 1229 wood = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
1230 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1231 NULL, _("Logging"), _("Enable logging"), |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1232 _("Logging"), wood_p, GTK_SIGNAL_FUNC(toggle_loggle), c); |
66 | 1233 speaker = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
1234 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1235 NULL, _("Sound"), _("Enable sounds"), |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
1236 _("Sound"), speaker_p, GTK_SIGNAL_FUNC(set_option), &c->makesound); |
66 | 1237 c->makesound=0; |
1238 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(speaker), TRUE); | |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1239 |
66 | 1240 state_lock = 1; |
1241 if (find_log_info(c->name)) | |
1242 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), TRUE); | |
1243 else | |
1244 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), FALSE); | |
1245 state_lock = 0; | |
1246 | |
1247 gtk_widget_show(toolbar); | |
1248 | |
1249 c->bold = bold; | |
1250 c->strike = strike; | |
1251 c->italic = italic; | |
1252 c->underline = underline; | |
1253 c->log_button = wood; | |
1254 c->palette = palette; | |
1255 c->link = link; | |
308
e5fa88351dc8
[gaim-migrate @ 318]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
1256 c->font = font; |
66 | 1257 |
1258 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); | |
1259 | |
1260 gtk_widget_set_sensitive(c->bold, ((font_options & OPT_FONT_BOLD)) ? FALSE : TRUE); | |
1261 gtk_widget_set_sensitive(c->italic, ((font_options & OPT_FONT_ITALIC)) ? FALSE : TRUE); | |
1262 gtk_widget_set_sensitive(c->underline, ((font_options & OPT_FONT_UNDERLINE)) ? FALSE : TRUE); | |
1263 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1264 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1265 return toolbar; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1266 } |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1267 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1268 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1269 void show_conv(struct conversation *c) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1270 { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1271 GtkWidget *win; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1272 char buf[256]; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1273 GtkWidget *text; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1274 GtkWidget *sw; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1275 GtkWidget *send; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1276 GtkWidget *info; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1277 GtkWidget *warn; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1278 GtkWidget *block; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1279 /* GtkWidget *color; */ |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1280 GtkWidget *close; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1281 GtkWidget *entry; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1282 GtkWidget *toolbar; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1283 GtkWidget *bbox; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1284 GtkWidget *vbox; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1285 GtkWidget *vbox2; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1286 GtkWidget *paned; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1287 GtkWidget *add; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1288 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1289 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1290 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1291 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1292 gtk_widget_realize(win); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1293 aol_icon(win->window); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1294 |
66 | 1295 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1296 c->window = win; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1297 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1298 send = gtk_button_new_with_label(_("Send")); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1299 info = gtk_button_new_with_label(_("Info")); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1300 warn = gtk_button_new_with_label(_("Warn")); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1301 /* color = gtk_button_new_with_label("Color"); */ |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1302 close = gtk_button_new_with_label(_("Close")); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1303 if (find_buddy(c->name) != NULL) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1304 add = gtk_button_new_with_label(_("Remove")); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1305 } |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1306 else { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1307 add = gtk_button_new_with_label(_("Add")); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1308 } |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1309 block = gtk_button_new_with_label(_("Block")); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1310 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1311 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1312 bbox = gtk_hbox_new(TRUE, 0); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1313 vbox = gtk_vbox_new(FALSE, 0); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1314 vbox2 = gtk_vbox_new(FALSE, 0); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1315 paned = gtk_vpaned_new(); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1316 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1317 gtk_paned_pack1(GTK_PANED(paned), vbox, FALSE, TRUE); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1318 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1319 gtk_widget_show(vbox2); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1320 gtk_widget_show(paned); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1321 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1322 entry = gtk_text_new(NULL, NULL); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1323 gtk_text_set_editable(GTK_TEXT(entry), TRUE); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1324 gtk_text_set_word_wrap(GTK_TEXT(entry), TRUE); |
66 | 1325 gtk_object_set_user_data(GTK_OBJECT(entry), c); |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1326 c->entry = entry; |
66 | 1327 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1328 /* Toolbar */ |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1329 toolbar = build_conv_toolbar(c); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1330 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1331 |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1332 c->add_button = add; |
66 | 1333 |
1334 | |
1335 gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(send_callback),c); | |
1336 | |
1337 /* Text box */ | |
1338 | |
1339 | |
1340 text = gtk_html_new(NULL, NULL); | |
1341 | |
1342 gtk_html_set_editable(GTK_HTML(text), FALSE); | |
1343 /* gtk_html_set_transparent(GTK_HTML(text), (transparent) ? TRUE : FALSE);*/ | |
1344 c->text = text; | |
1345 | |
1346 sw = gtk_scrolled_window_new (NULL, NULL); | |
1347 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
1348 GTK_POLICY_NEVER, | |
1349 GTK_POLICY_ALWAYS); | |
1350 gtk_widget_show(sw); | |
1351 gtk_container_add(GTK_CONTAINER(sw), text); | |
1352 gtk_widget_show(text); | |
1353 | |
1354 | |
1355 | |
1356 | |
1357 GTK_HTML (text)->hadj->step_increment = 10.0; | |
1358 GTK_HTML (text)->vadj->step_increment = 10.0; | |
1359 gtk_widget_set_usize(sw, 320, 150); | |
1360 | |
1361 | |
1362 | |
1363 /* Ready and pack buttons */ | |
1364 gtk_object_set_user_data(GTK_OBJECT(win), c); | |
1365 gtk_object_set_user_data(GTK_OBJECT(close), c); | |
1366 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_callback), c); | |
1367 gtk_signal_connect(GTK_OBJECT(send), "clicked", GTK_SIGNAL_FUNC(send_callback), c); | |
1368 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(add_callback), c); | |
1369 gtk_signal_connect(GTK_OBJECT(info), "clicked", GTK_SIGNAL_FUNC(info_callback), c); | |
1370 gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(warn_callback), c); | |
1371 gtk_signal_connect(GTK_OBJECT(block), "clicked", GTK_SIGNAL_FUNC(block_callback), c); | |
308
e5fa88351dc8
[gaim-migrate @ 318]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
1372 /* gtk_signal_connect(GTK_OBJECT(color), "clicked", GTK_SIGNAL_FUNC(color_callback), c); */ |
66 | 1373 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1374 gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(keypress_callback), c); |
81 | 1375 gtk_widget_set_usize(entry, 300, 25); |
66 | 1376 |
1377 gtk_box_pack_start(GTK_BOX(bbox), send, TRUE, TRUE, 5); | |
1378 gtk_box_pack_start(GTK_BOX(bbox), info, TRUE, TRUE, 5); | |
1379 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 5); | |
1380 gtk_box_pack_start(GTK_BOX(bbox), block, TRUE, TRUE, 5); | |
308
e5fa88351dc8
[gaim-migrate @ 318]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
1381 /* gtk_box_pack_start(GTK_BOX(bbox), color, TRUE, TRUE, 5); */ |
66 | 1382 gtk_box_pack_start(GTK_BOX(bbox), add, TRUE, TRUE, 5); |
1383 gtk_box_pack_start(GTK_BOX(bbox), close, TRUE, TRUE, 5); | |
1384 | |
1385 /* pack and fill the rest */ | |
1386 | |
1387 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 5); | |
81 | 1388 gtk_box_pack_start(GTK_BOX(vbox2), toolbar, FALSE, FALSE, 5); |
1389 gtk_box_pack_start(GTK_BOX(vbox2), entry, TRUE, TRUE, 5); | |
1390 gtk_box_pack_start(GTK_BOX(vbox2), bbox, FALSE, FALSE, 5); | |
66 | 1391 |
1392 gtk_widget_show(send); | |
1393 gtk_widget_show(info); | |
1394 gtk_widget_show(warn); | |
1395 /* gtk_widget_show(color); */ | |
1396 gtk_widget_show(close); | |
1397 gtk_widget_show(add); | |
1398 gtk_widget_show(block); | |
1399 gtk_widget_show(bbox); | |
1400 gtk_widget_show(vbox); | |
1401 gtk_widget_show(entry); | |
1402 gtk_widget_show(text); | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
1403 |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
1404 c->font_dialog = NULL; |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
309
diff
changeset
|
1405 c->color_dialog = NULL; |
67 | 1406 |
81 | 1407 gtk_container_add(GTK_CONTAINER(win), paned); |
66 | 1408 gtk_container_border_width(GTK_CONTAINER(win), 10); |
1409 | |
1410 if ((find_log_info(c->name)) || ((general_options & OPT_GEN_LOG_ALL))) | |
1411 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name); | |
1412 else | |
1413 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, c->name); | |
1414 gtk_window_set_title(GTK_WINDOW(win), buf); | |
1415 gtk_window_set_focus(GTK_WINDOW(win),entry); | |
1416 | |
1417 gtk_signal_connect(GTK_OBJECT(win), "delete_event", GTK_SIGNAL_FUNC(delete_event_convo), c); | |
206 | 1418 gtk_signal_connect(GTK_OBJECT(entry), "insert-text", GTK_SIGNAL_FUNC(check_spelling), entry); |
66 | 1419 gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(entry_key_pressed), entry); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1420 |
315
68637b451377
[gaim-migrate @ 325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
1421 if (fontface) |
68637b451377
[gaim-migrate @ 325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
1422 strncpy(c->current_fontface, fontface, sizeof(c->current_fontface)); |
68637b451377
[gaim-migrate @ 325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
1423 if (fontname) |
68637b451377
[gaim-migrate @ 325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
1424 strncpy(c->current_fontname, fontname, sizeof(c->current_fontname)); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
1425 |
66 | 1426 gtk_widget_show(win); |
1427 } | |
1428 | |
1429 |