Mercurial > pidgin
annotate src/prefs.c @ 249:810c595258c8
[gaim-migrate @ 259]
You can now get users' away messages.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 22 May 2000 01:18:32 +0000 |
parents | 985635758c33 |
children | 5b28ef2b550e |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 #include <string.h> | |
23 #include <sys/time.h> | |
24 | |
25 #include <sys/types.h> | |
26 #include <sys/stat.h> | |
27 | |
28 #include <unistd.h> | |
29 #include <stdio.h> | |
30 #include <stdlib.h> | |
31 #include <gtk/gtk.h> | |
32 #include "gaim.h" | |
33 #include "proxy.h" | |
34 | |
35 struct prefs_data *pd = NULL; | |
36 struct debug_window *dw = NULL; | |
37 | |
38 GtkWidget *debugbutton; | |
39 | |
40 struct chat_page { | |
41 GtkWidget *list1; | |
42 GtkWidget *list2; | |
43 }; | |
44 | |
45 | |
46 char debug_buff[BUF_LONG]; | |
47 | |
48 void do_chat_page(GtkWidget *page); | |
49 | |
50 void list_clicked( GtkWidget *widget, struct away_message *a); | |
51 void list_unclicked( GtkWidget *widget, struct away_message *a); | |
52 | |
171
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
150
diff
changeset
|
53 void show_debug(GtkObject *); |
1 | 54 |
55 void remove_away_message(GtkWidget *widget, void *dummy) | |
56 { | |
57 GList *i; | |
58 struct away_message *a; | |
59 | |
60 i = GTK_LIST(pd->away_list)->selection; | |
61 | |
62 a = gtk_object_get_user_data(GTK_OBJECT(i->data)); | |
63 | |
64 rem_away_mess(NULL, a); | |
65 } | |
66 | |
67 void away_list_clicked( GtkWidget *widget, struct away_message *a) | |
68 { | |
69 gchar buffer[2048]; | |
70 guint text_len; | |
71 | |
72 pd->cur_message = a; | |
73 | |
74 /* Get proper Length */ | |
75 text_len = gtk_text_get_length(GTK_TEXT(pd->away_text)); | |
76 pd->edited_message = gtk_editable_get_chars(GTK_EDITABLE(pd->away_text), 0, text_len); | |
77 | |
78 /* Clear the Box */ | |
79 gtk_text_set_point(GTK_TEXT(pd->away_text), 0 ); | |
80 gtk_text_forward_delete (GTK_TEXT(pd->away_text), text_len); | |
81 | |
82 /* Fill the text box with new message */ | |
83 strcpy(buffer, a->message); | |
84 gtk_text_insert(GTK_TEXT(pd->away_text), NULL, NULL, NULL, buffer, -1); | |
85 | |
86 | |
87 } | |
88 | |
89 void away_list_unclicked( GtkWidget *widget, struct away_message *a) | |
90 { | |
91 if (pd == NULL) | |
92 return; | |
93 strcpy(a->message, pd->edited_message); | |
94 save_prefs(); | |
95 } | |
96 | |
97 void set_option(GtkWidget *w, int *option) | |
98 { | |
99 *option = !(*option); | |
100 } | |
101 | |
102 void set_display_option(GtkWidget *w, int *option) | |
103 { | |
104 display_options = display_options ^ (int)option; | |
9 | 105 |
18 | 106 if (blist) update_button_pix(); |
9 | 107 |
84 | 108 #ifdef USE_APPLET |
82 | 109 update_pixmaps(); |
110 #endif | |
111 | |
1 | 112 save_prefs(); |
113 } | |
114 | |
115 void set_sound_option(GtkWidget *w, int *option) | |
116 { | |
117 sound_options = sound_options ^ (int)option; | |
118 save_prefs(); | |
119 } | |
120 | |
121 void set_font_option(GtkWidget *w, int *option) | |
122 { | |
123 font_options = font_options ^ (int)option; | |
124 | |
125 update_font_buttons(); | |
126 | |
127 save_prefs(); | |
128 } | |
129 | |
130 void set_general_option(GtkWidget *w, int *option) | |
131 { | |
132 general_options = general_options ^ (int)option; | |
133 | |
134 if ((int)option == OPT_GEN_SHOW_LAGMETER) | |
135 update_lagometer(-1); | |
136 if ((int)option == OPT_GEN_LOG_ALL) | |
137 update_log_convs(); | |
138 save_prefs(); | |
139 | |
140 /* | |
141 if (data == &show_grp_nums) | |
142 update_num_groups(); | |
143 if (data == &showidle || data == &showpix) | |
144 update_show_idlepix(); | |
18 | 145 if (data == &button_pix && blist) |
1 | 146 update_button_pix(); |
147 if (data == &transparent) | |
148 update_transparency(); | |
149 */ | |
150 | |
151 } | |
152 | |
153 | |
154 static gint debug_delete(GtkWidget *w, GdkEvent *event, void *dummy) | |
155 { | |
171
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
150
diff
changeset
|
156 if (debugbutton) |
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
150
diff
changeset
|
157 gtk_button_clicked(GTK_BUTTON(debugbutton)); |
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
150
diff
changeset
|
158 if (general_options & OPT_GEN_DEBUG) |
1 | 159 { |
171
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
150
diff
changeset
|
160 general_options = general_options ^ (int)OPT_GEN_DEBUG; |
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
150
diff
changeset
|
161 save_prefs(); |
1 | 162 } |
163 g_free(dw); | |
164 dw=NULL; | |
165 return FALSE; | |
166 | |
167 } | |
168 | |
169 static gint handle_delete(GtkWidget *w, GdkEvent *event, void *dummy) | |
170 { | |
171 guint text_len; | |
172 struct away_message *a; | |
173 | |
174 | |
175 if (pd->cur_message) { | |
176 | |
177 a = pd->cur_message; | |
178 | |
179 | |
180 /* Get proper Length and grab data */ | |
181 text_len = gtk_text_get_length(GTK_TEXT(pd->away_text)); | |
182 pd->edited_message = gtk_editable_get_chars(GTK_EDITABLE(pd->away_text), 0, text_len); | |
183 | |
184 /* Store the data for later use */ | |
185 strcpy(a->message, pd->edited_message); | |
186 | |
187 } | |
188 | |
189 save_prefs(); | |
190 | |
191 if (event == NULL) | |
192 { | |
193 gtk_widget_destroy(pd->window); | |
194 debugbutton=NULL; | |
195 } | |
196 g_free(pd); | |
197 pd = NULL; | |
198 | |
199 | |
200 return FALSE; | |
201 } | |
202 | |
203 static int | |
204 manualentry_key_pressed(GtkWidget *w, GdkEvent *event, void *dummy) | |
205 { | |
206 g_snprintf(web_command, sizeof(web_command), "%s", gtk_entry_get_text(GTK_ENTRY(pd->browser_entry))); | |
207 save_prefs(); | |
208 return TRUE; | |
209 } | |
210 | |
211 static int | |
212 connection_key_pressed(GtkWidget *w, GdkEvent *event, void *dummy) | |
213 { | |
214 g_snprintf(aim_host, sizeof(aim_host), "%s", gtk_entry_get_text(GTK_ENTRY(pd->aim_host_entry))); | |
215 sscanf(gtk_entry_get_text(GTK_ENTRY(pd->aim_port_entry)), "%d", &aim_port); | |
216 g_snprintf(proxy_host, sizeof(proxy_host), "%s", gtk_entry_get_text(GTK_ENTRY(pd->http_proxy_host_entry))); | |
217 sscanf(gtk_entry_get_text(GTK_ENTRY(pd->http_proxy_port_entry)), "%d", &proxy_port); | |
218 | |
219 g_snprintf(login_host, sizeof(login_host), "%s", gtk_entry_get_text(GTK_ENTRY(pd->login_host_entry))); | |
220 sscanf(gtk_entry_get_text(GTK_ENTRY(pd->login_port_entry)), "%d", &login_port); | |
221 save_prefs(); | |
222 return TRUE; | |
223 } | |
224 | |
225 | |
226 | |
227 | |
228 static void set_browser(GtkWidget *w, int *data) | |
229 { | |
230 web_browser = (int)data; | |
231 if (web_browser != BROWSER_MANUAL) { | |
232 if (pd->browser_entry) | |
233 gtk_widget_set_sensitive(pd->browser_entry, FALSE); | |
234 } else { | |
235 if (pd->browser_entry) | |
236 gtk_widget_set_sensitive(pd->browser_entry, TRUE); | |
237 } | |
238 | |
239 if (web_browser != BROWSER_NETSCAPE) { | |
240 if (pd->nwbutton) | |
241 gtk_widget_set_sensitive(pd->nwbutton, FALSE); | |
242 } else { | |
243 if (pd->nwbutton) | |
244 gtk_widget_set_sensitive(pd->nwbutton, TRUE); | |
245 } | |
246 | |
247 | |
248 save_prefs(); | |
249 } | |
250 | |
251 static void set_connect(GtkWidget *w, int *data) | |
252 { | |
253 proxy_type = (int)data; | |
254 if (proxy_type == PROXY_HTTP) { | |
255 if (pd->http_proxy_host_entry) | |
256 gtk_widget_set_sensitive(pd->http_proxy_host_entry, TRUE); | |
257 if (pd->http_proxy_port_entry) | |
258 gtk_widget_set_sensitive(pd->http_proxy_port_entry, TRUE); | |
259 | |
260 } else { | |
261 if (pd->http_proxy_host_entry) | |
262 gtk_widget_set_sensitive(pd->http_proxy_host_entry, FALSE); | |
263 if (pd->http_proxy_port_entry) | |
264 gtk_widget_set_sensitive(pd->http_proxy_port_entry, FALSE); | |
265 | |
266 } | |
267 | |
268 save_prefs(); | |
269 } | |
270 | |
271 static void set_idle(GtkWidget *w, int *data) | |
272 { | |
273 report_idle = (int)data; | |
274 save_prefs(); | |
275 } | |
276 | |
277 | |
278 GtkWidget *gaim_button(const char *text, int *options, int option, GtkWidget *page) | |
279 { | |
280 GtkWidget *button; | |
281 button = gtk_check_button_new_with_label(text); | |
282 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (*options & option)); | |
283 gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); | |
284 | |
285 if (options == &font_options) | |
286 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_font_option), (int *)option); | |
287 | |
288 if (options == &sound_options) | |
289 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_sound_option), (int *)option); | |
290 if (options == &display_options) | |
291 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_display_option), (int *)option); | |
292 | |
293 if (options == &general_options) | |
294 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_general_option), (int *)option); | |
295 gtk_widget_show(button); | |
296 | |
297 return button; | |
298 } | |
299 | |
300 | |
301 void build_prefs() | |
302 { | |
303 GtkWidget *bbox; | |
304 GtkWidget *vbox; | |
305 GtkWidget *hbox; | |
306 GtkWidget *hbox2; | |
307 GtkWidget *idlebox; | |
308 GtkWidget *idleframe; | |
309 GtkWidget *genbox; | |
310 GtkWidget *fontbox; | |
311 GtkWidget *fontframe; | |
312 GtkWidget *appbox; | |
313 GtkWidget *away_topbox; | |
314 GtkWidget *away_botbox; | |
315 GtkWidget *add_away; | |
316 GtkWidget *remove_away; | |
317 GtkWidget *close; | |
318 GtkWidget *notebook; | |
319 GtkWidget *sound_page; | |
320 /* GtkWidget *debug_page; */ | |
321 GtkWidget *general_page; | |
322 GtkWidget *appearance_page; | |
323 GtkWidget *chat_page; | |
324 GtkWidget *browser_page; | |
325 GtkWidget *connection_page; | |
326 GtkWidget *label; | |
327 GtkWidget *browseropt; | |
328 GtkWidget *connectopt; | |
329 GtkWidget *idleopt; | |
330 | |
331 GList *awy = away_messages; | |
332 struct away_message *a; | |
333 GtkWidget *sw; | |
334 GtkWidget *sw2; | |
335 GtkWidget *away_page; | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
206
diff
changeset
|
336 GtkWidget *select_font; |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
337 GtkWidget *font_face_for_text; |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
206
diff
changeset
|
338 |
1 | 339 GtkWidget *list_item; |
340 | |
341 gchar buffer[64]; | |
342 | |
343 if (!pd) | |
344 pd = g_new0(struct prefs_data, 1); | |
345 | |
346 pd->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
347 gtk_widget_realize(pd->window); | |
348 aol_icon(pd->window->window); | |
349 gtk_container_border_width(GTK_CONTAINER(pd->window), 10); | |
350 gtk_window_set_title(GTK_WINDOW(pd->window), "Gaim - Preferences"); | |
351 | |
352 vbox = gtk_vbox_new(FALSE, 5); | |
353 gtk_container_add(GTK_CONTAINER(pd->window), vbox); | |
354 | |
355 /* Notebooks */ | |
356 notebook = gtk_notebook_new(); | |
357 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 5); | |
358 | |
359 | |
360 /* General page */ | |
361 general_page = gtk_hbox_new(FALSE, 0); | |
362 label = gtk_label_new("General"); | |
363 gtk_widget_show(label); | |
364 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), general_page, label); | |
365 | |
366 genbox = gtk_vbox_new(FALSE, 5); | |
367 idleframe = gtk_frame_new("Idle"); | |
368 idlebox = gtk_vbox_new(FALSE, 5); | |
369 | |
370 gtk_box_pack_start(GTK_BOX(general_page), genbox, TRUE, TRUE, 5); | |
371 gtk_box_pack_start(GTK_BOX(general_page), idleframe, TRUE, TRUE, 5); | |
372 gtk_container_add(GTK_CONTAINER(idleframe), idlebox); | |
373 | |
374 | |
375 gaim_button("Enter sends message", &general_options, OPT_GEN_ENTER_SENDS, genbox); | |
376 gaim_button("Auto-login", &general_options, OPT_GEN_AUTO_LOGIN, genbox); | |
377 gaim_button("Log All Conversations", &general_options, OPT_GEN_LOG_ALL, genbox); | |
378 gaim_button("Strip HTML from log files", &general_options, OPT_GEN_STRIP_HTML, genbox); | |
379 #ifdef USE_APPLET | |
10 | 380 gaim_button("Automatically Show Buddy List", &general_options, OPT_GEN_APP_BUDDY_SHOW, genbox); |
1 | 381 #endif |
382 gaim_button("Raise windows when message recieved", &general_options, OPT_GEN_POPUP_WINDOWS, genbox); | |
383 gaim_button("Send URLs as links", &general_options, OPT_GEN_SEND_LINKS, genbox); | |
384 gaim_button("Show Lag-O-Meter", &general_options, OPT_GEN_SHOW_LAGMETER, genbox); | |
385 gaim_button("Save some window size/positions", &general_options, OPT_GEN_SAVED_WINDOWS, genbox); | |
386 gaim_button("Ignore new conversations when away", &general_options, OPT_GEN_DISCARD_WHEN_AWAY, genbox); | |
180 | 387 gaim_button("Automagically check for new releases", &general_options, OPT_GEN_CHECK_VERSIONS, genbox); |
206 | 388 gaim_button("Automagically highlight misspelled words", &general_options, OPT_GEN_CHECK_SPELLING, genbox); |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
171
diff
changeset
|
389 if (!dw && (general_options & OPT_GEN_DEBUG)) |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
171
diff
changeset
|
390 general_options = general_options ^ OPT_GEN_DEBUG; |
1 | 391 debugbutton = gaim_button("Enable debug mode", &general_options, OPT_GEN_DEBUG, genbox); |
392 | |
393 | |
394 idleopt = gtk_radio_button_new_with_label(NULL, "No Idle"); | |
395 gtk_box_pack_start(GTK_BOX(idlebox), idleopt, FALSE, FALSE, 0); | |
396 gtk_signal_connect(GTK_OBJECT(idleopt), "clicked", GTK_SIGNAL_FUNC(set_idle), (void *)IDLE_NONE); | |
397 gtk_widget_show(idleopt); | |
398 if (report_idle == IDLE_NONE) | |
399 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(idleopt), TRUE); | |
400 | |
401 idleopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(idleopt)), "GAIM Use"); | |
402 gtk_box_pack_start(GTK_BOX(idlebox), idleopt, FALSE, FALSE, 0); | |
403 gtk_signal_connect(GTK_OBJECT(idleopt), "clicked", GTK_SIGNAL_FUNC(set_idle), (void *)IDLE_GAIM); | |
404 gtk_widget_show(idleopt); | |
405 if (report_idle == IDLE_GAIM) | |
406 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(idleopt), TRUE); | |
407 | |
408 /* idleopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(idleopt)), "X Use"); | |
409 gtk_box_pack_start(GTK_BOX(idlebox), idleopt, FALSE, FALSE, 0); | |
410 gtk_signal_connect(GTK_OBJECT(idleopt), "clicked", GTK_SIGNAL_FUNC(set_idle), (void *)IDLE_SYSTEM); | |
411 gtk_widget_show(idleopt); | |
412 if (report_idle == IDLE_SYSTEM) | |
413 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(idleopt), TRUE); | |
414 */ | |
415 | |
416 gtk_widget_show(general_page); | |
417 gtk_widget_show(genbox); | |
418 gtk_widget_show(idlebox); | |
419 gtk_widget_show(idleframe); | |
420 | |
421 | |
171
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
150
diff
changeset
|
422 gtk_signal_connect_object( GTK_OBJECT(debugbutton), "clicked", GTK_SIGNAL_FUNC(show_debug), NULL); |
1 | 423 |
424 /* Connection */ | |
425 | |
426 connection_page = gtk_vbox_new(FALSE, 0); | |
427 label = gtk_label_new("Connection"); | |
428 gtk_widget_show(label); | |
429 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), connection_page, label); | |
430 | |
431 hbox = gtk_hbox_new(FALSE, 0); | |
432 label = gtk_label_new("TOC Host:"); | |
433 gtk_widget_show(label); | |
434 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
435 pd->aim_host_entry = gtk_entry_new(); | |
436 gtk_widget_show(pd->aim_host_entry); | |
437 gtk_box_pack_start(GTK_BOX(hbox), pd->aim_host_entry, FALSE, FALSE, 0); | |
438 | |
439 label = gtk_label_new("Port:"); | |
440 gtk_widget_show(label); | |
441 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
442 pd->aim_port_entry = gtk_entry_new(); | |
443 gtk_widget_show(pd->aim_port_entry); | |
444 gtk_box_pack_start(GTK_BOX(hbox), pd->aim_port_entry, FALSE, FALSE, 0); | |
445 gtk_widget_show(hbox); | |
446 | |
447 gtk_box_pack_start(GTK_BOX(connection_page), hbox, FALSE, FALSE, 0); | |
448 gtk_entry_set_text(GTK_ENTRY(pd->aim_host_entry), aim_host); | |
449 | |
450 g_snprintf(buffer, sizeof(buffer), "%d", aim_port); | |
451 gtk_entry_set_text(GTK_ENTRY(pd->aim_port_entry), buffer); | |
452 | |
453 hbox2 = gtk_hbox_new(FALSE, 0); | |
454 label = gtk_label_new("Login Host:"); | |
455 gtk_widget_show(label); | |
456 gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 5); | |
457 pd->login_host_entry = gtk_entry_new(); | |
458 gtk_widget_show(pd->login_host_entry); | |
459 gtk_box_pack_start(GTK_BOX(hbox2), pd->login_host_entry, FALSE, FALSE, 0); | |
460 | |
461 label = gtk_label_new("Port:"); | |
462 gtk_widget_show(label); | |
463 gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 5); | |
464 pd->login_port_entry = gtk_entry_new(); | |
465 gtk_widget_show(pd->login_port_entry); | |
466 gtk_box_pack_start(GTK_BOX(hbox2), pd->login_port_entry, FALSE, FALSE, 0); | |
467 gtk_widget_show(hbox2); | |
468 | |
469 gtk_box_pack_start(GTK_BOX(connection_page), hbox2, FALSE, FALSE, 0); | |
470 gtk_entry_set_text(GTK_ENTRY(pd->login_host_entry), login_host); | |
471 | |
472 g_snprintf(buffer, sizeof(buffer), "%d", login_port); | |
473 gtk_entry_set_text(GTK_ENTRY(pd->login_port_entry), buffer); | |
474 | |
475 connectopt = gtk_radio_button_new_with_label(NULL, "No Proxy"); | |
476 gtk_box_pack_start(GTK_BOX(connection_page), connectopt, FALSE, FALSE, 0); | |
477 gtk_signal_connect(GTK_OBJECT(connectopt), "clicked", GTK_SIGNAL_FUNC(set_connect), (void *)PROXY_NONE); | |
478 gtk_widget_show(connectopt); | |
479 if (proxy_type == PROXY_NONE) | |
480 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(connectopt), TRUE); | |
481 | |
482 connectopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(connectopt)), "HTTP Proxy"); | |
483 gtk_box_pack_start(GTK_BOX(connection_page), connectopt, FALSE, FALSE, 0); | |
484 gtk_signal_connect(GTK_OBJECT(connectopt), "clicked", GTK_SIGNAL_FUNC(set_connect), (void *)PROXY_HTTP); | |
485 gtk_widget_show(connectopt); | |
486 if (proxy_type == PROXY_HTTP) | |
487 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(connectopt), TRUE); | |
488 | |
489 | |
490 hbox = gtk_hbox_new(FALSE, 0); | |
491 label = gtk_label_new("Proxy Host:"); | |
492 gtk_widget_show(label); | |
493 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
494 pd->http_proxy_host_entry = gtk_entry_new(); | |
495 gtk_widget_show(pd->http_proxy_host_entry); | |
496 gtk_box_pack_start(GTK_BOX(hbox), pd->http_proxy_host_entry, FALSE, FALSE, 0); | |
497 | |
498 label = gtk_label_new("Port:"); | |
499 gtk_widget_show(label); | |
500 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
501 pd->http_proxy_port_entry = gtk_entry_new(); | |
502 gtk_widget_show(pd->http_proxy_port_entry); | |
503 gtk_box_pack_start(GTK_BOX(hbox), pd->http_proxy_port_entry, FALSE, FALSE, 0); | |
504 gtk_widget_show(hbox); | |
505 | |
506 gtk_box_pack_start(GTK_BOX(connection_page), hbox, FALSE, FALSE, 0); | |
507 gtk_entry_set_text(GTK_ENTRY(pd->http_proxy_host_entry), proxy_host); | |
508 | |
509 g_snprintf(buffer, sizeof(buffer), "%d", proxy_port); | |
510 gtk_entry_set_text(GTK_ENTRY(pd->http_proxy_port_entry), buffer); | |
511 | |
512 | |
513 gtk_widget_show(connection_page); | |
514 | |
515 | |
516 if (proxy_type == PROXY_HTTP) { | |
517 if (pd->http_proxy_host_entry) | |
518 gtk_widget_set_sensitive(pd->http_proxy_host_entry, TRUE); | |
519 if (pd->http_proxy_port_entry) | |
520 gtk_widget_set_sensitive(pd->http_proxy_port_entry, TRUE); | |
521 | |
522 } else { | |
523 if (pd->http_proxy_host_entry) | |
524 gtk_widget_set_sensitive(pd->http_proxy_host_entry, FALSE); | |
525 if (pd->http_proxy_port_entry) | |
526 gtk_widget_set_sensitive(pd->http_proxy_port_entry, FALSE); | |
527 | |
528 } | |
529 | |
530 | |
531 | |
532 gtk_signal_connect(GTK_OBJECT(pd->aim_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL); | |
533 gtk_signal_connect(GTK_OBJECT(pd->aim_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL); | |
534 gtk_signal_connect(GTK_OBJECT(pd->login_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL); | |
535 gtk_signal_connect(GTK_OBJECT(pd->login_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL); | |
536 gtk_signal_connect(GTK_OBJECT(pd->http_proxy_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL); | |
537 gtk_signal_connect(GTK_OBJECT(pd->http_proxy_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL); | |
538 | |
539 | |
540 /* Away */ | |
541 | |
542 a = awaymessage; | |
543 pd->cur_message = NULL; | |
544 pd->nwbutton = NULL; | |
545 pd->browser_entry = NULL; | |
546 | |
547 away_page = gtk_vbox_new(FALSE, 0); | |
548 away_topbox = gtk_hbox_new(FALSE, 0); | |
549 away_botbox = gtk_hbox_new(FALSE, 0); | |
550 | |
551 label = gtk_label_new("Away"); | |
552 gtk_widget_show(label); | |
553 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), away_page, label); | |
554 gtk_widget_show(away_page); | |
555 | |
556 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
557 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
558 GTK_POLICY_AUTOMATIC, | |
559 GTK_POLICY_AUTOMATIC); | |
560 gtk_widget_show(sw2); | |
561 | |
562 pd->away_list = gtk_list_new(); | |
563 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), pd->away_list); | |
564 gtk_box_pack_start(GTK_BOX(away_topbox), sw2, TRUE, TRUE, 0); | |
565 | |
566 sw = gtk_scrolled_window_new(NULL, NULL); | |
567 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
568 GTK_POLICY_AUTOMATIC, | |
569 GTK_POLICY_AUTOMATIC); | |
570 gtk_widget_show(sw); | |
571 | |
572 pd->away_text = gtk_text_new(NULL, NULL); | |
573 gtk_container_add(GTK_CONTAINER(sw), pd->away_text); | |
574 gtk_box_pack_start(GTK_BOX(away_topbox), sw, TRUE, TRUE, 0); | |
575 gtk_text_set_word_wrap(GTK_TEXT(pd->away_text), TRUE); | |
576 gtk_text_set_editable(GTK_TEXT(pd->away_text), TRUE ); | |
577 | |
578 add_away = gtk_button_new_with_label("Create Message"); | |
579 gtk_signal_connect(GTK_OBJECT(add_away), "clicked", GTK_SIGNAL_FUNC(create_away_mess), NULL); | |
580 gtk_box_pack_start(GTK_BOX(away_botbox), add_away, TRUE, FALSE, 5); | |
581 | |
582 remove_away = gtk_button_new_with_label("Remove Message"); | |
583 gtk_signal_connect(GTK_OBJECT(remove_away), "clicked", GTK_SIGNAL_FUNC(remove_away_message), NULL); | |
584 gtk_box_pack_start(GTK_BOX(away_botbox), remove_away, TRUE, FALSE, 5); | |
585 | |
586 gtk_box_pack_start(GTK_BOX(away_page), away_topbox, TRUE, TRUE, 0); | |
587 gtk_box_pack_start(GTK_BOX(away_page), away_botbox, FALSE, FALSE, 0); | |
588 | |
589 gtk_widget_show(add_away); | |
590 gtk_widget_show(remove_away); | |
591 gtk_widget_show(pd->away_list); | |
592 gtk_widget_show(pd->away_text); | |
593 gtk_widget_show(away_topbox); | |
594 gtk_widget_show(away_botbox); | |
595 | |
596 if (awy != NULL) { | |
597 a = (struct away_message *)awy->data; | |
598 g_snprintf(buffer, sizeof(buffer), "%s", a->message); | |
599 gtk_text_insert(GTK_TEXT(pd->away_text), NULL, NULL, NULL, buffer, -1); | |
600 } | |
601 | |
602 while(awy) { | |
603 a = (struct away_message *)awy->data; | |
604 label = gtk_label_new(a->name); | |
605 list_item = gtk_list_item_new(); | |
606 gtk_container_add(GTK_CONTAINER(list_item), label); | |
607 gtk_signal_connect(GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(away_list_clicked), a); | |
608 gtk_signal_connect(GTK_OBJECT(list_item), "deselect", GTK_SIGNAL_FUNC(away_list_unclicked), a); | |
609 gtk_object_set_user_data(GTK_OBJECT(list_item), a); | |
610 | |
611 gtk_widget_show(label); | |
612 gtk_container_add(GTK_CONTAINER(pd->away_list), list_item); | |
613 gtk_widget_show(list_item); | |
614 | |
615 awy = awy->next; | |
616 | |
617 } | |
618 | |
619 /* Sound */ | |
620 sound_page = gtk_vbox_new(FALSE, 0); | |
621 label = gtk_label_new("Sounds"); | |
622 gtk_widget_show(label); | |
623 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sound_page, label); | |
624 gaim_button("Sound when buddy logs in", &sound_options, OPT_SOUND_LOGIN, sound_page); | |
625 gaim_button("Sound when buddy logs out", &sound_options, OPT_SOUND_LOGOUT, sound_page); | |
626 gaim_button("Sound when message is received", &sound_options, OPT_SOUND_RECV, sound_page); | |
627 gaim_button("Sound when message is sent", &sound_options, OPT_SOUND_SEND, sound_page); | |
628 gaim_button("Sound when first message is received", &sound_options, OPT_SOUND_FIRST_RCV, sound_page); | |
629 gaim_button("Sound when message is received if away", &sound_options, OPT_SOUND_WHEN_AWAY, sound_page); | |
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
630 gaim_button("No sound for buddies signed on when you log in", &sound_options, OPT_SOUND_SILENT_SIGNON, sound_page); |
1 | 631 gtk_widget_show(sound_page); |
632 | |
633 | |
634 /* Browser */ | |
635 browser_page = gtk_vbox_new(FALSE, 0); | |
636 | |
637 label = gtk_label_new("Browser"); | |
638 gtk_widget_show(label); | |
639 | |
640 | |
641 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), browser_page, label); | |
642 browseropt = gtk_radio_button_new_with_label(NULL, "Netscape"); | |
643 gtk_box_pack_start(GTK_BOX(browser_page), browseropt, FALSE, FALSE, 0); | |
644 gtk_signal_connect(GTK_OBJECT(browseropt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)BROWSER_NETSCAPE); | |
645 gtk_widget_show(browseropt); | |
646 if (web_browser == BROWSER_NETSCAPE) | |
647 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(browseropt), TRUE); | |
648 | |
649 browseropt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(browseropt)), "KFM (The KDE browser)"); | |
650 gtk_box_pack_start(GTK_BOX(browser_page), browseropt, FALSE, FALSE, 0); | |
651 gtk_signal_connect(GTK_OBJECT(browseropt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)BROWSER_KFM); | |
652 gtk_widget_show(browseropt); | |
653 if (web_browser == BROWSER_KFM) | |
654 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(browseropt), TRUE); | |
655 | |
656 | |
657 browseropt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(browseropt)), "Internal HTML widget (Quite likely a bad idea!)"); | |
658 gtk_box_pack_start(GTK_BOX(browser_page), browseropt, FALSE, FALSE, 0); | |
659 gtk_signal_connect(GTK_OBJECT(browseropt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)BROWSER_INTERNAL); | |
660 gtk_widget_show(browseropt); | |
661 if (web_browser == BROWSER_INTERNAL) | |
662 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(browseropt), TRUE); | |
663 | |
664 | |
665 browseropt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(browseropt)), "Manual"); | |
666 gtk_box_pack_start(GTK_BOX(browser_page), browseropt, FALSE, FALSE, 0); | |
667 gtk_signal_connect(GTK_OBJECT(browseropt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)BROWSER_MANUAL); | |
668 gtk_widget_show(browseropt); | |
669 if (web_browser == BROWSER_MANUAL) | |
670 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(browseropt), TRUE); | |
671 | |
672 | |
673 pd->browser_entry = gtk_entry_new(); | |
674 gtk_widget_show(pd->browser_entry); | |
675 | |
676 gtk_box_pack_start(GTK_BOX(browser_page), pd->browser_entry, FALSE, FALSE, 0); | |
677 gtk_entry_set_text(GTK_ENTRY(pd->browser_entry), web_command); | |
678 | |
679 pd->nwbutton = gaim_button("Pop up new window by default", &general_options, OPT_GEN_BROWSER_POPUP, browser_page); | |
680 gtk_widget_show(browser_page); | |
681 | |
682 gtk_signal_connect(GTK_OBJECT(pd->browser_entry), "focus_out_event", GTK_SIGNAL_FUNC(manualentry_key_pressed), NULL); | |
683 | |
684 | |
685 | |
686 if (web_browser != BROWSER_MANUAL) { | |
687 gtk_widget_set_sensitive(pd->browser_entry, FALSE); | |
688 } else { | |
689 gtk_widget_set_sensitive(pd->browser_entry, TRUE); | |
690 } | |
691 | |
692 if (web_browser != BROWSER_NETSCAPE) { | |
693 gtk_widget_set_sensitive(pd->nwbutton, FALSE); | |
694 } else { | |
695 gtk_widget_set_sensitive(pd->nwbutton, TRUE); | |
696 } | |
697 | |
698 | |
699 | |
700 | |
701 /* Appearance */ | |
702 appearance_page = gtk_hbox_new(FALSE, 0); | |
703 label = gtk_label_new("Appearance"); | |
704 gtk_widget_show(label); | |
705 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), appearance_page, label); | |
706 appbox = gtk_vbox_new(FALSE, 5); | |
707 fontframe = gtk_frame_new("Font Properties"); | |
708 fontbox = gtk_vbox_new(FALSE, 5); | |
709 | |
710 gtk_box_pack_start(GTK_BOX(appearance_page), appbox, TRUE, TRUE, 5); | |
711 gtk_box_pack_start(GTK_BOX(appearance_page), fontframe, TRUE, TRUE, 5); | |
712 gtk_container_add(GTK_CONTAINER(fontframe), fontbox); | |
713 | |
714 gaim_button("Show time on messages", &display_options, OPT_DISP_SHOW_TIME, appbox); | |
715 gaim_button("Show numbers in groups", &display_options, OPT_DISP_SHOW_GRPNUM, appbox ); | |
716 gaim_button("Show buddy-type pixmaps", &display_options, OPT_DISP_SHOW_PIXMAPS, appbox ); | |
717 gaim_button("Show idle times", &display_options, OPT_DISP_SHOW_IDLETIME, appbox ); | |
718 gaim_button("Show button pixmaps", &display_options, OPT_DISP_SHOW_BUTTON_XPM, appbox ); | |
719 gaim_button("Ignore incoming colours", &display_options, OPT_DISP_IGNORE_COLOUR, appbox ); | |
720 #if 0 | |
721 gaim_button("Transparent text window (experimental)", &transparent, appbox ); | |
722 #endif | |
723 gaim_button("Show logon/logoffs in conversation windows", &display_options, OPT_DISP_SHOW_LOGON, appbox ); | |
150
d4e99c17e399
[gaim-migrate @ 160]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
109
diff
changeset
|
724 gaim_button("Use devil icons", &display_options, OPT_DISP_DEVIL_PIXMAPS, appbox ); |
d4e99c17e399
[gaim-migrate @ 160]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
109
diff
changeset
|
725 |
1 | 726 |
727 | |
728 gaim_button("Bold Text", &font_options, OPT_FONT_BOLD, fontbox); | |
729 gaim_button("Italics Text", &font_options, OPT_FONT_ITALIC, fontbox); | |
730 gaim_button("Underlined Text", &font_options, OPT_FONT_UNDERLINE, fontbox); | |
731 gaim_button("Strike Text", &font_options, OPT_FONT_STRIKE, fontbox); | |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
732 font_face_for_text = gaim_button("Font Face for Text", &font_options, OPT_FONT_FACE, fontbox); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
733 |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
206
diff
changeset
|
734 select_font = gtk_button_new_with_label("Select Font"); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
206
diff
changeset
|
735 gtk_box_pack_start(GTK_BOX(fontbox), select_font, FALSE, FALSE, 0); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
206
diff
changeset
|
736 gtk_signal_connect(GTK_OBJECT(select_font), "clicked", GTK_SIGNAL_FUNC(show_font_dialog), NULL); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
737 if (!(font_options & OPT_FONT_FACE)) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
738 gtk_widget_set_sensitive(GTK_WIDGET(select_font), FALSE); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
206
diff
changeset
|
739 gtk_widget_show(select_font); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
740 gtk_signal_connect(GTK_OBJECT(font_face_for_text), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), select_font); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
230
diff
changeset
|
741 |
1 | 742 gtk_widget_show(appearance_page); |
743 gtk_widget_show(fontbox); | |
744 gtk_widget_show(fontframe); | |
745 gtk_widget_show(appbox); | |
746 | |
747 | |
748 /* Buddy Chats */ | |
749 chat_page = gtk_vbox_new(FALSE, 0); | |
750 label = gtk_label_new("Buddy Chats"); | |
751 | |
752 gtk_widget_show(label); | |
753 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), chat_page, label); | |
754 | |
755 do_chat_page(chat_page); | |
756 gtk_widget_show(chat_page); | |
757 | |
758 bbox = gtk_hbox_new(FALSE, 5); | |
759 close = gtk_button_new_with_label("Close"); | |
760 | |
761 /* Pack the button(s) in the button box */ | |
762 gtk_box_pack_end(GTK_BOX(bbox), close, FALSE, FALSE, 5); | |
763 gtk_box_pack_start(GTK_BOX(vbox),bbox, FALSE, FALSE, 5); | |
764 | |
765 gtk_widget_show(notebook); | |
766 gtk_widget_show(close); | |
767 | |
768 gtk_widget_show(bbox); | |
769 gtk_widget_show(vbox); | |
770 | |
771 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(handle_delete), NULL); | |
772 gtk_signal_connect(GTK_OBJECT(pd->window),"delete_event", GTK_SIGNAL_FUNC(handle_delete), NULL); | |
773 | |
774 } | |
775 | |
776 void show_prefs() | |
777 { | |
778 if (!pd || !pd->window) | |
779 build_prefs(); | |
780 gtk_widget_show(pd->window); | |
781 } | |
782 void add_chat(GtkWidget *w, struct chat_page *cp) | |
783 { | |
784 GList *sel = GTK_LIST(cp->list1)->selection; | |
785 struct chat_room *cr, *cr2; | |
786 GList *crs = chat_rooms; | |
787 GtkWidget *item; | |
788 | |
789 if (sel) { | |
790 cr = (struct chat_room *)gtk_object_get_user_data(GTK_OBJECT(sel->data)); | |
791 } else | |
792 return; | |
793 | |
794 while(crs) { | |
795 cr2 = (struct chat_room *)crs->data; | |
796 if (!strcasecmp(cr->name, cr2->name)) | |
797 return; | |
798 crs = crs->next; | |
799 } | |
800 item = gtk_list_item_new_with_label(cr->name); | |
801 cr2 = g_new0(struct chat_room, 1); | |
802 strcpy(cr2->name, cr->name); | |
803 cr2->exchange = cr->exchange; | |
804 gtk_object_set_user_data(GTK_OBJECT(item), cr2); | |
805 gtk_widget_show(item); | |
806 sel = g_list_append(NULL, item); | |
807 gtk_list_append_items(GTK_LIST(cp->list2), sel); | |
808 chat_rooms = g_list_append(chat_rooms, cr2); | |
809 | |
810 setup_buddy_chats(); | |
811 save_prefs(); | |
812 | |
813 | |
814 } | |
815 | |
816 void remove_chat(GtkWidget *w, struct chat_page *cp) | |
817 { | |
818 GList *sel = GTK_LIST(cp->list2)->selection; | |
819 struct chat_room *cr; | |
820 GList *crs; | |
821 GtkWidget *item; | |
822 | |
823 if (sel) { | |
824 item = (GtkWidget *)sel->data; | |
825 cr = (struct chat_room *)gtk_object_get_user_data(GTK_OBJECT(item)); | |
826 } else | |
827 return; | |
828 | |
829 chat_rooms = g_list_remove(chat_rooms, cr); | |
830 | |
831 | |
832 gtk_list_clear_items(GTK_LIST(cp->list2), 0, -1); | |
833 | |
834 if (g_list_length(chat_rooms) == 0) | |
835 chat_rooms = NULL; | |
836 | |
837 crs = chat_rooms; | |
838 | |
839 while(crs) { | |
840 cr = (struct chat_room *)crs->data; | |
841 item = gtk_list_item_new_with_label(cr->name); | |
842 gtk_object_set_user_data(GTK_OBJECT(item), cr); | |
843 gtk_widget_show(item); | |
844 gtk_list_append_items(GTK_LIST(cp->list2), g_list_append(NULL, item)); | |
845 | |
846 | |
847 crs = crs->next; | |
848 } | |
849 | |
850 setup_buddy_chats(); | |
851 save_prefs(); | |
852 } | |
853 | |
854 void refresh_list(GtkWidget *w, struct chat_page *cp) | |
855 { | |
856 char *text = grab_url("http://www.aol.com/community/chat/allchats.html"); | |
857 char *c; | |
858 int len = strlen(text); | |
859 GtkWidget *item; | |
860 GList *items = GTK_LIST(cp->list1)->children; | |
861 struct chat_room *cr; | |
862 c = text; | |
863 | |
864 while(items) { | |
865 g_free(gtk_object_get_user_data(GTK_OBJECT(items->data))); | |
866 items = items->next; | |
867 } | |
868 | |
869 items = NULL; | |
870 | |
871 gtk_list_clear_items(GTK_LIST(cp->list1), 0, -1); | |
872 | |
873 item = gtk_list_item_new_with_label("Gaim Chat"); | |
874 cr = g_new0(struct chat_room, 1); | |
875 strcpy(cr->name, "Gaim Chat"); | |
876 cr->exchange = 4; | |
877 gtk_object_set_user_data(GTK_OBJECT(item), cr); | |
878 gtk_widget_show(item); | |
879 | |
880 items = g_list_append(NULL, item); | |
881 | |
882 while(c) { | |
883 if (c - text > len - 30) | |
884 break; /* assume no chat rooms 30 from end, padding */ | |
885 if (!strncasecmp(AOL_SRCHSTR, c, strlen(AOL_SRCHSTR))) { | |
886 char *t; | |
887 int len=0; | |
888 int exchange; | |
889 char *name = NULL; | |
890 | |
891 c += strlen(AOL_SRCHSTR); | |
892 t = c; | |
893 while(t) { | |
894 len++; | |
895 name = g_realloc(name, len); | |
896 if (*t == '+') | |
897 name[len - 1] = ' '; | |
898 else if (*t == '&') { | |
899 name[len - 1] = 0; | |
900 sscanf(t, "&Exchange=%d", &exchange); | |
901 c = t + strlen("&Exchange=x"); | |
902 break; | |
903 } else | |
904 name[len - 1] = *t; | |
905 t++; | |
906 } | |
907 cr = g_new0(struct chat_room, 1); | |
908 strcpy(cr->name, name); | |
909 cr->exchange = exchange; | |
910 item = gtk_list_item_new_with_label(name); | |
911 gtk_widget_show(item); | |
912 items = g_list_append(items, item); | |
913 gtk_object_set_user_data(GTK_OBJECT(item), cr); | |
914 g_free(name); | |
915 } | |
916 c++; | |
917 } | |
918 gtk_list_append_items(GTK_LIST(cp->list1), items); | |
919 g_free(text); | |
920 } | |
921 | |
922 | |
923 | |
924 void do_chat_page(GtkWidget *page) | |
925 { | |
926 GtkWidget *table; | |
927 GtkWidget *rem_button, *add_button, *ref_button; | |
928 GtkWidget *list1, *list2; | |
929 GtkWidget *label; | |
930 GtkWidget *sw1, *sw2; | |
931 GtkWidget *item; | |
932 struct chat_page *cp = g_new0(struct chat_page, 1); | |
933 GList *crs = chat_rooms; | |
934 GList *items = NULL; | |
935 struct chat_room *cr; | |
936 | |
937 table = gtk_table_new(4, 2, FALSE); | |
938 gtk_widget_show(table); | |
939 | |
940 | |
941 gtk_box_pack_start(GTK_BOX(page), table, TRUE, TRUE, 0); | |
942 | |
943 | |
944 list1 = gtk_list_new(); | |
945 list2 = gtk_list_new(); | |
946 sw1 = gtk_scrolled_window_new(NULL, NULL); | |
947 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
948 ref_button = gtk_button_new_with_label("Refresh"); | |
949 add_button = gtk_button_new_with_label("Add"); | |
950 rem_button = gtk_button_new_with_label("Remove"); | |
951 gtk_widget_show(list1); | |
952 gtk_widget_show(sw1); | |
953 gtk_widget_show(list2); | |
954 gtk_widget_show(sw2); | |
955 gtk_widget_show(ref_button); | |
956 gtk_widget_show(add_button); | |
957 gtk_widget_show(rem_button); | |
958 | |
959 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw1), list1); | |
960 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list2); | |
961 | |
962 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw1), | |
963 GTK_POLICY_AUTOMATIC,GTK_POLICY_ALWAYS); | |
964 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
965 GTK_POLICY_AUTOMATIC,GTK_POLICY_ALWAYS); | |
966 | |
967 cp->list1 = list1; | |
968 cp->list2 = list2; | |
969 | |
970 gtk_signal_connect(GTK_OBJECT(ref_button), "clicked", | |
971 GTK_SIGNAL_FUNC(refresh_list), cp); | |
972 gtk_signal_connect(GTK_OBJECT(rem_button), "clicked", | |
973 GTK_SIGNAL_FUNC(remove_chat), cp); | |
974 gtk_signal_connect(GTK_OBJECT(add_button), "clicked", | |
975 GTK_SIGNAL_FUNC(add_chat), cp); | |
976 | |
977 | |
978 | |
979 label = gtk_label_new("List of available chats"); | |
980 gtk_widget_show(label); | |
981 | |
982 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, | |
983 GTK_SHRINK, GTK_SHRINK, 0, 0); | |
984 gtk_table_attach(GTK_TABLE(table), ref_button, 0, 1, 1, 2, | |
985 GTK_SHRINK, GTK_SHRINK, 0, 0); | |
986 gtk_table_attach(GTK_TABLE(table), sw1, 0, 1, 2, 3, | |
987 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, | |
988 5, 5); | |
989 gtk_table_attach(GTK_TABLE(table), add_button, 0, 1, 3, 4, | |
990 GTK_SHRINK, GTK_SHRINK, 0, 0); | |
991 | |
992 | |
993 label = gtk_label_new("List of subscribed chats"); | |
994 gtk_widget_show(label); | |
995 | |
996 gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, | |
997 GTK_SHRINK, GTK_SHRINK, 0, 0); | |
998 gtk_table_attach(GTK_TABLE(table), sw2, 1, 2, 2, 3, | |
999 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, | |
1000 5, 5); | |
1001 gtk_table_attach(GTK_TABLE(table), rem_button, 1, 2, 3, 4, | |
1002 GTK_SHRINK, GTK_SHRINK, 0, 0); | |
1003 | |
1004 | |
1005 item = gtk_list_item_new_with_label("Gaim Chat"); | |
1006 cr = g_new0(struct chat_room, 1); | |
1007 strcpy(cr->name, "Gaim Chat"); | |
1008 cr->exchange = 4; | |
1009 gtk_object_set_user_data(GTK_OBJECT(item), cr); | |
1010 gtk_widget_show(item); | |
1011 gtk_list_append_items(GTK_LIST(list1), g_list_append(NULL, item)); | |
1012 | |
1013 | |
1014 while(crs) { | |
1015 cr = (struct chat_room *)crs->data; | |
1016 item = gtk_list_item_new_with_label(cr->name); | |
1017 gtk_object_set_user_data(GTK_OBJECT(item), cr); | |
1018 gtk_widget_show(item); | |
1019 items = g_list_append(items, item); | |
1020 | |
1021 crs = crs->next; | |
1022 } | |
1023 | |
1024 gtk_list_append_items(GTK_LIST(list2), items); | |
1025 } | |
1026 | |
1027 | |
1028 | |
1029 | |
1030 | |
1031 void debug_print(char *chars) | |
1032 { | |
18 | 1033 if(general_options & OPT_GEN_DEBUG && dw) |
1 | 1034 gtk_text_insert(GTK_TEXT(dw->entry),NULL, NULL, NULL, chars, strlen(chars)); |
1035 #ifdef DEBUG | |
1036 printf("%s\n", chars); | |
1037 #endif | |
1038 } | |
1039 | |
1040 | |
1041 void build_debug() | |
1042 { | |
1043 GtkWidget *scroll; | |
1044 GtkWidget *box; | |
1045 if (!dw) | |
1046 dw = g_new0(struct debug_window, 1); | |
1047 | |
1048 box = gtk_hbox_new(FALSE,0); | |
1049 dw->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1050 gtk_window_set_title(GTK_WINDOW(dw->window), "GAIM debug output window"); | |
1051 gtk_container_add(GTK_CONTAINER(dw->window), box); | |
1052 dw->entry = gtk_text_new(NULL,NULL); | |
1053 gtk_widget_set_usize(dw->entry, 500, 200); | |
1054 scroll = gtk_vscrollbar_new(GTK_TEXT(dw->entry)->vadj); | |
1055 gtk_box_pack_start(GTK_BOX(box), dw->entry, TRUE,TRUE,0); | |
1056 gtk_box_pack_end(GTK_BOX(box), scroll,FALSE,FALSE,0); | |
1057 gtk_widget_show(dw->entry); | |
1058 gtk_widget_show(scroll); | |
1059 gtk_widget_show(box); | |
1060 gtk_signal_connect(GTK_OBJECT(dw->window),"delete_event", GTK_SIGNAL_FUNC(debug_delete), NULL); | |
1061 gtk_widget_show(dw->window); | |
1062 } | |
1063 | |
1064 | |
1065 | |
1066 void show_debug(GtkObject * object) | |
1067 { | |
1068 if((general_options & OPT_GEN_DEBUG)) { | |
1069 if(!dw || !dw->window) | |
1070 build_debug(); | |
1071 gtk_widget_show(dw->window); | |
1072 } else { | |
171
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
150
diff
changeset
|
1073 if (!dw) return; |
1 | 1074 gtk_widget_destroy(dw->window); |
1075 dw->window = NULL; | |
1076 } | |
1077 } | |
1078 |