Mercurial > pidgin
annotate src/conversation.c @ 210:ec0686b3b03f
[gaim-migrate @ 220]
Mostly small changes trying to get -Wall not to give any messages.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 01 May 2000 19:39:00 +0000 |
parents | 6e9b375e30e7 |
children | 83dd297aa363 |
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 | |
22 #include <string.h> | |
23 #include <sys/time.h> | |
24 #include <sys/types.h> | |
25 #include <sys/stat.h> | |
26 #include <unistd.h> | |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
210
ec0686b3b03f
[gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
209
diff
changeset
|
29 #include <ctype.h> |
66 | 30 #include <gtk/gtk.h> |
31 #include "gaim.h" | |
32 #include "gtkhtml.h" | |
33 #include <gdk/gdkkeysyms.h> | |
34 #include "pixmaps/underline.xpm" | |
35 #include "pixmaps/bold.xpm" | |
36 #include "pixmaps/italic.xpm" | |
37 #include "pixmaps/small.xpm" | |
38 #include "pixmaps/normal.xpm" | |
39 #include "pixmaps/big.xpm" | |
40 #include "pixmaps/speaker.xpm" | |
210
ec0686b3b03f
[gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
209
diff
changeset
|
41 /* #include "pixmaps/aimicon2.xpm" */ |
66 | 42 #include "pixmaps/wood.xpm" |
43 #include "pixmaps/palette.xpm" | |
44 #include "pixmaps/link.xpm" | |
45 #include "pixmaps/strike.xpm" | |
46 | |
47 int state_lock=0; | |
48 | |
49 GdkPixmap *dark_icon_pm = NULL; | |
50 GdkBitmap *dark_icon_bm = NULL; | |
51 | |
52 | |
53 void check_everything(GtkWidget *entry); | |
54 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c); | |
55 | |
56 | |
57 /*------------------------------------------------------------------------*/ | |
58 /* Helpers */ | |
59 /*------------------------------------------------------------------------*/ | |
60 | |
61 | |
62 void quiet_set(GtkWidget *tb, int state) | |
63 { | |
64 state_lock=1; | |
65 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(tb), state); | |
66 state_lock=0; | |
67 } | |
68 | |
69 | |
70 void set_state_lock(int i) | |
71 { | |
72 state_lock = i; | |
73 } | |
74 | |
75 struct conversation *new_conversation(char *name) | |
76 { | |
77 struct conversation *c; | |
78 | |
79 c = find_conversation(name); | |
80 | |
81 if (c != NULL) | |
82 return c; | |
83 | |
84 c = (struct conversation *)g_new0(struct conversation, 1); | |
85 g_snprintf(c->name, sizeof(c->name), "%s", name); | |
86 | |
87 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
88 FILE *fd; | |
70 | 89 |
66 | 90 fd = open_log_file(c); |
91 if (!(general_options & OPT_GEN_STRIP_HTML)) | |
70 | 92 fprintf(fd, "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n", full_date()); |
66 | 93 else |
70 | 94 fprintf(fd, " ---- New Conversation @ %s ----\n", full_date()); |
95 | |
66 | 96 fclose(fd); |
97 } | |
98 | |
99 show_conv(c); | |
100 conversations = g_list_append(conversations, c); | |
101 return c; | |
102 } | |
103 | |
104 | |
105 struct conversation *find_conversation(char *name) | |
106 { | |
107 char *cuser = g_malloc(64); | |
108 struct conversation *c; | |
109 GList *cnv = conversations; | |
110 | |
111 strcpy(cuser, normalize(name)); | |
112 | |
113 while(cnv) { | |
114 c = (struct conversation *)cnv->data; | |
115 if(!strcasecmp(cuser, normalize(c->name))) { | |
116 g_free(cuser); | |
117 return c; | |
118 } | |
119 cnv = cnv->next; | |
120 } | |
121 g_free(cuser); | |
122 return NULL; | |
123 } | |
124 | |
125 /* --------------------------------------------------- | |
126 * Function to remove a log file entry | |
127 * --------------------------------------------------- | |
128 */ | |
129 | |
130 void rm_log(struct log_conversation *a) | |
131 { | |
132 struct conversation *cnv = find_conversation(a->name); | |
133 char buf[128]; | |
134 | |
135 log_conversations = g_list_remove(log_conversations, a); | |
136 | |
137 save_prefs(); | |
138 | |
139 if (cnv) { | |
140 if (!(general_options & OPT_GEN_LOG_ALL)) | |
141 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, cnv->name); | |
142 else | |
143 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, cnv->name); | |
144 gtk_window_set_title(GTK_WINDOW(cnv->window), buf); | |
145 } | |
146 } | |
147 | |
148 struct log_conversation *find_log_info(char *name) | |
149 { | |
150 char *pname = g_malloc(64); | |
151 GList *lc = log_conversations; | |
152 struct log_conversation *l; | |
153 | |
154 | |
155 strcpy(pname, normalize(name)); | |
156 | |
157 while(lc) { | |
158 l = (struct log_conversation *)lc->data; | |
159 if (!strcasecmp(pname, normalize(l->name))) { | |
160 g_free(pname); | |
161 return l; | |
162 } | |
163 lc = lc->next; | |
164 } | |
165 g_free(pname); | |
166 return NULL; | |
167 } | |
168 | |
169 void delete_conversation(struct conversation *cnv) | |
170 { | |
171 conversations = g_list_remove(conversations, cnv); | |
172 g_free(cnv); | |
173 } | |
174 | |
175 void update_log_convs() | |
176 { | |
177 GList *cnv = conversations; | |
178 struct conversation *c; | |
179 | |
180 while(cnv) { | |
181 c = (struct conversation *)cnv->data; | |
182 | |
183 if (c->log_button) | |
184 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); | |
185 | |
186 cnv = cnv->next; | |
187 } | |
188 } | |
189 | |
190 void update_font_buttons() | |
191 { | |
192 GList *cnv = conversations; | |
193 struct conversation *c; | |
194 | |
195 while (cnv) { | |
196 c = (struct conversation *)cnv->data; | |
197 | |
198 if (c->bold) | |
199 gtk_widget_set_sensitive(c->bold, ((font_options & OPT_FONT_BOLD)) ? FALSE : TRUE); | |
200 | |
201 if (c->italic) | |
202 gtk_widget_set_sensitive(c->italic, ((font_options & OPT_FONT_ITALIC)) ? FALSE : TRUE); | |
203 | |
204 if (c->underline) | |
205 gtk_widget_set_sensitive(c->underline, ((font_options & OPT_FONT_UNDERLINE)) ? FALSE : TRUE); | |
206 | |
207 if (c->strike) | |
208 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); | |
209 | |
210 cnv = cnv->next; | |
211 } | |
212 } | |
213 | |
214 /* | |
215 void update_transparency() | |
216 { | |
217 GList *cnv = conversations; | |
218 struct conversation *c; | |
219 | |
220 This func should be uncalled! | |
221 | |
222 while(cnv) { | |
223 c = (struct conversation *)cnv->data; | |
224 | |
225 if (c->text) | |
226 gtk_html_set_transparent(GTK_HTML(c->text), | |
227 (transparent) ? TRUE : FALSE); | |
228 | |
229 cnv = cnv->next; | |
230 } | |
231 } | |
232 */ | |
233 | |
234 | |
235 /*------------------------------------------------------------------------*/ | |
236 /* Callbacks */ | |
237 /*------------------------------------------------------------------------*/ | |
238 | |
239 void toggle_loggle(GtkWidget *w, struct conversation *p) | |
240 { | |
241 if (state_lock) | |
242 return; | |
243 | |
244 if (find_log_info(p->name)) | |
245 rm_log(find_log_info(p->name)); | |
246 else | |
247 show_log_dialog(p->name); | |
248 } | |
249 | |
250 | |
251 static int close_callback(GtkWidget *widget, struct conversation *c) | |
252 { | |
253 gtk_widget_destroy(c->window); | |
254 delete_conversation(c); | |
255 return TRUE; | |
256 } | |
257 | |
258 static gint delete_event_convo(GtkWidget *w, GdkEventAny *e, struct conversation *c) | |
259 { | |
260 delete_conversation(c); | |
261 return FALSE; | |
262 } | |
263 | |
264 | |
265 static void color_callback(GtkWidget *widget, struct conversation *c) | |
266 { | |
267 /* show_color_dialog(c); */ | |
268 gtk_widget_grab_focus(c->entry); | |
269 } | |
270 | |
271 static void add_callback(GtkWidget *widget, struct conversation *c) | |
272 { | |
273 if (find_buddy(c->name) != NULL) { | |
274 sprintf(debug_buff,"Removing '%s' from buddylist.\n", c->name); | |
275 debug_print(debug_buff); | |
276 remove_buddy(find_group_by_buddy(c->name), find_buddy(c->name)); | |
277 build_edit_tree(); | |
278 gtk_label_set_text(GTK_LABEL(GTK_BIN(c->add_button)->child), "Add"); | |
279 } | |
280 else | |
281 { | |
282 show_add_buddy(c->name, NULL); | |
283 } | |
284 | |
285 gtk_widget_grab_focus(c->entry); | |
286 } | |
287 | |
288 | |
289 static void block_callback(GtkWidget *widget, struct conversation *c) | |
290 { | |
291 show_add_perm(c->name); | |
292 gtk_widget_grab_focus(c->entry); | |
293 } | |
294 | |
295 static void warn_callback(GtkWidget *widget, struct conversation *c) | |
296 { | |
297 show_warn_dialog(c->name); | |
298 gtk_widget_grab_focus(c->entry); | |
299 } | |
300 | |
301 static void info_callback(GtkWidget *widget, struct conversation *c) | |
302 { | |
303 serv_get_info(c->name); | |
304 gtk_widget_grab_focus(c->entry); | |
305 } | |
306 | |
307 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c) | |
308 { | |
309 int pos; | |
310 if(event->keyval==GDK_Return) { | |
311 if(!(event->state & GDK_SHIFT_MASK)){ | |
312 gtk_signal_emit_by_name(GTK_OBJECT(entry), "activate", c); | |
313 //to stop the putting in of the enter character | |
314 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); | |
315 } else { | |
316 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); | |
317 pos=gtk_editable_get_position(GTK_EDITABLE(entry)); | |
318 gtk_editable_insert_text(GTK_EDITABLE(entry), "\n", 1, &pos); | |
319 } | |
320 } | |
321 | |
322 return TRUE; | |
323 | |
324 } | |
325 | |
326 | |
327 static void send_callback(GtkWidget *widget, struct conversation *c) | |
328 { | |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
329 char *buf = g_malloc(BUF_LEN * 4); |
66 | 330 char *buf2; |
331 gchar *buf4; | |
332 int hdrlen; | |
333 | |
334 buf4 = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1); | |
335 g_snprintf(buf, BUF_LONG, "%s", buf4); | |
336 g_free(buf4); | |
337 | |
338 if (!strlen(buf)) { | |
339 return; | |
340 } | |
341 | |
342 if (general_options & OPT_GEN_SEND_LINKS) { | |
343 linkify_text(buf); | |
344 } | |
345 | |
346 /* Let us determine how long the message CAN be. | |
347 * toc_send_im is 11 chars long + 2 quotes. | |
348 * + 2 spaces + 6 for the header + 2 for good | |
349 * measure = 23 bytes + the length of normalize c->name */ | |
350 | |
351 buf2 = g_malloc(BUF_LONG); | |
352 | |
353 hdrlen = 23 + strlen(normalize(c->name)); | |
354 | |
355 /* printf("%d %d %d\n", strlen(buf), hdrlen, BUF_LONG);*/ | |
356 | |
357 if (font_options & OPT_FONT_BOLD) { | |
358 g_snprintf(buf2, BUF_LONG, "<B>%s</B>", buf); | |
359 strcpy(buf, buf2); | |
360 } | |
361 | |
362 if (font_options & OPT_FONT_ITALIC) { | |
363 g_snprintf(buf2, BUF_LONG, "<I>%s</I>", buf); | |
364 strcpy(buf, buf2); | |
365 } | |
366 | |
367 if (font_options & OPT_FONT_UNDERLINE) { | |
368 g_snprintf(buf2, BUF_LONG, "<U>%s</U>", buf); | |
369 strcpy(buf, buf2); | |
370 } | |
371 | |
372 if (font_options & OPT_FONT_STRIKE) { | |
373 g_snprintf(buf2, BUF_LONG, "<STRIKE>%s</STRIKE>", buf); | |
374 strcpy(buf, buf2); | |
375 } | |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
376 |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
377 #ifdef GAIM_PLUGINS |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
378 { |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
379 GList *ca = callbacks; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
380 struct gaim_callback *g; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
381 void (*function)(char *, char **, void *); |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
382 while (ca) { |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
383 g = (struct gaim_callback *)(ca->data); |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
384 if (g->event == event_im_send && g->function != NULL) { |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
385 function = g->function; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
386 (*function)(c->name, &buf, g->data); |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
387 } |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
388 ca = ca->next; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
389 } |
102
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
390 if (buf == NULL) { |
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
391 g_free(buf2); |
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
392 return; |
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
393 } |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
394 } |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
395 #endif |
66 | 396 |
397 write_to_conv(c, buf, WFLAG_SEND); | |
398 | |
399 gtk_editable_delete_text(GTK_EDITABLE(c->entry), 0, -1); | |
400 | |
401 escape_text(buf); | |
402 if (escape_message(buf) > MSG_LEN - hdrlen) { | |
403 do_error_dialog("Message too long, some data truncated.", "Error"); | |
404 } | |
405 | |
406 serv_send_im(c->name, buf, 0); | |
407 | |
408 quiet_set(c->bold, FALSE); | |
409 quiet_set(c->strike, FALSE); | |
410 quiet_set(c->italic, FALSE); | |
411 quiet_set(c->underline, FALSE); | |
412 quiet_set(c->palette, FALSE); | |
413 quiet_set(c->link, FALSE); | |
414 | |
415 if (c->makesound && (sound_options & OPT_SOUND_SEND)) | |
416 play_sound(SEND); | |
417 | |
418 if (awaymessage != NULL) { | |
419 do_im_back(); | |
420 } | |
421 | |
422 | |
423 gtk_widget_grab_focus(c->entry); | |
424 | |
425 g_free(buf2); | |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
426 g_free(buf); |
66 | 427 } |
428 | |
429 static int | |
430 entry_key_pressed(GtkWidget *w, GtkWidget *entry) | |
431 { | |
432 check_everything(w); | |
433 return TRUE; | |
434 } | |
435 | |
436 /*------------------------------------------------------------------------*/ | |
437 /* HTML-type stuff */ | |
438 /*------------------------------------------------------------------------*/ | |
439 | |
440 int count_tag(GtkWidget *entry, char *s1, char *s2) | |
441 { | |
442 char *p1, *p2; | |
443 int res=0; | |
444 char *tmp, *tmpo, h; | |
445 tmpo = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
446 h = tmpo[GTK_EDITABLE(entry)->current_pos]; | |
447 tmpo[GTK_EDITABLE(entry)->current_pos]='\0'; | |
448 tmp=tmpo; | |
449 do { | |
450 p1 = strstr(tmp, s1); | |
451 p2 = strstr(tmp, s2); | |
452 if (p1 && p2) { | |
453 if (p1 < p2) { | |
454 res=1; | |
455 tmp = p1 +strlen(s1); | |
456 } else if (p2 < p1) { | |
457 res = 0; | |
458 tmp = p2 + strlen(s2); | |
459 } | |
460 } else { | |
461 if (p1) { | |
462 res = 1; | |
463 tmp = p1 + strlen(s1); | |
464 } else if (p2) { | |
465 res = 0; | |
466 tmp = p2 + strlen(s2); | |
467 } | |
468 } | |
469 } while (p1 || p2); | |
470 tmpo[GTK_EDITABLE(entry)->current_pos]=h; | |
471 g_free(tmpo); | |
472 return res; | |
473 } | |
474 | |
475 | |
476 int invert_tags(GtkWidget *entry, char *s1, char *s2, int really) | |
477 { | |
478 int start = GTK_EDITABLE(entry)->selection_start_pos; | |
479 int finish = GTK_EDITABLE(entry)->selection_end_pos; | |
480 char *s; | |
481 | |
482 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
483 if (!strncasecmp(&s[start], s1, strlen(s1)) && | |
484 !strncasecmp(&s[finish - strlen(s2)], s2, strlen(s2))) { | |
485 if (really) { | |
486 gtk_editable_delete_text(GTK_EDITABLE(entry), start, start + strlen(s1)); | |
487 gtk_editable_delete_text(GTK_EDITABLE(entry), finish - strlen(s2) - strlen(s1), finish - strlen(s1)); | |
488 } | |
489 g_free(s); | |
490 return 1; | |
491 } | |
492 g_free(s); | |
493 return 0; | |
494 } | |
495 | |
496 | |
497 void remove_tags(GtkWidget *entry, char *tag) | |
498 { | |
499 char *s; | |
500 char *t; | |
501 int start = GTK_EDITABLE(entry)->selection_start_pos; | |
502 int finish = GTK_EDITABLE(entry)->selection_end_pos; | |
503 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
504 t = s; | |
505 while((t = strstr(t, tag))) { | |
68 | 506 if (((t-s) < finish) && ((t-s) >= start)) { |
66 | 507 gtk_editable_delete_text(GTK_EDITABLE(entry), (t-s), (t-s) + strlen(tag)); |
182
b3b188f057f2
[gaim-migrate @ 192]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
145
diff
changeset
|
508 t = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
68 | 509 } |
66 | 510 else t++; |
511 } | |
512 g_free(s); | |
513 } | |
514 | |
515 void surround(GtkWidget *entry, char *pre, char *post) | |
516 { | |
517 int pos = GTK_EDITABLE(entry)->current_pos; | |
518 int dummy; | |
519 int start, finish; | |
520 if (GTK_EDITABLE(entry)->has_selection) { | |
521 remove_tags(entry, pre); | |
522 remove_tags(entry, post); | |
523 start = GTK_EDITABLE(entry)->selection_start_pos; | |
524 finish = GTK_EDITABLE(entry)->selection_end_pos; | |
525 if (start > finish) { | |
526 dummy = finish; | |
527 finish = start; | |
528 start = dummy; | |
529 } | |
530 dummy = start; | |
531 gtk_editable_insert_text(GTK_EDITABLE(entry), pre, strlen(pre), &dummy); | |
532 dummy = finish + strlen(pre); | |
533 gtk_editable_insert_text(GTK_EDITABLE(entry), post, strlen(post), &dummy); | |
534 gtk_editable_select_region(GTK_EDITABLE(entry), start, finish + strlen(pre) + strlen(post)); | |
535 } else { | |
536 gtk_editable_insert_text(GTK_EDITABLE(entry), pre, strlen(pre), &pos); | |
537 dummy = pos; | |
538 gtk_editable_insert_text(GTK_EDITABLE(entry), post, strlen(post), &dummy); | |
539 gtk_editable_set_position(GTK_EDITABLE(entry), pos); | |
540 } | |
541 gtk_widget_grab_focus(entry); | |
542 } | |
543 | |
544 static void advance_past(GtkWidget *entry, char *pre, char *post) | |
545 { | |
546 char *s, *s2; | |
547 int pos; | |
548 if (invert_tags(entry, pre, post, 1)) | |
549 return; | |
550 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
551 pos = GTK_EDITABLE(entry)->current_pos; | |
552 sprintf(debug_buff,"Currently at %d\n",pos); | |
553 debug_print(debug_buff); | |
554 s2= strstr(&s[pos], post); | |
555 if (s2) | |
556 pos = s2 - s + strlen(post); | |
557 else | |
187 | 558 pos=strlen(s); |
66 | 559 sprintf(debug_buff,"Setting position to %d\n",pos); |
560 debug_print(debug_buff); | |
561 gtk_editable_set_position(GTK_EDITABLE(entry), pos); | |
562 gtk_widget_grab_focus(entry); | |
563 } | |
564 | |
565 static void toggle_color(GtkWidget *color, GtkWidget *entry) | |
566 { | |
567 if (state_lock) | |
568 return; | |
569 if (GTK_TOGGLE_BUTTON(color)->active) | |
570 show_color_dialog(entry, color); | |
189
50dc3db25513
[gaim-migrate @ 199]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
187
diff
changeset
|
571 else |
50dc3db25513
[gaim-migrate @ 199]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
187
diff
changeset
|
572 advance_past(entry, "<FONT COLOR>", "</FONT>" ); |
66 | 573 } |
574 | |
575 static void do_link(GtkWidget *linky, GtkWidget *entry) | |
576 { | |
577 if (state_lock) | |
578 return; | |
579 if (GTK_TOGGLE_BUTTON(linky)->active) | |
580 show_add_link(entry, linky); | |
581 else | |
582 advance_past(entry, "<A HREF>", "</A>" ); | |
583 } | |
584 | |
585 static void do_strike(GtkWidget *strike, GtkWidget *entry) | |
586 { | |
587 if (state_lock) | |
588 return; | |
589 if (GTK_TOGGLE_BUTTON(strike)->active) | |
590 surround(entry, "<STRIKE>","</STRIKE>"); | |
591 else | |
592 advance_past(entry, "<STRIKE>", "</STRIKE>"); | |
593 } | |
594 | |
595 static void do_bold(GtkWidget *bold, GtkWidget *entry) | |
596 { | |
597 if (state_lock) | |
598 return; | |
599 if (GTK_TOGGLE_BUTTON(bold)->active) | |
600 surround(entry, "<B>","</B>"); | |
601 else | |
602 advance_past(entry, "<B>", "</B>"); | |
603 } | |
604 | |
605 static void do_underline(GtkWidget *underline, GtkWidget *entry) | |
606 { | |
607 if (state_lock) | |
608 return; | |
609 if (GTK_TOGGLE_BUTTON(underline)->active) | |
610 surround(entry, "<U>","</U>"); | |
611 else | |
612 advance_past(entry, "<U>", "</U>"); | |
613 } | |
614 | |
615 static void do_italic(GtkWidget *italic, GtkWidget *entry) | |
616 { | |
617 if (state_lock) | |
618 return; | |
619 if (GTK_TOGGLE_BUTTON(italic)->active) | |
620 surround(entry, "<I>","</I>"); | |
621 else | |
622 advance_past(entry, "<I>", "</I>"); | |
623 } | |
624 | |
625 static void do_small(GtkWidget *small, GtkWidget *entry) | |
626 { | |
627 if (state_lock) | |
628 return; | |
88 | 629 surround(entry, "<FONT SIZE=\"-2\">","</FONT>"); |
66 | 630 } |
631 | |
632 static void do_normal(GtkWidget *normal, GtkWidget *entry) | |
633 { | |
634 if (state_lock) | |
635 return; | |
88 | 636 surround(entry, "<FONT SIZE=\"3\">","</FONT>"); |
66 | 637 } |
638 | |
639 static void do_big(GtkWidget *big, GtkWidget *entry) | |
640 { | |
641 if (state_lock) | |
642 return; | |
643 surround(entry, "<FONT SIZE=\"+5\">","</FONT>"); | |
644 } | |
645 | |
646 void check_everything(GtkWidget *entry) | |
647 { | |
648 struct conversation *c; | |
206 | 649 |
66 | 650 c = (struct conversation *)gtk_object_get_user_data(GTK_OBJECT(entry)); |
651 if (!c) return; | |
652 if (invert_tags(entry, "<B>", "</B>", 0)) | |
653 quiet_set(c->bold, TRUE); | |
654 else if (count_tag(entry, "<B>", "</B>")) | |
655 quiet_set(c->bold, TRUE); | |
656 else | |
657 quiet_set(c->bold,FALSE); | |
658 if (invert_tags(entry, "<I>", "</I>", 0)) | |
659 quiet_set(c->italic, TRUE); | |
660 else if (count_tag(entry, "<I>", "</I>")) | |
661 quiet_set(c->italic, TRUE); | |
662 else | |
663 quiet_set(c->italic, FALSE); | |
664 | |
665 if (invert_tags(entry, "<FONT COLOR", "</FONT>", 0)) | |
666 quiet_set(c->palette, TRUE); | |
667 else if (count_tag(entry, "<FONT COLOR", "</FONT>")) | |
668 quiet_set(c->palette, TRUE); | |
669 else | |
670 quiet_set(c->palette, FALSE); | |
671 | |
672 if (invert_tags(entry, "<A HREF", "</A>", 0)) | |
673 quiet_set(c->link, TRUE); | |
674 else if (count_tag(entry, "<A HREF", "</A>")) | |
675 quiet_set(c->link, TRUE); | |
676 else | |
677 quiet_set(c->link, FALSE); | |
678 | |
679 if (invert_tags(entry, "<U>", "</U>", 0)) | |
680 quiet_set(c->underline, TRUE); | |
681 else if (count_tag(entry, "<U>", "</U>")) | |
682 quiet_set(c->underline, TRUE); | |
683 else | |
684 quiet_set(c->underline, FALSE); | |
685 | |
686 if (invert_tags(entry, "<STRIKE>", "</STRIKE>", 0)) | |
687 quiet_set(c->strike, TRUE); | |
688 else if (count_tag(entry, "<STRIKE>", "</STRIKE>")) | |
689 quiet_set(c->strike, TRUE); | |
690 else | |
691 quiet_set(c->strike, FALSE); | |
692 } | |
693 | |
694 | |
695 /*------------------------------------------------------------------------*/ | |
696 /* Takin care of the window.. */ | |
697 /*------------------------------------------------------------------------*/ | |
698 | |
699 | |
700 void write_to_conv(struct conversation *c, char *what, int flags) | |
701 { | |
702 char *buf = g_malloc(BUF_LONG); | |
703 char *buf2 = g_malloc(BUF_LONG); | |
704 char *who = NULL; | |
705 FILE *fd; | |
706 char colour[10]; | |
707 | |
708 if (flags & WFLAG_SYSTEM) { | |
709 | |
710 gtk_html_freeze(GTK_HTML(c->text)); | |
711 | |
712 gtk_html_append_text(GTK_HTML(c->text), what, 0); | |
713 | |
714 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0); | |
715 | |
716 gtk_html_thaw(GTK_HTML(c->text)); | |
717 | |
718 | |
719 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
720 char *t1; | |
721 | |
722 if (general_options & OPT_GEN_STRIP_HTML) { | |
723 t1 = strip_html(what); | |
724 } else { | |
725 t1 = what; | |
726 } | |
727 fd = open_log_file(c); | |
728 fprintf(fd, "%s\n", t1); | |
729 fclose(fd); | |
730 if (general_options & OPT_GEN_STRIP_HTML) { | |
731 g_free(t1); | |
732 } | |
733 } | |
734 | |
735 } else { | |
736 | |
737 if (flags & WFLAG_RECV) { | |
738 strcpy(colour, "#ff0000"); | |
145
41bd1cd48571
[gaim-migrate @ 155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
128
diff
changeset
|
739 who = c->name; |
66 | 740 } else if (flags & WFLAG_SEND) { |
741 strcpy(colour, "#0000ff"); | |
742 who = current_user->username; | |
743 } | |
744 | |
145
41bd1cd48571
[gaim-migrate @ 155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
128
diff
changeset
|
745 if (flags & WFLAG_AUTO) |
66 | 746 sprintf(buf2, " %s", AUTO_RESPONSE); |
747 else | |
748 buf2[0]=0; /* sprintf(buf2, ""); */ | |
749 | |
750 if (display_options & OPT_DISP_SHOW_TIME) | |
751 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s %s:%s</B></FONT> ", colour, date(), who, buf2); | |
752 else | |
753 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s:%s</B></FONT> ", colour, who, buf2); | |
754 | |
755 gtk_html_freeze(GTK_HTML(c->text)); | |
756 | |
757 gtk_html_append_text(GTK_HTML(c->text), buf, 0); | |
758 gtk_html_append_text(GTK_HTML(c->text), what, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); | |
759 | |
760 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0); | |
761 | |
762 | |
763 gtk_html_thaw(GTK_HTML(c->text)); | |
764 | |
765 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
766 char *t1, *t2; | |
767 | |
768 if (general_options & OPT_GEN_STRIP_HTML) { | |
769 t1 = strip_html(buf); | |
770 t2 = strip_html(what); | |
771 } else { | |
772 t1 = buf; | |
773 t2 = what; | |
774 } | |
775 fd = open_log_file(c); | |
776 fprintf(fd, "%s%s\n", t1, t2); | |
777 fclose(fd); | |
778 if (general_options & OPT_GEN_STRIP_HTML) { | |
779 g_free(t1); | |
780 g_free(t2); | |
781 } | |
782 } | |
783 } | |
784 | |
785 /* if (!GTK_WIDGET_MAPPED(c->window)) { | |
786 | |
787 if (dark_icon_pm == NULL) | |
788 dark_icon_pm = gdk_pixmap_create_from_xpm_d(c->window->window, &dark_icon_bm, | |
789 NULL, (gchar **)aimicon2_xpm); | |
790 gdk_window_set_icon(c->window->window, NULL, dark_icon_pm, dark_icon_bm); | |
791 } | |
792 */ | |
793 | |
794 if (general_options & OPT_GEN_POPUP_WINDOWS) | |
81 | 795 gdk_window_show(c->window->window); |
66 | 796 |
797 | |
798 g_free(buf); | |
799 g_free(buf2); | |
800 } | |
801 | |
802 | |
803 | |
206 | 804 static void check_spelling( GtkEditable * editable, gchar * new_text, |
805 gint length, gint * position, | |
806 gpointer data ) | |
807 { | |
207 | 808 if (general_options & OPT_GEN_CHECK_SPELLING) |
809 { | |
810 gtk_signal_handler_block_by_func(GTK_OBJECT(editable), | |
811 GTK_SIGNAL_FUNC(check_spelling), data); | |
812 gtk_text_set_point(GTK_TEXT(editable), *position); | |
813 gtk_text_insert(GTK_TEXT(editable), NULL, &(GTK_WIDGET(editable)->style->fg[0]), NULL, new_text, length ); | |
814 if(isspace(new_text[0])) | |
815 { | |
816 gtk_text_freeze(GTK_TEXT(editable)); | |
209 | 817 spell_checker(GTK_WIDGET(editable)); |
207 | 818 gtk_text_thaw(GTK_TEXT(editable)); |
819 } | |
820 gtk_signal_handler_unblock_by_func(GTK_OBJECT(editable), | |
821 GTK_SIGNAL_FUNC(check_spelling), data); | |
822 gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert-text"); | |
823 } | |
206 | 824 } |
66 | 825 |
826 | |
827 void show_conv(struct conversation *c) | |
828 { | |
829 GtkWidget *win; | |
830 char buf[256]; | |
831 GtkWidget *text; | |
832 GtkWidget *sw; | |
833 GtkWidget *send; | |
834 GtkWidget *info; | |
835 GtkWidget *warn; | |
836 GtkWidget *block; | |
837 GtkWidget *color; | |
838 GtkWidget *close; | |
839 GtkWidget *entry; | |
840 GtkWidget *toolbar; | |
841 GtkWidget *bbox; | |
842 GtkWidget *vbox; | |
81 | 843 GtkWidget *vbox2; |
844 GtkWidget *paned; | |
66 | 845 GtkWidget *add; |
846 GdkPixmap *strike_i, *small_i, *normal_i, *big_i, *bold_i, *italic_i, *underline_i, *speaker_i, *wood_i, *palette_i, *link_i; | |
847 GtkWidget *strike_p, *small_p, *normal_p, *big_p, *bold_p, *italic_p, *underline_p, *speaker_p, *wood_p, *palette_p, *link_p; | |
848 GtkWidget *strike, *small, *normal, *big, *bold, *italic, *underline, *speaker, *wood, *palette, *link; | |
849 GdkBitmap *mask; | |
850 | |
851 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
852 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); | |
853 | |
854 gtk_widget_realize(win); | |
855 aol_icon(win->window); | |
856 | |
857 | |
858 c->window = win; | |
859 | |
860 send = gtk_button_new_with_label("Send"); | |
861 info = gtk_button_new_with_label("Info"); | |
862 warn = gtk_button_new_with_label("Warn"); | |
863 color = gtk_button_new_with_label("Color"); | |
864 close = gtk_button_new_with_label("Close"); | |
865 if (find_buddy(c->name) != NULL) { | |
866 add = gtk_button_new_with_label("Remove"); | |
867 } | |
868 else { | |
869 add = gtk_button_new_with_label("Add"); | |
870 } | |
871 block = gtk_button_new_with_label("Block"); | |
872 | |
873 | |
874 bbox = gtk_hbox_new(TRUE, 0); | |
875 vbox = gtk_vbox_new(FALSE, 0); | |
81 | 876 vbox2 = gtk_vbox_new(FALSE, 0); |
877 paned = gtk_vpaned_new(); | |
66 | 878 |
81 | 879 gtk_paned_pack1(GTK_PANED(paned), vbox, FALSE, TRUE); |
880 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); | |
881 gtk_widget_show(vbox2); | |
882 gtk_widget_show(paned); | |
883 | |
66 | 884 entry = gtk_text_new(NULL, NULL); |
885 gtk_text_set_editable(GTK_TEXT(entry), TRUE); | |
886 gtk_text_set_word_wrap(GTK_TEXT(entry), TRUE); | |
887 | |
888 /* Toolbar */ | |
889 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); | |
890 | |
891 link_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, | |
892 &win->style->white, link_xpm ); | |
893 link_p = gtk_pixmap_new(link_i, mask); | |
894 gtk_widget_show(link_p); | |
895 | |
896 palette_i = gdk_pixmap_create_from_xpm_d (win->window, &mask, | |
897 &win->style->white, palette_xpm ); | |
898 palette_p = gtk_pixmap_new(palette_i, mask); | |
899 gtk_widget_show(palette_p); | |
900 | |
901 wood_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
902 &win->style->white, wood_xpm ); | |
903 wood_p = gtk_pixmap_new(wood_i, mask); | |
904 gtk_widget_show(wood_p); | |
905 speaker_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
906 &win->style->white, speaker_xpm ); | |
907 speaker_p = gtk_pixmap_new(speaker_i, mask); | |
908 gtk_widget_show(speaker_p); | |
909 c->makesound=1; | |
910 strike_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
911 &win->style->white, strike_xpm ); | |
912 strike_p = gtk_pixmap_new(strike_i, mask); | |
913 gtk_widget_show(strike_p); | |
914 bold_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
915 &win->style->white, bold_xpm ); | |
916 bold_p = gtk_pixmap_new(bold_i, mask); | |
917 gtk_widget_show(bold_p); | |
918 italic_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
919 &win->style->white, italic_xpm ); | |
920 italic_p = gtk_pixmap_new(italic_i, mask); | |
921 gtk_widget_show(italic_p); | |
922 underline_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
923 &win->style->white, underline_xpm ); | |
924 underline_p = gtk_pixmap_new(underline_i, mask); | |
925 gtk_widget_show(underline_p); | |
926 small_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
927 &win->style->white, small_xpm ); | |
928 small_p = gtk_pixmap_new(small_i, mask); | |
929 gtk_widget_show(small_p); | |
930 normal_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
931 &win->style->white, normal_xpm ); | |
932 normal_p = gtk_pixmap_new(normal_i, mask); | |
933 gtk_widget_show(normal_p); | |
934 big_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
935 &win->style->white, big_xpm ); | |
936 big_p = gtk_pixmap_new(big_i, mask); | |
937 gtk_widget_show(big_p); | |
938 | |
939 | |
940 bold = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
941 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, | |
942 "Bold", "Bold Text", "Bold", bold_p, | |
943 GTK_SIGNAL_FUNC(do_bold), entry); | |
944 italic = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
945 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
946 NULL, "Italics", "Italics Text", | |
947 "Italics", italic_p, GTK_SIGNAL_FUNC(do_italic), entry); | |
948 underline = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
949 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
950 NULL, "Underline", "Underline Text", | |
951 "Underline", underline_p, GTK_SIGNAL_FUNC(do_underline), entry); | |
952 strike = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
953 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
954 NULL, "Strike", "Strike through Text", | |
955 "Strike", strike_p, GTK_SIGNAL_FUNC(do_strike), entry); | |
956 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); | |
957 small = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Small", "Decrease font size", "Small", small_p, GTK_SIGNAL_FUNC(do_small), entry); | |
958 normal = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Normal", "Normal font size", "Normal", normal_p, GTK_SIGNAL_FUNC(do_normal), entry); | |
959 big = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Big", "Increase font size", "Big", big_p, GTK_SIGNAL_FUNC(do_big), entry); | |
960 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); | |
961 link = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
962 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, "Link", "Insert Link", | |
963 "Link", link_p, GTK_SIGNAL_FUNC(do_link), entry); | |
964 palette = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
965 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
966 NULL, "Color", "Text Color", | |
967 "Color", palette_p, GTK_SIGNAL_FUNC(toggle_color), entry); | |
968 wood = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
969 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
970 NULL, "Logging", "Enable logging", | |
971 "Logging", wood_p, GTK_SIGNAL_FUNC(toggle_loggle), c); | |
972 speaker = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
973 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
974 NULL, "Sound", "Enable sounds", | |
975 "Sound", speaker_p, GTK_SIGNAL_FUNC(set_option), &c->makesound); | |
976 c->makesound=0; | |
977 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(speaker), TRUE); | |
978 | |
979 state_lock = 1; | |
980 if (find_log_info(c->name)) | |
981 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), TRUE); | |
982 else | |
983 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), FALSE); | |
984 state_lock = 0; | |
985 | |
986 gtk_widget_show(toolbar); | |
987 | |
988 c->entry = entry; | |
989 c->bold = bold; | |
990 c->strike = strike; | |
991 c->italic = italic; | |
992 c->underline = underline; | |
993 c->log_button = wood; | |
994 c->palette = palette; | |
995 c->link = link; | |
996 c->add_button = add; | |
997 | |
998 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); | |
999 | |
1000 gtk_widget_set_sensitive(c->bold, ((font_options & OPT_FONT_BOLD)) ? FALSE : TRUE); | |
1001 gtk_widget_set_sensitive(c->italic, ((font_options & OPT_FONT_ITALIC)) ? FALSE : TRUE); | |
1002 gtk_widget_set_sensitive(c->underline, ((font_options & OPT_FONT_UNDERLINE)) ? FALSE : TRUE); | |
1003 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); | |
1004 | |
1005 gtk_object_set_user_data(GTK_OBJECT(entry), c); | |
1006 | |
1007 | |
1008 | |
1009 gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(send_callback),c); | |
1010 | |
1011 /* Text box */ | |
1012 | |
1013 | |
1014 text = gtk_html_new(NULL, NULL); | |
1015 | |
1016 gtk_html_set_editable(GTK_HTML(text), FALSE); | |
1017 /* gtk_html_set_transparent(GTK_HTML(text), (transparent) ? TRUE : FALSE);*/ | |
1018 c->text = text; | |
1019 | |
1020 sw = gtk_scrolled_window_new (NULL, NULL); | |
1021 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
1022 GTK_POLICY_NEVER, | |
1023 GTK_POLICY_ALWAYS); | |
1024 gtk_widget_show(sw); | |
1025 gtk_container_add(GTK_CONTAINER(sw), text); | |
1026 gtk_widget_show(text); | |
1027 | |
1028 | |
1029 | |
1030 | |
1031 GTK_HTML (text)->hadj->step_increment = 10.0; | |
1032 GTK_HTML (text)->vadj->step_increment = 10.0; | |
1033 gtk_widget_set_usize(sw, 320, 150); | |
1034 | |
1035 | |
1036 | |
1037 /* Ready and pack buttons */ | |
1038 gtk_object_set_user_data(GTK_OBJECT(win), c); | |
1039 gtk_object_set_user_data(GTK_OBJECT(close), c); | |
1040 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_callback), c); | |
1041 gtk_signal_connect(GTK_OBJECT(send), "clicked", GTK_SIGNAL_FUNC(send_callback), c); | |
1042 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(add_callback), c); | |
1043 gtk_signal_connect(GTK_OBJECT(info), "clicked", GTK_SIGNAL_FUNC(info_callback), c); | |
1044 gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(warn_callback), c); | |
1045 gtk_signal_connect(GTK_OBJECT(block), "clicked", GTK_SIGNAL_FUNC(block_callback), c); | |
1046 gtk_signal_connect(GTK_OBJECT(color), "clicked", GTK_SIGNAL_FUNC(color_callback), c); | |
1047 | |
1048 gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(user_keypress_callback), c); | |
81 | 1049 gtk_widget_set_usize(entry, 300, 25); |
66 | 1050 |
1051 gtk_box_pack_start(GTK_BOX(bbox), send, TRUE, TRUE, 5); | |
1052 gtk_box_pack_start(GTK_BOX(bbox), info, TRUE, TRUE, 5); | |
1053 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 5); | |
1054 gtk_box_pack_start(GTK_BOX(bbox), block, TRUE, TRUE, 5); | |
1055 gtk_box_pack_start(GTK_BOX(bbox), color, TRUE, TRUE, 5); | |
1056 gtk_box_pack_start(GTK_BOX(bbox), add, TRUE, TRUE, 5); | |
1057 gtk_box_pack_start(GTK_BOX(bbox), close, TRUE, TRUE, 5); | |
1058 | |
1059 /* pack and fill the rest */ | |
1060 | |
1061 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 5); | |
81 | 1062 gtk_box_pack_start(GTK_BOX(vbox2), toolbar, FALSE, FALSE, 5); |
1063 gtk_box_pack_start(GTK_BOX(vbox2), entry, TRUE, TRUE, 5); | |
1064 gtk_box_pack_start(GTK_BOX(vbox2), bbox, FALSE, FALSE, 5); | |
66 | 1065 |
1066 | |
1067 | |
1068 | |
1069 gtk_widget_show(send); | |
1070 gtk_widget_show(info); | |
1071 gtk_widget_show(warn); | |
1072 /* gtk_widget_show(color); */ | |
1073 gtk_widget_show(close); | |
1074 gtk_widget_show(add); | |
1075 gtk_widget_show(block); | |
1076 gtk_widget_show(bbox); | |
1077 gtk_widget_show(vbox); | |
1078 gtk_widget_show(entry); | |
1079 gtk_widget_show(text); | |
1080 | |
67 | 1081 |
81 | 1082 gtk_container_add(GTK_CONTAINER(win), paned); |
66 | 1083 gtk_container_border_width(GTK_CONTAINER(win), 10); |
1084 | |
1085 if ((find_log_info(c->name)) || ((general_options & OPT_GEN_LOG_ALL))) | |
1086 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name); | |
1087 else | |
1088 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, c->name); | |
1089 gtk_window_set_title(GTK_WINDOW(win), buf); | |
1090 gtk_window_set_focus(GTK_WINDOW(win),entry); | |
1091 | |
1092 gtk_signal_connect(GTK_OBJECT(win), "delete_event", GTK_SIGNAL_FUNC(delete_event_convo), c); | |
206 | 1093 gtk_signal_connect(GTK_OBJECT(entry), "insert-text", GTK_SIGNAL_FUNC(check_spelling), entry); |
66 | 1094 gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(entry_key_pressed), entry); |
1095 | |
1096 gtk_widget_show(win); | |
1097 | |
1098 } | |
1099 | |
1100 |