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