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