Mercurial > pidgin.yaz
annotate src/buddy_chat.c @ 289:d618dc6c7d21
[gaim-migrate @ 299]
Problems like this always come about at release time... :-P
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 31 May 2000 21:08:44 +0000 |
parents | cffec6a16d31 |
children | b32c83750104 |
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 |
223 | 309 strncpy(buf, gtk_editable_get_chars(GTK_EDITABLE(b->entry), 0, -1), sizeof(buf)/2); |
1 | 310 if (!strlen(buf)) |
311 return; | |
312 | |
223 | 313 gtk_editable_delete_text(GTK_EDITABLE(b->entry), 0, -1); |
1 | 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 *lbox; | |
456 GtkWidget *bbox; | |
457 GtkWidget *bbox2; | |
458 GtkWidget *im, *ignore, *info; | |
459 GtkWidget *sw; | |
460 GtkWidget *sw2; | |
461 GtkWidget *vbox; | |
223 | 462 GtkWidget *vpaned; |
463 GtkWidget *hpaned; | |
1 | 464 |
465 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
466 b->window = win; | |
467 | |
223 | 468 vpaned = gtk_vpaned_new(); |
469 hpaned = gtk_hpaned_new(); | |
470 | |
26 | 471 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); |
472 | |
1 | 473 close = gtk_button_new_with_label("Close"); |
474 invite_btn = gtk_button_new_with_label("Invite"); | |
475 whisper = gtk_button_new_with_label("Whisper"); | |
476 send = gtk_button_new_with_label("Send"); | |
477 | |
478 im = gtk_button_new_with_label("IM"); | |
479 ignore = gtk_button_new_with_label("Ignore"); | |
480 info = gtk_button_new_with_label("Info"); | |
481 | |
482 text = gtk_html_new(NULL, NULL); | |
483 | |
484 b->text = text; | |
485 | |
486 list = gtk_list_new(); | |
487 b->list = list; | |
488 | |
489 bbox = gtk_hbox_new(TRUE, 0); | |
490 bbox2 = gtk_hbox_new(TRUE, 0); | |
491 vbox = gtk_vbox_new(FALSE, 0); | |
492 lbox = gtk_vbox_new(FALSE, 4); | |
223 | 493 chatentry = gtk_text_new( NULL, NULL ); |
494 gtk_text_set_editable(GTK_TEXT(chatentry), TRUE); | |
495 | |
496 gtk_text_set_word_wrap(GTK_TEXT(chatentry), TRUE); | |
1 | 497 |
498 gtk_widget_realize(win); | |
499 | |
500 | |
501 b->makesound=1; | |
502 | |
503 gtk_object_set_user_data(GTK_OBJECT(chatentry), b); | |
504 b->entry = chatentry; | |
505 | |
506 /* Hack something so we know have an entry click event */ | |
507 | |
508 gtk_signal_connect(GTK_OBJECT(chatentry), "activate", GTK_SIGNAL_FUNC(send_callback),b); | |
509 /* Text box */ | |
510 | |
511 sw = gtk_scrolled_window_new (NULL, NULL); | |
512 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
513 GTK_POLICY_NEVER, | |
514 GTK_POLICY_ALWAYS); | |
515 gtk_widget_show(sw); | |
516 gtk_container_add(GTK_CONTAINER(sw), text); | |
517 gtk_widget_show(text); | |
518 | |
519 | |
520 GTK_HTML (text)->hadj->step_increment = 10.0; | |
521 GTK_HTML (text)->vadj->step_increment = 10.0; | |
522 gtk_widget_set_usize(sw, 320, 150); | |
523 | |
223 | 524 gtk_paned_pack1(GTK_PANED(hpaned), sw, TRUE, TRUE); |
1 | 525 |
526 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
527 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
528 GTK_POLICY_NEVER, | |
529 GTK_POLICY_AUTOMATIC); | |
530 gtk_widget_show(sw2); | |
531 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list); | |
532 | |
533 gtk_box_pack_start(GTK_BOX(lbox), sw2, TRUE, TRUE, 0); | |
226 | 534 gtk_box_pack_start(GTK_BOX(lbox), bbox2, FALSE, FALSE, 5); |
1 | 535 |
536 | |
223 | 537 gtk_paned_pack2(GTK_PANED(hpaned), lbox, TRUE, TRUE); |
1 | 538 gtk_widget_show(list); |
539 | |
540 | |
541 gtk_widget_set_usize(list, 150, 150); | |
542 | |
543 | |
544 /* Ready and pack buttons */ | |
545 gtk_object_set_user_data(GTK_OBJECT(win), b); | |
546 gtk_object_set_user_data(GTK_OBJECT(close), b); | |
547 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_callback),b); | |
548 gtk_signal_connect(GTK_OBJECT(send), "clicked", GTK_SIGNAL_FUNC(send_callback),b); | |
549 gtk_signal_connect(GTK_OBJECT(invite_btn), "clicked", GTK_SIGNAL_FUNC(invite_callback), b); | |
550 gtk_signal_connect(GTK_OBJECT(whisper), "clicked", GTK_SIGNAL_FUNC(whisper_callback), b); | |
551 | |
552 gtk_signal_connect(GTK_OBJECT(im), "clicked", GTK_SIGNAL_FUNC(im_callback), b); | |
553 gtk_signal_connect(GTK_OBJECT(ignore), "clicked", GTK_SIGNAL_FUNC(ignore_callback), b); | |
554 gtk_signal_connect(GTK_OBJECT(info), "clicked", GTK_SIGNAL_FUNC(info_callback), b); | |
555 | |
556 gtk_box_pack_start(GTK_BOX(bbox), send, TRUE, TRUE, 5); | |
557 gtk_box_pack_start(GTK_BOX(bbox), whisper, TRUE, TRUE, 5); | |
558 gtk_box_pack_start(GTK_BOX(bbox), invite_btn, TRUE, TRUE, 5); | |
559 gtk_box_pack_start(GTK_BOX(bbox), close, TRUE, TRUE, 5); | |
560 | |
561 gtk_box_pack_start(GTK_BOX(bbox2), im, TRUE, TRUE, 5); | |
562 gtk_box_pack_start(GTK_BOX(bbox2), ignore, TRUE, TRUE, 5); | |
563 gtk_box_pack_start(GTK_BOX(bbox2), info, TRUE, TRUE, 5); | |
564 | |
565 /* pack and fill the rest */ | |
566 | |
567 | |
223 | 568 gtk_paned_pack1(GTK_PANED(vpaned), hpaned, TRUE, FALSE); |
569 gtk_box_pack_start(GTK_BOX(vbox), chatentry, TRUE, TRUE, 5); | |
1 | 570 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); |
223 | 571 gtk_paned_pack2(GTK_PANED(vpaned), vbox, TRUE, FALSE); |
1 | 572 |
573 gtk_widget_show(send); | |
574 gtk_widget_show(invite_btn); | |
575 gtk_widget_show(whisper); | |
576 gtk_widget_show(close); | |
577 gtk_widget_show(im); | |
578 gtk_widget_show(ignore); | |
579 gtk_widget_show(info); | |
580 gtk_widget_show(bbox); | |
581 gtk_widget_show(lbox); | |
582 gtk_widget_show(bbox2); | |
583 gtk_widget_show(vbox); | |
223 | 584 gtk_widget_show( vpaned ); |
585 gtk_widget_show( hpaned ); | |
1 | 586 gtk_widget_show(chatentry); |
223 | 587 gtk_widget_set_usize(chatentry, 320, 25); |
1 | 588 |
223 | 589 gtk_container_add(GTK_CONTAINER(win),vpaned); |
1 | 590 gtk_container_border_width(GTK_CONTAINER(win), 10); |
591 | |
592 gtk_window_set_title(GTK_WINDOW(win), b->name); | |
593 gtk_window_set_focus(GTK_WINDOW(win), chatentry); | |
594 | |
595 gtk_signal_connect(GTK_OBJECT(win), "destroy", GTK_SIGNAL_FUNC(close_callback),b); | |
596 | |
597 | |
598 gtk_widget_realize(win); | |
599 aol_icon(win->window); | |
600 | |
601 gtk_widget_show(win); | |
602 | |
603 | |
604 } | |
605 | |
606 | |
607 | |
608 void handle_click_chat(GtkWidget *widget, GdkEventButton *event, struct chat_room *cr) | |
609 { | |
610 if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { | |
611 serv_join_chat(cr->exchange, cr->name); | |
612 } | |
613 } | |
614 | |
615 | |
616 void setup_buddy_chats() | |
617 { | |
21 | 618 GList *list; |
1 | 619 struct chat_room *cr; |
620 GList *crs = chat_rooms; | |
621 GtkWidget *w; | |
622 GtkWidget *item; | |
623 GtkWidget *tree; | |
624 | |
21 | 625 if (buddies == NULL) |
626 return; | |
627 | |
628 list = GTK_TREE(buddies)->children; | |
629 | |
1 | 630 while(list) { |
631 w = (GtkWidget *)list->data; | |
632 if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, "Buddy Chat")) { | |
633 gtk_tree_remove_items(GTK_TREE(buddies), list); | |
634 list = GTK_TREE(buddies)->children; | |
635 if (!list) | |
636 break; | |
637 } | |
638 list = list->next; | |
639 } | |
640 | |
641 if (crs == NULL) | |
642 return; | |
643 | |
644 item = gtk_tree_item_new_with_label("Buddy Chat"); | |
645 tree = gtk_tree_new(); | |
646 gtk_widget_show(item); | |
647 gtk_widget_show(tree); | |
648 gtk_tree_append(GTK_TREE(buddies), item); | |
649 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), tree); | |
650 gtk_tree_item_expand(GTK_TREE_ITEM(item)); | |
651 | |
652 while (crs) { | |
653 cr = (struct chat_room *)crs->data; | |
654 | |
655 item = gtk_tree_item_new_with_label(cr->name); | |
656 gtk_object_set_user_data(GTK_OBJECT(item), cr); | |
657 gtk_tree_append(GTK_TREE(tree), item); | |
658 gtk_widget_show(item); | |
659 gtk_signal_connect(GTK_OBJECT(item), "button_press_event", | |
660 GTK_SIGNAL_FUNC(handle_click_chat), | |
661 cr); | |
662 | |
663 crs = crs->next; | |
664 | |
665 } | |
666 | |
667 } |