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