changeset 652:4d3285caa191

[gaim-migrate @ 662] damn i'm smooth committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 10 Aug 2000 00:29:06 +0000
parents 650687b7ca0e
children c8a3bf382108
files src/away.c src/dialogs.c src/gaim.h src/prefs.c
diffstat 4 files changed, 1246 insertions(+), 1020 deletions(-) [+]
line wrap: on
line diff
--- a/src/away.c	Wed Aug 09 15:06:00 2000 +0000
+++ b/src/away.c	Thu Aug 10 00:29:06 2000 +0000
@@ -41,7 +41,7 @@
 extern enum gaim_user_states MRI_user_status;
 #endif
 
-GtkWidget *awaymenu;
+GtkWidget *awaymenu = NULL;
 struct away_message *awaymessage = NULL;
 
 static void destroy_im_away()
@@ -95,6 +95,9 @@
         GList *cnv = conversations;
         struct conversation *c;
 
+	if (!blist)
+		return;
+
 #ifdef USE_APPLET
 	remove_applet_away();
         applet_widget_register_callback(APPLET_WIDGET(applet),
@@ -159,6 +162,7 @@
         } else {
 		destroy_im_away();
 		do_away_message(w, a);
+		return;
 	}
 
         /* New away message... Clear out the old sent_aways */
@@ -233,8 +237,8 @@
 		insert_applet_away();
 #endif
 
-	if (pd != NULL) {
-                gtk_list_clear_items(GTK_LIST(pd->away_list), 0, -1);
+	if (prefs_away_list != NULL) {
+                gtk_list_clear_items(GTK_LIST(prefs_away_list), 0, -1);
 		while(awy) {
 			a = (struct away_message *)awy->data;
 			label = gtk_label_new(a->name);
@@ -245,16 +249,16 @@
 			gtk_object_set_user_data(GTK_OBJECT(list_item), a);
 
 			gtk_widget_show(label);
-			gtk_container_add(GTK_CONTAINER(pd->away_list), list_item);
+			gtk_container_add(GTK_CONTAINER(prefs_away_list), list_item);
 			gtk_widget_show(list_item);
 
 			awy = awy->next;
 		}
 		if (away_messages != NULL)
-                        gtk_list_select_item(GTK_LIST(pd->away_list), 0);
+                        gtk_list_select_item(GTK_LIST(prefs_away_list), 0);
 	}
 	
-        
+	if (!awaymenu) return;
 	l = gtk_container_children(GTK_CONTAINER(awaymenu));
 	
 	while(l) {
--- a/src/dialogs.c	Wed Aug 09 15:06:00 2000 +0000
+++ b/src/dialogs.c	Thu Aug 10 00:29:06 2000 +0000
@@ -2732,8 +2732,8 @@
                 away_messages = g_list_append(away_messages, b);
                 save_prefs();
                 do_away_menu();
-                if (pd != NULL)
-                        gtk_list_select_item(GTK_LIST(pd->away_list), g_list_index(away_messages, b));
+                if (prefs_away_list != NULL)
+                        gtk_list_select_item(GTK_LIST(prefs_away_list), g_list_index(away_messages, b));
 	}
 
 	/* stick it on the away list */
--- a/src/gaim.h	Wed Aug 09 15:06:00 2000 +0000
+++ b/src/gaim.h	Thu Aug 10 00:29:06 2000 +0000
@@ -113,7 +113,6 @@
 #endif
 #endif
 
-extern struct prefs_data *pd;
 extern struct debug_window *dw;
 
 struct aim_user {
@@ -131,23 +130,6 @@
         int yoff;
 };
 
-struct prefs_data {
-        GtkWidget *window;
-        GtkWidget *away_list;
-        struct away_message *cur_message;
-        GtkWidget *away_text;
-        char *edited_message;
-        GtkWidget *browser_entry;
-        GtkWidget *nwbutton;
-        GtkWidget *aim_host_entry;
-        GtkWidget *aim_port_entry;
-        GtkWidget *login_host_entry;
-        GtkWidget *login_port_entry;
-        GtkWidget *proxy_host_entry;
-        GtkWidget *proxy_port_entry;
-
-};
-
 
 struct option_set {
         int *options;
@@ -408,7 +390,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 633 $"
+#define REVISION "gaim:$Revision: 662 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -747,6 +729,8 @@
 extern void set_general_option(GtkWidget *, int *);
 extern void set_option(GtkWidget *, int *);
 extern void show_prefs();
+extern void show_debug(GtkObject *);
+extern GtkWidget *prefs_away_list;
 
 /* Functions in gaimrc.c */
 extern void set_defaults();
--- a/src/prefs.c	Wed Aug 09 15:06:00 2000 +0000
+++ b/src/prefs.c	Thu Aug 10 00:29:06 2000 +0000
@@ -41,66 +41,1187 @@
 #include "pixmaps/gnome_add.xpm"
 #include "pixmaps/gnome_remove.xpm"
 
-struct prefs_data *pd = NULL;
 struct debug_window *dw = NULL;
+static GtkWidget *prefs = NULL;
 
-GtkWidget *debugbutton;
+static GtkWidget *gaim_button(const char *, int *, int, GtkWidget *);
+static void prefs_build_general(GtkWidget *);
+static void prefs_build_connect(GtkWidget *);
+static void prefs_build_buddy(GtkWidget *);
+static void prefs_build_convo(GtkWidget *);
+static void prefs_build_sound(GtkWidget *);
+static void prefs_build_away(GtkWidget *);
+static void prefs_build_browser(GtkWidget *);
+static gint handle_delete(GtkWidget *, GdkEvent *, void *);
+
+static GtkWidget *prefdialog = NULL;
+static GtkWidget *debugbutton = NULL;
+GtkWidget *prefs_away_list = NULL;
+
+static void general_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+	GtkWidget *sep;
+	GtkWidget *idle;
+	
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("General Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	gaim_button(_("Remember password"), &general_options, OPT_GEN_REMEMBER_PASS, box);
+	gaim_button(_("Auto-login"), &general_options, OPT_GEN_AUTO_LOGIN, box);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+	gaim_button(_("Show Lagometer"), &general_options, OPT_GEN_SHOW_LAGMETER, box);
+	gaim_button(_("Use borderless buttons (requires restart for some buttons)"), &display_options, OPT_DISP_COOL_LOOK, box);
+	gaim_button(_("Show Buddy Ticker after restart"), &display_options, OPT_DISP_SHOW_BUDDYTICKER, box);
+	if (!dw && (general_options & OPT_GEN_DEBUG))
+		general_options = general_options ^ OPT_GEN_DEBUG;
+	debugbutton = gaim_button(_("Show Debug Window"), &general_options, OPT_GEN_DEBUG, box);
+	gtk_signal_connect_object(GTK_OBJECT(debugbutton), "clicked", GTK_SIGNAL_FUNC(show_debug), 0);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+	idle = gaim_button(_("Report Idle Times"), &report_idle, 1, box);
+	gtk_signal_connect(GTK_OBJECT(idle), "clicked", set_option, &report_idle);
+
+	gtk_widget_show(prefdialog);
+}
+
+static GtkWidget *aim_host_entry;
+static GtkWidget *aim_port_entry;
+static GtkWidget *login_host_entry;
+static GtkWidget *login_port_entry;
+static GtkWidget *proxy_host_entry;
+static GtkWidget *proxy_port_entry;
+
+static int connection_key_pressed(GtkWidget *w, GdkEvent *event, void *dummy)
+{
+	g_snprintf(aim_host, sizeof(aim_host), "%s", gtk_entry_get_text(GTK_ENTRY(aim_host_entry)));
+	sscanf(gtk_entry_get_text(GTK_ENTRY(aim_port_entry)), "%d", &aim_port);
+	g_snprintf(login_host, sizeof(login_host), "%s", gtk_entry_get_text(GTK_ENTRY(login_host_entry)));
+	sscanf(gtk_entry_get_text(GTK_ENTRY(login_port_entry)), "%d", &login_port);
+	if (proxy_type != PROXY_NONE) {
+		g_snprintf(proxy_host, sizeof(proxy_host), "%s", gtk_entry_get_text(GTK_ENTRY(proxy_host_entry)));
+		sscanf(gtk_entry_get_text(GTK_ENTRY(proxy_port_entry)), "%d", &proxy_port);
+	}
+	save_prefs();
+	return TRUE;
+}
+
+static void set_connect(GtkWidget *w, int *data)
+{
+        proxy_type = (int)data;
+        if (proxy_type != PROXY_NONE) {
+                if (proxy_host_entry)
+                        gtk_widget_set_sensitive(proxy_host_entry, TRUE);
+                if (proxy_port_entry)
+                        gtk_widget_set_sensitive(proxy_port_entry, TRUE);
+        } else {
+                if (proxy_host_entry)
+                        gtk_widget_set_sensitive(proxy_host_entry, FALSE);
+                if (proxy_port_entry)
+                        gtk_widget_set_sensitive(proxy_port_entry, FALSE);
+        }
+
+        save_prefs();
+}
+
+static GtkWidget *connect_radio(char *label, int which, GtkWidget *box, GtkWidget *set)
+{
+	GtkWidget *opt;
+
+	if (!set)
+		opt = gtk_radio_button_new_with_label(NULL, label);
+	else
+		opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(set)), label);
+	gtk_box_pack_start(GTK_BOX(box), opt, FALSE, FALSE, 0);
+	gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(set_connect), (void *)which);
+	gtk_widget_show(opt);
+	if (web_browser == which)
+		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE);
+
+	return opt;
+}
+
+static void connect_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+	GtkWidget *sep;
+	GtkWidget *hbox;
+	GtkWidget *opt;
+	char buffer[1024];
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Connection Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	gaim_button(_("Use Oscar Protocol (experimental; only takes effect before signon)"), &general_options, OPT_GEN_USE_OSCAR, box);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+	label = gtk_label_new(_("The following options do not apply if you use Oscar."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("TOC Host:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	aim_host_entry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(hbox), aim_host_entry, FALSE, FALSE, 0);
+	gtk_entry_set_text(GTK_ENTRY(aim_host_entry), aim_host);
+	gtk_signal_connect(GTK_OBJECT(aim_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
+	gtk_widget_show(aim_host_entry);
+
+	label = gtk_label_new(_("Port:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	aim_port_entry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(hbox), aim_port_entry, FALSE, FALSE, 0);
+	g_snprintf(buffer, sizeof(buffer), "%d", aim_port);
+	gtk_entry_set_text(GTK_ENTRY(aim_port_entry), buffer);
+	gtk_signal_connect(GTK_OBJECT(aim_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
+	gtk_widget_show(aim_port_entry);
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("Login Host:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	login_host_entry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(hbox), login_host_entry, FALSE, FALSE, 0);
+	gtk_entry_set_text(GTK_ENTRY(login_host_entry), login_host);
+	gtk_signal_connect(GTK_OBJECT(login_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
+	gtk_widget_show(login_host_entry);
+
+	label = gtk_label_new(_("Port:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	login_port_entry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(hbox), login_port_entry, FALSE, FALSE, 0);
+	g_snprintf(buffer, sizeof(buffer), "%d", login_port);
+	gtk_entry_set_text(GTK_ENTRY(login_port_entry), buffer);
+	gtk_signal_connect(GTK_OBJECT(login_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
+	gtk_widget_show(login_port_entry);
+
+	opt = connect_radio(_("No Proxy"), PROXY_NONE, box, NULL);
+	opt = connect_radio(_("HTTP Proxy"), PROXY_HTTP, box, opt);
+	opt = connect_radio(_("Socks 4 Proxy"), PROXY_SOCKS4, box, opt);
+	opt = connect_radio(_("Socks 5 Proxy"), PROXY_SOCKS5, box, opt);
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("Proxy Host:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	proxy_host_entry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(hbox), proxy_host_entry, FALSE, FALSE, 0);
+	gtk_entry_set_text(GTK_ENTRY(proxy_host_entry), proxy_host);
+	gtk_signal_connect(GTK_OBJECT(proxy_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
+	gtk_widget_show(proxy_host_entry);
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("Port:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	proxy_port_entry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(hbox), proxy_port_entry, FALSE, FALSE, 0);
+	g_snprintf(buffer, sizeof(buffer), "%d", proxy_port);
+	gtk_entry_set_text(GTK_ENTRY(proxy_port_entry), buffer);
+	gtk_signal_connect(GTK_OBJECT(proxy_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
+	gtk_widget_show(proxy_port_entry);
+
+	if (proxy_type != PROXY_NONE) {
+		gtk_widget_set_sensitive(proxy_host_entry, TRUE);
+		gtk_widget_set_sensitive(proxy_port_entry, TRUE);
+	} else {
+		gtk_widget_set_sensitive(proxy_host_entry, FALSE);
+		gtk_widget_set_sensitive(proxy_port_entry, FALSE);
+	}
+
+	gtk_widget_show(prefdialog);
+}
+
+static void buddy_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Buddy List Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	gaim_button(_("Show numbers in groups"), &display_options, OPT_DISP_SHOW_GRPNUM, box);
+	gaim_button(_("Show idle times"), &display_options, OPT_DISP_SHOW_IDLETIME, box);
+	gaim_button(_("Show buddy type icons"), &display_options, OPT_DISP_SHOW_PIXMAPS, box);
+	gaim_button(_("Show pictures on buttons"), &display_options, OPT_DISP_SHOW_BUTTON_XPM, box);
+	gaim_button(_("Use Daemon pictures"), &display_options, OPT_DISP_DEVIL_PIXMAPS, box);
+
+	gtk_widget_show(prefdialog);
+}
+
+static void convo_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+	GtkWidget *sep;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Conversation Window Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	gaim_button(_("Enter sends message"), &general_options, OPT_GEN_ENTER_SENDS, box);
+	gaim_button(_("Control-{B/I/U/S} inserts HTML tags"), &general_options, OPT_GEN_CTL_CHARS, box);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+	gaim_button(_("Show graphical smileys"), &display_options, OPT_DISP_SHOW_SMILEY, box);
+	gaim_button(_("Ignore incoming colors"), &display_options, OPT_DISP_IGNORE_COLOUR, box);
+	gaim_button(_("Show timestamp on messages"), &display_options, OPT_DISP_SHOW_TIME, box);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+	gaim_button(_("Highlight misspelled words"), &general_options, OPT_GEN_CHECK_SPELLING, box);
+	gaim_button(_("Show URLs as links"), &general_options, OPT_GEN_SEND_LINKS, box);
+	gaim_button(_("Sending messages removes away status"), &general_options, OPT_GEN_BACK_ON_IM, box);
+
+	gtk_widget_show(prefdialog);
+}
+
+static void im_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("IM Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	gaim_button(_("Show logins in window"), &display_options, OPT_DISP_SHOW_LOGON, box);
+	gaim_button(_("Raise windows on events"), &general_options, OPT_GEN_POPUP_WINDOWS, box);
+	gaim_button(_("Ignore new conversations when away"), &general_options, OPT_GEN_DISCARD_WHEN_AWAY, box);
+
+	gtk_widget_show(prefdialog);
+}
+
+static void chat_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Chat Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	gaim_button(_("Show people joining/leaving in window"), &display_options, OPT_DISP_CHAT_LOGON, box);
+	gaim_button(_("Raise windows on events"), &general_options, OPT_GEN_POPUP_CHAT, box);
+
+	gtk_widget_show(prefdialog);
+}
 
 struct chat_page {
 	GtkWidget *list1;
 	GtkWidget *list2;
 };
 
+static struct chat_page *cp = NULL;
 
-char debug_buff[BUF_LONG];
+static refresh_list(GtkWidget *w, gpointer *m)
+{
+        char *text = grab_url("http://www.aol.com/community/chat/allchats.html");
+        char *c;
+        int len = strlen(text);
+        GtkWidget *item;
+        GList *items = GTK_LIST(cp->list1)->children;
+        struct chat_room *cr;
+        c = text;
 
-void do_chat_page(GtkWidget *page);
+        while(items) {
+                g_free(gtk_object_get_user_data(GTK_OBJECT(items->data)));
+                items = items->next;
+        }
+
+        items = NULL;
+
+        gtk_list_clear_items(GTK_LIST(cp->list1), 0, -1);
+
+        item = gtk_list_item_new_with_label(_("Gaim Chat"));
+        cr = g_new0(struct chat_room, 1);
+        strcpy(cr->name, _("Gaim Chat"));
+        cr->exchange = 4;
+        gtk_object_set_user_data(GTK_OBJECT(item), cr);
+        gtk_widget_show(item);
+
+        items = g_list_append(NULL, item);
 
-void list_clicked( GtkWidget *widget, struct away_message *a);
-void list_unclicked( GtkWidget *widget, struct away_message *a);
+        while(c) {
+                if (c - text > len - 30)
+                        break; /* assume no chat rooms 30 from end, padding */
+                if (!strncasecmp(AOL_SRCHSTR, c, strlen(AOL_SRCHSTR))) {
+                        char *t;
+                        int len=0;
+                        int exchange;
+                        char *name = NULL;
 
-void show_debug(GtkObject *);
+                        c += strlen(AOL_SRCHSTR);
+                        t = c;
+                        while(t) {
+                                len++;
+                                name = g_realloc(name, len);
+                                if (*t == '+')
+                                        name[len - 1] = ' ';
+                                else if (*t == '&') {
+                                        name[len - 1] = 0;
+                                        sscanf(t, "&Exchange=%d", &exchange);
+                                        c = t + strlen("&Exchange=x");
+                                        break;
+                                } else
+                                        name[len - 1] = *t;
+                                t++;
+                        }
+                        cr = g_new0(struct chat_room, 1);
+                        strcpy(cr->name, name);
+                        cr->exchange = exchange;
+                        item = gtk_list_item_new_with_label(name);
+                        gtk_widget_show(item);
+                        items = g_list_append(items, item);
+                        gtk_object_set_user_data(GTK_OBJECT(item), cr);
+                        g_free(name);
+                }
+                c++;
+        }
+        gtk_list_append_items(GTK_LIST(cp->list1), items);
+        g_free(text);
+}
 
-void remove_away_message(GtkWidget *widget, void *dummy)
+static void add_chat(GtkWidget *w, gpointer *m)
 {
-	GList *i;
-	struct away_message *a;
+        GList *sel = GTK_LIST(cp->list1)->selection;
+        struct chat_room *cr, *cr2;
+        GList *crs = chat_rooms;
+        GtkWidget *item;
+
+        if (sel) {
+                cr = (struct chat_room *)gtk_object_get_user_data(GTK_OBJECT(sel->data));
+        } else
+                return;
+
+        while(crs) {
+                cr2 = (struct chat_room *)crs->data;
+                if (!strcasecmp(cr->name, cr2->name))
+                        return;
+                crs = crs->next;
+        }
+        item = gtk_list_item_new_with_label(cr->name);
+        cr2 = g_new0(struct chat_room, 1);
+        strcpy(cr2->name, cr->name);
+        cr2->exchange = cr->exchange;
+        gtk_object_set_user_data(GTK_OBJECT(item), cr2);
+        gtk_widget_show(item);
+        sel = g_list_append(NULL, item);
+        gtk_list_append_items(GTK_LIST(cp->list2), sel);
+        chat_rooms = g_list_append(chat_rooms, cr2);
+
+        setup_buddy_chats();
+        save_prefs();
+
+
+}
 
-	i = GTK_LIST(pd->away_list)->selection;
+static void remove_chat(GtkWidget *w, gpointer *m)
+{
+        GList *sel = GTK_LIST(cp->list2)->selection;
+        struct chat_room *cr;
+        GList *crs;
+        GtkWidget *item;
+
+        if (sel) {
+                item = (GtkWidget *)sel->data;
+                cr = (struct chat_room *)gtk_object_get_user_data(GTK_OBJECT(item));
+        } else
+                return;
+
+        chat_rooms = g_list_remove(chat_rooms, cr);
+
+
+        gtk_list_clear_items(GTK_LIST(cp->list2), 0, -1);
 
-	a = gtk_object_get_user_data(GTK_OBJECT(i->data));
+        if (g_list_length(chat_rooms) == 0)
+                chat_rooms = NULL;
+
+        crs = chat_rooms;
 
-	rem_away_mess(NULL, a);
+        while(crs) {
+                cr = (struct chat_room *)crs->data;
+                item = gtk_list_item_new_with_label(cr->name);
+                gtk_object_set_user_data(GTK_OBJECT(item), cr);
+                gtk_widget_show(item);
+                gtk_list_append_items(GTK_LIST(cp->list2), g_list_append(NULL, item));
+
+
+                crs = crs->next;
+        }
+
+        setup_buddy_chats();
+        save_prefs();
 }
 
-void away_list_clicked( GtkWidget *widget, struct away_message *a)
+static void room_page()
+{
+        GtkWidget *table;
+        GtkWidget *rem_button, *add_button, *ref_button;
+        GtkWidget *list1, *list2;
+        GtkWidget *label;
+        GtkWidget *sw1, *sw2;
+        GtkWidget *item;
+        GList *crs = chat_rooms;
+        GList *items = NULL;
+        struct chat_room *cr;
+
+	GtkWidget *parent;
+	GtkWidget *box;
+
+	if (!cp)
+		g_free(cp);
+	cp = g_new0(struct chat_page, 1);
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Chat Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+        table = gtk_table_new(4, 2, FALSE);
+        gtk_widget_show(table);
+
+        gtk_box_pack_start(GTK_BOX(box), table, TRUE, TRUE, 0);
+
+        list1 = gtk_list_new();
+        list2 = gtk_list_new();
+        sw1 = gtk_scrolled_window_new(NULL, NULL);
+        sw2 = gtk_scrolled_window_new(NULL, NULL);
+
+        ref_button = picture_button(prefs, _("Refresh"), refresh_xpm);
+        add_button = picture_button(prefs, _("Add"), gnome_add_xpm);
+        rem_button = picture_button(prefs, _("Remove"), gnome_remove_xpm);
+        gtk_widget_show(list1);
+        gtk_widget_show(sw1);
+        gtk_widget_show(list2);
+        gtk_widget_show(sw2);
+
+        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw1), list1);
+        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list2);
+
+        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw1),
+                                       GTK_POLICY_AUTOMATIC,GTK_POLICY_ALWAYS);
+        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2),
+                                       GTK_POLICY_AUTOMATIC,GTK_POLICY_ALWAYS);
+
+        cp->list1 = list1;
+        cp->list2 = list2;
+
+        gtk_signal_connect(GTK_OBJECT(ref_button), "clicked",
+                           GTK_SIGNAL_FUNC(refresh_list), cp);
+        gtk_signal_connect(GTK_OBJECT(rem_button), "clicked",
+                           GTK_SIGNAL_FUNC(remove_chat), cp);
+        gtk_signal_connect(GTK_OBJECT(add_button), "clicked",
+                           GTK_SIGNAL_FUNC(add_chat), cp);
+
+
+
+        label = gtk_label_new(_("List of available chats"));
+        gtk_widget_show(label);
+
+        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
+                         GTK_SHRINK, GTK_SHRINK, 0, 0);
+        gtk_table_attach(GTK_TABLE(table), ref_button, 0, 1, 1, 2,
+                         GTK_SHRINK, GTK_SHRINK, 0, 0);
+        gtk_table_attach(GTK_TABLE(table), sw1, 0, 1, 2, 3,
+                         GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
+                         5, 5);
+        gtk_table_attach(GTK_TABLE(table), add_button, 0, 1, 3, 4,
+                         GTK_SHRINK, GTK_SHRINK, 0, 0);
+
+
+        label = gtk_label_new(_("List of subscribed chats"));
+        gtk_widget_show(label);
+
+        gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1,
+                         GTK_SHRINK, GTK_SHRINK, 0, 0);
+        gtk_table_attach(GTK_TABLE(table), sw2, 1, 2, 2, 3,
+                         GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
+                         5, 5);
+        gtk_table_attach(GTK_TABLE(table), rem_button, 1, 2, 3, 4,
+                         GTK_SHRINK, GTK_SHRINK, 0, 0);
+
+
+        item = gtk_list_item_new_with_label(_("Gaim Chat"));
+        cr = g_new0(struct chat_room, 1);
+        strcpy(cr->name, _("Gaim Chat"));
+        cr->exchange = 4;
+        gtk_object_set_user_data(GTK_OBJECT(item), cr);
+        gtk_widget_show(item);
+        gtk_list_append_items(GTK_LIST(list1), g_list_append(NULL, item));
+
+
+        while(crs) {
+                cr = (struct chat_room *)crs->data;
+                item = gtk_list_item_new_with_label(cr->name);
+                gtk_object_set_user_data(GTK_OBJECT(item), cr);
+                gtk_widget_show(item);
+                items = g_list_append(items, item);
+
+                crs = crs->next;
+        }
+
+        gtk_list_append_items(GTK_LIST(list2), items);
+
+	gtk_widget_show(prefdialog);
+}
+
+static void font_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+	GtkWidget *sep;
+	GtkWidget *hbox;
+	GtkWidget *button;
+	GtkWidget *select;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Font Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+        gaim_button(_("Bold Text"), &font_options, OPT_FONT_BOLD, box);
+        gaim_button(_("Italics Text"), &font_options, OPT_FONT_ITALIC, box);
+        gaim_button(_("Underlined Text"), &font_options, OPT_FONT_UNDERLINE, box);
+        gaim_button(_("Strike Text"), &font_options, OPT_FONT_STRIKE, box);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+/*
+	label = gtk_label_new(_("FIXME : This is where bg/fg color should go"));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+*/
+
+	hbox = gtk_hbox_new(FALSE, 5);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
+	gtk_widget_show(hbox);
+
+	button = gaim_button(_("Font Face for Text"), &font_options, OPT_FONT_FACE, hbox);
+
+	select = picture_button(prefs, _("Select"), fontface2_xpm);
+	gtk_box_pack_start(GTK_BOX(hbox), select, FALSE, FALSE, 0);
+	if (!(font_options & OPT_FONT_FACE))
+		gtk_widget_set_sensitive(GTK_WIDGET(select), FALSE);
+	gtk_signal_connect(GTK_OBJECT(select), "clicked", GTK_SIGNAL_FUNC(show_font_dialog), NULL);
+	gtk_widget_show(select);
+
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), select);
+
+	gtk_widget_show(prefdialog);
+}
+
+static void sound_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Sound Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+#ifdef USE_GNOME
+	gaim_button(_("Sounds go through GNOME"), &sound_options, OPT_SOUND_THROUGH_GNOME, box);
+#endif
+	gaim_button(_("No sounds when you log in"), &sound_options, OPT_SOUND_SILENT_SIGNON, box);
+	gaim_button(_("Sounds while away"), &sound_options, OPT_SOUND_WHEN_AWAY, box);
+
+	gtk_widget_show(prefdialog);
+}
+
+static void event_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+	GtkWidget *sep;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Sound Events"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	gaim_button(_("Sound when buddy logs in"), &sound_options, OPT_SOUND_LOGIN, box);
+	gaim_button(_("Sound when buddy logs out"), &sound_options, OPT_SOUND_LOGOUT, box);
+	gaim_button(_("Sound when message is received"), &sound_options, OPT_SOUND_RECV, box);
+	gaim_button(_("Sound when message is first received"), &sound_options, OPT_SOUND_FIRST_RCV, box);
+	gaim_button(_("Sound when message is sent"), &sound_options, OPT_SOUND_SEND, box);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+	gaim_button(_("Sound in chat rooms when people enter/leave"), &sound_options, OPT_SOUND_CHAT_JOIN, box);
+	gaim_button(_("Sound in chat rooms when people talk"), &sound_options, OPT_SOUND_CHAT_SAY, box);
+
+	gtk_widget_show(prefdialog);
+}
+
+static struct away_message *cur_message;
+static char *edited_message;
+static GtkWidget *away_text;
+
+void away_list_clicked(GtkWidget *widget, struct away_message *a)
 {
 	gchar buffer[2048];
 	guint text_len;
 
-	pd->cur_message = a;
+	cur_message = a;
 
 	/* Get proper Length */
-	text_len = gtk_text_get_length(GTK_TEXT(pd->away_text));
-	pd->edited_message = gtk_editable_get_chars(GTK_EDITABLE(pd->away_text), 0, text_len);
+	text_len = gtk_text_get_length(GTK_TEXT(away_text));
+	edited_message = gtk_editable_get_chars(GTK_EDITABLE(away_text), 0, text_len);
 
 	/* Clear the Box */
-	gtk_text_set_point(GTK_TEXT(pd->away_text), 0 );
-	gtk_text_forward_delete (GTK_TEXT(pd->away_text), text_len); 
+	gtk_text_set_point(GTK_TEXT(away_text), 0 );
+	gtk_text_forward_delete (GTK_TEXT(away_text), text_len);
 
 	/* Fill the text box with new message */
 	strcpy(buffer, a->message);
-	gtk_text_insert(GTK_TEXT(pd->away_text), NULL, NULL, NULL, buffer, -1);
+	gtk_text_insert(GTK_TEXT(away_text), NULL, NULL, NULL, buffer, -1);
+}
+
+void away_list_unclicked(GtkWidget *widget, struct away_message *a)
+{
+	if (prefs_away_list == NULL)
+		return;
+	strcpy(a->message, edited_message);
+	save_prefs();
+}
+
+void remove_away_message(GtkWidget *widget, void *dummy)
+{
+        GList *i;
+        struct away_message *a;
+
+        i = GTK_LIST(prefs_away_list)->selection;
+
+        a = gtk_object_get_user_data(GTK_OBJECT(i->data));
+
+        rem_away_mess(NULL, a);
+}
+
+static void away_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *top;
+	GtkWidget *bot;
+	GtkWidget *sw;
+	GtkWidget *sw2;
+	GtkWidget *button;
+	GtkWidget *label;
+	GtkWidget *list_item;
+	GList *awy = away_messages;
+	struct away_message *a;
+	char buffer[BUF_LONG];
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Away Messages"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	top = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), top, TRUE, TRUE, 0);
+	gtk_widget_show(top);
+
+	sw = gtk_scrolled_window_new(NULL, NULL);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
+			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+	gtk_box_pack_start(GTK_BOX(top), sw, TRUE, TRUE, 0);
+	gtk_widget_show(sw);
+
+	prefs_away_list = gtk_list_new();
+	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), prefs_away_list);
+	gtk_widget_show(prefs_away_list);
+
+	sw2 = gtk_scrolled_window_new(NULL, NULL);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2),
+			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+	gtk_box_pack_start(GTK_BOX(top), sw2, TRUE, TRUE, 0);
+	gtk_widget_show(sw2);
+
+	away_text = gtk_text_new(NULL, NULL);
+	gtk_container_add(GTK_CONTAINER(sw2), away_text);
+	gtk_text_set_word_wrap(GTK_TEXT(away_text), TRUE);
+	gtk_text_set_editable(GTK_TEXT(away_text), TRUE);
+	gtk_widget_show(away_text);
+
+	bot = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), bot, FALSE, FALSE, 0);
+	gtk_widget_show(bot);
+
+	button = picture_button(prefs, _("Add"), gnome_add_xpm);
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(create_away_mess), NULL);
+	gtk_box_pack_start(GTK_BOX(bot), button, TRUE, FALSE, 5);
+
+	button = picture_button(prefs, _("Remove"), gnome_remove_xpm);
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(remove_away_message), NULL);
+	gtk_box_pack_start(GTK_BOX(bot), button, TRUE, FALSE, 5);
+
+	if (awy != NULL) {
+		a = (struct away_message *)awy->data;
+		g_snprintf(buffer, sizeof(buffer), "%s", a->message);
+		gtk_text_insert(GTK_TEXT(away_text), NULL, NULL, NULL, buffer, -1);
+	}
+
+	while (awy) {
+		a = (struct away_message *)awy->data;
+		label = gtk_label_new(a->name);
+		list_item = gtk_list_item_new();
+                gtk_container_add(GTK_CONTAINER(list_item), label);
+                gtk_signal_connect(GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(away_list_clicked), a);
+                gtk_signal_connect(GTK_OBJECT(list_item), "deselect", GTK_SIGNAL_FUNC(away_list_unclicked), a);
+                gtk_object_set_user_data(GTK_OBJECT(list_item), a);
+
+                gtk_widget_show(label);
+                gtk_container_add(GTK_CONTAINER(prefs_away_list), list_item);
+                gtk_widget_show(list_item);
+
+                awy = awy->next;
+        }
+
+	gtk_widget_show(prefdialog);
+}
+
+static GtkWidget *browser_entry = NULL;
+static GtkWidget *new_window = NULL;
+
+static void set_browser(GtkWidget *w, int *data)
+{
+	web_browser = (int)data;
+        if (web_browser != BROWSER_MANUAL) {
+                if (browser_entry)
+                        gtk_widget_set_sensitive(browser_entry, FALSE);
+        } else {
+                if (browser_entry)
+                        gtk_widget_set_sensitive(browser_entry, TRUE);
+        }
+
+        if (web_browser != BROWSER_NETSCAPE) {
+                if (new_window)
+                        gtk_widget_set_sensitive(new_window, FALSE);
+        } else {
+                if (new_window)
+                        gtk_widget_set_sensitive(new_window, TRUE);
+        }
+
+
+        save_prefs();
+}
+
+static int manualentry_key_pressed(GtkWidget *w, GdkEvent *event, void *dummy)
+{
+	g_snprintf(web_command, sizeof(web_command), "%s", gtk_entry_get_text(GTK_ENTRY(browser_entry)));
+	save_prefs();
+	return TRUE;
+}
+
+static GtkWidget *browser_radio(char *label, int which, GtkWidget *box, GtkWidget *set)
+{
+	GtkWidget *opt;
 
+	if (!set)
+		opt = gtk_radio_button_new_with_label(NULL, label);
+	else
+		opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(set)), label);
+	gtk_box_pack_start(GTK_BOX(box), opt, FALSE, FALSE, 0);
+	gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)which);
+	gtk_widget_show(opt);
+	if (web_browser == which)
+		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE);
+
+	return opt;
+}
+
+static void browser_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+	GtkWidget *opt;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+	debugbutton = NULL;
+	prefs_away_list = NULL;
+
+	prefdialog = gtk_frame_new(_("Browser Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	opt = browser_radio(_("Netscape"), BROWSER_NETSCAPE, box, NULL);
+	opt = browser_radio(_("KFM"), BROWSER_KFM, box, opt);
+	opt = browser_radio(_("Internal HTML Widget (Quite likely a bad idea!)"), BROWSER_INTERNAL, box, opt);
+	opt = browser_radio(_("Manual"), BROWSER_MANUAL, box, opt);
+
+	browser_entry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(box), browser_entry, FALSE, FALSE, 0);
+	gtk_entry_set_text(GTK_ENTRY(browser_entry), web_command);
+	gtk_signal_connect(GTK_OBJECT(browser_entry), "focus_out_event", GTK_SIGNAL_FUNC(manualentry_key_pressed), NULL);
+	gtk_widget_show(browser_entry);
+
+	new_window = gaim_button(_("Pop up new window by default"), &general_options, OPT_GEN_BROWSER_POPUP, box);
+
+        if (web_browser != BROWSER_MANUAL) {
+                gtk_widget_set_sensitive(browser_entry, FALSE);
+        } else {
+                gtk_widget_set_sensitive(browser_entry, TRUE);
+        }
+
+        if (web_browser != BROWSER_NETSCAPE) {
+                gtk_widget_set_sensitive(new_window, FALSE);
+        } else {
+                gtk_widget_set_sensitive(new_window, TRUE);
+        }
+
+	gtk_widget_show(prefdialog);
+}
+
+static void try_me(GtkCTree *ctree, GtkCTreeNode *node)
+{
+	/* this is a hack */
+	void (*func)();
+	func = gtk_ctree_node_get_row_data(ctree, node);
+	(*func)();
+}
+
+void show_prefs()
+{
+	GtkWidget *vbox;
+	GtkWidget *hpaned;
+	GtkWidget *scroll;
+	GtkWidget *preftree;
+	GtkWidget *container;
+	GtkWidget *hbox;
+	GtkWidget *close;
+
+	if (prefs) {
+		gtk_widget_show(prefs);
+		return;
+	}
+
+	prefs = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	gtk_widget_realize(prefs);
+	aol_icon(prefs->window);
+	gtk_container_border_width(GTK_CONTAINER(prefs), 10);
+	gtk_window_set_title(GTK_WINDOW(prefs), _("Gaim - Preferences"));
+	gtk_widget_set_usize(prefs, 600, 400);
+
+	vbox = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefs), vbox);
+	gtk_widget_show(vbox);
+
+	hpaned = gtk_hpaned_new();
+	gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 5);
+	gtk_widget_show(hpaned);
+	
+       	scroll = gtk_scrolled_window_new(NULL, NULL);
+	gtk_paned_pack1(GTK_PANED(hpaned), scroll, TRUE, TRUE);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
+			GTK_POLICY_NEVER, GTK_POLICY_NEVER);
+	gtk_widget_set_usize(scroll, 125, -1);
+	gtk_widget_show(scroll);
+
+	preftree = gtk_ctree_new(1, 0);
+	gtk_ctree_set_line_style (GTK_CTREE(preftree), GTK_CTREE_LINES_SOLID);
+        gtk_ctree_set_expander_style(GTK_CTREE(preftree), GTK_CTREE_EXPANDER_TRIANGLE);
+	gtk_clist_set_reorderable(GTK_CLIST(preftree), FALSE);
+	gtk_container_add(GTK_CONTAINER(scroll), preftree);
+	gtk_signal_connect(GTK_OBJECT(preftree), "tree_select_row", GTK_SIGNAL_FUNC(try_me), NULL);
+	gtk_widget_show(preftree);
+
+	prefs_build_general(preftree);
+	prefs_build_connect(preftree);
+	prefs_build_buddy(preftree);
+	prefs_build_convo(preftree);
+	prefs_build_sound(preftree);
+	prefs_build_away(preftree);
+	prefs_build_browser(preftree);
+
+	container = gtk_frame_new(NULL);
+	gtk_container_set_border_width(GTK_CONTAINER(container), 0);
+	gtk_frame_set_shadow_type(GTK_FRAME(container), GTK_SHADOW_NONE);
+	gtk_paned_pack2(GTK_PANED(hpaned), container, TRUE, TRUE);
+	gtk_widget_show(container);
+
+	prefdialog = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(container), prefdialog);
+	gtk_widget_show(prefdialog);
+
+	general_page();
+
+	hbox = gtk_hbox_new(FALSE, 5);
+	gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+	gtk_widget_show(hbox);
+
+	close = picture_button(prefs, _("Close"), cancel_xpm);
+	gtk_box_pack_end(GTK_BOX(hbox), close, FALSE, FALSE, 5);
+	gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(handle_delete), NULL);
+
+	gtk_widget_show(prefs);
+}
+
+char debug_buff[BUF_LONG];
+
+static gint debug_delete(GtkWidget *w, GdkEvent *event, void *dummy)
+{
+	if (debugbutton)
+		gtk_button_clicked(GTK_BUTTON(debugbutton));
+        if (general_options & OPT_GEN_DEBUG)
+        {
+                general_options = general_options ^ (int)OPT_GEN_DEBUG;
+                save_prefs();
+        }
+        g_free(dw);
+        dw=NULL;
+        return FALSE;
 
 }
 
-void away_list_unclicked( GtkWidget *widget, struct away_message *a)
+static void build_debug()
+{
+	GtkWidget *scroll;
+	GtkWidget *box;
+	if (!dw)
+		dw = g_new0(struct debug_window, 1);
+
+	box = gtk_hbox_new(FALSE,0);
+	dw->window = gtk_window_new(GTK_WINDOW_DIALOG);
+	gtk_window_set_title(GTK_WINDOW(dw->window), _("GAIM debug output window"));
+	gtk_container_add(GTK_CONTAINER(dw->window), box);
+	dw->entry = gtk_text_new(NULL,NULL);
+	gtk_widget_set_usize(dw->entry, 500, 200);
+	scroll = gtk_vscrollbar_new(GTK_TEXT(dw->entry)->vadj);
+	gtk_box_pack_start(GTK_BOX(box), dw->entry, TRUE,TRUE,0);
+	gtk_box_pack_end(GTK_BOX(box), scroll,FALSE,FALSE,0);
+	gtk_widget_show(dw->entry);
+	gtk_widget_show(scroll);
+	gtk_widget_show(box);
+	gtk_signal_connect(GTK_OBJECT(dw->window),"delete_event", GTK_SIGNAL_FUNC(debug_delete), NULL);
+	gtk_widget_show(dw->window);
+}
+
+void show_debug(GtkObject *obj)
 {
-        if (pd == NULL)
-                return;
-	strcpy(a->message, pd->edited_message);
+	if((general_options & OPT_GEN_DEBUG)) {
+                if(!dw || !dw->window)
+                        build_debug();
+                gtk_widget_show(dw->window);
+        } else {
+		if (!dw) return;
+                gtk_widget_destroy(dw->window);
+                dw->window = NULL;
+	}
+}
+
+void debug_print(char *chars)
+{
+	if (general_options & OPT_GEN_DEBUG && dw)
+		gtk_text_insert(GTK_TEXT(dw->entry), NULL, NULL, NULL, chars, strlen(chars));
+#ifdef DEBUG
+        printf("%s\n", chars);
+#endif
+}
+
+static gint handle_delete(GtkWidget *w, GdkEvent *event, void *dummy)
+{
 	save_prefs();
+
+	if (cp)
+		g_free(cp);
+	cp = NULL;
+
+	if (event == NULL)
+		gtk_widget_destroy(prefs);
+	prefs = NULL;
+	prefdialog = NULL;
+	debugbutton = NULL;
+	
+        return FALSE;
 }
 
 void set_option(GtkWidget *w, int *option)
@@ -108,6 +1229,17 @@
 	*option = !(*option);
 }
 
+void set_general_option(GtkWidget *w, int *option)
+{
+	general_options = general_options ^ (int)option;
+
+       	if ((int)option == OPT_GEN_SHOW_LAGMETER)
+       		update_lagometer(-1);
+       	if ((int)option == OPT_GEN_LOG_ALL)
+       		update_log_convs();
+	save_prefs();
+}
+
 void set_display_option(GtkWidget *w, int *option)
 {
         display_options = display_options ^ (int)option;
@@ -136,154 +1268,6 @@
 	save_prefs();
 }
 
-void set_general_option(GtkWidget *w, int *option)
-{
-	general_options = general_options ^ (int)option;
-
-       	if ((int)option == OPT_GEN_SHOW_LAGMETER)
-       		update_lagometer(-1);
-       	if ((int)option == OPT_GEN_LOG_ALL)
-       		update_log_convs();
-	save_prefs();
-
-	/*
-        if (data == &show_grp_nums)
-		update_num_groups();
-	if (data == &showidle || data == &showpix)
-		update_show_idlepix();
-	if (data == &button_pix && blist)
-                update_button_pix();
-        if (data == &transparent)
-                update_transparency();
-          */
-        
-}
-
-
-static gint debug_delete(GtkWidget *w, GdkEvent *event, void *dummy)
-{
-	if (debugbutton)
-		gtk_button_clicked(GTK_BUTTON(debugbutton));
-	if (general_options & OPT_GEN_DEBUG)
-	{
-		general_options = general_options ^ (int)OPT_GEN_DEBUG;
-		save_prefs();
-	}
-	g_free(dw);
-	dw=NULL;
-	return FALSE;
-
-}
-
-static gint handle_delete(GtkWidget *w, GdkEvent *event, void *dummy)
-{
-	guint text_len;
-	struct away_message *a;
-
-
-        if (pd->cur_message) {
-        
-		a = pd->cur_message;
-
-
-		/* Get proper Length and grab data */
-		text_len = gtk_text_get_length(GTK_TEXT(pd->away_text));
-		pd->edited_message = gtk_editable_get_chars(GTK_EDITABLE(pd->away_text), 0, text_len);
-
-		/* Store the data for later use */
-		strcpy(a->message, pd->edited_message);
-
-	}
-	
-	save_prefs();
-
-	if (event == NULL)
-	{
-		gtk_widget_destroy(pd->window);
-		debugbutton=NULL;
-	}
-	g_free(pd);
-	pd = NULL;
-
-	
-        return FALSE;
-}
-
-static int
-manualentry_key_pressed(GtkWidget *w, GdkEvent *event, void *dummy)
-{
-        g_snprintf(web_command, sizeof(web_command), "%s", gtk_entry_get_text(GTK_ENTRY(pd->browser_entry)));
-        save_prefs();
-	return TRUE;
-}
-
-static int
-connection_key_pressed(GtkWidget *w, GdkEvent *event, void *dummy)
-{
-	g_snprintf(aim_host, sizeof(aim_host), "%s", gtk_entry_get_text(GTK_ENTRY(pd->aim_host_entry)));
-	sscanf(gtk_entry_get_text(GTK_ENTRY(pd->aim_port_entry)), "%d", &aim_port);
-	if (proxy_type != PROXY_NONE) {
-		g_snprintf(proxy_host, sizeof(proxy_host), "%s", gtk_entry_get_text(GTK_ENTRY(pd->proxy_host_entry)));
-		sscanf(gtk_entry_get_text(GTK_ENTRY(pd->proxy_port_entry)), "%d", &proxy_port);
-	}
-
-	g_snprintf(login_host, sizeof(login_host), "%s", gtk_entry_get_text(GTK_ENTRY(pd->login_host_entry)));
-	sscanf(gtk_entry_get_text(GTK_ENTRY(pd->login_port_entry)), "%d", &login_port);	
-	save_prefs();
-	return TRUE;
-}
-
-
-
-                   
-static void set_browser(GtkWidget *w, int *data)
-{
-	web_browser = (int)data;
-        if (web_browser != BROWSER_MANUAL) {
-                if (pd->browser_entry)
-                        gtk_widget_set_sensitive(pd->browser_entry, FALSE);
-        } else {
-                if (pd->browser_entry)
-                        gtk_widget_set_sensitive(pd->browser_entry, TRUE);
-        }
-        
-        if (web_browser != BROWSER_NETSCAPE) {
-                if (pd->nwbutton)
-                        gtk_widget_set_sensitive(pd->nwbutton, FALSE);
-        } else {
-                if (pd->nwbutton)
-                        gtk_widget_set_sensitive(pd->nwbutton, TRUE);
-        }
-        
-
-        save_prefs();
-}
-
-static void set_connect(GtkWidget *w, int *data)
-{
-	proxy_type = (int)data;
-	if (proxy_type != PROXY_NONE) {
-                if (pd->proxy_host_entry)
-                        gtk_widget_set_sensitive(pd->proxy_host_entry, TRUE);
-		if (pd->proxy_port_entry)
-			gtk_widget_set_sensitive(pd->proxy_port_entry, TRUE);
-	} else {
-                if (pd->proxy_host_entry)
-                        gtk_widget_set_sensitive(pd->proxy_host_entry, FALSE);
-		if (pd->proxy_port_entry)
-			gtk_widget_set_sensitive(pd->proxy_port_entry, FALSE);
-	}
-        
-        save_prefs();
-}
-
-static void set_idle(GtkWidget *w, int *data)
-{
-	report_idle = (int)data;
-        save_prefs();
-}
-
-
 GtkWidget *gaim_button(const char *text, int *options, int option, GtkWidget *page)
 {
 	GtkWidget *button;
@@ -306,850 +1290,104 @@
 	return button;
 }
 
-
-void build_prefs()
+void prefs_build_general(GtkWidget *preftree)
 {
-	GtkWidget *bbox;
-	GtkWidget *vbox;
-        GtkWidget *idlebox;
-        GtkWidget *idleframe;
-        GtkWidget *genbox;
-	GtkWidget *fontbox;
-	GtkWidget *fontframe;
-	GtkWidget *appbox;
-	GtkWidget *away_topbox;
-	GtkWidget *away_botbox;
-	GtkWidget *add_away;
-	GtkWidget *remove_away;
-	GtkWidget *close;
-	GtkWidget *notebook;
-	GtkWidget *sound_page;
-	/* GtkWidget *debug_page; */
-	GtkWidget *general_page;
-	GtkWidget *appearance_page;
-	GtkWidget *chat_page;
-        GtkWidget *browser_page;
-        GtkWidget *connection_page;
-        GtkWidget *connectopt;
-	GtkWidget *hbox;
-        GtkWidget *hbox2;
-#ifdef USE_APPLET
-	GtkWidget *applet_page;
-	GtkWidget *appletbox;
-#endif
-        GtkWidget *label;
-        GtkWidget *browseropt;
-        GtkWidget *idleopt;
-	        
-        GList *awy = away_messages;
-        struct away_message *a;
-        GtkWidget *sw;
-	GtkWidget *sw2;
-	GtkWidget *away_page;
-	GtkWidget *select_font;
-	GtkWidget *font_face_for_text;
-	GtkWidget *list_item;
-	gchar buffer[64];
-
-	if (!pd)
-                pd = g_new0(struct prefs_data, 1);
-
-	pd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-	gtk_widget_realize(pd->window);
-	aol_icon(pd->window->window);
-	gtk_container_border_width(GTK_CONTAINER(pd->window), 10);
-	gtk_window_set_title(GTK_WINDOW(pd->window), _("Gaim - Preferences"));
-	
-        vbox = gtk_vbox_new(FALSE, 5);
-        gtk_container_add(GTK_CONTAINER(pd->window), vbox);
-
-	/* Notebooks */
-	notebook = gtk_notebook_new();
-	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 5);
-
-
-	/* General page */
-	general_page = gtk_hbox_new(FALSE, 0);
-	label = gtk_label_new(_("General"));
-	gtk_widget_show(label);
-        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), general_page, label);
-
-        genbox = gtk_vbox_new(FALSE, 5);
-        idleframe = gtk_frame_new(_("Idle"));
-        idlebox = gtk_vbox_new(FALSE, 5);
-
-        gtk_box_pack_start(GTK_BOX(general_page), genbox, TRUE, TRUE, 5);
-        gtk_box_pack_start(GTK_BOX(general_page), idleframe, TRUE, TRUE, 5);
-        gtk_container_add(GTK_CONTAINER(idleframe), idlebox);
-
-        
-	gaim_button(_("Enter sends message"), &general_options, OPT_GEN_ENTER_SENDS, genbox);
-	gaim_button(_("Control characters for HTML (e.g. Ctrl-I for italics)"), &general_options, OPT_GEN_CTL_CHARS, genbox);
-	gaim_button(_("Auto-login"), &general_options, OPT_GEN_AUTO_LOGIN, genbox);
-	gaim_button(_("Log All Conversations"), &general_options, OPT_GEN_LOG_ALL, genbox);
-	gaim_button(_("Strip HTML from log files"), &general_options, OPT_GEN_STRIP_HTML, genbox);
-	gaim_button(_("Raise windows when message recieved"), &general_options, OPT_GEN_POPUP_WINDOWS, genbox);
-	gaim_button(_("Raise chat windows when people speak"), &general_options, OPT_GEN_POPUP_CHAT, genbox);
-        gaim_button(_("Show URLs as links"), &general_options, OPT_GEN_SEND_LINKS, genbox);
-	gaim_button(_("Show Lag-O-Meter"), &general_options, OPT_GEN_SHOW_LAGMETER, genbox);
-        gaim_button(_("Save some window size/positions"), &general_options, OPT_GEN_SAVED_WINDOWS, genbox);
-        gaim_button(_("Ignore new conversations when away"), &general_options, OPT_GEN_DISCARD_WHEN_AWAY, genbox);
-	gaim_button(_("Automagically highlight misspelled words"), &general_options, OPT_GEN_CHECK_SPELLING, genbox);
-	gaim_button(_("Sending messages removes away status"), &general_options, OPT_GEN_BACK_ON_IM, genbox);
-	if (!dw && (general_options & OPT_GEN_DEBUG))
-		general_options = general_options ^ OPT_GEN_DEBUG;
-        debugbutton = gaim_button(_("Enable debug mode"), &general_options, OPT_GEN_DEBUG, genbox);
-
-
-        idleopt = gtk_radio_button_new_with_label(NULL, _("No Idle"));
-        gtk_box_pack_start(GTK_BOX(idlebox), idleopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(idleopt), "clicked", GTK_SIGNAL_FUNC(set_idle), (void *)IDLE_NONE);
-	gtk_widget_show(idleopt);
-        if (report_idle == IDLE_NONE)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(idleopt), TRUE);
-
-        idleopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(idleopt)), _("GAIM Use"));
-        gtk_box_pack_start(GTK_BOX(idlebox), idleopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(idleopt), "clicked", GTK_SIGNAL_FUNC(set_idle), (void *)IDLE_GAIM);
-	gtk_widget_show(idleopt);
-        if (report_idle == IDLE_GAIM)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(idleopt), TRUE);
-
-/*        idleopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(idleopt)), "X Use");
-        gtk_box_pack_start(GTK_BOX(idlebox), idleopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(idleopt), "clicked", GTK_SIGNAL_FUNC(set_idle), (void *)IDLE_SYSTEM);
-	gtk_widget_show(idleopt);
-        if (report_idle == IDLE_SYSTEM)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(idleopt), TRUE);
-*/
-        
-        gtk_widget_show(general_page);
-        gtk_widget_show(genbox);
-        gtk_widget_show(idlebox);
-        gtk_widget_show(idleframe);
-
-
-        gtk_signal_connect_object( GTK_OBJECT(debugbutton), "clicked", GTK_SIGNAL_FUNC(show_debug), NULL);
-
-
-	/* Applet */
-#ifdef USE_APPLET
+	GtkCTreeNode *parent;
+	char *text[1];
 
-	applet_page = gtk_vbox_new(FALSE, 0);
-	label = gtk_label_new(_("Applet"));
-	gtk_widget_show(label);
-	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), applet_page, label);
-
-        appletbox = gtk_vbox_new(FALSE, 5);
-        gtk_box_pack_start(GTK_BOX(applet_page), appletbox, TRUE, TRUE, 5);
-
-	gaim_button(_("Automatically Show Buddy List"), &general_options, OPT_GEN_APP_BUDDY_SHOW, appletbox);
-	gaim_button(_("Buddy list displays near the applet"), &general_options, OPT_GEN_NEAR_APPLET, appletbox);
-
-	gtk_widget_show(appletbox);
-	gtk_widget_show(applet_page);
-
-#endif
-	
-
-        /* Connection */
-        
-        connection_page = gtk_vbox_new(FALSE, 0);
-        label = gtk_label_new(_("Connection"));
-        gtk_widget_show(label);
-	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), connection_page, label);
-
-	gaim_button(_("Use Oscar Protocol (experimental; only takes effect before signon)"), &general_options, OPT_GEN_USE_OSCAR, connection_page);
-	label = gtk_label_new(_("The following options do not apply if you use Oscar."));
-	gtk_box_pack_start(GTK_BOX(connection_page), label, FALSE, FALSE, 10);
-	gtk_widget_show(label);
-	hbox = gtk_hbox_new(FALSE, 0);
-	label = gtk_label_new(_("TOC Host:"));
-	gtk_widget_show(label);
-	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-        pd->aim_host_entry = gtk_entry_new();
-        gtk_widget_show(pd->aim_host_entry);
-	gtk_box_pack_start(GTK_BOX(hbox), pd->aim_host_entry, FALSE, FALSE, 0);
-
-	label = gtk_label_new(_("Port:"));
-	gtk_widget_show(label);
-	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-        pd->aim_port_entry = gtk_entry_new();
-        gtk_widget_show(pd->aim_port_entry);
-	gtk_box_pack_start(GTK_BOX(hbox), pd->aim_port_entry, FALSE, FALSE, 0);
-	gtk_widget_show(hbox);
-	
-	gtk_box_pack_start(GTK_BOX(connection_page), hbox, FALSE, FALSE, 0);
-	gtk_entry_set_text(GTK_ENTRY(pd->aim_host_entry), aim_host);
-
-	g_snprintf(buffer, sizeof(buffer), "%d", aim_port);
-	gtk_entry_set_text(GTK_ENTRY(pd->aim_port_entry), buffer);
-        
-        hbox2 = gtk_hbox_new(FALSE, 0);
-        label = gtk_label_new(_("Login Host:"));
-        gtk_widget_show(label);
-        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 5);
-        pd->login_host_entry = gtk_entry_new();
-        gtk_widget_show(pd->login_host_entry);
-        gtk_box_pack_start(GTK_BOX(hbox2), pd->login_host_entry, FALSE, FALSE, 0);
+	text[0] = _("General");
+	parent = gtk_ctree_insert_node(GTK_CTREE(preftree), NULL, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), parent, general_page);
+}
 
-        label = gtk_label_new(_("Port:"));
-        gtk_widget_show(label);
-        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 5);
-        pd->login_port_entry = gtk_entry_new();
-        gtk_widget_show(pd->login_port_entry);
-        gtk_box_pack_start(GTK_BOX(hbox2), pd->login_port_entry, FALSE, FALSE, 0);
-        gtk_widget_show(hbox2);
-
-        gtk_box_pack_start(GTK_BOX(connection_page), hbox2, FALSE, FALSE, 0);
-        gtk_entry_set_text(GTK_ENTRY(pd->login_host_entry), login_host);
-
-        g_snprintf(buffer, sizeof(buffer), "%d", login_port);
-        gtk_entry_set_text(GTK_ENTRY(pd->login_port_entry), buffer);
-
-        connectopt = gtk_radio_button_new_with_label(NULL, _("No Proxy"));
-        gtk_box_pack_start(GTK_BOX(connection_page), connectopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(connectopt), "clicked", GTK_SIGNAL_FUNC(set_connect), (void *)PROXY_NONE);
-	gtk_widget_show(connectopt);
-        if (proxy_type == PROXY_NONE)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(connectopt), TRUE);
-
-        connectopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(connectopt)), _("HTTP Proxy"));
-        gtk_box_pack_start(GTK_BOX(connection_page), connectopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(connectopt), "clicked", GTK_SIGNAL_FUNC(set_connect), (void *)PROXY_HTTP);
-	gtk_widget_show(connectopt);
-	if (proxy_type == PROXY_HTTP)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(connectopt), TRUE);
-
-
-        connectopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(connectopt)), _("SOCKS v4 Proxy"));
-        gtk_box_pack_start(GTK_BOX(connection_page), connectopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(connectopt), "clicked", GTK_SIGNAL_FUNC(set_connect), (void *)PROXY_SOCKS4);
-	gtk_widget_show(connectopt);
-	if (proxy_type == PROXY_SOCKS4)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(connectopt), TRUE);
-
-
-        connectopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(connectopt)), _("SOCKS v5 Proxy (DOES NOT WORK!)"));
-        gtk_box_pack_start(GTK_BOX(connection_page), connectopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(connectopt), "clicked", GTK_SIGNAL_FUNC(set_connect), (void *)PROXY_SOCKS5);
-	gtk_widget_show(connectopt);
-	if (proxy_type == PROXY_SOCKS5)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(connectopt), TRUE);
-
-
-	hbox = gtk_hbox_new(FALSE, 0);
-	label = gtk_label_new(_("Proxy Host:"));
-	gtk_widget_show(label);
-	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-        pd->proxy_host_entry = gtk_entry_new();
-        gtk_widget_show(pd->proxy_host_entry);
-	gtk_box_pack_start(GTK_BOX(hbox), pd->proxy_host_entry, FALSE, FALSE, 0);
-
-	label = gtk_label_new(_("Port:"));
-	gtk_widget_show(label);
-	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-        pd->proxy_port_entry = gtk_entry_new();
-        gtk_widget_show(pd->proxy_port_entry);
-	gtk_box_pack_start(GTK_BOX(hbox), pd->proxy_port_entry, FALSE, FALSE, 0);
-	gtk_widget_show(hbox);
-	
-	gtk_box_pack_start(GTK_BOX(connection_page), hbox, FALSE, FALSE, 0);
-	gtk_entry_set_text(GTK_ENTRY(pd->proxy_host_entry), proxy_host);
-
-	g_snprintf(buffer, sizeof(buffer), "%d", proxy_port);
-	gtk_entry_set_text(GTK_ENTRY(pd->proxy_port_entry), buffer);
-
-
-	gtk_widget_show(connection_page);
-
+void prefs_build_connect(GtkWidget *preftree)
+{
+	GtkCTreeNode *parent;
+	char *text[1];
 
-	if (proxy_type != PROXY_NONE) {
-                if (pd->proxy_host_entry)
-                        gtk_widget_set_sensitive(pd->proxy_host_entry, TRUE);
-		if (pd->proxy_port_entry)
-			gtk_widget_set_sensitive(pd->proxy_port_entry, TRUE);
-	} else {
-                if (pd->proxy_host_entry)
-                        gtk_widget_set_sensitive(pd->proxy_host_entry, FALSE);
-		if (pd->proxy_port_entry)
-			gtk_widget_set_sensitive(pd->proxy_port_entry, FALSE);
-	}
-
-	
-
-	gtk_signal_connect(GTK_OBJECT(pd->aim_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
-        gtk_signal_connect(GTK_OBJECT(pd->aim_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
-	gtk_signal_connect(GTK_OBJECT(pd->login_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
-	gtk_signal_connect(GTK_OBJECT(pd->login_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
-	gtk_signal_connect(GTK_OBJECT(pd->proxy_host_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
-        gtk_signal_connect(GTK_OBJECT(pd->proxy_port_entry), "focus_out_event", GTK_SIGNAL_FUNC(connection_key_pressed), NULL);
-
-
-	/* Away */
-	
-        a = awaymessage;
-        pd->cur_message = NULL;
-        pd->nwbutton = NULL;
-        pd->browser_entry = NULL;
-        
-	away_page = gtk_vbox_new(FALSE, 0);
-	away_topbox = gtk_hbox_new(FALSE, 0);
-	away_botbox = gtk_hbox_new(FALSE, 0);
-
-	label = gtk_label_new(_("Away"));
-	gtk_widget_show(label);
-	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), away_page, label);
-	gtk_widget_show(away_page);
-
-	sw2 = gtk_scrolled_window_new(NULL, NULL);
-    	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2),
-				       GTK_POLICY_AUTOMATIC,
-				       GTK_POLICY_AUTOMATIC);
-	gtk_widget_show(sw2);
-
-	pd->away_list = gtk_list_new();
-	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), pd->away_list);
-	gtk_box_pack_start(GTK_BOX(away_topbox), sw2, TRUE, TRUE, 0);
-
-	sw = gtk_scrolled_window_new(NULL, NULL);
-    	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
-				       GTK_POLICY_AUTOMATIC,
-				       GTK_POLICY_AUTOMATIC);
-	gtk_widget_show(sw);
-    
-	pd->away_text = gtk_text_new(NULL, NULL);
-	gtk_container_add(GTK_CONTAINER(sw), pd->away_text);
-	gtk_box_pack_start(GTK_BOX(away_topbox), sw, TRUE, TRUE, 0);
-	gtk_text_set_word_wrap(GTK_TEXT(pd->away_text), TRUE);
-	gtk_text_set_editable(GTK_TEXT(pd->away_text), TRUE );
-
-	add_away = picture_button(pd->window, _("Add Message"), gnome_add_xpm);
-	gtk_signal_connect(GTK_OBJECT(add_away), "clicked", GTK_SIGNAL_FUNC(create_away_mess), NULL);
-	gtk_box_pack_start(GTK_BOX(away_botbox), add_away, TRUE, FALSE, 5);
-
-	remove_away = picture_button(pd->window, _("Remove Message"), gnome_remove_xpm);
-	gtk_signal_connect(GTK_OBJECT(remove_away), "clicked", GTK_SIGNAL_FUNC(remove_away_message), NULL);
-	gtk_box_pack_start(GTK_BOX(away_botbox), remove_away, TRUE, FALSE, 5);
-
-	if (display_options & OPT_DISP_COOL_LOOK)
-	{
-		gtk_button_set_relief(GTK_BUTTON(remove_away), GTK_RELIEF_NONE);
-		gtk_button_set_relief(GTK_BUTTON(add_away), GTK_RELIEF_NONE);
-	}
-		
-	gtk_box_pack_start(GTK_BOX(away_page), away_topbox, TRUE, TRUE, 0);
-	gtk_box_pack_start(GTK_BOX(away_page), away_botbox, FALSE, FALSE, 0);
-
-	gtk_widget_show(add_away);
-	gtk_widget_show(remove_away);
-	gtk_widget_show(pd->away_list);
-	gtk_widget_show(pd->away_text);
-	gtk_widget_show(away_topbox);
-	gtk_widget_show(away_botbox);
-    
-	if (awy != NULL) {
-		a = (struct away_message *)awy->data;
-		g_snprintf(buffer, sizeof(buffer), "%s", a->message);
-		gtk_text_insert(GTK_TEXT(pd->away_text), NULL, NULL, NULL, buffer, -1);
-	}
-
-        while(awy) {
-		a = (struct away_message *)awy->data;
-		label = gtk_label_new(a->name);
-		list_item = gtk_list_item_new();
-		gtk_container_add(GTK_CONTAINER(list_item), label);
-		gtk_signal_connect(GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(away_list_clicked), a);
-		gtk_signal_connect(GTK_OBJECT(list_item), "deselect", GTK_SIGNAL_FUNC(away_list_unclicked), a);
-		gtk_object_set_user_data(GTK_OBJECT(list_item), a);
-               
-		gtk_widget_show(label);
-		gtk_container_add(GTK_CONTAINER(pd->away_list), list_item);
-		gtk_widget_show(list_item);
-	
-		awy = awy->next;
-
-	}
-       
-	/* Sound */
-	sound_page = gtk_vbox_new(FALSE, 0);
-	label = gtk_label_new(_("Sounds"));
-	gtk_widget_show(label);
-	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sound_page, label);
-	gaim_button(_("Sounds go through GNOME"), &sound_options, OPT_SOUND_THROUGH_GNOME, sound_page);
-        gaim_button(_("Sound when buddy logs in"), &sound_options, OPT_SOUND_LOGIN, sound_page);
-	gaim_button(_("Sound when buddy logs out"), &sound_options, OPT_SOUND_LOGOUT, sound_page);
-        gaim_button(_("Sound when message is received"), &sound_options, OPT_SOUND_RECV, sound_page);
-	gaim_button(_("Sound when message is sent"), &sound_options, OPT_SOUND_SEND, sound_page);
-        gaim_button(_("Sound when first message is received"), &sound_options, OPT_SOUND_FIRST_RCV, sound_page);
-        gaim_button(_("Sound when message is received if away"), &sound_options, OPT_SOUND_WHEN_AWAY, sound_page);
-	gaim_button(_("No sound for buddies signed on when you log in"), &sound_options, OPT_SOUND_SILENT_SIGNON, sound_page);
-	gaim_button(_("Sounds in chat rooms when people enter/leave"), &sound_options, OPT_SOUND_CHAT_JOIN, sound_page);
-	gaim_button(_("Sounds in chat rooms when people talk"), &sound_options, OPT_SOUND_CHAT_SAY, sound_page);
-        gtk_widget_show(sound_page);
-
-
-        /* Browser */
-        browser_page = gtk_vbox_new(FALSE, 0);
-
-        label = gtk_label_new(_("Browser"));
-        gtk_widget_show(label);
-        
-
-        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), browser_page, label);
-        browseropt = gtk_radio_button_new_with_label(NULL, _("Netscape"));
-        gtk_box_pack_start(GTK_BOX(browser_page), browseropt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(browseropt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)BROWSER_NETSCAPE);
-	gtk_widget_show(browseropt);
-        if (web_browser == BROWSER_NETSCAPE)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(browseropt), TRUE);
+	text[0] = _("Connection");
+	parent = gtk_ctree_insert_node(GTK_CTREE(preftree), NULL, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), parent, connect_page);
+}
 
-        browseropt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(browseropt)), _("KFM (The KDE browser)"));
-        gtk_box_pack_start(GTK_BOX(browser_page), browseropt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(browseropt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)BROWSER_KFM);
-	gtk_widget_show(browseropt);
-	if (web_browser == BROWSER_KFM)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(browseropt), TRUE);
-
-
-        browseropt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(browseropt)), _("Internal HTML widget (Quite likely a bad idea!)"));
-        gtk_box_pack_start(GTK_BOX(browser_page), browseropt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(browseropt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)BROWSER_INTERNAL);
-	gtk_widget_show(browseropt);
-	if (web_browser == BROWSER_INTERNAL)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(browseropt), TRUE);
-
-        
-        browseropt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(browseropt)), _("Manual"));
-        gtk_box_pack_start(GTK_BOX(browser_page), browseropt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(browseropt), "clicked", GTK_SIGNAL_FUNC(set_browser), (void *)BROWSER_MANUAL);
-        gtk_widget_show(browseropt);
-	if (web_browser == BROWSER_MANUAL)
-                gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(browseropt), TRUE);
-
-
-        pd->browser_entry = gtk_entry_new();
-        gtk_widget_show(pd->browser_entry);
-
-        gtk_box_pack_start(GTK_BOX(browser_page), pd->browser_entry, FALSE, FALSE, 0);
-        gtk_entry_set_text(GTK_ENTRY(pd->browser_entry), web_command);
-
-	pd->nwbutton = gaim_button(_("Pop up new window by default"), &general_options, OPT_GEN_BROWSER_POPUP, browser_page);
-	gtk_widget_show(browser_page);
-
-        gtk_signal_connect(GTK_OBJECT(pd->browser_entry), "focus_out_event", GTK_SIGNAL_FUNC(manualentry_key_pressed), NULL);
-
-        
-
-        if (web_browser != BROWSER_MANUAL) {
-                gtk_widget_set_sensitive(pd->browser_entry, FALSE);
-        } else {
-                gtk_widget_set_sensitive(pd->browser_entry, TRUE);
-        }
-        
-        if (web_browser != BROWSER_NETSCAPE) {
-                gtk_widget_set_sensitive(pd->nwbutton, FALSE);
-        } else {
-                gtk_widget_set_sensitive(pd->nwbutton, TRUE);
-        }
-        
-
-
-
-	/* Appearance */
-	appearance_page = gtk_hbox_new(FALSE, 0);
-        label = gtk_label_new(_("Appearance"));
-        gtk_widget_show(label);
-	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), appearance_page, label);
-	appbox = gtk_vbox_new(FALSE, 5);
-	fontframe = gtk_frame_new(_("Font Properties"));
-	fontbox = gtk_vbox_new(FALSE, 5);
-
-	gtk_box_pack_start(GTK_BOX(appearance_page), appbox, TRUE, TRUE, 5);
-	gtk_box_pack_start(GTK_BOX(appearance_page), fontframe, TRUE, TRUE, 5);
-	gtk_container_add(GTK_CONTAINER(fontframe), fontbox);
+void prefs_build_buddy(GtkWidget *preftree)
+{
+	GtkCTreeNode *parent;
+	char *text[1];
 
-	gaim_button(_("Show time on messages"), &display_options, OPT_DISP_SHOW_TIME, appbox);
-	gaim_button(_("Show numbers in groups"), &display_options, OPT_DISP_SHOW_GRPNUM, appbox );
-	gaim_button(_("Show buddy-type pixmaps"), &display_options, OPT_DISP_SHOW_PIXMAPS, appbox );
-	gaim_button(_("Show idle times"), &display_options, OPT_DISP_SHOW_IDLETIME, appbox );
-	gaim_button(_("Show button pixmaps"), &display_options, OPT_DISP_SHOW_BUTTON_XPM, appbox );
-	gaim_button(_("Ignore incoming colours"), &display_options, OPT_DISP_IGNORE_COLOUR, appbox );
-#if 0
-	gaim_button("Transparent text window (experimental)", &transparent, appbox );
-#endif
-	gaim_button(_("Show logon/logoffs in conversation windows"), &display_options, OPT_DISP_SHOW_LOGON, appbox );
-	gaim_button(_("Show people joining/leaving in chat windows"), &display_options, OPT_DISP_CHAT_LOGON, appbox );
-	gaim_button(_("Use devil icons"), &display_options, OPT_DISP_DEVIL_PIXMAPS, appbox );
-	gaim_button(_("Show graphical smileys (experimental)"), &display_options, OPT_DISP_SHOW_SMILEY, appbox );
-	gaim_button(_("Show Buddy Ticker after restart"), &display_options, OPT_DISP_SHOW_BUDDYTICKER, appbox );
-	gaim_button(_("Use borderless buttons (requires restart for some buttons)"), &display_options, OPT_DISP_COOL_LOOK, appbox);
-	
-	
-	gaim_button(_("Bold Text"), &font_options, OPT_FONT_BOLD, fontbox);
-	gaim_button(_("Italics Text"), &font_options, OPT_FONT_ITALIC, fontbox);
-	gaim_button(_("Underlined Text"), &font_options, OPT_FONT_UNDERLINE, fontbox);
-	gaim_button(_("Strike Text"), &font_options, OPT_FONT_STRIKE, fontbox);
-	font_face_for_text = gaim_button(_("Font Face for Text"), &font_options, OPT_FONT_FACE, fontbox);
-		
-	/* Build font button */
-	select_font = picture_button(pd->window, _("Select Font"), fontface2_xpm);
-	gtk_box_pack_start(GTK_BOX(fontbox), select_font, FALSE, FALSE, 0);
-	gtk_signal_connect(GTK_OBJECT(select_font), "clicked", GTK_SIGNAL_FUNC(show_font_dialog), NULL);
-	if (display_options & OPT_DISP_COOL_LOOK)
-		gtk_button_set_relief(GTK_BUTTON(select_font), GTK_RELIEF_NONE);
-	if (!(font_options & OPT_FONT_FACE))
-	    gtk_widget_set_sensitive(GTK_WIDGET(select_font), FALSE);
-	gtk_widget_show(select_font);
-	gtk_signal_connect(GTK_OBJECT(font_face_for_text), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), select_font);
-	
-	gtk_widget_show(appearance_page);
-	gtk_widget_show(fontbox);
-	gtk_widget_show(fontframe);
-	gtk_widget_show(appbox);	
-
-
-	/* Buddy Chats */
-	chat_page = gtk_vbox_new(FALSE, 0);
-	label = gtk_label_new(_("Buddy Chats"));
-
-	gtk_widget_show(label);
-	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), chat_page, label);
-	
-	do_chat_page(chat_page);
-	gtk_widget_show(chat_page);
-	
-	bbox = gtk_hbox_new(FALSE, 5);
-
-	/* Build close button */
-	close = picture_button(pd->window, _("Close"), cancel_xpm);
-	gtk_widget_set_usize(close, 75, 30);
-	/* End of close button */
-
-
-	if (display_options & OPT_DISP_COOL_LOOK)
-		gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE);
-			
-	/* Pack the button(s) in the button box */
-	gtk_box_pack_end(GTK_BOX(bbox), close, FALSE, FALSE, 5);
-	gtk_box_pack_start(GTK_BOX(vbox),bbox, FALSE, FALSE, 5);
-
-	gtk_widget_show(notebook);
-        gtk_widget_show(close);
-
-	gtk_widget_show(bbox);
-	gtk_widget_show(vbox);
-
-	gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(handle_delete), NULL);
-        gtk_signal_connect(GTK_OBJECT(pd->window),"delete_event", GTK_SIGNAL_FUNC(handle_delete), NULL);
-
+	text[0] = _("Buddy List");
+	parent = gtk_ctree_insert_node(GTK_CTREE(preftree), NULL, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), parent, buddy_page);
 }
 
-void show_prefs()
-{
-	if (!pd || !pd->window)
-		build_prefs();
-	gtk_widget_show(pd->window);
-}
-void add_chat(GtkWidget *w, struct chat_page *cp)
+void prefs_build_convo(GtkWidget *preftree)
 {
-	GList *sel = GTK_LIST(cp->list1)->selection;
-	struct chat_room *cr, *cr2;
-	GList *crs = chat_rooms;
-        GtkWidget *item;
-
-	if (sel) {
-		cr = (struct chat_room *)gtk_object_get_user_data(GTK_OBJECT(sel->data));
-	} else
-		return;
-
-	while(crs) {
-		cr2 = (struct chat_room *)crs->data;
-		if (!strcasecmp(cr->name, cr2->name))
-                        return;
-                crs = crs->next;
-	}
-	item = gtk_list_item_new_with_label(cr->name);
-	cr2 = g_new0(struct chat_room, 1);
-	strcpy(cr2->name, cr->name);
-	cr2->exchange = cr->exchange;
-	gtk_object_set_user_data(GTK_OBJECT(item), cr2);
-	gtk_widget_show(item);
-	sel = g_list_append(NULL, item);
-	gtk_list_append_items(GTK_LIST(cp->list2), sel);
-	chat_rooms = g_list_append(chat_rooms, cr2);
+	GtkCTreeNode *parent, *node, *node2;
+	char *text[1];
 
-	setup_buddy_chats();
-	save_prefs();
-	
-
-}
+	text[0] = _("Conversations");
+	parent = gtk_ctree_insert_node(GTK_CTREE(preftree), NULL, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), parent, convo_page);
 
-void remove_chat(GtkWidget *w, struct chat_page *cp)
-{
-	GList *sel = GTK_LIST(cp->list2)->selection;
-	struct chat_room *cr;
-	GList *crs;
-	GtkWidget *item;
-	
-	if (sel) {
-		item = (GtkWidget *)sel->data;
-		cr = (struct chat_room *)gtk_object_get_user_data(GTK_OBJECT(item));
-	} else
-		return;
-
-	chat_rooms = g_list_remove(chat_rooms, cr);
-
-
-	gtk_list_clear_items(GTK_LIST(cp->list2), 0, -1);
-
-	if (g_list_length(chat_rooms) == 0)
-		chat_rooms = NULL;
-
-	crs = chat_rooms;
-
-	while(crs) {
-		cr = (struct chat_room *)crs->data;
-		item = gtk_list_item_new_with_label(cr->name);
-		gtk_object_set_user_data(GTK_OBJECT(item), cr);
-		gtk_widget_show(item);
-		gtk_list_append_items(GTK_LIST(cp->list2), g_list_append(NULL, item));
+	text[0] = _("IM Window");
+	node = gtk_ctree_insert_node(GTK_CTREE(preftree), parent, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), node, im_page);
 
-		
-		crs = crs->next;
-	}
-
-	setup_buddy_chats();
-        save_prefs();
-}
-
-void refresh_list(GtkWidget *w, struct chat_page *cp)
-{
-	char *text = grab_url("http://www.aol.com/community/chat/allchats.html");
-	char *c;
-	int len = strlen(text);
-	GtkWidget *item;
-	GList *items = GTK_LIST(cp->list1)->children;
-	struct chat_room *cr;
-	c = text;
-
-	while(items) {
-		g_free(gtk_object_get_user_data(GTK_OBJECT(items->data)));
-		items = items->next;
-	}
-
-	items = NULL;
-
-        gtk_list_clear_items(GTK_LIST(cp->list1), 0, -1);
-	
-	item = gtk_list_item_new_with_label(_("Gaim Chat"));
-	cr = g_new0(struct chat_room, 1);
-	strcpy(cr->name, _("Gaim Chat"));
-	cr->exchange = 4;
-	gtk_object_set_user_data(GTK_OBJECT(item), cr);
-	gtk_widget_show(item);
+	text[0] = _("Chat Window");
+	node = gtk_ctree_insert_node(GTK_CTREE(preftree), parent, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), node, chat_page);
 
-        items = g_list_append(NULL, item);
-	
-	while(c) {
-		if (c - text > len - 30)
-			break; /* assume no chat rooms 30 from end, padding */
-		if (!strncasecmp(AOL_SRCHSTR, c, strlen(AOL_SRCHSTR))) {
-			char *t;
-			int len=0;
-			int exchange;
-			char *name = NULL;
-			
-			c += strlen(AOL_SRCHSTR);
-                        t = c;
-			while(t) {
-				len++;
-				name = g_realloc(name, len);
-				if (*t == '+')
-					name[len - 1] = ' ';
-				else if (*t == '&') {
-					name[len - 1] = 0;
-					sscanf(t, "&Exchange=%d", &exchange);
-					c = t + strlen("&Exchange=x");
-					break;
-				} else
-					name[len - 1] = *t;
-				t++;
-			}
-			cr = g_new0(struct chat_room, 1);
-			strcpy(cr->name, name);
-			cr->exchange = exchange;
-			item = gtk_list_item_new_with_label(name);
-			gtk_widget_show(item);
-			items = g_list_append(items, item);
-			gtk_object_set_user_data(GTK_OBJECT(item), cr);
-                        g_free(name);
-		}
-		c++;
-	}
-	gtk_list_append_items(GTK_LIST(cp->list1), items);
-	g_free(text);
+	text[0] = _("Chat Rooms");
+	node2 = gtk_ctree_insert_node(GTK_CTREE(preftree), node, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 1, 0);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), node2, room_page);
+
+	text[0] = _("Font Options");
+	node = gtk_ctree_insert_node(GTK_CTREE(preftree), parent, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), node, font_page);
 }
 
-
-
-void do_chat_page(GtkWidget *page)
+void prefs_build_sound(GtkWidget *preftree)
 {
-	GtkWidget *table;
-	GtkWidget *rem_button, *add_button, *ref_button;
-	GtkWidget *list1, *list2;
-	GtkWidget *label;
-	GtkWidget *sw1, *sw2;
-	GtkWidget *item;
-	struct chat_page *cp = g_new0(struct chat_page, 1);
-	GList *crs = chat_rooms;
-	GList *items = NULL;
-	struct chat_room *cr;
-
-	table = gtk_table_new(4, 2, FALSE);
-	gtk_widget_show(table);
-	
-	gtk_box_pack_start(GTK_BOX(page), table, TRUE, TRUE, 0);
-
-	list1 = gtk_list_new();
-	list2 = gtk_list_new();
-	sw1 = gtk_scrolled_window_new(NULL, NULL);
-	sw2 = gtk_scrolled_window_new(NULL, NULL);
-
-	ref_button = picture_button(pd->window, _("Refresh"), refresh_xpm);
-	add_button = picture_button(pd->window, _("Add"), gnome_add_xpm);
-	rem_button = picture_button(pd->window, _("Remove"), gnome_remove_xpm);
-	if (display_options & OPT_DISP_COOL_LOOK)
-	{
-		gtk_button_set_relief(GTK_BUTTON(ref_button), GTK_RELIEF_NONE);
-		gtk_button_set_relief(GTK_BUTTON(add_button), GTK_RELIEF_NONE);
-		gtk_button_set_relief(GTK_BUTTON(rem_button), GTK_RELIEF_NONE);
-	}
-	gtk_widget_show(list1);
-	gtk_widget_show(sw1);
-	gtk_widget_show(list2);
-	gtk_widget_show(sw2);
-	gtk_widget_show(ref_button);
-	gtk_widget_show(add_button);
-	gtk_widget_show(rem_button);
-
-	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw1), list1);
-	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list2);
-
-	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw1),
-				       GTK_POLICY_AUTOMATIC,GTK_POLICY_ALWAYS);
-	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2),
-				       GTK_POLICY_AUTOMATIC,GTK_POLICY_ALWAYS);
-
-	cp->list1 = list1;
-	cp->list2 = list2;
+	GtkCTreeNode *parent, *node;
+	char *text[1];
 
-	gtk_signal_connect(GTK_OBJECT(ref_button), "clicked",
-			   GTK_SIGNAL_FUNC(refresh_list), cp);
-	gtk_signal_connect(GTK_OBJECT(rem_button), "clicked",
-			   GTK_SIGNAL_FUNC(remove_chat), cp);
-	gtk_signal_connect(GTK_OBJECT(add_button), "clicked",
-			   GTK_SIGNAL_FUNC(add_chat), cp);
-
-
-	
-	label = gtk_label_new(_("List of available chats"));
-	gtk_widget_show(label);
-
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
-			 GTK_SHRINK, GTK_SHRINK, 0, 0);
-	gtk_table_attach(GTK_TABLE(table), ref_button, 0, 1, 1, 2,
-			 GTK_SHRINK, GTK_SHRINK, 0, 0);
-	gtk_table_attach(GTK_TABLE(table), sw1, 0, 1, 2, 3,
-			 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-			 5, 5);
-	gtk_table_attach(GTK_TABLE(table), add_button, 0, 1, 3, 4,
-			 GTK_SHRINK, GTK_SHRINK, 0, 0);
+	text[0] = _("Sounds");
+	parent = gtk_ctree_insert_node(GTK_CTREE(preftree), NULL, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), parent, sound_page);
 
-	
-	label = gtk_label_new(_("List of subscribed chats"));
-	gtk_widget_show(label);
-	
-	gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1,
-			 GTK_SHRINK, GTK_SHRINK, 0, 0);
-	gtk_table_attach(GTK_TABLE(table), sw2, 1, 2, 2, 3,
-			 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-			 5, 5);
-	gtk_table_attach(GTK_TABLE(table), rem_button, 1, 2, 3, 4,
-			 GTK_SHRINK, GTK_SHRINK, 0, 0);
-
-
-	item = gtk_list_item_new_with_label(_("Gaim Chat"));
-	cr = g_new0(struct chat_room, 1);
-	strcpy(cr->name, _("Gaim Chat"));
-	cr->exchange = 4;
-	gtk_object_set_user_data(GTK_OBJECT(item), cr);
-	gtk_widget_show(item);
-        gtk_list_append_items(GTK_LIST(list1), g_list_append(NULL, item));
-
-	
-	while(crs) {
-		cr = (struct chat_room *)crs->data;
-		item = gtk_list_item_new_with_label(cr->name);
-		gtk_object_set_user_data(GTK_OBJECT(item), cr);
-		gtk_widget_show(item);
-		items = g_list_append(items, item);
-
-		crs = crs->next;
-	}
-
-	gtk_list_append_items(GTK_LIST(list2), items);
+	text[0] = _("Events");
+	node = gtk_ctree_insert_node(GTK_CTREE(preftree), parent, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), node, event_page);
 }
 
-
-	
-
-
-void debug_print(char *chars)
+void prefs_build_away(GtkWidget *preftree)
 {
-	if(general_options & OPT_GEN_DEBUG && dw)
-            gtk_text_insert(GTK_TEXT(dw->entry),NULL, NULL, NULL, chars, strlen(chars));
-#ifdef DEBUG
-        printf("%s\n", chars);
-#endif
+	GtkCTreeNode *parent;
+	char *text[1];
+
+	text[0] = _("Away Messages");
+	parent = gtk_ctree_insert_node(GTK_CTREE(preftree), NULL, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), parent, away_page);
 }
 
-
-void build_debug()
+void prefs_build_browser(GtkWidget *preftree)
 {
-	GtkWidget *scroll;
-	GtkWidget *box;
-	if (!dw)
-		dw = g_new0(struct debug_window, 1);
+	GtkCTreeNode *parent;
+	char *text[1];
 
-	box = gtk_hbox_new(FALSE,0);
-	dw->window = gtk_window_new(GTK_WINDOW_DIALOG);
-	gtk_window_set_title(GTK_WINDOW(dw->window), _("GAIM debug output window"));
-	gtk_container_add(GTK_CONTAINER(dw->window), box);
-	dw->entry = gtk_text_new(NULL,NULL);
-	gtk_widget_set_usize(dw->entry, 500, 200);
-	scroll = gtk_vscrollbar_new(GTK_TEXT(dw->entry)->vadj);
-	gtk_box_pack_start(GTK_BOX(box), dw->entry, TRUE,TRUE,0);
-	gtk_box_pack_end(GTK_BOX(box), scroll,FALSE,FALSE,0);
-	gtk_widget_show(dw->entry);
-	gtk_widget_show(scroll);
-	gtk_widget_show(box);
-	gtk_signal_connect(GTK_OBJECT(dw->window),"delete_event", GTK_SIGNAL_FUNC(debug_delete), NULL);
-	gtk_widget_show(dw->window);
+	text[0] = _("Browser");
+	parent = gtk_ctree_insert_node(GTK_CTREE(preftree), NULL, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), parent, browser_page);
 }
-
-
-
-void show_debug(GtkObject * object)
-{
-	if((general_options & OPT_GEN_DEBUG)) {
-                if(!dw || !dw->window)
-                        build_debug();
-                gtk_widget_show(dw->window);
-        } else {
-		if (!dw) return;
-                gtk_widget_destroy(dw->window);
-                dw->window = NULL;
-	}
-}
-