Mercurial > pidgin
annotate src/buddy_chat.c @ 686:cd6772d0685a
[gaim-migrate @ 696]
:)
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 15 Aug 2000 18:32:56 +0000 |
parents | 71ea550c22ac |
children | f4026275bc9f |
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 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
344
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
344
diff
changeset
|
23 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
344
diff
changeset
|
24 #endif |
1 | 25 #include <string.h> |
26 #include <sys/time.h> | |
27 #include <unistd.h> | |
28 #include <stdio.h> | |
29 #include <stdlib.h> | |
30 #include <gtk/gtk.h> | |
31 #include "gtkhtml.h" | |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
226
diff
changeset
|
32 #include <gdk/gdkkeysyms.h> |
1 | 33 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
34 #include "convo.h" |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
35 |
604
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
535
diff
changeset
|
36 #include "pixmaps/join.xpm" |
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
535
diff
changeset
|
37 #include "pixmaps/cancel.xpm" |
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
535
diff
changeset
|
38 |
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
535
diff
changeset
|
39 |
1 | 40 static GtkWidget *joinchat; |
41 static GtkWidget *entry; | |
42 static GtkWidget *invite; | |
43 static GtkWidget *inviteentry; | |
44 static GtkWidget *invitemess; | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
45 extern int state_lock; |
1 | 46 |
47 static void destroy_join_chat() | |
48 { | |
49 if (joinchat) | |
50 gtk_widget_destroy(joinchat); | |
51 joinchat=NULL; | |
52 } | |
53 | |
54 static void destroy_invite() | |
55 { | |
56 if (invite) | |
57 gtk_widget_destroy(invite); | |
58 invite=NULL; | |
59 } | |
60 | |
61 | |
62 | |
63 | |
64 static void do_join_chat() | |
65 { | |
66 char *group; | |
67 | |
68 group = gtk_entry_get_text(GTK_ENTRY(entry)); | |
69 | |
70 if (joinchat) { | |
71 serv_join_chat(4, group); | |
72 gtk_widget_destroy(joinchat); | |
73 } | |
74 joinchat=NULL; | |
75 } | |
76 | |
77 | |
78 | |
79 void join_chat() | |
80 { | |
81 GtkWidget *cancel; | |
82 GtkWidget *join; | |
83 GtkWidget *label; | |
84 GtkWidget *bbox; | |
85 GtkWidget *vbox; | |
86 GtkWidget *topbox; | |
456 | 87 GtkWidget *button_box; |
88 GtkWidget *icon_i; | |
89 GdkBitmap *mask; | |
90 GdkPixmap *icon; | |
457 | 91 GtkWidget *frame; |
456 | 92 |
1 | 93 if (!joinchat) { |
457 | 94 joinchat = gtk_window_new(GTK_WINDOW_DIALOG); |
485 | 95 gtk_widget_set_usize(joinchat, 300, 100); |
457 | 96 gtk_window_set_policy(GTK_WINDOW(joinchat), FALSE, FALSE, TRUE); |
456 | 97 gtk_widget_show(joinchat); |
1 | 98 bbox = gtk_hbox_new(TRUE, 10); |
99 topbox = gtk_hbox_new(FALSE, 5); | |
100 vbox = gtk_vbox_new(FALSE, 5); | |
101 entry = gtk_entry_new(); | |
102 | |
457 | 103 frame = gtk_frame_new(_("Buddy Chat")); |
456 | 104 /* Build Join Button */ |
105 | |
106 join = gtk_button_new(); | |
107 | |
108 button_box = gtk_hbox_new(FALSE, 5); | |
109 icon = gdk_pixmap_create_from_xpm_d (joinchat->window, &mask, NULL, join_xpm); | |
110 icon_i = gtk_pixmap_new(icon, mask); | |
111 | |
112 label = gtk_label_new(_("Join")); | |
113 | |
114 gtk_box_pack_start(GTK_BOX(button_box), icon_i, FALSE, FALSE, 2); | |
115 gtk_box_pack_end(GTK_BOX(button_box), label, FALSE, FALSE, 2); | |
116 | |
117 gtk_widget_show(label); | |
118 gtk_widget_show(icon_i); | |
119 | |
120 gtk_widget_show(button_box); | |
121 | |
122 gtk_container_add(GTK_CONTAINER(join), button_box); | |
483 | 123 gtk_widget_set_usize(join, 75, 30); |
456 | 124 |
125 /* End of OK Button */ | |
126 | |
127 /* Build Cancel Button */ | |
128 | |
129 cancel = gtk_button_new(); | |
130 | |
131 button_box = gtk_hbox_new(FALSE, 5); | |
132 icon = gdk_pixmap_create_from_xpm_d ( joinchat->window, &mask, NULL, cancel_xpm); | |
133 icon_i = gtk_pixmap_new(icon, mask); | |
134 | |
135 label = gtk_label_new(_("Cancel")); | |
136 | |
137 gtk_box_pack_start(GTK_BOX(button_box), icon_i, FALSE, FALSE, 2); | |
138 gtk_box_pack_end(GTK_BOX(button_box), label, FALSE, FALSE, 2); | |
139 | |
140 gtk_widget_show(label); | |
141 gtk_widget_show(icon_i); | |
142 | |
143 gtk_widget_show(button_box); | |
144 | |
145 gtk_container_add(GTK_CONTAINER(cancel), button_box); | |
146 | |
483 | 147 gtk_widget_set_usize(cancel, 75, 30); |
148 | |
456 | 149 /* End of Cancel Button */ |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
150 |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
151 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
152 { |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
153 gtk_button_set_relief(GTK_BUTTON(join), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
154 gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
155 } |
456 | 156 |
157 gtk_box_pack_start(GTK_BOX(bbox), join, FALSE, FALSE, 5); | |
158 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5); | |
159 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
160 label = gtk_label_new(_("Join what group:")); |
1 | 161 gtk_widget_show(label); |
162 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
163 gtk_box_pack_start(GTK_BOX(topbox), entry, FALSE, FALSE, 5); | |
164 | |
165 /* And the boxes in the box */ | |
166 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
457 | 167 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5); |
1 | 168 |
169 /* Handle closes right */ | |
170 gtk_signal_connect(GTK_OBJECT(joinchat), "delete_event", | |
171 GTK_SIGNAL_FUNC(destroy_join_chat), joinchat); | |
172 | |
173 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
174 GTK_SIGNAL_FUNC(destroy_join_chat), joinchat); | |
175 gtk_signal_connect(GTK_OBJECT(join), "clicked", | |
176 GTK_SIGNAL_FUNC(do_join_chat), joinchat); | |
177 gtk_signal_connect(GTK_OBJECT(entry), "activate", | |
178 GTK_SIGNAL_FUNC(do_join_chat), joinchat); | |
179 /* Finish up */ | |
180 gtk_widget_show(join); | |
181 gtk_widget_show(cancel); | |
182 gtk_widget_show(entry); | |
183 gtk_widget_show(topbox); | |
184 gtk_widget_show(bbox); | |
185 gtk_widget_show(vbox); | |
457 | 186 gtk_widget_show(frame); |
187 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
188 gtk_window_set_title(GTK_WINDOW(joinchat), _("Join Chat")); |
1 | 189 gtk_window_set_focus(GTK_WINDOW(joinchat), entry); |
457 | 190 gtk_container_add(GTK_CONTAINER(joinchat), frame); |
191 gtk_container_set_border_width(GTK_CONTAINER(joinchat), 5); | |
1 | 192 gtk_widget_realize(joinchat); |
193 aol_icon(joinchat->window); | |
194 | |
195 } | |
196 gtk_widget_show(joinchat); | |
197 } | |
198 | |
199 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
200 static void do_invite(GtkWidget *w, struct conversation *b) |
1 | 201 { |
202 char *buddy; | |
203 char *mess; | |
204 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
205 if (!b->is_chat) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
206 debug_print("do_invite: expecting chat, got IM\n"); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
207 return; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
208 } |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
209 |
1 | 210 buddy = gtk_entry_get_text(GTK_ENTRY(inviteentry)); |
211 mess = gtk_entry_get_text(GTK_ENTRY(invitemess)); | |
212 | |
213 if (invite) { | |
214 serv_chat_invite(b->id, mess, buddy); | |
215 gtk_widget_destroy(invite); | |
216 } | |
217 invite=NULL; | |
218 } | |
219 | |
220 | |
221 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
222 void invite_callback(GtkWidget *w, struct conversation *b) |
1 | 223 { |
224 GtkWidget *cancel; | |
225 GtkWidget *invite_btn; | |
226 GtkWidget *label; | |
227 GtkWidget *bbox; | |
228 GtkWidget *vbox; | |
229 GtkWidget *topbox; | |
230 if (!invite) { | |
231 invite = gtk_window_new(GTK_WINDOW_DIALOG); | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
232 cancel = gtk_button_new_with_label(_("Cancel")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
233 invite_btn = gtk_button_new_with_label(_("Invite")); |
1 | 234 bbox = gtk_hbox_new(TRUE, 10); |
235 topbox = gtk_hbox_new(FALSE, 5); | |
236 vbox = gtk_vbox_new(FALSE, 5); | |
237 inviteentry = gtk_entry_new(); | |
238 invitemess = gtk_entry_new(); | |
239 | |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
240 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
241 { |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
242 gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
243 gtk_button_set_relief(GTK_BUTTON(invite_btn), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
244 } |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
245 |
1 | 246 /* Put the buttons in the box */ |
247 gtk_box_pack_start(GTK_BOX(bbox), invite_btn, TRUE, TRUE, 10); | |
248 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
249 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
250 label = gtk_label_new(_("Invite who?")); |
1 | 251 gtk_widget_show(label); |
252 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
253 gtk_box_pack_start(GTK_BOX(topbox), inviteentry, FALSE, FALSE, 5); | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
254 label = gtk_label_new(_("With message:")); |
1 | 255 gtk_widget_show(label); |
256 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
257 gtk_box_pack_start(GTK_BOX(topbox), invitemess, FALSE, FALSE, 5); | |
258 | |
259 /* And the boxes in the box */ | |
260 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
261 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
262 | |
263 /* Handle closes right */ | |
264 gtk_signal_connect(GTK_OBJECT(invite), "delete_event", | |
265 GTK_SIGNAL_FUNC(destroy_invite), invite); | |
266 | |
267 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
268 GTK_SIGNAL_FUNC(destroy_invite), b); | |
269 gtk_signal_connect(GTK_OBJECT(invite_btn), "clicked", | |
270 GTK_SIGNAL_FUNC(do_invite), b); | |
271 gtk_signal_connect(GTK_OBJECT(inviteentry), "activate", | |
272 GTK_SIGNAL_FUNC(do_invite), b); | |
273 /* Finish up */ | |
274 gtk_widget_show(invite_btn); | |
275 gtk_widget_show(cancel); | |
276 gtk_widget_show(inviteentry); | |
277 gtk_widget_show(invitemess); | |
278 gtk_widget_show(topbox); | |
279 gtk_widget_show(bbox); | |
280 gtk_widget_show(vbox); | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
281 gtk_window_set_title(GTK_WINDOW(invite), _("Invite to Buddy Chat")); |
1 | 282 gtk_window_set_focus(GTK_WINDOW(invite), inviteentry); |
283 gtk_container_add(GTK_CONTAINER(invite), vbox); | |
284 gtk_widget_realize(invite); | |
285 aol_icon(invite->window); | |
286 | |
287 } | |
288 gtk_widget_show(invite); | |
289 } | |
290 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
291 gboolean meify(char *message) { |
415
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
292 /* read /me-ify : if the message (post-HTML) starts with /me, remove |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
293 * the "/me " part of it (including that space) and return TRUE */ |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
294 char *c = message; |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
295 int inside_HTML = 0; /* i really don't like descriptive names */ |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
296 if (!c) return FALSE; /* um... this would be very bad if this happens */ |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
297 while (*c) { |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
298 if (inside_HTML) { |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
299 if (*c == '>') inside_HTML = 0; |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
300 } else { |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
301 if (*c == '<') inside_HTML = 1; |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
302 else break; |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
303 } |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
304 c++; /* i really don't like c++ either */ |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
305 } |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
306 /* k, so now we've gotten past all the HTML crap. */ |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
307 if (!*c) return FALSE; |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
308 if (!strncmp(c, "/me ", 4)) { |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
309 sprintf(c, "%s", c+4); |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
310 return TRUE; |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
311 } else |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
312 return FALSE; |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
313 } |
a266fd221c3c
[gaim-migrate @ 425]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
314 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
315 void chat_write(struct conversation *b, char *who, int flag, char *message) |
1 | 316 { |
317 GList *ignore = b->ignored; | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
318 char *str; |
1 | 319 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
320 if (!b->is_chat) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
321 debug_print("chat_write: expecting chat, got IM\n"); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
322 return; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
323 } |
1 | 324 |
325 while(ignore) { | |
326 if (!strcasecmp(who, ignore->data)) | |
327 return; | |
328 ignore = ignore->next; | |
329 } | |
371
9d22acf6db73
[gaim-migrate @ 381]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
330 |
1 | 331 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
332 if (!(flag & WFLAG_WHISPER)) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
333 str = g_strdup(normalize(who)); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
334 if (!strcasecmp(str, normalize(current_user->username))) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
335 sprintf(debug_buff, "%s %s\n", normalize(who), normalize(current_user->username)); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
336 debug_print(debug_buff); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
337 if (b->makesound && (sound_options & OPT_SOUND_CHAT_SAY)) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
338 play_sound(SEND); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
339 flag |= WFLAG_SEND; |
371
9d22acf6db73
[gaim-migrate @ 381]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
340 } else { |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
341 if (b->makesound && (sound_options & OPT_SOUND_CHAT_SAY)) |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
342 play_sound(RECEIVE); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
343 flag |= WFLAG_RECV; |
371
9d22acf6db73
[gaim-migrate @ 381]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
344 } |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
345 g_free(str); |
1 | 346 } |
347 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
348 write_to_conv(b, message, flag, who); |
1 | 349 } |
350 | |
351 | |
368
9bf1f77985d2
[gaim-migrate @ 378]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
363
diff
changeset
|
352 |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
353 void whisper_callback(GtkWidget *widget, struct conversation *b) |
1 | 354 { |
79 | 355 char buf[BUF_LEN*4]; |
1 | 356 char buf2[BUF_LONG]; |
357 GList *selected; | |
358 char *who; | |
359 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
300
diff
changeset
|
360 strncpy(buf, gtk_editable_get_chars(GTK_EDITABLE(b->entry), 0, -1), sizeof(buf)/2); |
1 | 361 if (!strlen(buf)) |
362 return; | |
363 | |
364 selected = GTK_LIST(b->list)->selection; | |
365 | |
366 if (!selected) | |
367 return; | |
368 | |
369 | |
370 who = GTK_LABEL(gtk_container_children(GTK_CONTAINER(selected->data))->data)->label; | |
371 | |
372 if (!who) | |
373 return; | |
374 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
300
diff
changeset
|
375 gtk_editable_delete_text(GTK_EDITABLE(b->entry), 0, -1); |
1 | 376 |
377 escape_text(buf); | |
378 serv_chat_whisper(b->id, who, buf); | |
379 | |
380 g_snprintf(buf2, sizeof(buf2), "%s->%s", current_user->username, who); | |
381 | |
382 chat_write(b, buf2, WFLAG_WHISPER, buf); | |
383 | |
384 gtk_widget_grab_focus(GTK_WIDGET(b->entry)); | |
385 | |
386 | |
387 } | |
388 | |
389 | |
390 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
391 void update_chat_list(struct conversation *b) |
1 | 392 { |
393 GtkWidget *list_item; | |
394 char name[80]; | |
395 char *tmp; | |
396 GList *names = b->in_room; | |
397 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
398 if (!b->is_chat) { |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
399 debug_print("update_chat_list: expecting chat, got IM\n"); |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
400 return; |
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
401 } |
1 | 402 |
403 gtk_list_clear_items(GTK_LIST(b->list), 0, -1); | |
404 | |
405 | |
406 while(names) { | |
407 tmp = (char *)names->data; | |
408 if (g_list_index(b->ignored, names->data) != -1) | |
409 g_snprintf(name, sizeof(name), "X %s", tmp); | |
410 else | |
411 g_snprintf(name, sizeof(name), "%s", tmp); | |
412 | |
413 list_item = gtk_list_item_new_with_label(name); | |
414 gtk_widget_show(list_item); | |
415 gtk_object_set_user_data(GTK_OBJECT(list_item), tmp); | |
416 | |
417 gtk_list_append_items(GTK_LIST(b->list), g_list_append(NULL, list_item)); | |
418 | |
419 names = names->next; | |
420 } | |
421 | |
422 } | |
423 | |
424 | |
425 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
426 void add_chat_buddy(struct conversation *b, char *buddy) |
1 | 427 { |
428 char *name = g_strdup(buddy); | |
612
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
429 char tmp[BUF_LONG]; |
1 | 430 |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
431 #ifdef GAIM_PLUGINS |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
432 GList *c = callbacks; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
433 struct gaim_callback *g; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
434 void (*function)(char *, char *, void *); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
435 while (c) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
436 g = (struct gaim_callback *)c->data; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
437 if (g->event == event_chat_buddy_join && g->function != NULL) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
438 function = g->function; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
439 (*function)(b->name, name, g->data); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
440 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
441 c = c->next; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
442 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
443 #endif |
1 | 444 b->in_room = g_list_append(b->in_room, name); |
445 | |
446 update_chat_list(b); | |
447 | |
371
9d22acf6db73
[gaim-migrate @ 381]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
448 if (b->makesound && (sound_options & OPT_SOUND_CHAT_JOIN)) |
9d22acf6db73
[gaim-migrate @ 381]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
449 play_sound(BUDDY_ARRIVE); |
612
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
450 |
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
451 if (display_options & OPT_DISP_CHAT_LOGON) { |
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
452 g_snprintf(tmp, sizeof(tmp), _("<B>%s entered the room.</B>"), name); |
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
453 write_to_conv(b, tmp, WFLAG_SYSTEM, NULL); |
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
454 } |
1 | 455 } |
456 | |
457 | |
458 | |
459 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
460 void remove_chat_buddy(struct conversation *b, char *buddy) |
1 | 461 { |
462 GList *names = b->in_room; | |
612
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
463 char tmp[BUF_LONG]; |
1 | 464 |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
465 #ifdef GAIM_PLUGINS |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
466 GList *c = callbacks; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
467 struct gaim_callback *g; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
468 void (*function)(char *, char *, void *); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
469 while (c) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
470 g = (struct gaim_callback *)c->data; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
471 if (g->event == event_chat_buddy_leave && g->function != NULL) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
472 function = g->function; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
473 (*function)(b->name, buddy, g->data); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
474 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
475 c = c->next; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
476 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
477 #endif |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
375
diff
changeset
|
478 |
1 | 479 while(names) { |
480 if (!strcasecmp((char *)names->data, buddy)) { | |
481 b->in_room = g_list_remove(b->in_room, names->data); | |
482 update_chat_list(b); | |
483 break; | |
484 } | |
485 names = names->next; | |
486 } | |
371
9d22acf6db73
[gaim-migrate @ 381]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
487 |
9d22acf6db73
[gaim-migrate @ 381]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
488 if (b->makesound && (sound_options & OPT_SOUND_CHAT_JOIN)) |
9d22acf6db73
[gaim-migrate @ 381]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
489 play_sound(BUDDY_LEAVE); |
612
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
490 |
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
491 if (display_options & OPT_DISP_CHAT_LOGON) { |
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
492 g_snprintf(tmp, sizeof(tmp), _("<B>%s left the room.</B>"), buddy); |
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
493 write_to_conv(b, tmp, WFLAG_SYSTEM, NULL); |
12bb64b42ad1
[gaim-migrate @ 622]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
604
diff
changeset
|
494 } |
1 | 495 } |
496 | |
497 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
498 void im_callback(GtkWidget *w, struct conversation *b) |
1 | 499 { |
500 char *name; | |
501 GList *i; | |
502 struct conversation *c; | |
503 | |
504 i = GTK_LIST(b->list)->selection; | |
505 if (i) | |
506 name = (char *)gtk_object_get_user_data(GTK_OBJECT(i->data)); | |
507 else | |
508 return; | |
509 | |
510 c = find_conversation(name); | |
511 | |
512 if (c != NULL) { | |
513 gdk_window_raise(c->window->window); | |
514 } else { | |
515 c = new_conversation(name); | |
516 } | |
517 | |
518 | |
519 } | |
520 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
521 void ignore_callback(GtkWidget *w, struct conversation *b) |
1 | 522 { |
523 char *name; | |
524 GList *i; | |
525 | |
526 i = GTK_LIST(b->list)->selection; | |
527 if (i) | |
528 name = (char *)gtk_object_get_user_data(GTK_OBJECT(i->data)); | |
529 else | |
530 return; | |
531 | |
532 if (g_list_index(b->ignored, (gpointer)name) == -1) | |
533 b->ignored = g_list_append(b->ignored, name); | |
534 else | |
535 b->ignored = g_list_remove(b->ignored, name); | |
536 | |
537 update_chat_list(b); | |
538 } | |
539 | |
540 | |
541 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
542 void show_new_buddy_chat(struct conversation *b) |
1 | 543 { |
544 GtkWidget *win; | |
545 GtkWidget *text; | |
546 GtkWidget *send; | |
547 GtkWidget *list; | |
548 GtkWidget *invite_btn; | |
549 GtkWidget *whisper; | |
550 GtkWidget *close; | |
551 GtkWidget *chatentry; | |
552 GtkWidget *lbox; | |
553 GtkWidget *bbox; | |
554 GtkWidget *bbox2; | |
555 GtkWidget *im, *ignore, *info; | |
556 GtkWidget *sw; | |
557 GtkWidget *sw2; | |
558 GtkWidget *vbox; | |
223 | 559 GtkWidget *vpaned; |
560 GtkWidget *hpaned; | |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
561 GtkWidget *toolbar; |
1 | 562 |
563 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
564 b->window = win; | |
565 | |
223 | 566 vpaned = gtk_vpaned_new(); |
567 hpaned = gtk_hpaned_new(); | |
568 | |
26 | 569 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); |
570 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
571 close = gtk_button_new_with_label(_("Close")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
572 invite_btn = gtk_button_new_with_label(_("Invite")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
573 whisper = gtk_button_new_with_label(_("Whisper")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
574 send = gtk_button_new_with_label(_("Send")); |
1 | 575 |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
576 im = gtk_button_new_with_label(_("IM")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
577 ignore = gtk_button_new_with_label(_("Ignore")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
578 info = gtk_button_new_with_label(_("Info")); |
1 | 579 |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
580 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
581 { |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
582 gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
583 gtk_button_set_relief(GTK_BUTTON(invite_btn), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
584 gtk_button_set_relief(GTK_BUTTON(whisper), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
585 gtk_button_set_relief(GTK_BUTTON(send), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
586 gtk_button_set_relief(GTK_BUTTON(im), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
587 gtk_button_set_relief(GTK_BUTTON(ignore), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
588 gtk_button_set_relief(GTK_BUTTON(info), GTK_RELIEF_NONE); |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
589 } |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
485
diff
changeset
|
590 |
1 | 591 text = gtk_html_new(NULL, NULL); |
592 | |
593 b->text = text; | |
594 | |
595 list = gtk_list_new(); | |
596 b->list = list; | |
597 | |
598 bbox = gtk_hbox_new(TRUE, 0); | |
599 bbox2 = gtk_hbox_new(TRUE, 0); | |
600 vbox = gtk_vbox_new(FALSE, 0); | |
601 lbox = gtk_vbox_new(FALSE, 4); | |
646
83c773b5b6dc
[gaim-migrate @ 656]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
615
diff
changeset
|
602 |
223 | 603 chatentry = gtk_text_new( NULL, NULL ); |
604 gtk_text_set_editable(GTK_TEXT(chatentry), TRUE); | |
605 gtk_text_set_word_wrap(GTK_TEXT(chatentry), TRUE); | |
646
83c773b5b6dc
[gaim-migrate @ 656]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
615
diff
changeset
|
606 gtk_object_set_user_data(GTK_OBJECT(chatentry), b); |
83c773b5b6dc
[gaim-migrate @ 656]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
615
diff
changeset
|
607 b->entry = chatentry; |
1 | 608 |
609 gtk_widget_realize(win); | |
610 | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
611 toolbar = build_conv_toolbar(b); |
1 | 612 |
613 /* Hack something so we know have an entry click event */ | |
614 | |
615 gtk_signal_connect(GTK_OBJECT(chatentry), "activate", GTK_SIGNAL_FUNC(send_callback),b); | |
472
6a92cd7322cc
[gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
457
diff
changeset
|
616 gtk_signal_connect(GTK_OBJECT(chatentry), "key_press_event", GTK_SIGNAL_FUNC(keypress_callback), b); |
1 | 617 /* Text box */ |
618 | |
619 sw = gtk_scrolled_window_new (NULL, NULL); | |
620 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
621 GTK_POLICY_NEVER, | |
622 GTK_POLICY_ALWAYS); | |
623 gtk_widget_show(sw); | |
624 gtk_container_add(GTK_CONTAINER(sw), text); | |
625 gtk_widget_show(text); | |
626 | |
627 | |
628 GTK_HTML (text)->hadj->step_increment = 10.0; | |
629 GTK_HTML (text)->vadj->step_increment = 10.0; | |
630 gtk_widget_set_usize(sw, 320, 150); | |
631 | |
223 | 632 gtk_paned_pack1(GTK_PANED(hpaned), sw, TRUE, TRUE); |
1 | 633 |
634 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
635 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
636 GTK_POLICY_NEVER, | |
637 GTK_POLICY_AUTOMATIC); | |
638 gtk_widget_show(sw2); | |
639 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list); | |
640 | |
641 gtk_box_pack_start(GTK_BOX(lbox), sw2, TRUE, TRUE, 0); | |
226 | 642 gtk_box_pack_start(GTK_BOX(lbox), bbox2, FALSE, FALSE, 5); |
1 | 643 |
644 | |
223 | 645 gtk_paned_pack2(GTK_PANED(hpaned), lbox, TRUE, TRUE); |
1 | 646 gtk_widget_show(list); |
647 | |
648 | |
649 gtk_widget_set_usize(list, 150, 150); | |
650 | |
651 | |
652 /* Ready and pack buttons */ | |
653 gtk_object_set_user_data(GTK_OBJECT(win), b); | |
654 gtk_object_set_user_data(GTK_OBJECT(close), b); | |
655 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_callback),b); | |
656 gtk_signal_connect(GTK_OBJECT(send), "clicked", GTK_SIGNAL_FUNC(send_callback),b); | |
657 gtk_signal_connect(GTK_OBJECT(invite_btn), "clicked", GTK_SIGNAL_FUNC(invite_callback), b); | |
658 gtk_signal_connect(GTK_OBJECT(whisper), "clicked", GTK_SIGNAL_FUNC(whisper_callback), b); | |
659 | |
660 gtk_signal_connect(GTK_OBJECT(im), "clicked", GTK_SIGNAL_FUNC(im_callback), b); | |
661 gtk_signal_connect(GTK_OBJECT(ignore), "clicked", GTK_SIGNAL_FUNC(ignore_callback), b); | |
662 gtk_signal_connect(GTK_OBJECT(info), "clicked", GTK_SIGNAL_FUNC(info_callback), b); | |
663 | |
664 gtk_box_pack_start(GTK_BOX(bbox), send, TRUE, TRUE, 5); | |
665 gtk_box_pack_start(GTK_BOX(bbox), whisper, TRUE, TRUE, 5); | |
666 gtk_box_pack_start(GTK_BOX(bbox), invite_btn, TRUE, TRUE, 5); | |
667 gtk_box_pack_start(GTK_BOX(bbox), close, TRUE, TRUE, 5); | |
668 | |
669 gtk_box_pack_start(GTK_BOX(bbox2), im, TRUE, TRUE, 5); | |
670 gtk_box_pack_start(GTK_BOX(bbox2), ignore, TRUE, TRUE, 5); | |
671 gtk_box_pack_start(GTK_BOX(bbox2), info, TRUE, TRUE, 5); | |
672 | |
673 /* pack and fill the rest */ | |
674 | |
675 | |
223 | 676 gtk_paned_pack1(GTK_PANED(vpaned), hpaned, TRUE, FALSE); |
344
2434adbb8703
[gaim-migrate @ 354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
677 gtk_box_pack_start(GTK_BOX(vbox), toolbar, TRUE, TRUE, 5); |
223 | 678 gtk_box_pack_start(GTK_BOX(vbox), chatentry, TRUE, TRUE, 5); |
1 | 679 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); |
223 | 680 gtk_paned_pack2(GTK_PANED(vpaned), vbox, TRUE, FALSE); |
1 | 681 |
682 gtk_widget_show(send); | |
683 gtk_widget_show(invite_btn); | |
684 gtk_widget_show(whisper); | |
685 gtk_widget_show(close); | |
686 gtk_widget_show(im); | |
687 gtk_widget_show(ignore); | |
688 gtk_widget_show(info); | |
689 gtk_widget_show(bbox); | |
690 gtk_widget_show(lbox); | |
691 gtk_widget_show(bbox2); | |
692 gtk_widget_show(vbox); | |
223 | 693 gtk_widget_show( vpaned ); |
694 gtk_widget_show( hpaned ); | |
1 | 695 gtk_widget_show(chatentry); |
223 | 696 gtk_widget_set_usize(chatentry, 320, 25); |
1 | 697 |
223 | 698 gtk_container_add(GTK_CONTAINER(win),vpaned); |
1 | 699 gtk_container_border_width(GTK_CONTAINER(win), 10); |
700 | |
701 gtk_window_set_title(GTK_WINDOW(win), b->name); | |
702 gtk_window_set_focus(GTK_WINDOW(win), chatentry); | |
703 | |
704 gtk_signal_connect(GTK_OBJECT(win), "destroy", GTK_SIGNAL_FUNC(close_callback),b); | |
705 | |
615 | 706 gtk_widget_realize(win); |
1 | 707 aol_icon(win->window); |
708 | |
709 gtk_widget_show(win); | |
710 } | |
711 | |
712 | |
713 | |
714 void handle_click_chat(GtkWidget *widget, GdkEventButton *event, struct chat_room *cr) | |
715 { | |
716 if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { | |
717 serv_join_chat(cr->exchange, cr->name); | |
718 } | |
719 } | |
720 | |
721 | |
722 void setup_buddy_chats() | |
723 { | |
21 | 724 GList *list; |
1 | 725 struct chat_room *cr; |
726 GList *crs = chat_rooms; | |
727 GtkWidget *w; | |
728 GtkWidget *item; | |
729 GtkWidget *tree; | |
730 | |
21 | 731 if (buddies == NULL) |
732 return; | |
733 | |
734 list = GTK_TREE(buddies)->children; | |
735 | |
1 | 736 while(list) { |
737 w = (GtkWidget *)list->data; | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
738 if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, _("Buddy Chat"))) { |
1 | 739 gtk_tree_remove_items(GTK_TREE(buddies), list); |
740 list = GTK_TREE(buddies)->children; | |
741 if (!list) | |
742 break; | |
743 } | |
744 list = list->next; | |
745 } | |
746 | |
747 if (crs == NULL) | |
748 return; | |
749 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
750 item = gtk_tree_item_new_with_label(_("Buddy Chat")); |
1 | 751 tree = gtk_tree_new(); |
752 gtk_widget_show(item); | |
753 gtk_widget_show(tree); | |
754 gtk_tree_append(GTK_TREE(buddies), item); | |
755 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), tree); | |
756 gtk_tree_item_expand(GTK_TREE_ITEM(item)); | |
757 | |
758 while (crs) { | |
759 cr = (struct chat_room *)crs->data; | |
760 | |
761 item = gtk_tree_item_new_with_label(cr->name); | |
762 gtk_object_set_user_data(GTK_OBJECT(item), cr); | |
763 gtk_tree_append(GTK_TREE(tree), item); | |
764 gtk_widget_show(item); | |
765 gtk_signal_connect(GTK_OBJECT(item), "button_press_event", | |
766 GTK_SIGNAL_FUNC(handle_click_chat), | |
767 cr); | |
768 | |
769 crs = crs->next; | |
770 | |
771 } | |
772 | |
773 } |