Mercurial > pidgin
annotate src/buddy_chat.c @ 206:610b7ffc4821
[gaim-migrate @ 216]
Yeah, I ripped off torrey's spell checking code and made it work with GAIM :)
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Mon, 01 May 2000 10:12:08 +0000 |
parents | be5fbefdb195 |
children | ac05dfb9e762 |
rev | line source |
---|---|
1 | 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 <unistd.h> | |
25 #include <stdio.h> | |
26 #include <stdlib.h> | |
27 #include <gtk/gtk.h> | |
28 #include "gaim.h" | |
29 #include "gtkhtml.h" | |
30 | |
31 static GtkWidget *joinchat; | |
32 static GtkWidget *entry; | |
33 static GtkWidget *invite; | |
34 static GtkWidget *inviteentry; | |
35 static GtkWidget *invitemess; | |
36 | |
37 static void destroy_join_chat() | |
38 { | |
39 if (joinchat) | |
40 gtk_widget_destroy(joinchat); | |
41 joinchat=NULL; | |
42 } | |
43 | |
44 static void destroy_invite() | |
45 { | |
46 if (invite) | |
47 gtk_widget_destroy(invite); | |
48 invite=NULL; | |
49 } | |
50 | |
51 | |
52 | |
53 | |
54 static void do_join_chat() | |
55 { | |
56 char *group; | |
57 | |
58 group = gtk_entry_get_text(GTK_ENTRY(entry)); | |
59 | |
60 if (joinchat) { | |
61 serv_join_chat(4, group); | |
62 gtk_widget_destroy(joinchat); | |
63 } | |
64 joinchat=NULL; | |
65 } | |
66 | |
67 | |
68 | |
69 void join_chat() | |
70 { | |
71 GtkWidget *cancel; | |
72 GtkWidget *join; | |
73 GtkWidget *label; | |
74 GtkWidget *bbox; | |
75 GtkWidget *vbox; | |
76 GtkWidget *topbox; | |
77 if (!joinchat) { | |
78 joinchat = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
79 cancel = gtk_button_new_with_label("Cancel"); | |
80 join = gtk_button_new_with_label("Join"); | |
81 bbox = gtk_hbox_new(TRUE, 10); | |
82 topbox = gtk_hbox_new(FALSE, 5); | |
83 vbox = gtk_vbox_new(FALSE, 5); | |
84 entry = gtk_entry_new(); | |
85 | |
86 /* Put the buttons in the box */ | |
87 gtk_box_pack_start(GTK_BOX(bbox), join, TRUE, TRUE, 10); | |
88 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
89 | |
90 label = gtk_label_new("Join what group:"); | |
91 gtk_widget_show(label); | |
92 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
93 gtk_box_pack_start(GTK_BOX(topbox), entry, FALSE, FALSE, 5); | |
94 | |
95 /* And the boxes in the box */ | |
96 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
97 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
98 | |
99 /* Handle closes right */ | |
100 gtk_signal_connect(GTK_OBJECT(joinchat), "delete_event", | |
101 GTK_SIGNAL_FUNC(destroy_join_chat), joinchat); | |
102 | |
103 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
104 GTK_SIGNAL_FUNC(destroy_join_chat), joinchat); | |
105 gtk_signal_connect(GTK_OBJECT(join), "clicked", | |
106 GTK_SIGNAL_FUNC(do_join_chat), joinchat); | |
107 gtk_signal_connect(GTK_OBJECT(entry), "activate", | |
108 GTK_SIGNAL_FUNC(do_join_chat), joinchat); | |
109 /* Finish up */ | |
110 gtk_widget_show(join); | |
111 gtk_widget_show(cancel); | |
112 gtk_widget_show(entry); | |
113 gtk_widget_show(topbox); | |
114 gtk_widget_show(bbox); | |
115 gtk_widget_show(vbox); | |
116 gtk_window_set_title(GTK_WINDOW(joinchat), "Join Chat"); | |
117 gtk_window_set_focus(GTK_WINDOW(joinchat), entry); | |
118 gtk_container_add(GTK_CONTAINER(joinchat), vbox); | |
119 gtk_widget_realize(joinchat); | |
120 aol_icon(joinchat->window); | |
121 | |
122 } | |
123 gtk_widget_show(joinchat); | |
124 } | |
125 | |
126 | |
127 static void do_invite(GtkWidget *w, struct buddy_chat *b) | |
128 { | |
129 char *buddy; | |
130 char *mess; | |
131 | |
132 buddy = gtk_entry_get_text(GTK_ENTRY(inviteentry)); | |
133 mess = gtk_entry_get_text(GTK_ENTRY(invitemess)); | |
134 | |
135 if (invite) { | |
136 serv_chat_invite(b->id, mess, buddy); | |
137 gtk_widget_destroy(invite); | |
138 } | |
139 invite=NULL; | |
140 } | |
141 | |
142 | |
143 | |
144 static void invite_callback(GtkWidget *w, struct buddy_chat *b) | |
145 { | |
146 GtkWidget *cancel; | |
147 GtkWidget *invite_btn; | |
148 GtkWidget *label; | |
149 GtkWidget *bbox; | |
150 GtkWidget *vbox; | |
151 GtkWidget *topbox; | |
152 if (!invite) { | |
153 invite = gtk_window_new(GTK_WINDOW_DIALOG); | |
154 cancel = gtk_button_new_with_label("Cancel"); | |
155 invite_btn = gtk_button_new_with_label("Invite"); | |
156 bbox = gtk_hbox_new(TRUE, 10); | |
157 topbox = gtk_hbox_new(FALSE, 5); | |
158 vbox = gtk_vbox_new(FALSE, 5); | |
159 inviteentry = gtk_entry_new(); | |
160 invitemess = gtk_entry_new(); | |
161 | |
162 /* Put the buttons in the box */ | |
163 gtk_box_pack_start(GTK_BOX(bbox), invite_btn, TRUE, TRUE, 10); | |
164 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
165 | |
166 label = gtk_label_new("Invite who?"); | |
167 gtk_widget_show(label); | |
168 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
169 gtk_box_pack_start(GTK_BOX(topbox), inviteentry, FALSE, FALSE, 5); | |
170 label = gtk_label_new("With message:"); | |
171 gtk_widget_show(label); | |
172 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
173 gtk_box_pack_start(GTK_BOX(topbox), invitemess, FALSE, FALSE, 5); | |
174 | |
175 /* And the boxes in the box */ | |
176 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
177 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
178 | |
179 /* Handle closes right */ | |
180 gtk_signal_connect(GTK_OBJECT(invite), "delete_event", | |
181 GTK_SIGNAL_FUNC(destroy_invite), invite); | |
182 | |
183 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
184 GTK_SIGNAL_FUNC(destroy_invite), b); | |
185 gtk_signal_connect(GTK_OBJECT(invite_btn), "clicked", | |
186 GTK_SIGNAL_FUNC(do_invite), b); | |
187 gtk_signal_connect(GTK_OBJECT(inviteentry), "activate", | |
188 GTK_SIGNAL_FUNC(do_invite), b); | |
189 /* Finish up */ | |
190 gtk_widget_show(invite_btn); | |
191 gtk_widget_show(cancel); | |
192 gtk_widget_show(inviteentry); | |
193 gtk_widget_show(invitemess); | |
194 gtk_widget_show(topbox); | |
195 gtk_widget_show(bbox); | |
196 gtk_widget_show(vbox); | |
197 gtk_window_set_title(GTK_WINDOW(invite), "Invite to Buddy Chat"); | |
198 gtk_window_set_focus(GTK_WINDOW(invite), inviteentry); | |
199 gtk_container_add(GTK_CONTAINER(invite), vbox); | |
200 gtk_widget_realize(invite); | |
201 aol_icon(invite->window); | |
202 | |
203 } | |
204 gtk_widget_show(invite); | |
205 } | |
206 | |
207 void chat_write(struct buddy_chat *b, char *who, int flag, char *message) | |
208 { | |
209 char *buf; | |
210 GList *ignore = b->ignored; | |
211 char *str; | |
212 char colour[10]; | |
213 | |
214 | |
215 while(ignore) { | |
216 if (!strcasecmp(who, ignore->data)) | |
217 return; | |
218 ignore = ignore->next; | |
219 } | |
220 | |
221 buf = g_malloc(BUF_LONG); | |
222 | |
223 if (flag & WFLAG_WHISPER) { | |
224 str = g_malloc(64); | |
225 g_snprintf(str, 62, "*%s*", who); | |
226 strcpy(colour, "#00ff00\0"); | |
227 } else { | |
228 str = g_strdup(normalize(who)); | |
229 if (!strcasecmp(str, normalize(current_user->username))) | |
230 strcpy(colour, "#0000ff\0"); | |
231 else | |
232 strcpy(colour, "#ff0000\0"); | |
233 g_free(str); | |
234 str = who; | |
235 } | |
236 | |
237 | |
238 | |
239 if (display_options & OPT_DISP_SHOW_TIME) | |
240 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s %s: </B></FONT>", colour, date(), str); | |
241 else | |
242 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s: </B></FONT>", colour, str); | |
243 | |
244 gtk_html_freeze(GTK_HTML(b->text)); | |
245 | |
246 gtk_html_append_text(GTK_HTML(b->text), buf, 0); | |
247 gtk_html_append_text(GTK_HTML(b->text), message, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); | |
248 gtk_html_append_text(GTK_HTML(b->text), "<BR>", 0); | |
249 | |
250 gtk_html_thaw(GTK_HTML(b->text)); | |
251 | |
252 if (flag & WFLAG_WHISPER) | |
253 g_free(str); | |
254 | |
255 g_free(buf); | |
256 } | |
257 | |
258 static void close_callback(GtkWidget *widget, struct buddy_chat *b) | |
259 { | |
260 serv_chat_leave(b->id); | |
261 | |
262 if (b->window) | |
263 gtk_widget_destroy(b->window); | |
264 b->window = NULL; | |
265 } | |
266 | |
267 | |
268 static void whisper_callback(GtkWidget *widget, struct buddy_chat *b) | |
269 { | |
79 | 270 char buf[BUF_LEN*4]; |
1 | 271 char buf2[BUF_LONG]; |
272 GList *selected; | |
273 char *who; | |
274 | |
275 strncpy(buf, gtk_entry_get_text(GTK_ENTRY(b->entry)), sizeof(buf)/2); | |
276 if (!strlen(buf)) | |
277 return; | |
278 | |
279 selected = GTK_LIST(b->list)->selection; | |
280 | |
281 if (!selected) | |
282 return; | |
283 | |
284 | |
285 who = GTK_LABEL(gtk_container_children(GTK_CONTAINER(selected->data))->data)->label; | |
286 | |
287 if (!who) | |
288 return; | |
289 | |
290 gtk_entry_set_text(GTK_ENTRY(b->entry), ""); | |
291 | |
292 escape_text(buf); | |
293 serv_chat_whisper(b->id, who, buf); | |
294 | |
295 g_snprintf(buf2, sizeof(buf2), "%s->%s", current_user->username, who); | |
296 | |
297 chat_write(b, buf2, WFLAG_WHISPER, buf); | |
298 | |
299 gtk_widget_grab_focus(GTK_WIDGET(b->entry)); | |
300 | |
301 | |
302 } | |
303 | |
304 | |
305 static void send_callback(GtkWidget *widget, struct buddy_chat *b) | |
306 { | |
79 | 307 char buf[BUF_LEN*4]; |
1 | 308 |
309 strncpy(buf, gtk_entry_get_text(GTK_ENTRY(b->entry)), sizeof(buf)/2); | |
310 if (!strlen(buf)) | |
311 return; | |
312 | |
313 gtk_entry_set_text(GTK_ENTRY(b->entry), ""); | |
314 | |
315 if (general_options & OPT_GEN_SEND_LINKS) { | |
316 linkify_text(buf); | |
317 } | |
318 | |
319 escape_text(buf); | |
320 serv_chat_send(b->id, buf); | |
321 | |
322 gtk_widget_grab_focus(GTK_WIDGET(b->entry)); | |
323 | |
199
be5fbefdb195
[gaim-migrate @ 209]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
324 serv_set_idle(0); |
1 | 325 } |
326 | |
327 | |
328 void update_chat_list(struct buddy_chat *b) | |
329 { | |
330 GtkWidget *list_item; | |
331 char name[80]; | |
332 char *tmp; | |
333 GList *names = b->in_room; | |
334 | |
335 | |
336 gtk_list_clear_items(GTK_LIST(b->list), 0, -1); | |
337 | |
338 | |
339 while(names) { | |
340 tmp = (char *)names->data; | |
341 if (g_list_index(b->ignored, names->data) != -1) | |
342 g_snprintf(name, sizeof(name), "X %s", tmp); | |
343 else | |
344 g_snprintf(name, sizeof(name), "%s", tmp); | |
345 | |
346 list_item = gtk_list_item_new_with_label(name); | |
347 gtk_widget_show(list_item); | |
348 gtk_object_set_user_data(GTK_OBJECT(list_item), tmp); | |
349 | |
350 gtk_list_append_items(GTK_LIST(b->list), g_list_append(NULL, list_item)); | |
351 | |
352 names = names->next; | |
353 } | |
354 | |
355 } | |
356 | |
357 | |
358 | |
359 void add_chat_buddy(struct buddy_chat *b, char *buddy) | |
360 { | |
361 char *name = g_strdup(buddy); | |
362 | |
363 b->in_room = g_list_append(b->in_room, name); | |
364 | |
365 update_chat_list(b); | |
366 | |
367 } | |
368 | |
369 | |
370 | |
371 | |
372 void remove_chat_buddy(struct buddy_chat *b, char *buddy) | |
373 { | |
374 GList *names = b->in_room; | |
375 | |
376 while(names) { | |
377 if (!strcasecmp((char *)names->data, buddy)) { | |
378 b->in_room = g_list_remove(b->in_room, names->data); | |
379 update_chat_list(b); | |
380 break; | |
381 } | |
382 names = names->next; | |
383 } | |
384 } | |
385 | |
386 | |
387 static void im_callback(GtkWidget *w, struct buddy_chat *b) | |
388 { | |
389 char *name; | |
390 GList *i; | |
391 struct conversation *c; | |
392 | |
393 i = GTK_LIST(b->list)->selection; | |
394 if (i) | |
395 name = (char *)gtk_object_get_user_data(GTK_OBJECT(i->data)); | |
396 else | |
397 return; | |
398 | |
399 c = find_conversation(name); | |
400 | |
401 if (c != NULL) { | |
402 gdk_window_raise(c->window->window); | |
403 } else { | |
404 c = new_conversation(name); | |
405 } | |
406 | |
407 | |
408 } | |
409 | |
410 static void ignore_callback(GtkWidget *w, struct buddy_chat *b) | |
411 { | |
412 char *name; | |
413 GList *i; | |
414 | |
415 i = GTK_LIST(b->list)->selection; | |
416 if (i) | |
417 name = (char *)gtk_object_get_user_data(GTK_OBJECT(i->data)); | |
418 else | |
419 return; | |
420 | |
421 if (g_list_index(b->ignored, (gpointer)name) == -1) | |
422 b->ignored = g_list_append(b->ignored, name); | |
423 else | |
424 b->ignored = g_list_remove(b->ignored, name); | |
425 | |
426 update_chat_list(b); | |
427 } | |
428 | |
429 static void info_callback(GtkWidget *w, struct buddy_chat *b) | |
430 { | |
431 char *name; | |
432 GList *i; | |
433 | |
434 i = GTK_LIST(b->list)->selection; | |
435 if (i) | |
436 name = (char *)gtk_object_get_user_data(GTK_OBJECT(i->data)); | |
437 else | |
438 return; | |
439 | |
440 serv_get_info(name); | |
441 } | |
442 | |
443 | |
444 | |
445 void show_new_buddy_chat(struct buddy_chat *b) | |
446 { | |
447 GtkWidget *win; | |
448 GtkWidget *text; | |
449 GtkWidget *send; | |
450 GtkWidget *list; | |
451 GtkWidget *invite_btn; | |
452 GtkWidget *whisper; | |
453 GtkWidget *close; | |
454 GtkWidget *chatentry; | |
455 GtkWidget *tbox; | |
456 GtkWidget *lbox; | |
457 GtkWidget *bbox; | |
458 GtkWidget *bbox2; | |
459 GtkWidget *im, *ignore, *info; | |
460 GtkWidget *sw; | |
461 GtkWidget *sw2; | |
462 GtkWidget *vbox; | |
463 | |
464 | |
465 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
466 b->window = win; | |
467 | |
26 | 468 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); |
469 | |
1 | 470 close = gtk_button_new_with_label("Close"); |
471 invite_btn = gtk_button_new_with_label("Invite"); | |
472 whisper = gtk_button_new_with_label("Whisper"); | |
473 send = gtk_button_new_with_label("Send"); | |
474 | |
475 im = gtk_button_new_with_label("IM"); | |
476 ignore = gtk_button_new_with_label("Ignore"); | |
477 info = gtk_button_new_with_label("Info"); | |
478 | |
479 text = gtk_html_new(NULL, NULL); | |
480 | |
481 b->text = text; | |
482 | |
483 list = gtk_list_new(); | |
484 b->list = list; | |
485 | |
486 bbox = gtk_hbox_new(TRUE, 0); | |
487 bbox2 = gtk_hbox_new(TRUE, 0); | |
488 tbox = gtk_hbox_new(FALSE, 0); | |
489 vbox = gtk_vbox_new(FALSE, 0); | |
490 lbox = gtk_vbox_new(FALSE, 4); | |
491 chatentry = gtk_entry_new(); | |
492 | |
493 gtk_widget_realize(win); | |
494 | |
495 | |
496 b->makesound=1; | |
497 | |
498 gtk_object_set_user_data(GTK_OBJECT(chatentry), b); | |
499 b->entry = chatentry; | |
500 | |
501 /* Hack something so we know have an entry click event */ | |
502 | |
503 gtk_signal_connect(GTK_OBJECT(chatentry), "activate", GTK_SIGNAL_FUNC(send_callback),b); | |
504 /* Text box */ | |
505 | |
506 sw = gtk_scrolled_window_new (NULL, NULL); | |
507 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
508 GTK_POLICY_NEVER, | |
509 GTK_POLICY_ALWAYS); | |
510 gtk_widget_show(sw); | |
511 gtk_container_add(GTK_CONTAINER(sw), text); | |
512 gtk_widget_show(text); | |
513 | |
514 | |
515 GTK_HTML (text)->hadj->step_increment = 10.0; | |
516 GTK_HTML (text)->vadj->step_increment = 10.0; | |
517 gtk_widget_set_usize(sw, 320, 150); | |
518 | |
519 gtk_box_pack_start(GTK_BOX(tbox), sw, TRUE, TRUE, 0); | |
520 | |
521 | |
522 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
523 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
524 GTK_POLICY_NEVER, | |
525 GTK_POLICY_AUTOMATIC); | |
526 gtk_widget_show(sw2); | |
527 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list); | |
528 | |
529 gtk_box_pack_start(GTK_BOX(lbox), sw2, TRUE, TRUE, 0); | |
530 gtk_box_pack_start(GTK_BOX(lbox), bbox2, FALSE, FALSE, 0); | |
531 | |
532 | |
533 gtk_box_pack_start(GTK_BOX(tbox), lbox, TRUE, TRUE, 0); | |
534 gtk_widget_show(list); | |
535 | |
536 | |
537 gtk_widget_set_usize(list, 150, 150); | |
538 | |
539 | |
540 /* Ready and pack buttons */ | |
541 gtk_object_set_user_data(GTK_OBJECT(win), b); | |
542 gtk_object_set_user_data(GTK_OBJECT(close), b); | |
543 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_callback),b); | |
544 gtk_signal_connect(GTK_OBJECT(send), "clicked", GTK_SIGNAL_FUNC(send_callback),b); | |
545 gtk_signal_connect(GTK_OBJECT(invite_btn), "clicked", GTK_SIGNAL_FUNC(invite_callback), b); | |
546 gtk_signal_connect(GTK_OBJECT(whisper), "clicked", GTK_SIGNAL_FUNC(whisper_callback), b); | |
547 | |
548 gtk_signal_connect(GTK_OBJECT(im), "clicked", GTK_SIGNAL_FUNC(im_callback), b); | |
549 gtk_signal_connect(GTK_OBJECT(ignore), "clicked", GTK_SIGNAL_FUNC(ignore_callback), b); | |
550 gtk_signal_connect(GTK_OBJECT(info), "clicked", GTK_SIGNAL_FUNC(info_callback), b); | |
551 | |
552 gtk_box_pack_start(GTK_BOX(bbox), send, TRUE, TRUE, 5); | |
553 gtk_box_pack_start(GTK_BOX(bbox), whisper, TRUE, TRUE, 5); | |
554 gtk_box_pack_start(GTK_BOX(bbox), invite_btn, TRUE, TRUE, 5); | |
555 gtk_box_pack_start(GTK_BOX(bbox), close, TRUE, TRUE, 5); | |
556 | |
557 gtk_box_pack_start(GTK_BOX(bbox2), im, TRUE, TRUE, 5); | |
558 gtk_box_pack_start(GTK_BOX(bbox2), ignore, TRUE, TRUE, 5); | |
559 gtk_box_pack_start(GTK_BOX(bbox2), info, TRUE, TRUE, 5); | |
560 | |
561 /* pack and fill the rest */ | |
562 | |
563 | |
564 gtk_box_pack_start(GTK_BOX(vbox), tbox, TRUE, TRUE, 5); | |
565 gtk_box_pack_start(GTK_BOX(vbox), chatentry, FALSE, FALSE, 5); | |
566 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
567 | |
568 gtk_widget_show(send); | |
569 gtk_widget_show(invite_btn); | |
570 gtk_widget_show(whisper); | |
571 gtk_widget_show(close); | |
572 gtk_widget_show(im); | |
573 gtk_widget_show(ignore); | |
574 gtk_widget_show(info); | |
575 gtk_widget_show(bbox); | |
576 gtk_widget_show(lbox); | |
577 gtk_widget_show(bbox2); | |
578 gtk_widget_show(vbox); | |
579 gtk_widget_show(tbox); | |
580 gtk_widget_show(chatentry); | |
581 | |
582 | |
583 gtk_container_add(GTK_CONTAINER(win),vbox); | |
584 gtk_container_border_width(GTK_CONTAINER(win), 10); | |
585 | |
586 gtk_window_set_title(GTK_WINDOW(win), b->name); | |
587 gtk_window_set_focus(GTK_WINDOW(win), chatentry); | |
588 | |
589 gtk_signal_connect(GTK_OBJECT(win), "destroy", GTK_SIGNAL_FUNC(close_callback),b); | |
590 | |
591 | |
592 gtk_widget_realize(win); | |
593 aol_icon(win->window); | |
594 | |
595 gtk_widget_show(win); | |
596 | |
597 | |
598 } | |
599 | |
600 | |
601 | |
602 void handle_click_chat(GtkWidget *widget, GdkEventButton *event, struct chat_room *cr) | |
603 { | |
604 if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { | |
605 serv_join_chat(cr->exchange, cr->name); | |
606 } | |
607 } | |
608 | |
609 | |
610 void setup_buddy_chats() | |
611 { | |
21 | 612 GList *list; |
1 | 613 struct chat_room *cr; |
614 GList *crs = chat_rooms; | |
615 GtkWidget *w; | |
616 GtkWidget *item; | |
617 GtkWidget *tree; | |
618 | |
21 | 619 if (buddies == NULL) |
620 return; | |
621 | |
622 list = GTK_TREE(buddies)->children; | |
623 | |
1 | 624 while(list) { |
625 w = (GtkWidget *)list->data; | |
626 if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, "Buddy Chat")) { | |
627 gtk_tree_remove_items(GTK_TREE(buddies), list); | |
628 list = GTK_TREE(buddies)->children; | |
629 if (!list) | |
630 break; | |
631 } | |
632 list = list->next; | |
633 } | |
634 | |
635 if (crs == NULL) | |
636 return; | |
637 | |
638 item = gtk_tree_item_new_with_label("Buddy Chat"); | |
639 tree = gtk_tree_new(); | |
640 gtk_widget_show(item); | |
641 gtk_widget_show(tree); | |
642 gtk_tree_append(GTK_TREE(buddies), item); | |
643 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), tree); | |
644 gtk_tree_item_expand(GTK_TREE_ITEM(item)); | |
645 | |
646 while (crs) { | |
647 cr = (struct chat_room *)crs->data; | |
648 | |
649 item = gtk_tree_item_new_with_label(cr->name); | |
650 gtk_object_set_user_data(GTK_OBJECT(item), cr); | |
651 gtk_tree_append(GTK_TREE(tree), item); | |
652 gtk_widget_show(item); | |
653 gtk_signal_connect(GTK_OBJECT(item), "button_press_event", | |
654 GTK_SIGNAL_FUNC(handle_click_chat), | |
655 cr); | |
656 | |
657 crs = crs->next; | |
658 | |
659 } | |
660 | |
661 } |