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