summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/cfgfiles.c40
-rw-r--r--src/common/chanopt.c1
-rw-r--r--src/common/ctcp.c5
-rw-r--r--src/common/dcc.c6
-rw-r--r--src/common/dirent.c199
-rw-r--r--src/common/dirent.h28
-rw-r--r--src/common/ignore.c1
-rw-r--r--src/common/inbound.c1
-rw-r--r--src/common/inet.h4
-rw-r--r--src/common/makefile.mak45
-rw-r--r--src/common/msproxy.c1
-rw-r--r--src/common/network.c1
-rw-r--r--src/common/notify.c1
-rw-r--r--src/common/outbound.c16
-rw-r--r--src/common/plugin-timer.c2
-rw-r--r--src/common/plugin.c7
-rw-r--r--src/common/proto-irc.c1
-rw-r--r--src/common/server.c37
-rw-r--r--src/common/servlist.c1
-rw-r--r--src/common/ssl.c2
-rw-r--r--src/common/text.c33
-rw-r--r--src/common/thread.c33
-rw-r--r--src/common/thread.h10
-rw-r--r--src/common/util.c135
-rw-r--r--src/common/util.h6
-rw-r--r--src/common/wdkutil.c27
-rw-r--r--src/common/wdkutil.h2
-rw-r--r--src/common/xchat.c4
-rw-r--r--src/common/xchat.h15
-rw-r--r--src/fe-gtk/about.c51
-rw-r--r--src/fe-gtk/banlist.c6
-rw-r--r--src/fe-gtk/chanlist.c1
-rw-r--r--src/fe-gtk/chanview-tabs.c8
-rw-r--r--src/fe-gtk/editlist.c1
-rw-r--r--src/fe-gtk/fe-gtk.c87
-rw-r--r--src/fe-gtk/fe-gtk.h2
-rw-r--r--src/fe-gtk/fkeys.c3
-rw-r--r--src/fe-gtk/gtkutil.c248
-rw-r--r--src/fe-gtk/joind.c1
-rw-r--r--src/fe-gtk/maingui.c88
-rw-r--r--src/fe-gtk/makefile.mak62
-rw-r--r--src/fe-gtk/menu.c14
-rw-r--r--src/fe-gtk/palette.c4
-rw-r--r--src/fe-gtk/palette.h1
-rw-r--r--src/fe-gtk/plugin-tray.c48
-rw-r--r--src/fe-gtk/plugingui.c6
-rw-r--r--src/fe-gtk/rawlog.c1
-rw-r--r--src/fe-gtk/search.c2
-rw-r--r--src/fe-gtk/setup.c53
-rw-r--r--src/fe-gtk/sexy-iso-codes.c301
-rw-r--r--src/fe-gtk/sexy-iso-codes.h37
-rw-r--r--src/fe-gtk/sexy-marshal.c129
-rw-r--r--src/fe-gtk/sexy-marshal.h28
-rw-r--r--src/fe-gtk/sexy-spell-entry.c101
-rw-r--r--src/fe-gtk/typedef.h11
-rw-r--r--src/fe-gtk/xchat.exe.manifest22
-rw-r--r--src/fe-gtk/xchat.rc28
-rw-r--r--src/fe-gtk/xtext.c39
-rw-r--r--src/fe-gtk/xtext.h1
-rw-r--r--src/fe-text/fe-text.c473
-rw-r--r--src/fe-text/fe-text.h30
-rw-r--r--src/fe-text/makefile.mak20
-rw-r--r--src/gtk2-prefs/callbacks.cpp224
-rw-r--r--src/gtk2-prefs/callbacks.h71
-rw-r--r--src/gtk2-prefs/config.h59
-rw-r--r--src/gtk2-prefs/interface.cpp836
-rw-r--r--src/gtk2-prefs/interface.h5
-rw-r--r--src/gtk2-prefs/main.cpp616
-rw-r--r--src/gtk2-prefs/main.h32
-rw-r--r--src/gtk2-prefs/makefile.mak24
-rw-r--r--src/gtk2-prefs/support.cpp146
-rw-r--r--src/gtk2-prefs/support.h44
-rw-r--r--src/gtk2-prefs/sys_win32.h28
-rw-r--r--src/gtk2-prefs/win32util.cpp80
-rw-r--r--src/gtk2-prefs/win32util.h26
-rw-r--r--src/makefile.mak23
-rw-r--r--src/makeinc.skel.mak44
-rw-r--r--src/pixmaps/makefile.mak18
78 files changed, 4297 insertions, 550 deletions
diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
index 8bb2a61b..c3dcb347 100644
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -17,7 +17,6 @@
  */
 
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -30,10 +29,9 @@
 #include "fe.h"
 #include "text.h"
 #include "xchatc.h"
+#include "wdkutil.h"
 
-#ifdef WIN32
-#define XCHAT_DIR "X-Chat 2"
-#else
+#ifndef WIN32
 #define XCHAT_DIR ".xchat2"
 #endif
 #define DEF_FONT "Monospace 9"
@@ -308,12 +306,19 @@ get_xdir_fs (void)
 {
 	if (!xdir_fs)
 	{
-		char out[256];
+		if (portable_mode ())
+		{
+			xdir_fs = ".\\config";
+		}
+		else
+		{
+			char out[256];
 
-		if (!get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\"
-				"Explorer\\Shell Folders", "AppData", out, sizeof (out)))
-			return "./config";
-		xdir_fs = g_strdup_printf ("%s\\" XCHAT_DIR, out);
+			if (!get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\"
+					"Explorer\\Shell Folders", "AppData", out, sizeof (out)))
+				return "./config";
+			xdir_fs = g_strdup_printf ("%s\\" "X-Chat 2", out);
+		}
 	}
 	return xdir_fs;
 }
@@ -393,7 +398,7 @@ const struct prefs vars[] = {
 	{"dcc_blocksize", P_OFFINT (dcc_blocksize), TYPE_INT},
 	{"dcc_completed_dir", P_OFFSET (dcc_completed_dir), TYPE_STR},
 	{"dcc_dir", P_OFFSET (dccdir), TYPE_STR},
-	{"dcc_fast_send", P_OFFINT (fastdccsend), TYPE_BOOL},
+	/* {"dcc_fast_send", P_OFFINT (fastdccsend), TYPE_BOOL}, */
 	{"dcc_global_max_get_cps", P_OFFINT (dcc_global_max_get_cps), TYPE_INT},
 	{"dcc_global_max_send_cps", P_OFFINT (dcc_global_max_send_cps), TYPE_INT},
 	{"dcc_ip", P_OFFSET (dcc_ip_str), TYPE_STR},
@@ -418,6 +423,7 @@ const struct prefs vars[] = {
 
 	{"gui_auto_open_chat", P_OFFINT (autoopendccchatwindow), TYPE_BOOL},
 	{"gui_auto_open_dialog", P_OFFINT (autodialog), TYPE_BOOL},
+	{"gui_auto_open_msg", P_OFFINT (gui_auto_open_msg), TYPE_BOOL},
 	{"gui_auto_open_recv", P_OFFINT (autoopendccrecvwindow), TYPE_BOOL},
 	{"gui_auto_open_send", P_OFFINT (autoopendccsendwindow), TYPE_BOOL},
 	{"gui_dialog_height", P_OFFINT (dialog_height), TYPE_INT},
@@ -429,6 +435,7 @@ const struct prefs vars[] = {
 	{"gui_input_style", P_OFFINT (style_inputbox), TYPE_BOOL},
 	{"gui_join_dialog", P_OFFINT (gui_join_dialog), TYPE_BOOL},
 	{"gui_lagometer", P_OFFINT (lagometer), TYPE_INT},
+	{"gui_license", P_OFFSET (gui_license), TYPE_STR},
 	{"gui_mode_buttons", P_OFFINT (chanmodebuttons), TYPE_BOOL},
 	{"gui_pane_left_size", P_OFFINT (gui_pane_left_size), TYPE_INT},
 	{"gui_pane_right_size", P_OFFINT (gui_pane_right_size), TYPE_INT},
@@ -536,6 +543,7 @@ const struct prefs vars[] = {
 
 	{"tab_chans", P_OFFINT (tabchannels), TYPE_BOOL},
 	{"tab_dialogs", P_OFFINT (privmsgtab), TYPE_BOOL},
+	{"tab_icons", P_OFFINT (tab_icons), TYPE_BOOL},
 	{"tab_layout", P_OFFINT (tab_layout), TYPE_INT},
 	{"tab_new_to_front", P_OFFINT (newtabstofront), TYPE_INT},
 	{"tab_notices", P_OFFINT (notices_tabs), TYPE_BOOL},
@@ -546,9 +554,14 @@ const struct prefs vars[] = {
 	{"tab_sort", P_OFFINT (tab_sort), TYPE_BOOL},
 	{"tab_trunc", P_OFFINT (truncchans), TYPE_INT},
 	{"tab_utils", P_OFFINT (windows_as_tabs), TYPE_BOOL},
+	{"tab_xp", P_OFFINT (tab_xp), TYPE_BOOL},
 
+	{"text_auto_copy_color", P_OFFINT (autocopy_color), TYPE_BOOL},	
+	{"text_auto_copy_stamp", P_OFFINT (autocopy_stamp), TYPE_BOOL},
+	{"text_auto_copy_text", P_OFFINT (autocopy_text), TYPE_BOOL},
 	{"text_background", P_OFFSET (background), TYPE_STR},
 	{"text_color_nicks", P_OFFINT (colorednicks), TYPE_BOOL},
+	{"text_emoticons", P_OFFINT (emoticons), TYPE_BOOL},
 	{"text_font", P_OFFSET (font_normal), TYPE_STR},
 	{"text_indent", P_OFFINT (indent_nicks), TYPE_BOOL},
 	{"text_max_indent", P_OFFINT (max_auto_indent), TYPE_INT},
@@ -556,6 +569,7 @@ const struct prefs vars[] = {
 	{"text_replay", P_OFFINT (text_replay), TYPE_BOOL},
 	{"text_show_marker", P_OFFINT (show_marker), TYPE_BOOL},
 	{"text_show_sep", P_OFFINT (show_separator), TYPE_BOOL},
+	{"text_spell_langs", P_OFFSET (spell_langs), TYPE_STR},
 	{"text_stripcolor", P_OFFINT (stripcolor), TYPE_BOOL},
 	{"text_thin_sep", P_OFFINT (thin_separator), TYPE_BOOL},
 	{"text_tint_blue", P_OFFINT (tint_blue), TYPE_INT},
@@ -624,13 +638,14 @@ load_config (void)
 	prefs.indent_nicks = 1;
 	prefs.thin_separator = 1;
 	prefs._tabs_position = 2; /* 2 = left */
-	prefs.fastdccsend = 1;
+	/* prefs.fastdccsend = 1; */
 	prefs.wordwrap = 1;
 	prefs.autosave = 1;
 	prefs.autodialog = 1;
 	prefs.gui_input_spell = 1;
 	prefs.autoreconnect = 1;
 	prefs.recon_delay = 10;
+	prefs.autocopy_text = 1;
 	prefs.text_replay = 1;
 	prefs.tabchannels = 1;
 	prefs.tab_layout = 2;	/* 0=Tabs 1=Reserved 2=Tree */
@@ -648,6 +663,7 @@ load_config (void)
 	prefs.dialog_height = 256;
 	prefs.gui_join_dialog = 1;
 	prefs.gui_quit_dialog = 1;
+	prefs.slist_skip = 1;
 	prefs.dcctimeout = 180;
 	prefs.dccstalltimeout = 60;
 	prefs.notify_timeout = 15;
@@ -683,6 +699,8 @@ load_config (void)
 #ifdef WIN32
 	prefs.identd = 1;
 #endif
+	strcpy (prefs.gui_license, "");
+	strcpy (prefs.spell_langs, g_getenv ("LC_ALL") ? g_getenv ("LC_ALL") : "en_US");
 	strcpy (prefs.stamp_format, "[%H:%M] ");
 	strcpy (prefs.timestamp_log_format, "%b %d %H:%M:%S ");
 	strcpy (prefs.logmask, "%n-%c.log");
diff --git a/src/common/chanopt.c b/src/common/chanopt.c
index a4fd8faa..ce37157a 100644
--- a/src/common/chanopt.c
+++ b/src/common/chanopt.c
@@ -3,7 +3,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff --git a/src/common/ctcp.c b/src/common/ctcp.c
index 574cda79..37392372 100644
--- a/src/common/ctcp.c
+++ b/src/common/ctcp.c
@@ -18,7 +18,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <stdlib.h>
 
 #include "xchat.h"
@@ -134,8 +133,8 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
 
 	if (!strcasecmp (msg, "VERSION") && !prefs.hidever)
 	{
-		snprintf (outbuf, sizeof (outbuf), "VERSION xchat "PACKAGE_VERSION" %s",
-					 get_cpu_str ());
+		snprintf (outbuf, sizeof (outbuf), "VERSION XChat-WDK "PACKAGE_VERSION" [x%d] / %s",
+					 get_cpu_arch (), get_cpu_str ());
 		serv->p_nctcp (serv, nick, outbuf);
 	}
 
diff --git a/src/common/dcc.c b/src/common/dcc.c
index 8f289342..9375095e 100644
--- a/src/common/dcc.c
+++ b/src/common/dcc.c
@@ -31,7 +31,6 @@
 #include <time.h>
 #include <errno.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <fcntl.h>
 
 #define WANTSOCKET
@@ -57,6 +56,7 @@
 
 #ifdef USE_DCC64
 #define BIG_STR_TO_INT(x) strtoull(x,NULL,10)
+#define stat _stat64
 #else
 #define BIG_STR_TO_INT(x) strtoul(x,NULL,10)
 #endif
@@ -1983,9 +1983,7 @@ is_same_file (struct DCC *dcc, struct DCC *new_dcc)
 		return TRUE;
 
 	/* now handle case-insensitive Filesystems: HFS+, FAT */
-#ifdef WIN32
-#warning no win32 implementation - behaviour may be unreliable
-#else
+#ifndef WIN32
 	/* this fstat() shouldn't really fail */
 	if ((dcc->fp == -1 ? stat (dcc->destfile_fs, &st_a) : fstat (dcc->fp, &st_a)) == -1)
 		return FALSE;
diff --git a/src/common/dirent.c b/src/common/dirent.c
new file mode 100644
index 00000000..a84f1b65
--- /dev/null
+++ b/src/common/dirent.c
@@ -0,0 +1,199 @@
+/*****************************************************************************
+ * dirent.h - dirent API for Microsoft Visual Studio
+ *
+ * Copyright (C) 2006 Toni Ronkko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Dec 15, 2009, John Cunningham
+ * Added rewinddir member function
+ *
+ * Jan 18, 2008, Toni Ronkko
+ * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
+ * between multi-byte and unicode representations.  This makes the
+ * code simpler and also allows the code to be compiled under MingW.  Thanks
+ * to Azriel Fasten for the suggestion.
+ *
+ * Mar 4, 2007, Toni Ronkko
+ * Bug fix: due to the strncpy_s() function this file only compiled in
+ * Visual Studio 2005.  Using the new string functions only when the
+ * compiler version allows.
+ *
+ * Nov  2, 2006, Toni Ronkko
+ * Major update: removed support for Watcom C, MS-DOS and Turbo C to
+ * simplify the file, updated the code to compile cleanly on Visual
+ * Studio 2005 with both unicode and multi-byte character strings,
+ * removed rewinddir() as it had a bug.
+ *
+ * Aug 20, 2006, Toni Ronkko
+ * Removed all remarks about MSVC 1.0, which is antiqued now.  Simplified
+ * comments by removing SGML tags.
+ *
+ * May 14 2002, Toni Ronkko
+ * Embedded the function definitions directly to the header so that no
+ * source modules need to be included in the Visual Studio project.  Removed
+ * all the dependencies to other projects so that this very header can be
+ * used independently.
+ *
+ * May 28 1998, Toni Ronkko
+ * First version.
+ *****************************************************************************/
+
+#include "dirent.h"
+
+/* Use the new safe string functions introduced in Visual Studio 2005 */
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+# define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
+#else
+# define STRNCPY(dest,src,size) strncpy((dest),(src),(size))
+#endif
+
+
+/*****************************************************************************
+ * Open directory stream DIRNAME for read and return a pointer to the
+ * internal working area that is used to retrieve individual directory
+ * entries.
+ */
+DIR *opendir(const char *dirname)
+{
+   DIR *dirp;
+   assert (dirname != NULL);
+   assert (strlen (dirname) < MAX_PATH);
+
+   /* construct new DIR structure */
+   dirp = (DIR*) malloc (sizeof (struct DIR));
+   if (dirp != NULL) {
+      char *p;
+
+      /* take directory name... */
+      STRNCPY (dirp->patt, dirname, sizeof(dirp->patt));
+      dirp->patt[MAX_PATH] = '\0';
+
+      /* ... and append search pattern to it */
+      p = strchr (dirp->patt, '\0');
+      if (dirp->patt < p  &&  *(p-1) != '\\'  &&  *(p-1) != ':') {
+         *p++ = '\\';
+      }
+      *p++ = '*';
+      *p = '\0';
+
+      /* open stream and retrieve first file */
+      dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data);
+      if (dirp->search_handle == INVALID_HANDLE_VALUE) {
+         /* invalid search pattern? */
+         free (dirp);
+         return NULL;
+      }
+
+      /* there is an un-processed directory entry in memory now */
+      dirp->cached = 1;
+   }
+
+   return dirp;
+}
+
+
+/*****************************************************************************
+ * Read a directory entry, and return a pointer to a dirent structure
+ * containing the name of the entry in d_name field.  Individual directory
+ * entries returned by this very function include regular files,
+ * sub-directories, pseudo-directories "." and "..", but also volume labels,
+ * hidden files and system files may be returned.
+ */
+struct dirent *readdir(DIR *dirp)
+{
+   assert (dirp != NULL);
+
+   if (dirp->search_handle == INVALID_HANDLE_VALUE) {
+      /* directory stream was opened/rewound incorrectly or ended normally */
+      return NULL;
+   }
+
+   /* get next directory entry */
+   if (dirp->cached != 0) {
+      /* a valid directory entry already in memory */
+      dirp->cached = 0;
+   } else {
+      /* read next directory entry from disk */
+      if (FindNextFileA (dirp->search_handle, &dirp->current.data) == FALSE) {
+         /* the very last file has been processed or an error occured */
+         FindClose (dirp->search_handle);
+         dirp->search_handle = INVALID_HANDLE_VALUE;
+         return NULL;
+      }
+   }
+
+   /* copy as a multibyte character string */
+   STRNCPY ( dirp->current.d_name,
+             dirp->current.data.cFileName,
+             sizeof(dirp->current.d_name) );
+   dirp->current.d_name[MAX_PATH] = '\0';
+
+   return &dirp->current;
+}
+
+
+/*****************************************************************************
+ * Close directory stream opened by opendir() function.  Close of the
+ * directory stream invalidates the DIR structure as well as any previously
+ * read directory entry.
+ */
+int closedir(DIR *dirp)
+{
+   assert (dirp != NULL);
+
+   /* release search handle */
+   if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+      FindClose (dirp->search_handle);
+      dirp->search_handle = INVALID_HANDLE_VALUE;
+   }
+
+   /* release directory handle */
+   free (dirp);
+   return 0;
+}
+
+
+/*****************************************************************************
+ * Resets the position of the directory stream to which dirp refers to the
+ * beginning of the directory. It also causes the directory stream to refer
+ * to the current state of the corresponding directory, as a call to opendir()
+ * would have done. If dirp does not refer to a directory stream, the effect
+ * is undefined.
+ */
+void rewinddir(DIR* dirp)
+{
+   /* release search handle */
+   if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+      FindClose (dirp->search_handle);
+      dirp->search_handle = INVALID_HANDLE_VALUE;
+   }
+
+   /* open new search handle and retrieve first file */
+   dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data);
+   if (dirp->search_handle == INVALID_HANDLE_VALUE) {
+      /* invalid search pattern? */
+      free (dirp);
+      return;
+   }
+
+   /* there is an un-processed directory entry in memory now */
+   dirp->cached = 1;
+}
diff --git a/src/common/dirent.h b/src/common/dirent.h
new file mode 100644
index 00000000..cbb753e6
--- /dev/null
+++ b/src/common/dirent.h
@@ -0,0 +1,28 @@
+#ifndef DIRENT_H
+#define DIRENT_H
+
+#include <windows.h>
+#include <string.h>
+#include <assert.h>
+
+typedef struct dirent
+{
+   char d_name[MAX_PATH + 1]; /* current dir entry (multi-byte char string) */
+   WIN32_FIND_DATAA data;     /* file attributes */
+}  dirent;
+
+typedef struct DIR
+{
+   dirent current;            /* Current directory entry */
+   int    cached;             /* Indicates un-processed entry in memory */
+   HANDLE search_handle;      /* File search handle */
+   char   patt[MAX_PATH + 3]; /* search pattern (3 = pattern + "\\*\0") */
+} DIR;
+
+/* Forward declarations */
+DIR *opendir (const char *dirname);
+struct dirent *readdir (DIR *dirp);
+int closedir (DIR *dirp);
+void rewinddir(DIR* dirp);
+
+#endif /*DIRENT_H*/
diff --git a/src/common/ignore.c b/src/common/ignore.c
index c3544f30..adb61f37 100644
--- a/src/common/ignore.c
+++ b/src/common/ignore.c
@@ -19,7 +19,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff --git a/src/common/inbound.c b/src/common/inbound.c
index 41f5cff3..3485dfd4 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -21,7 +21,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
-#include <unistd.h>
 #include <time.h>
 
 #define WANTARPA
diff --git a/src/common/inet.h b/src/common/inet.h
index b420c9c6..8995569c 100644
--- a/src/common/inet.h
+++ b/src/common/inet.h
@@ -21,12 +21,12 @@
 
 #else
 
+#include "../../config.h"
 #ifdef USE_IPV6
 #include <winsock2.h>
 #include <ws2tcpip.h>
-#include <tpipv6.h>
 #else
-#include <winsock.h>
+#include <winsock2.h>
 #endif
 
 #define set_blocking(sok)	{ \
diff --git a/src/common/makefile.mak b/src/common/makefile.mak
new file mode 100644
index 00000000..424316c0
--- /dev/null
+++ b/src/common/makefile.mak
@@ -0,0 +1,45 @@
+include "..\makeinc.mak"
+
+COMMON_OBJECTS = \
+cfgfiles.obj \
+chanopt.obj \
+ctcp.obj \
+dcc.obj \
+dirent.obj \
+history.obj \
+ignore.obj \
+inbound.obj \
+modes.obj \
+network.obj \
+notify.obj \
+outbound.obj \
+plugin.obj \
+plugin-timer.obj \
+proto-irc.obj \
+server.obj \
+servlist.obj \
+ssl.obj \
+text.obj \
+thread.obj \
+tree.obj \
+url.obj \
+userlist.obj \
+util.obj \
+wdkutil.obj \
+xchat.obj
+
+all: $(COMMON_OBJECTS) xchatcommon.lib dirent.lib
+
+xchatcommon.lib: $(COMMON_OBJECTS)
+	lib /nologo /out:xchatcommon.lib $(COMMON_OBJECTS)
+
+dirent.lib: dirent.obj
+	lib /nologo /out:dirent.lib dirent.obj
+
+.c.obj::
+	$(CC) $(CFLAGS) $(GLIB) $<
+
+clean:
+	@del *.obj
+	@del xchatcommon.lib
+	@del dirent.lib
diff --git a/src/common/msproxy.c b/src/common/msproxy.c
index 9c85394d..8ad37ffc 100644
--- a/src/common/msproxy.c
+++ b/src/common/msproxy.c
@@ -26,7 +26,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <fcntl.h>
 
 #define WANTSOCKET
diff --git a/src/common/network.c b/src/common/network.c
index 0c409506..b7d9aa1f 100644
--- a/src/common/network.c
+++ b/src/common/network.c
@@ -21,7 +21,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <glib.h>
 
 #include "../../config.h"				  /* grab USE_IPV6 and LOOKUPD defines */
diff --git a/src/common/notify.c b/src/common/notify.c
index 04795849..4aa5ea17 100644
--- a/src/common/notify.c
+++ b/src/common/notify.c
@@ -22,7 +22,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <unistd.h>
 #include <time.h>
 
 #include "xchat.h"
diff --git a/src/common/outbound.c b/src/common/outbound.c
index 7c6e5e6a..3a4d379c 100644
--- a/src/common/outbound.c
+++ b/src/common/outbound.c
@@ -32,7 +32,6 @@
 #include <sys/wait.h>
 #endif
 
-#include <unistd.h>
 #include <time.h>
 #include <signal.h>
 #include <sys/stat.h>
@@ -2606,7 +2605,13 @@ cmd_msg (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 			}
 			newsess = find_dialog (sess->server, nick);
 			if (!newsess)
+			{
 				newsess = find_channel (sess->server, nick);
+				if (!newsess && prefs.gui_auto_open_msg)
+				{
+					newsess = new_ircwindow (sess->server, nick, SESS_DIALOG, 0);
+				}
+			}
 			if (newsess)
 				inbound_chanmsg (newsess->server, NULL, newsess->channel,
 									  newsess->server->nick, msg, TRUE, FALSE);
@@ -2882,6 +2887,14 @@ cmd_recv (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 }
 
 static int
+cmd_saveconf (struct session *sess, char *tbuf, char *word[], char *word_eol[])
+{
+	save_config ();
+
+	return TRUE;
+}
+
+static int
 cmd_say (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 {
 	char *speech = word_eol[2];
@@ -3633,6 +3646,7 @@ const struct commands xc_cmds[] = {
 #endif
 	{"RECV", cmd_recv, 1, 0, 1, N_("RECV <text>, send raw data to xchat, as if it was received from the irc server")},
 
+	{"SAVECONF", cmd_saveconf, 0, 0, 1, N_("SAVECONF, saves the current settings to disk")},
 	{"SAY", cmd_say, 0, 0, 1,
 	 N_("SAY <text>, sends the text to the object in the current window")},
 	{"SEND", cmd_send, 0, 0, 1, N_("SEND <nick> [<file>]")},
diff --git a/src/common/plugin-timer.c b/src/common/plugin-timer.c
index f09074a8..2524439d 100644
--- a/src/common/plugin-timer.c
+++ b/src/common/plugin-timer.c
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
-#include "xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 
 #ifdef WIN32
 #define strcasecmp stricmp
diff --git a/src/common/plugin.c b/src/common/plugin.c
index ada4d3be..b40660a1 100644
--- a/src/common/plugin.c
+++ b/src/common/plugin.c
@@ -34,7 +34,7 @@
 #include "text.h"
 #define PLUGIN_C
 typedef struct session xchat_context;
-#include "xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 #include "plugin.h"
 
 
@@ -996,13 +996,16 @@ xchat_get_info (xchat_plugin *ph, const char *id)
 		return XCHATLIBDIR;
 
 	case 0x14f51cd8: /* version */
-		return PACKAGE_VERSION;
+		return XCHAT_RELEASE;
 
 	case 0xdd9b1abd:	/* xchatdir */
 		return get_xdir_utf8 ();
 
 	case 0xe33f6c4a:	/* xchatdirfs */
 		return get_xdir_fs ();
+
+	case 0x3d1e70d7:	/* wdk_version */
+		return PACKAGE_VERSION;
 	}
 
 	sess = ph->context;
diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c
index f1df6ccd..3d45e1b0 100644
--- a/src/common/proto-irc.c
+++ b/src/common/proto-irc.c
@@ -18,7 +18,6 @@
 
 /* IRC RFC1459(+commonly used extensions) protocol implementation */
 
-#include <unistd.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/common/server.c b/src/common/server.c
index 99894687..f7347052 100644
--- a/src/common/server.c
+++ b/src/common/server.c
@@ -26,7 +26,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
 
@@ -845,33 +844,6 @@ server_flush_queue (server *serv)
 	fe_set_throttle (serv);
 }
 
-#ifdef WIN32
-
-static int
-waitline2 (GIOChannel *source, char *buf, int bufsize)
-{
-	int i = 0;
-	int len;
-
-	while (1)
-	{
-		if (g_io_channel_read (source, &buf[i], 1, &len) != G_IO_ERROR_NONE)
-			return -1;
-		if (buf[i] == '\n' || bufsize == i + 1)
-		{
-			buf[i] = 0;
-			return i;
-		}
-		i++;
-	}
-}
-
-#else
-
-#define waitline2(source,buf,size) waitline(serv->childread,buf,size,0)
-
-#endif
-
 /* connect() successed */
 
 static void
@@ -1395,12 +1367,7 @@ base64_encode (char *to, char *from, unsigned int len)
 static int
 http_read_line (int print_fd, int sok, char *buf, int len)
 {
-#ifdef WIN32
-	/* make sure waitline() uses recv() or it'll fail on win32 */
-	len = waitline (sok, buf, len, FALSE);
-#else
 	len = waitline (sok, buf, len, TRUE);
-#endif
 	if (len >= 1)
 	{
 		/* print the message out (send it to the parent process) */
@@ -1526,7 +1493,7 @@ server_child (server * serv)
 		if (FALSE)
 			;
 #ifdef USE_LIBPROXY
-		else if (prefs.proxy_type == 5)
+		} else if (prefs.proxy_type == 5)
 		{
 			char **proxy_list;
 			char *url, *proxy;
@@ -1796,7 +1763,7 @@ server_connect (server *serv, char *hostname, int port, int no_login)
 	}
 #endif
 	serv->childpid = pid;
-	serv->iotag = fe_input_add (serv->childread, FIA_READ, server_read_child,
+	serv->iotag = fe_input_add (serv->childread, FIA_READ|FIA_FD, server_read_child,
 										 serv);
 }
 
diff --git a/src/common/servlist.c b/src/common/servlist.c
index 29731b14..1ca63201 100644
--- a/src/common/servlist.c
+++ b/src/common/servlist.c
@@ -21,7 +21,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 
 #include "xchat.h"
 #include <glib/ghash.h>
diff --git a/src/common/ssl.c b/src/common/ssl.c
index a18ad47c..daa7416b 100644
--- a/src/common/ssl.c
+++ b/src/common/ssl.c
@@ -17,12 +17,12 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+#include "inet.h"				  /* make it first to avoid macro redefinitions */
 #include <openssl/ssl.h>		  /* SSL_() */
 #include <openssl/err.h>		  /* ERR_() */
 #include <time.h>					  /* asctime() */
 #include <string.h>				  /* strncpy() */
 #include "ssl.h"					  /* struct cert_info */
-#include "inet.h"
 #include "../../config.h"		  /* HAVE_SNPRINTF */
 
 #ifndef HAVE_SNPRINTF
diff --git a/src/common/text.c b/src/common/text.c
index a2198517..fcde5870 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -19,13 +19,11 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <ctype.h>
 #include <time.h>
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <sys/mman.h>
 
 #include "xchat.h"
 #include <glib/ghash.h>
@@ -271,9 +269,6 @@ scrollback_load (session *sess)
 	char *text;
 	time_t stamp;
 	int lines;
-	char *map, *end_map;
-	struct stat statbuf;
-	const char *begin, *eol;
 
 	if (sess->text_scrollback == SET_DEFAULT)
 	{
@@ -293,32 +288,9 @@ scrollback_load (session *sess)
 	if (fh == -1)
 		return;
 
-	if (fstat (fh, &statbuf) < 0)
-		return;
-
-	map = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fh, 0);
-	if (map == MAP_FAILED)
-		return;
-
-	end_map = map + statbuf.st_size;
-	
 	lines = 0;
-	begin = map;
-	while (begin < end_map)
+	while (waitline (fh, buf, sizeof buf, FALSE) != -1)
 	{
-		int n_bytes;
-
-		eol = memchr (begin, '\n', end_map - begin);
-
-		if (!eol)
-			eol = end_map;
-
-		n_bytes = MIN (eol - begin, sizeof (buf) - 1);
-		
-		strncpy (buf, begin, n_bytes);
-
-		buf[n_bytes] = 0;
-		
 		if (buf[0] == 'T')
 		{
 			if (sizeof (time_t) == 4)
@@ -334,8 +306,6 @@ scrollback_load (session *sess)
 			}
 			lines++;
 		}
-
-		begin = eol + 1;
 	}
 
 	sess->scrollwritten = lines;
@@ -349,7 +319,6 @@ scrollback_load (session *sess)
 		/*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/
 	}
 
-	munmap (map, statbuf.st_size);
 	close (fh);
 }
 
diff --git a/src/common/thread.c b/src/common/thread.c
new file mode 100644
index 00000000..02b17cfb
--- /dev/null
+++ b/src/common/thread.c
@@ -0,0 +1,33 @@
+#include <fcntl.h>
+#include "thread.h"
+
+thread *
+thread_new (void)
+{
+	thread *th;
+
+	th = calloc (1, sizeof (*th));
+	if (!th)
+	{
+		return NULL;
+	}
+
+	if (_pipe (th->pipe_fd, 4096, _O_BINARY) == -1)
+	{
+		free (th);
+		return NULL;
+	}
+
+	return th;
+}
+
+int
+thread_start (thread *th, void *(*start_routine)(void *), void *arg)
+{
+	DWORD id;
+
+	CloseHandle (CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, arg, 0, (DWORD *)&id));
+	th->threadid = id;
+
+	return 1;
+}
diff --git a/src/common/thread.h b/src/common/thread.h
new file mode 100644
index 00000000..7ca0f937
--- /dev/null
+++ b/src/common/thread.h
@@ -0,0 +1,10 @@
+#include <windows.h>
+
+typedef struct
+{
+	DWORD threadid;
+	int pipe_fd[2];
+} thread;
+
+thread *thread_new (void);
+int thread_start (thread *th, void *(*start_routine)(void *), void *arg);
diff --git a/src/common/util.c b/src/common/util.c
index 49517ec4..870f4d5c 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -16,11 +16,13 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+#define WANTSOCKET
+#include "inet.h"				/* make it first to avoid macro redefinitions */
+
 #define __APPLE_API_STRICT_CONFORMANCE
 
 #define _FILE_OFFSET_BITS 64
 #include <stdio.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -35,7 +37,7 @@
 #include <sys/utsname.h>
 #endif
 #include <fcntl.h>
-#include <dirent.h>
+#include "dirent.h"
 #include <errno.h>
 #include "xchat.h"
 #include "xchatc.h"
@@ -44,9 +46,6 @@
 #include "util.h"
 #include "../../config.h"
 
-#define WANTSOCKET
-#include "inet.h"
-
 #if defined (USING_FREEBSD) || defined (__APPLE__)
 #include <sys/sysctl.h>
 #endif
@@ -54,9 +53,11 @@
 #include <socks.h>
 #endif
 
+#ifndef ENABLE_NLS
 #ifndef HAVE_SNPRINTF
 #define snprintf g_snprintf
 #endif
+#endif
 
 #ifdef USE_DEBUG
 
@@ -383,6 +384,28 @@ waitline (int sok, char *buf, int bufsize, int use_recv)
 	}
 }
 
+#ifdef WIN32
+/* waitline2 using win32 file descriptor and glib instead of _read. win32 can't _read() sok! */
+int
+waitline2 (GIOChannel *source, char *buf, int bufsize)
+{
+	int i = 0;
+	int len;
+
+	while (1)
+	{
+		if (g_io_channel_read (source, &buf[i], 1, &len) != G_IO_ERROR_NONE)
+			return -1;
+		if (buf[i] == '\n' || bufsize == i + 1)
+		{
+			buf[i] = 0;
+			return i;
+		}
+		i++;
+	}
+}
+#endif
+
 /* checks for "~" in a file and expands */
 
 char *
@@ -624,30 +647,110 @@ get_mhz (void)
 	return 0;	/* fails on Win9x */
 }
 
+int
+get_cpu_arch (void)
+{
+	SYSTEM_INFO si;
+
+	GetSystemInfo (&si);
+
+	if (si.wProcessorArchitecture == 9)
+	{
+		return 64;
+	}
+	else
+	{
+		return 86;
+	}
+}
+
 char *
 get_cpu_str (void)
 {
 	static char verbuf[64];
-	OSVERSIONINFO osvi;
-	SYSTEM_INFO si;
+	static char winver[20];
+	OSVERSIONINFOEX osvi;
 	double mhz;
 
-	osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+	osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
 	GetVersionEx (&osvi);
-	GetSystemInfo (&si);
+
+	switch (osvi.dwMajorVersion)
+	{
+		case 5:
+			switch (osvi.dwMinorVersion)
+			{
+				case 1:
+					strcpy (winver, "XP");
+					break;
+				case 2:
+					if (osvi.wProductType == VER_NT_WORKSTATION)
+					{
+						strcpy (winver, "XP x64 Edition");
+					}
+					else
+					{
+						if (GetSystemMetrics(SM_SERVERR2) == 0)
+						{
+							strcpy (winver, "Server 2003");
+						}
+						else
+						{
+							strcpy (winver, "Server 2003 R2");
+						}
+					}
+					break;
+			}
+			break;
+		case 6:
+			switch (osvi.dwMinorVersion)
+			{
+				case 0:
+					if (osvi.wProductType == VER_NT_WORKSTATION)
+					{
+						strcpy (winver, "Vista");
+					}
+					else
+					{
+						strcpy (winver, "Server 2008");
+					}
+					break;
+				case 1:
+					if (osvi.wProductType == VER_NT_WORKSTATION)
+					{
+						strcpy (winver, "7");
+					}
+					else
+					{
+						strcpy (winver, "Server 2008 R2");
+					}
+					break;
+				case 2:
+					if (osvi.wProductType == VER_NT_WORKSTATION)
+					{
+						strcpy (winver, "8");
+					}
+					else
+					{
+						strcpy (winver, "8 Server");
+					}
+					break;
+			}
+			break;
+	}
 
 	mhz = get_mhz ();
 	if (mhz)
 	{
 		double cpuspeed = ( mhz > 1000 ) ? mhz / 1000 : mhz;
 		const char *cpuspeedstr = ( mhz > 1000 ) ? "GHz" : "MHz";
-		sprintf (verbuf, "Windows %ld.%ld [i%d86/%.2f%s]",
-					osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel, 
-					cpuspeed, cpuspeedstr);
-	} else
-		sprintf (verbuf, "Windows %ld.%ld [i%d86]",
-			osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel);
-
+		sprintf (verbuf, "Windows %s [%.2f%s]",	winver, cpuspeed, cpuspeedstr);
+	}
+	else
+	{
+		sprintf (verbuf, "Windows %s", winver);
+	}
+	
 	return verbuf;
 }
 
diff --git a/src/common/util.h b/src/common/util.h
index fce45def..92d2a843 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -43,6 +43,12 @@ int strip_color2 (const char *src, int len, char *dst, int flags);
 int strip_hidden_attribute (char *src, char *dst);
 char *errorstring (int err);
 int waitline (int sok, char *buf, int bufsize, int);
+#ifdef WIN32
+int waitline2 (GIOChannel *source, char *buf, int bufsize);
+int get_cpu_arch (void);
+#else
+#define waitline2(source,buf,size) waitline(serv->childread,buf,size,0)
+#endif
 unsigned long make_ping_time (void);
 void move_file_utf8 (char *src_dir, char *dst_dir, char *fname, int dccpermissions);
 int mkdir_utf8 (char *dir);
diff --git a/src/common/wdkutil.c b/src/common/wdkutil.c
new file mode 100644
index 00000000..5bf4f0c0
--- /dev/null
+++ b/src/common/wdkutil.c
@@ -0,0 +1,27 @@
+#include <io.h>
+
+int
+portable_mode ()
+{
+	if ((_access( "portable-mode", 0 )) != -1)
+	{
+		return 1;
+	}
+	else
+	{
+		return 0;
+	}
+}
+
+int
+xtray_mode ()
+{
+	if ((_access( "plugins/xtray.dll", 0 )) != -1)
+	{
+		return 1;
+	}
+	else
+	{
+		return 0;
+	}
+}
diff --git a/src/common/wdkutil.h b/src/common/wdkutil.h
new file mode 100644
index 00000000..2e4c693a
--- /dev/null
+++ b/src/common/wdkutil.h
@@ -0,0 +1,2 @@
+int portable_mode ();
+int xtray_mode ();
diff --git a/src/common/xchat.c b/src/common/xchat.c
index afac9a0e..ba2f5d41 100644
--- a/src/common/xchat.c
+++ b/src/common/xchat.c
@@ -22,7 +22,6 @@
 #include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 
 #define WANTSOCKET
 #include "inet.h"
@@ -38,7 +37,7 @@
 #include "cfgfiles.h"
 #include "chanopt.h"
 #include "ignore.h"
-#include "xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 #include "plugin.h"
 #include "plugin-timer.h"
 #include "notify.h"
@@ -590,6 +589,7 @@ static char defaultconf_commands[] =
 	"NAME DMSG\n"			"CMD msg =%2 &3\n\n"\
 	"NAME EXIT\n"			"CMD quit\n\n"\
 	"NAME GREP\n"			"CMD lastlog -r &2\n\n"\
+	"NAME IGNALL\n"			"CMD ignore %2!*@* ALL\n\n"\
 	"NAME J\n"				"CMD join &2\n\n"\
 	"NAME KILL\n"			"CMD quote KILL %2 :&3\n\n"\
 	"NAME LEAVE\n"			"CMD part &2\n\n"\
diff --git a/src/common/xchat.h b/src/common/xchat.h
index db7a6c4b..3ec13e6b 100644
--- a/src/common/xchat.h
+++ b/src/common/xchat.h
@@ -12,12 +12,14 @@
 
 #include "history.h"
 
+#ifndef ENABLE_NLS
 #ifndef HAVE_SNPRINTF
 #define snprintf g_snprintf
 #endif
 
 #ifndef HAVE_VSNPRINTF
-#define vsnprintf g_vsnprintf
+#define vsnprintf _vsnprintf
+#endif
 #endif
 
 #ifdef USE_DEBUG
@@ -58,7 +60,7 @@ void *xchat_realloc (char *old, int len, char *file, int line);
 
 #ifdef WIN32						/* for win32 */
 #define OFLAGS O_BINARY
-#define sleep(t) _sleep(t*1000)
+#define sleep(t) Sleep(t*1000)
 #include <direct.h>
 #define	F_OK	0
 #define	X_OK	1
@@ -119,6 +121,8 @@ struct xchatprefs
 	char partreason[256];
 	char font_normal[FONTNAMELEN + 1];
 	char doubleclickuser[256];
+	char gui_license[64];
+	char spell_langs[64];
 	char sounddir[PATHLEN + 1];
 	char soundcmd[PATHLEN + 1];
 	char background[PATHLEN + 1];
@@ -201,6 +205,7 @@ struct xchatprefs
 	unsigned int perc_ascii;
 	unsigned int autosave;
 	unsigned int autodialog;
+	unsigned int gui_auto_open_msg;
 	unsigned int autosave_url;
 	unsigned int autoreconnect;
 	unsigned int autoreconnectonfail;
@@ -209,6 +214,9 @@ struct xchatprefs
 	unsigned int wallops;
 	unsigned int skipmotd;
 	unsigned int autorejoin;
+	unsigned int autocopy_text;
+	unsigned int autocopy_stamp;
+	unsigned int autocopy_color;
 	unsigned int colorednicks;
 	unsigned int chanmodebuttons;
 	unsigned int userlistbuttons;
@@ -297,6 +305,9 @@ struct xchatprefs
 	unsigned int confmode;
 	unsigned int utf8_locale;
 	unsigned int identd;
+	unsigned int emoticons;
+	unsigned int tab_icons;
+	unsigned int tab_xp;
 
 	unsigned int ctcp_number_limit;	/*flood */
 	unsigned int ctcp_time_limit;	/*seconds of floods */
diff --git a/src/fe-gtk/about.c b/src/fe-gtk/about.c
index 60700aec..e1e5149c 100644
--- a/src/fe-gtk/about.c
+++ b/src/fe-gtk/about.c
@@ -39,6 +39,8 @@
 
 #include "../common/xchat.h"
 #include "../common/util.h"
+#include "../common/wdkutil.h"
+#include "../common/xchatc.h"
 #include "palette.h"
 #include "pixmaps.h"
 #include "gtkutil.h"
@@ -95,7 +97,7 @@ menu_about (GtkWidget * wid, gpointer sess)
 	}
 
 	about = gtk_dialog_new ();
-	gtk_window_set_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER);
+	gtk_window_set_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER_ON_PARENT);
 	gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
 	gtk_window_set_title (GTK_WINDOW (about), _("About "DISPLAY_NAME));
 	if (parent_window)
@@ -113,36 +115,45 @@ menu_about (GtkWidget * wid, gpointer sess)
 	gtk_container_add (GTK_CONTAINER (vbox), label);
 	g_get_charset (&locale);
 	(snprintf) (buf, sizeof (buf),
-				"<span size=\"x-large\"><b>"DISPLAY_NAME" "PACKAGE_VERSION"</b></span>\n\n"
-				"%s\n\n"
+				"<span size=\"x-large\"><b>"DISPLAY_NAME" "PACKAGE_VERSION"</b></span>\n"
+				"<span size=\"x-large\">%s</span>\n\n"
 #ifdef WIN32
-				/* leave this message to avoid time wasting bug reports! */
-				"This version is unofficial and comes with no support.\n\n"
-#endif
-				"%s\n"
+				"<b>XChat Release</b>: "XCHAT_RELEASE"\n\n"
+				"<b>OS</b>: %s\n"
 				"<b>Charset</b>: %s "
-#ifdef WIN32 
 				"<b>GTK+</b>: %i.%i.%i\n"
+				"<b>Compiled</b>: "__DATE__"\n"
+				"<b>Portable Mode</b>: %s\n"
+				"<b>Build Type</b>: x%d\n\n"
+				"<small>This version is unofficial and comes with no support.\n"
+				"\302\251 1998-2010 Peter \305\275elezn\303\275 &lt;zed@xchat.org>"
+				/* "\n<a href=\"http://code.google.com/p/xchat-wdk/\">http://code.google.com/p/xchat-wdk/</a>" this is broken in gtk ATM */
+				"</small>",
+				prefs.gui_license,
+				get_cpu_str (),
+				locale,
+				gtk_major_version,
+				gtk_minor_version,
+				gtk_micro_version,
+				(portable_mode () ? "Yes" : "No"),
+				get_cpu_arch ()
 #else
+				"%s\n\n"
+				"%s\n"
+				"<b>Charset</b>: %s "
 				"<b>Renderer</b>: %s\n"
-#endif
 				"<b>Compiled</b>: "__DATE__"\n\n"
 				"<small>\302\251 1998-2010 Peter \305\275elezn\303\275 &lt;zed@xchat.org></small>",
-					_("A multiplatform IRC Client"),
-					get_cpu_str(),
-					locale,
-#ifdef WIN32
-					gtk_major_version,
-					gtk_minor_version,
-					gtk_micro_version
-#else
+				_("A multiplatform IRC Client"),
+				get_cpu_str (),
+				locale,
 #ifdef USE_XFT
-					"Xft"
+				"Xft"
 #else
-					"Pango"
+				"Pango"
 #endif
 #endif
-					);
+				);
 	gtk_label_set_markup (GTK_LABEL (label), buf);
 	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
 
diff --git a/src/fe-gtk/banlist.c b/src/fe-gtk/banlist.c
index afaa7eb4..a714d186 100644
--- a/src/fe-gtk/banlist.c
+++ b/src/fe-gtk/banlist.c
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
 
@@ -134,11 +133,8 @@ banlist_do_refresh (struct session *sess)
 		gtk_list_store_clear (store);
 
 		handle_command (sess, "ban", FALSE);
-#ifdef WIN32
-		if (0)
-#else
+
 		if (supports_exempt (sess->server))
-#endif
 		{
 			snprintf (tbuf, sizeof (tbuf), "quote mode %s +e", sess->channel);
 			handle_command (sess, tbuf, FALSE);
diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c
index 2f65b518..6203083b 100644
--- a/src/fe-gtk/chanlist.c
+++ b/src/fe-gtk/chanlist.c
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
 
diff --git a/src/fe-gtk/chanview-tabs.c b/src/fe-gtk/chanview-tabs.c
index 8e3da8e6..f99e61f1 100644
--- a/src/fe-gtk/chanview-tabs.c
+++ b/src/fe-gtk/chanview-tabs.c
@@ -144,8 +144,8 @@ tab_scroll_left_up_clicked (GtkWidget *widget, chanview *cv)
 		for (i = adj->value; ((i > new_value) && (tab_left_is_moving)); i -= 0.1)
 		{
 			gtk_adjustment_set_value (adj, i);
-			while (g_main_pending ())
-				g_main_iteration (TRUE);
+			while (g_main_context_pending (NULL))
+				g_main_context_iteration (NULL, TRUE);
 		}
 
 		gtk_adjustment_set_value (adj, new_value);
@@ -191,8 +191,8 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
 		for (i = adj->value; ((i < new_value) && (tab_right_is_moving)); i += 0.1)
 		{
 			gtk_adjustment_set_value (adj, i);
-			while (g_main_pending ())
-				g_main_iteration (TRUE);
+			while (g_main_context_pending (NULL))
+				g_main_context_iteration (NULL, TRUE);
 		}
 
 		gtk_adjustment_set_value (adj, new_value);
diff --git a/src/fe-gtk/editlist.c b/src/fe-gtk/editlist.c
index 5af67e32..fd2d6810 100644
--- a/src/fe-gtk/editlist.c
+++ b/src/fe-gtk/editlist.c
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c
index 5efcaeec..3f403f94 100644
--- a/src/fe-gtk/fe-gtk.c
+++ b/src/fe-gtk/fe-gtk.c
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 
 #include "fe-gtk.h"
 
@@ -32,6 +31,8 @@
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtkversion.h>
 
+#include <gdk/gdkwin32.h>
+
 #include "../common/xchat.h"
 #include "../common/fe.h"
 #include "../common/util.h"
@@ -39,6 +40,7 @@
 #include "../common/cfgfiles.h"
 #include "../common/xchatc.h"
 #include "../common/plugin.h"
+#include "../common/server.h"
 #include "gtkutil.h"
 #include "maingui.h"
 #include "pixmaps.h"
@@ -136,11 +138,26 @@ static const GOptionEntry gopt_entries[] =
  {NULL}
 };
 
+#ifdef WIN32
+static void
+create_msg_dialog (gchar *title, gchar *message)
+{
+	GtkWidget *dialog;
+	dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, message);
+	gtk_window_set_title (GTK_WINDOW (dialog), title);
+	gtk_dialog_run (GTK_DIALOG (dialog));
+	gtk_widget_destroy (dialog);
+}
+#endif
+
 int
 fe_args (int argc, char *argv[])
 {
 	GError *error = NULL;
 	GOptionContext *context;
+#ifdef WIN32
+	char *buffer[2048];
+#endif
 
 #ifdef ENABLE_NLS
 	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
@@ -149,22 +166,67 @@ fe_args (int argc, char *argv[])
 #endif
 
 	context = g_option_context_new (NULL);
+#ifdef WIN32
+	g_option_context_set_help_enabled (context, FALSE);	/* disable stdout help as stdout is unavailable for subsystem:windows */
+#endif
 	g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE);
 	g_option_context_add_group (context, gtk_get_option_group (FALSE));
 	g_option_context_parse (context, &argc, &argv, &error);
 
+#ifdef WIN32
+	if (error)											/* workaround for argv not being available when using subsystem:windows */
+	{
+		if (error->message)								/* the error message contains argv so search for patterns in that */
+		{
+			if (strstr (error->message, "--help-all") != NULL)
+			{
+				if (snprintf (buffer, 2048, g_option_context_get_help (context, FALSE, NULL)))
+				{
+					gtk_init (&argc, &argv);
+					create_msg_dialog ("Long Help", buffer);
+				}
+				return 0;
+			} else if (strstr (error->message, "--help") != NULL || strstr (error->message, "-?") != NULL)
+			{
+				if (snprintf (buffer, 2048, g_option_context_get_help (context, TRUE, NULL)))
+				{
+					gtk_init (&argc, &argv);
+					create_msg_dialog ("Help", buffer);
+				}
+				return 0;
+			} else 
+			{
+				if (snprintf (buffer, 2048, "%s\n", error->message))
+				{
+					gtk_init (&argc, &argv);
+					create_msg_dialog ("Error", buffer);
+				}
+				return 1;
+			}
+		}
+	}
+#else
 	if (error)
 	{
 		if (error->message)
 			printf ("%s\n", error->message);
 		return 1;
 	}
+#endif
 
 	g_option_context_free (context);
 
 	if (arg_show_version)
 	{
+#ifdef WIN32
+		if (snprintf (buffer, 2048, DISPLAY_NAME" "PACKAGE_VERSION"\n"))
+		{
+			gtk_init (&argc, &argv);
+			create_msg_dialog ("Version Information", buffer);
+		}
+#else
 		printf (PACKAGE_TARNAME" "PACKAGE_VERSION"\n");
+#endif
 		return 0;
 	}
 
@@ -177,7 +239,18 @@ fe_args (int argc, char *argv[])
 		if (sl)
 		{
 			*sl = 0;
-			printf ("%s\\plugins\n", exe);
+			if (snprintf (buffer, 2048, "%s\\plugins\n", exe))
+			{
+				gtk_init (&argc, &argv);
+				create_msg_dialog ("Plugin Auto-load Directory", buffer);
+			}
+		} else
+		{
+			if (snprintf (buffer, 2048, ".\\plugins\n"))
+			{
+				gtk_init (&argc, &argv);
+				create_msg_dialog ("Plugin Auto-load Directory", buffer);
+			}
 		}
 #else
 		printf ("%s\n", XCHATLIBDIR"/plugins");
@@ -187,7 +260,15 @@ fe_args (int argc, char *argv[])
 
 	if (arg_show_config)
 	{
+#ifdef WIN32
+		if (snprintf (buffer, 2048, "%s\n", get_xdir_fs ()))
+		{
+			gtk_init (&argc, &argv);
+			create_msg_dialog ("User Config Directory", buffer);
+		}
+#else
 		printf ("%s\n", get_xdir_fs ());
+#endif
 		return 0;
 	}
 
@@ -330,7 +411,7 @@ log_handler (const gchar   *log_domain,
 {
 	session *sess;
 
-	if (getenv ("XCHAT_WARNING_IGNORE"))
+	/* if (getenv ("XCHAT_WARNING_IGNORE")) */
 		return;
 
 	sess = find_dialog (serv_list->data, "(warnings)");
diff --git a/src/fe-gtk/fe-gtk.h b/src/fe-gtk/fe-gtk.h
index 12516259..4183f559 100644
--- a/src/fe-gtk/fe-gtk.h
+++ b/src/fe-gtk/fe-gtk.h
@@ -4,7 +4,7 @@
 /* If you're compiling this for Windows, your release is un-official
  * and not condoned. Please don't use the XChat name. Make up your
  * own name! */
-#define DISPLAY_NAME "XChat-Unofficial"
+#define DISPLAY_NAME "XChat-WDK"
 #else
 #define DISPLAY_NAME "XChat"
 #endif
diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c
index 014b5cc3..7330854a 100644
--- a/src/fe-gtk/fkeys.c
+++ b/src/fe-gtk/fkeys.c
@@ -20,7 +20,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
 #include <ctype.h>
@@ -315,7 +314,7 @@ key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess)
 		key_action_tab_clean ();
 		break;
 
-#if defined(USE_GTKSPELL) && !defined(WIN32)
+#if defined(USE_GTKSPELL)/* && !defined(WIN32)
 	/* gtktextview has no 'activate' event, so we trap ENTER here */
 	case GDK_Return:
 	case GDK_KP_Enter:
diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c
index 63ab491b..522b44df 100644
--- a/src/fe-gtk/gtkutil.c
+++ b/src/fe-gtk/gtkutil.c
@@ -22,7 +22,6 @@
 #include <stdarg.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include "fe-gtk.h"
 
@@ -51,6 +50,10 @@
 #include "../common/util.h"
 #include "gtkutil.h"
 #include "pixmaps.h"
+#ifdef WIN32
+#include "../common/fe.h"
+#include "../common/thread.h"
+#endif
 
 /* gtkutil.c, just some gtk wrappers */
 
@@ -63,6 +66,13 @@ struct file_req
 	void *userdata;
 	filereqcallback callback;
 	int flags;		/* FRF_* flags */
+
+#ifdef WIN32
+	int multiple;
+	thread *th;
+	char *title;	/* native locale */
+	char *filter;
+#endif
 };
 
 static char last_dir[256] = "";
@@ -164,6 +174,190 @@ gtkutil_file_req_response (GtkWidget *dialog, gint res, struct file_req *freq)
 	}
 }
 
+#ifdef WIN32
+static int
+win32_openfile (char *file_buf, int file_buf_len, char *title_text, char *filter,
+			   int multiple)
+{
+	OPENFILENAME o;
+
+	memset (&o, 0, sizeof (o));
+
+	o.lStructSize = sizeof (o);
+	o.lpstrFilter = filter;
+	o.lpstrFile = file_buf;
+	o.nMaxFile = file_buf_len;
+	o.lpstrTitle = title_text;
+	o.Flags = 0x02000000 | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY |
+				OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON;
+	if (multiple)
+	{
+		o.Flags |= OFN_ALLOWMULTISELECT;
+	}
+
+	return GetOpenFileName (&o);
+}
+
+static int
+win32_savefile (char *file_buf, int file_buf_len, char *title_text, char *filter,
+               int multiple)
+{
+	/* we need the filter to get the default filename. it is from fe-gtk.c (fe_confirm);
+	 * but that filter is actually the whole filename, so apply an empty filter and all good.
+	 * in win32_thread2 we copy the filter ( = the filename) after the last dir into our
+	 * LPTSTR file buffer to make it actually work. the docs for this amazingly retard api:
+	 *
+	 * http://msdn.microsoft.com/en-us/library/ms646839%28VS.85%29.aspx
+	 */
+
+	OPENFILENAME o;
+
+	memset (&o, 0, sizeof (o));
+
+	o.lStructSize = sizeof (o);
+	o.lpstrFilter = "All files\0*.*\0\0";
+	o.lpstrFile = file_buf;
+	o.nMaxFile = file_buf_len;
+	o.lpstrTitle = title_text;
+	o.Flags = 0x02000000 | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY |
+				OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON;
+	if (multiple)
+	{
+		o.Flags |= OFN_ALLOWMULTISELECT;
+	}
+
+	return GetSaveFileName (&o);
+}
+
+static void *
+win32_thread (struct file_req *freq)
+{
+	char buf[1024 + 32];
+	char file[1024];
+
+	memset (file, 0, sizeof (file));
+	safe_strcpy (file, last_dir, sizeof (file));
+
+	if (win32_openfile (file, sizeof (file), freq->title, freq->filter, freq->multiple))
+	{
+		if (freq->multiple)
+		{
+			char *f = file;
+
+			if (f[strlen (f) + 1] == 0)	/* only selected one file */
+			{
+				snprintf (buf, sizeof (buf), "1\n%s\n", file);
+				write (freq->th->pipe_fd[1], buf, strlen (buf));
+			} else
+			{
+				f += strlen (f) + 1; /* skip first, it's only the dir */
+				while (f[0])
+				{
+					snprintf (buf, sizeof (buf), "1\n%s\\%s\n", /*dir!*/file, f);
+					write (freq->th->pipe_fd[1], buf, strlen (buf));
+					f += strlen (f) + 1;
+				}
+			}
+
+		} else
+		{
+			snprintf (buf, sizeof (buf), "1\n%s\n", file);
+			write (freq->th->pipe_fd[1], buf, strlen (buf));
+		}
+	}
+
+	write (freq->th->pipe_fd[1], "0\n", 2);
+	Sleep (2000);
+
+	return NULL;
+}
+
+static void *
+win32_thread2 (struct file_req *freq)
+{
+	char buf[1024 + 32];
+	char file[1024];
+
+	memset (file, 0, sizeof (file));
+	safe_strcpy (file, last_dir, sizeof (file));
+	safe_strcpy (file, freq->filter, sizeof (file));
+
+	if (win32_savefile (file, sizeof (file), freq->title, NULL, freq->multiple))
+	{
+		if (freq->multiple)
+		{
+			char *f = file;
+
+			if (f[strlen (f) + 1] == 0)    /* only selected one file */
+			{
+				snprintf (buf, sizeof (buf), "1\n%s\n", file);
+				write (freq->th->pipe_fd[1], buf, strlen (buf));
+			} else
+			{
+				f += strlen (f) + 1; /* skip first, it's only the dir */
+				while (f[0])
+				{
+					snprintf (buf, sizeof (buf), "1\n%s\\%s\n", /*dir!*/file, f);
+					write (freq->th->pipe_fd[1], buf, strlen (buf));
+					f += strlen (f) + 1;
+				}
+			}
+
+		} else
+		{
+			snprintf (buf, sizeof (buf), "1\n%s\n", file);
+			write (freq->th->pipe_fd[1], buf, strlen (buf));
+		}
+	}
+
+	write (freq->th->pipe_fd[1], "0\n", 2);
+	Sleep (2000);
+
+	return NULL;
+}
+
+static gboolean
+win32_close_pipe (int fd)
+{
+	close (fd);
+	return 0;
+}
+
+static gboolean
+win32_read_thread (GIOChannel *source, GIOCondition cond, struct file_req *freq)
+{
+	char buf[512];
+	char *file;
+
+	waitline2 (source, buf, sizeof buf);
+
+	switch (buf[0])
+	{
+	case '0':	/* filedialog has closed */
+		freq->callback (freq->userdata, NULL);
+		break;
+
+	case '1':	/* got a filename! */
+		waitline2 (source, buf, sizeof buf);
+		file = g_filename_to_utf8 (buf, -1, 0, 0, 0);
+		freq->callback (freq->userdata, file);
+		g_free (file);
+		return TRUE;
+	}
+
+	/* it doesn't work to close them here, because of the weird
+		way giowin32 works. We must _return_ before closing them */
+	g_timeout_add(3000, (GSourceFunc)win32_close_pipe, freq->th->pipe_fd[0]);
+	g_timeout_add(2000, (GSourceFunc)win32_close_pipe, freq->th->pipe_fd[1]);
+
+	g_free (freq->title);
+	free (freq->th);
+	free (freq);
+
+	return FALSE;
+}
+#endif
+
 void
 gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter,
 						int flags)
@@ -172,6 +366,58 @@ gtkutil_file_req (const char *title, void *callback, void *userdata, char *filte
 	GtkWidget *dialog;
 	extern char *get_xdir_fs (void);
 
+#ifdef WIN32
+	if (!(flags & FRF_WRITE))
+	{
+		freq = malloc (sizeof (struct file_req));
+		freq->th = thread_new ();
+		freq->flags = 0;
+		freq->multiple = (flags & FRF_MULTIPLE);
+		freq->callback = callback;
+		freq->userdata = userdata;
+		freq->title = g_locale_from_utf8 (title, -1, 0, 0, 0);
+		if (!filter)
+		{
+			freq->filter =	"All files\0*.*\0"
+							"Executables\0*.exe\0"
+							"ZIP files\0*.zip\0\0";
+		}
+		else
+		{
+			freq->filter = filter;
+		}
+
+		thread_start (freq->th, win32_thread, freq);
+		fe_input_add (freq->th->pipe_fd[0], FIA_FD|FIA_READ, win32_read_thread, freq);
+
+		return;
+
+	}
+	
+	else {
+		freq = malloc (sizeof (struct file_req));
+		freq->th = thread_new ();
+		freq->flags = 0;
+		freq->multiple = (flags & FRF_MULTIPLE);
+		freq->callback = callback;
+		freq->userdata = userdata;
+		freq->title = g_locale_from_utf8 (title, -1, 0, 0, 0);
+		if (!filter)
+		{
+			freq->filter = "All files\0*.*\0\0";
+		}
+		else
+		{
+			freq->filter = filter;
+		}
+
+		thread_start (freq->th, win32_thread2, freq);
+		fe_input_add (freq->th->pipe_fd[0], FIA_FD|FIA_READ, win32_read_thread, freq);
+
+	return;
+	}
+#endif
+
 	if (flags & FRF_WRITE)
 	{
 		dialog = gtk_file_chooser_dialog_new (title, NULL,
diff --git a/src/fe-gtk/joind.c b/src/fe-gtk/joind.c
index ee5c56d1..6cd812cf 100644
--- a/src/fe-gtk/joind.c
+++ b/src/fe-gtk/joind.c
@@ -9,7 +9,6 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdio.h>
 
diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c
index ef269f95..74157a7f 100644
--- a/src/fe-gtk/maingui.c
+++ b/src/fe-gtk/maingui.c
@@ -53,6 +53,7 @@
 #include "../common/plugin.h"
 #include "../common/modes.h"
 #include "../common/url.h"
+#include "../common/wdkutil.h"
 #include "fe-gtk.h"
 #include "banlist.h"
 #include "gtkutil.h"
@@ -214,60 +215,10 @@ mg_create_tab_colors (void)
 	away_list = mg_attr_list_create (&colors[COL_AWAY], FALSE);
 }
 
-#ifdef WIN32
-#define WINVER 0x0501	/* needed for vc6? */
-#include <windows.h>
-#include <gdk/gdkwin32.h>
-
-/* Flash the taskbar button on Windows when there's a highlight event. */
-
-static void
-flash_window (GtkWidget *win)
-{
-	FLASHWINFO fi;
-	static HMODULE user = NULL;
-	static BOOL (*flash) (PFLASHWINFO) = NULL;
-
-	if (!user)
-	{
-		user = GetModuleHandleA ("USER32");
-		if (!user)
-			return;	/* this should never fail */
-	}
-
-	if (!flash)
-	{
-		flash = (void *)GetProcAddress (user, "FlashWindowEx");
-		if (!flash)
-			return;	/* this fails on NT4.0 and Win95 */
-	}
-
-	fi.cbSize = sizeof (fi);
-	fi.hwnd = GDK_WINDOW_HWND (win->window);
-	fi.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
-	fi.uCount = 0;
-	fi.dwTimeout = 500;
-	flash (&fi);
-	/*FlashWindowEx (&fi);*/
-}
-#else
-
-#ifdef USE_XLIB
-#include <gdk/gdkx.h>
-
 static void
 set_window_urgency (GtkWidget *win, gboolean set)
 {
-	XWMHints *hints;
-
-	hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win->window), GDK_WINDOW_XWINDOW(win->window));
-	if (set)
-		hints->flags |= XUrgencyHint;
-	else
-		hints->flags &= ~XUrgencyHint;
-	XSetWMHints(GDK_WINDOW_XDISPLAY(win->window),
-	            GDK_WINDOW_XWINDOW(win->window), hints);
-	XFree(hints);
+	gtk_window_set_urgency_hint (GTK_WINDOW (win), set);
 }
 
 static void
@@ -281,18 +232,14 @@ unflash_window (GtkWidget *win)
 {
 	set_window_urgency (win, FALSE);
 }
-#endif
-#endif
 
 /* flash the taskbar button */
 
 void
 fe_flash_window (session *sess)
 {
-#if defined(WIN32) || defined(USE_XLIB)
 	if (fe_gui_info (sess, 0) != 1)	/* only do it if not focused */
 		flash_window (sess->gui->window);
-#endif
 }
 
 /* set a tab plain, red, light-red, or blue */
@@ -529,10 +476,22 @@ fe_set_title (session *sess)
 		break;
 	default:
 	def:
-		gtk_window_set_title (GTK_WINDOW (sess->gui->window), DISPLAY_NAME);
+		snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME);
+		if (strcmp (prefs.gui_license, ""))		/* zero means gui_license is empty */
+		{
+			strcat (tbuf, " - ");
+			strcat (tbuf, prefs.gui_license);
+		}
+		gtk_window_set_title (GTK_WINDOW (sess->gui->window), tbuf);
 		return;
 	}
 
+	if (strcmp (prefs.gui_license, ""))			/* zero means gui_license is empty */
+	{
+		strcat (tbuf, " - ");
+		strcat (tbuf, prefs.gui_license);
+	}
+
 	gtk_window_set_title (GTK_WINDOW (sess->gui->window), tbuf);
 }
 
@@ -1334,7 +1293,7 @@ mg_open_quit_dialog (gboolean minimize_button)
 	gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1),
 										GTK_BUTTONBOX_END);
 
-	if (minimize_button)
+	if (minimize_button && !xtray_mode ())
 	{
 		button = gtk_button_new_with_mnemonic (_("_Minimize to Tray"));
 		gtk_widget_show (button);
@@ -1632,7 +1591,12 @@ mg_create_alertmenu (session *sess, GtkWidget *menu)
 	submenu = menu_quick_sub (_("_Extra Alerts"), menu, NULL, XCMENU_MNEMONIC, -1);
 
 	mg_perchan_menu_item (_("Beep on _Message"), submenu, &sess->alert_beep, prefs.input_beep_chans);
-	mg_perchan_menu_item (_("Blink Tray _Icon"), submenu, &sess->alert_tray, prefs.input_tray_chans);
+
+	if (!xtray_mode ())		/*disable this context menu item when xtray is loaded */
+	{
+		mg_perchan_menu_item (_("Blink Tray _Icon"), submenu, &sess->alert_tray, prefs.input_tray_chans);
+	}
+
 	mg_perchan_menu_item (_("Blink Task _Bar"), submenu, &sess->alert_taskbar, prefs.input_flash_chans);
 }
 
@@ -2972,11 +2936,7 @@ mg_tabwin_focus_cb (GtkWindow * win, GdkEventFocus *event, gpointer userdata)
 		gtk_xtext_check_marker_visibility (GTK_XTEXT (current_sess->gui->xtext));
 		plugin_emit_dummy_print (current_sess, "Focus Window");
 	}
-#ifndef WIN32
-#ifdef USE_XLIB
 	unflash_window (GTK_WIDGET (win));
-#endif
-#endif
 	return FALSE;
 }
 
@@ -2987,11 +2947,7 @@ mg_topwin_focus_cb (GtkWindow * win, GdkEventFocus *event, session *sess)
 	if (!sess->server->server_session)
 		sess->server->server_session = sess;
 	gtk_xtext_check_marker_visibility(GTK_XTEXT (current_sess->gui->xtext));
-#ifndef WIN32
-#ifdef USE_XLIB
 	unflash_window (GTK_WIDGET (win));
-#endif
-#endif
 	plugin_emit_dummy_print (sess, "Focus Window");
 	return FALSE;
 }
diff --git a/src/fe-gtk/makefile.mak b/src/fe-gtk/makefile.mak
new file mode 100644
index 00000000..27922405
--- /dev/null
+++ b/src/fe-gtk/makefile.mak
@@ -0,0 +1,62 @@
+include "..\makeinc.mak"
+
+FEGTK_OBJECTS = \
+about.obj \
+ascii.obj \
+banlist.obj \
+chanlist.obj \
+chanview.obj \
+custom-list.obj \
+dccgui.obj \
+editlist.obj \
+fe-gtk.obj \
+fkeys.obj \
+gtkutil.obj \
+ignoregui.obj \
+joind.obj \
+maingui.obj \
+menu.obj \
+notifygui.obj \
+palette.obj \
+pixmaps.obj \
+plugingui.obj \
+plugin-tray.obj \
+rawlog.obj \
+search.obj \
+servlistgui.obj \
+setup.obj \
+sexy-iso-codes.obj \
+sexy-marshal.obj \
+sexy-spell-entry.obj \
+textgui.obj \
+urlgrab.obj \
+userlistgui.obj \
+xtext.obj
+
+!ifdef X64
+MACHINE_FLAG = /MACHINE:X64
+!else
+MACHINE_FLAG = /MACHINE:X86
+!endif
+
+COMLIB = ..\common\xchatcommon.lib
+PROG = xchat.exe
+
+all: $(PROG)
+
+.c.obj::
+	$(CC) $(CFLAGS) -I..\..\plugins $(GLIB) $(GTK) $<
+
+$(PROG): $(FEGTK_OBJECTS) $(COMLIB) xchat-icon.obj
+	$(LINK) /out:$(PROG) /entry:mainCRTStartup $(LDFLAGS) $(LIBS) $(FEGTK_OBJECTS) $(COMLIB) xchat-icon.obj
+
+xchat.res: xchat.rc ../../xchat.ico
+	rc /nologo /r xchat.rc
+
+xchat-icon.obj: xchat.res
+	cvtres /nologo $(MACHINE_FLAG) /OUT:xchat-icon.obj xchat.res
+
+clean:
+	@del *.obj
+	@del $(PROG)
+	@del xchat.res
diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c
index d04be222..da90ca7f 100644
--- a/src/fe-gtk/menu.c
+++ b/src/fe-gtk/menu.c
@@ -20,7 +20,6 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <string.h>
-#include <unistd.h>
 
 #ifdef WIN32
 #include <windows.h>
@@ -1204,6 +1203,12 @@ menu_resetmarker (GtkWidget * wid, gpointer none)
 }
 
 static void
+menu_copy_selection (GtkWidget * wid, gpointer none)
+{
+	gtk_xtext_copy_selection (GTK_XTEXT (current_sess->gui->xtext));
+}
+
+static void
 menu_flushbuffer (GtkWidget * wid, gpointer none)
 {
 	fe_text_clear (current_sess, 0);
@@ -1580,7 +1585,7 @@ static struct mymenu mymenu[] = {
 #endif
 	{0, 0, 0, M_SEP, 0, 0, 0},	/* 11 */
 #define DETACH_OFFSET (12)
-	{0, menu_detach, GTK_STOCK_REDO, M_MENUSTOCK, 0, 0, 1, GDK_I},	/* 12 */
+	{0, menu_detach, GTK_STOCK_REDO, M_MENUSTOCK, 0, 0, 1, GDK_i},	/* 12 */
 #define CLOSE_OFFSET (13)
 	{0, menu_close, GTK_STOCK_CLOSE, M_MENUSTOCK, 0, 0, 1, GDK_w},
 	{0, 0, 0, M_SEP, 0, 0, 0},
@@ -1645,6 +1650,7 @@ static struct mymenu mymenu[] = {
 	{N_("URL Grabber..."), url_opengui, 0, M_MENUITEM, 0, 0, 1},
 	{0, 0, 0, M_SEP, 0, 0, 0},
 	{N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, GDK_m},
+	{N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1, GDK_C},
 	{N_("C_lear Text"), menu_flushbuffer, GTK_STOCK_CLEAR, M_MENUSTOCK, 0, 0, 1, GDK_l},
 #define SEARCH_OFFSET 67
 	{N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f},
@@ -2188,7 +2194,9 @@ normalitem:
 										mymenu[i].key,
 										mymenu[i].key == GDK_F1 ? 0 :
 										mymenu[i].key == GDK_w ? close_mask :
-										GDK_CONTROL_MASK,
+										(g_ascii_isupper (mymenu[i].key)) ?
+											GDK_SHIFT_MASK | GDK_CONTROL_MASK :
+											GDK_CONTROL_MASK,
 										GTK_ACCEL_VISIBLE);
 			if (mymenu[i].callback)
 				g_signal_connect (G_OBJECT (item), "activate",
diff --git a/src/fe-gtk/palette.c b/src/fe-gtk/palette.c
index ebae92ff..b94ac874 100644
--- a/src/fe-gtk/palette.c
+++ b/src/fe-gtk/palette.c
@@ -18,7 +18,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -78,8 +77,9 @@ GdkColor colors[] = {
 	{0, 0x0000, 0x0000, 0xffff}, /* 38 tab Nick Mentioned (blue) */
 	{0, 0xffff, 0x0000, 0x0000}, /* 39 tab New Message (red) */
 	{0, 0x9595, 0x9595, 0x9595}, /* 40 away user (grey) */
+	{0, 0xffff, 0x0000, 0x0000}, /* 41 spell checker color (red) */
 };
-#define MAX_COL 40
+#define MAX_COL 41
 
 
 void
diff --git a/src/fe-gtk/palette.h b/src/fe-gtk/palette.h
index c97693bb..627c6963 100644
--- a/src/fe-gtk/palette.h
+++ b/src/fe-gtk/palette.h
@@ -9,6 +9,7 @@ extern GdkColor colors[];
 #define COL_HILIGHT 38
 #define COL_NEW_MSG 39
 #define COL_AWAY 40
+#define COL_SPELL 41
 
 void palette_alloc (GtkWidget * widget);
 void palette_load (void);
diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c
index e46d9570..62a726a4 100644
--- a/src/fe-gtk/plugin-tray.c
+++ b/src/fe-gtk/plugin-tray.c
@@ -1,14 +1,14 @@
 /* Copyright (C) 2006-2007 Peter Zelezny. */
 
 #include <string.h>
-#include <unistd.h>
-#include "../common/xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 #include "../common/xchat.h"
 #include "../common/xchatc.h"
 #include "../common/inbound.h"
 #include "../common/server.h"
 #include "../common/fe.h"
 #include "../common/util.h"
+#include "../common/wdkutil.h"
 #include "fe-gtk.h"
 #include "pixmaps.h"
 #include "maingui.h"
@@ -217,10 +217,10 @@ tray_stop_flash (void)
 		nets = tray_count_networks ();
 		chans = tray_count_channels ();
 		if (nets)
-			tray_set_tipf (_("XChat: Connected to %u networks and %u channels"),
+			tray_set_tipf (_("XChat-WDK: Connected to %u networks and %u channels"),
 								nets, chans);
 		else
-			tray_set_tipf ("XChat: %s", _("Not connected."));
+			tray_set_tipf ("XChat-WDK: %s", _("Not connected."));
 	}
 
 	if (custom_icon1)
@@ -370,7 +370,7 @@ tray_toggle_visibility (gboolean force_hide)
 	/* ph may have an invalid context now */
 	xchat_set_context (ph, xchat_find_context (ph, NULL, NULL));
 
-	win = (GtkWindow *)xchat_get_info (ph, "win_ptr");
+	win = xchat_get_info (ph, "gtkwin_ptr");
 
 	tray_stop_flash ();
 	tray_reset_counts ();
@@ -505,11 +505,12 @@ tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata)
 	/*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/
 
 	if (tray_get_window_status () == WS_HIDDEN)
-		tray_make_item (menu, _("_Restore"), tray_menu_restore_cb, NULL);
+		tray_make_item (menu, _("_Restore Window"), tray_menu_restore_cb, NULL);
 	else
-		tray_make_item (menu, _("_Hide"), tray_menu_restore_cb, NULL);
+		tray_make_item (menu, _("_Hide Window"), tray_menu_restore_cb, NULL);
 	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);
 
+#if 0
 	submenu = mg_submenu (menu, _("_Blink on"));
 	blink_item (&prefs.input_tray_chans, submenu, _("Channel Message"));
 	blink_item (&prefs.input_tray_priv, submenu, _("Private Message"));
@@ -526,6 +527,7 @@ tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata)
 		gtk_widget_set_sensitive (item, FALSE);
 
 	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);
+#endif
 	mg_create_icon_item (_("_Quit"), GTK_STOCK_QUIT, menu, tray_menu_quit_cb, NULL);
 
 	menu_add_plugin_items (menu, "\x5$TRAY", NULL);
@@ -551,8 +553,8 @@ tray_init (void)
 	sticon = gtk_status_icon_new_from_pixbuf (ICON_NORMAL);
 	if (!sticon)
 		return;
-	g_signal_connect (G_OBJECT (sticon), "popup-menu",
-							G_CALLBACK (tray_menu_cb), sticon);
+	/* g_signal_connect (G_OBJECT (sticon), "popup-menu",
+							G_CALLBACK (tray_menu_cb), sticon); */
 	g_signal_connect (G_OBJECT (sticon), "activate",
 							G_CALLBACK (tray_menu_restore_cb), NULL);
 }
@@ -570,15 +572,15 @@ tray_hilight_cb (char *word[], void *userdata)
 		/* FIXME: hides any previous private messages */
 		tray_hilight_count++;
 		if (tray_hilight_count == 1)
-			tray_set_tipf (_("XChat: Highlighted message from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: Highlighted message from: %s (%s)"),
 								word[1], xchat_get_info (ph, "channel"));
 		else
-			tray_set_tipf (_("XChat: %u highlighted messages, latest from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: %u highlighted messages, latest from: %s (%s)"),
 								tray_hilight_count, word[1], xchat_get_info (ph, "channel"));
 	}
 
 	if (prefs.input_balloon_hilight)
-		tray_set_balloonf (word[2], _("XChat: Highlighted message from: %s (%s)"),
+		tray_set_balloonf (word[2], _("XChat-WDK: Highlighted message from: %s (%s)"),
 								 word[1], xchat_get_info (ph, "channel"));
 
 	return XCHAT_EAT_NONE;
@@ -596,14 +598,14 @@ tray_message_cb (char *word[], void *userdata)
 
 		tray_pub_count++;
 		if (tray_pub_count == 1)
-			tray_set_tipf (_("XChat: New public message from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: New public message from: %s (%s)"),
 								word[1], xchat_get_info (ph, "channel"));
 		else
-			tray_set_tipf (_("XChat: %u new public messages."), tray_pub_count);
+			tray_set_tipf (_("XChat-WDK: %u new public messages."), tray_pub_count);
 	}
 
 	if (prefs.input_balloon_chans)
-		tray_set_balloonf (word[2], _("XChat: New public message from: %s (%s)"),
+		tray_set_balloonf (word[2], _("XChat-WDK: New public message from: %s (%s)"),
 								 word[1], xchat_get_info (ph, "channel"));
 
 	return XCHAT_EAT_NONE;
@@ -625,14 +627,14 @@ tray_priv (char *from, char *text)
 
 	tray_priv_count++;
 	if (tray_priv_count == 1)
-		tray_set_tipf (_("XChat: Private message from: %s (%s)"),
+		tray_set_tipf (_("XChat-WDK: Private message from: %s (%s)"),
 							from, network);
 	else
-		tray_set_tipf (_("XChat: %u private messages, latest from: %s (%s)"),
+		tray_set_tipf (_("XChat-WDK: %u private messages, latest from: %s (%s)"),
 							tray_priv_count, from, network);
 
 	if (prefs.input_balloon_priv)
-		tray_set_balloonf (text, _("XChat: Private message from: %s (%s)"),
+		tray_set_balloonf (text, _("XChat-WDK: Private message from: %s (%s)"),
 								 from, network);
 }
 
@@ -678,15 +680,15 @@ tray_dcc_cb (char *word[], void *userdata)
 
 		tray_file_count++;
 		if (tray_file_count == 1)
-			tray_set_tipf (_("XChat: File offer from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: File offer from: %s (%s)"),
 								word[1], network);
 		else
-			tray_set_tipf (_("XChat: %u file offers, latest from: %s (%s)"),
+			tray_set_tipf (_("XChat-WDK: %u file offers, latest from: %s (%s)"),
 								tray_file_count, word[1], network);
 	}
 
 	if (prefs.input_balloon_priv)
-		tray_set_balloonf ("", _("XChat: File offer from: %s (%s)"),
+		tray_set_balloonf ("", _("XChat-WDK: File offer from: %s (%s)"),
 								word[1], network);
 
 	return XCHAT_EAT_NONE;
@@ -722,7 +724,7 @@ tray_apply_setup (void)
 	}
 	else
 	{
-		if (prefs.gui_tray)
+		if (prefs.gui_tray && !xtray_mode ())
 			tray_init ();
 	}
 }
@@ -754,7 +756,7 @@ tray_plugin_init (xchat_plugin *plugin_handle, char **plugin_name,
 
 	xchat_hook_print (ph, "Focus Window", -1, tray_focus_cb, NULL);
 
-	if (prefs.gui_tray)
+	if (prefs.gui_tray && !xtray_mode ())
 		tray_init ();
 
 	return 1;       /* return 1 for success */
diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c
index de59e649..0edfc62b 100644
--- a/src/fe-gtk/plugingui.c
+++ b/src/fe-gtk/plugingui.c
@@ -35,7 +35,7 @@
 #include "../common/xchat.h"
 #define PLUGIN_C
 typedef struct session xchat_context;
-#include "../common/xchat-plugin.h"
+#include "../../plugins/xchat-plugin.h"
 #include "../common/plugin.h"
 #include "../common/util.h"
 #include "../common/outbound.h"
@@ -147,7 +147,9 @@ void
 plugingui_load (void)
 {
 	gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb,
-							current_sess, NULL, FRF_ADDFOLDER);
+							current_sess,
+							"Plugins and Scripts\0*.dll;*.lua;*.pl;*.py;*.tcl\0"
+							"All files\0*.*\0\0", 0);
 }
 
 static void
diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c
index 56ca0510..a3e1a63b 100644
--- a/src/fe-gtk/rawlog.c
+++ b/src/fe-gtk/rawlog.c
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 
 #include "fe-gtk.h"
diff --git a/src/fe-gtk/search.c b/src/fe-gtk/search.c
index d62e79c7..bbde9c5c 100644
--- a/src/fe-gtk/search.c
+++ b/src/fe-gtk/search.c
@@ -153,7 +153,7 @@ search_open (session * sess)
 								_("_Find"));
 	g_object_set_data (G_OBJECT (wid), "e", entry);
 
-	g_signal_connect (G_OBJECT (win), "key-press-event", G_CALLBACK (search_key_cb), win);
+	g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (search_key_cb), win);
 
 	gtk_widget_show (win);
 }
diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c
index 517e0944..a1a200a5 100644
--- a/src/fe-gtk/setup.c
+++ b/src/fe-gtk/setup.c
@@ -110,7 +110,7 @@ static const setting textbox_settings[] =
 	{ST_TOGGLR, N_("Indent nick names"), P_OFFINTNL(indent_nicks),
 					N_("Make nick names right-justified"),0,0},
 	{ST_TOGGLE, N_("Transparent background"), P_OFFINTNL(transparent),0,0,0},
-	{ST_TOGGLR, N_("Show marker line"), P_OFFINTNL(show_marker),
+	{ST_TOGGLE, N_("Show marker line"), P_OFFINTNL(show_marker),
 					N_("Insert a red line after the last read text."),0,0},
 	{ST_HEADER, N_("Transparency Settings"), 0,0,0},
 	{ST_HSCALE, N_("Red:"), P_OFFINTNL(tint_red),0,0,0},
@@ -122,6 +122,19 @@ static const setting textbox_settings[] =
 	{ST_ENTRY,  N_("Time stamp format:"), P_OFFSETNL(stamp_format),
 					N_("See strftime manpage for details."),0,sizeof prefs.stamp_format},
 
+	{ST_HEADER,	N_("Auto-Copy Behavior"),0,0,0},
+	{ST_TOGGLE, N_("Automatically copy selected text"), P_OFFINTNL(autocopy_text),
+					N_("Copy selected text to clipboard when left mouse button is released. "
+						"Otherwise, CONTROL-SHIFT-C will copy the "
+						"selected text to the clipboard."), 0, 0},
+	{ST_TOGGLE, N_("Automatically include time stamps"), P_OFFINTNL(autocopy_stamp),
+					N_("Automatically include time stamps in copied lines of text. Otherwise, "
+						"include time stamps if the SHIFT key is held down while selecting."), 0, 0},
+	{ST_TOGGLE, N_("Automatically include color information"), P_OFFINTNL(autocopy_color),
+					N_("Automatically include color information in copied lines of text.  "
+						"Otherwise, include color information if the CONTROL key is held down "
+						"while selecting."), 0, 0},
+
 	{ST_END, 0, 0, 0, 0, 0}
 };
 
@@ -138,6 +151,8 @@ static const setting inputbox_settings[] =
 	{ST_TOGGLE, N_("Use the Text box font and colors"), P_OFFINTNL(style_inputbox),0,0,0},
 #if defined(USE_GTKSPELL) || defined(USE_LIBSEXY)
 	{ST_TOGGLE, N_("Spell checking"), P_OFFINTNL(gui_input_spell),0,0,0},
+	{ST_ENTRY,	N_("Dictionaries to use:"), P_OFFSETNL(spell_langs),0,0,sizeof prefs.spell_langs},
+	{ST_LABEL,	N_("Use language codes (as in \"share\\myspell\\dicts\").\nSeparate multiple entries with commas.")},
 #endif
 
 	{ST_HEADER, N_("Nick Completion"),0,0,0},
@@ -250,6 +265,7 @@ static const setting tabs_settings[] =
 	{ST_TOGGLE, N_("Open an extra tab for server messages"), P_OFFINTNL(use_server_tab), 0, 0, 0},
 	{ST_TOGGLE, N_("Open an extra tab for server notices"), P_OFFINTNL(notices_tabs), 0, 0, 0},
 	{ST_TOGGLE, N_("Open a new tab when you receive a private message"), P_OFFINTNL(autodialog), 0, 0, 0},
+	{ST_TOGGLE, N_("Open a new tab when you send a private message"), P_OFFINTNL(gui_auto_open_msg), 0, 0, 0},
 	{ST_TOGGLE, N_("Sort tabs in alphabetical order"), P_OFFINTNL(tab_sort), 0, 0, 0},
 	{ST_TOGGLE, N_("Smaller text"), P_OFFINTNL(tab_small), 0, 0, 0},
 #if 0
@@ -348,6 +364,24 @@ static const setting alert_settings[] =
 	{ST_END, 0, 0, 0, 0, 0}
 };
 
+static const setting alert_settings_xtray[] =
+{
+	{ST_HEADER,	N_("Alerts"),0,0,0},
+
+	{ST_ALERTHEAD},
+	{ST_3OGGLE, N_("Blink task bar on:"), 0, 0, (void *)taskbarlist, 0},
+	{ST_3OGGLE, N_("Make a beep sound on:"), 0, 0, (void *)beeplist, 0},
+
+	{ST_HEADER,	N_("Highlighted Messages"),0,0,0},
+	{ST_LABEL,	N_("Highlighted messages are ones where your nickname is mentioned, but also:"), 0, 0, 0, 1},
+
+	{ST_ENTRY,	N_("Extra words to highlight:"), P_OFFSETNL(irc_extra_hilight), 0, 0, sizeof prefs.irc_extra_hilight},
+	{ST_ENTRY,	N_("Nick names not to highlight:"), P_OFFSETNL(irc_no_hilight), 0, 0, sizeof prefs.irc_no_hilight},
+	{ST_ENTRY,	N_("Nick names to always highlight:"), P_OFFSETNL(irc_nick_hilight), 0, 0, sizeof prefs.irc_nick_hilight},
+	{ST_LABEL,	N_("Separate multiple words with commas.\nWildcards are accepted.")},
+	{ST_END, 0, 0, 0, 0, 0}
+};
+
 static const setting general_settings[] =
 {
 	{ST_HEADER,	N_("Default Messages"),0,0,0},
@@ -363,7 +397,6 @@ static const setting general_settings[] =
 	{ST_END, 0, 0, 0, 0, 0}
 };
 
-#if 0
 static const setting advanced_settings[] =
 {
 	{ST_HEADER,	N_("Advanced Settings"),0,0,0},
@@ -371,6 +404,7 @@ static const setting advanced_settings[] =
 	{ST_TOGGLE,	N_("Display MODEs in raw form"), P_OFFINTNL(raw_modes), 0, 0, 0},
 	{ST_TOGGLE,	N_("Whois on notify"), P_OFFINTNL(whois_on_notifyonline), N_("Sends a /WHOIS when a user comes online in your notify list"), 0, 0},
 	{ST_TOGGLE,	N_("Hide join and part messages"), P_OFFINTNL(confmode), N_("Hide channel join/part messages by default"), 0, 0},
+	{ST_ENTRY,	N_("License Text:"), P_OFFSETNL(gui_license), 0, 0, sizeof prefs.gui_license},
 	{ST_HEADER,	N_("Auto Open DCC Windows"),0,0,0},
 	{ST_TOGGLE, N_("Send window"), P_OFFINTNL(autoopendccsendwindow), 0, 0, 0},
 	{ST_TOGGLE, N_("Receive window"), P_OFFINTNL(autoopendccrecvwindow), 0, 0, 0},
@@ -378,7 +412,6 @@ static const setting advanced_settings[] =
 
 	{ST_END, 0, 0, 0, 0, 0}
 };
-#endif
 
 static const setting logging_settings[] =
 {
@@ -1328,6 +1361,7 @@ setup_create_color_page (void)
 	setup_create_other_color (_("New message:"), COL_NEW_MSG, 10, tab);
 	setup_create_other_colorR (_("Away user:"), COL_AWAY, 10, tab);
 	setup_create_other_color (_("Highlight:"), COL_HILIGHT, 11, tab);
+	setup_create_other_colorR (_("Spell checker:"), COL_SPELL, 11, tab);
 
 	return box;
 }
@@ -1711,7 +1745,7 @@ static const char *const cata[] =
 		N_("General"),
 		N_("Logging"),
 		N_("Sound"),
-/*		N_("Advanced"),*/
+		N_("Advanced"),
 		NULL,
 	N_("Network"),
 		N_("Network setup"),
@@ -1732,10 +1766,19 @@ setup_create_pages (GtkWidget *box)
 	setup_add_page (cata[3], book, setup_create_page (userlist_settings));
 	setup_add_page (cata[4], book, setup_create_page (tabs_settings));
 	setup_add_page (cata[5], book, setup_create_color_page ());
-	setup_add_page (cata[8], book, setup_create_page (alert_settings));
+
+	if (xtray_mode ())
+	{
+		setup_add_page (cata[8], book, setup_create_page (alert_settings_xtray));
+	} else
+	{
+		setup_add_page (cata[8], book, setup_create_page (alert_settings));
+	}
+
 	setup_add_page (cata[9], book, setup_create_page (general_settings));
 	setup_add_page (cata[10], book, setup_create_page (logging_settings));
 	setup_add_page (cata[11], book, setup_create_sound_page ());
+	setup_add_page (cata[12], book, setup_create_page (advanced_settings));
 	setup_add_page (cata[14], book, setup_create_page (network_settings));
 	setup_add_page (cata[15], book, setup_create_page (filexfer_settings));
 
diff --git a/src/fe-gtk/sexy-iso-codes.c b/src/fe-gtk/sexy-iso-codes.c
new file mode 100644
index 00000000..3477cc30
--- /dev/null
+++ b/src/fe-gtk/sexy-iso-codes.c
@@ -0,0 +1,301 @@
+/*
+ *  Copyright (C) 2005 Nathan Fredrickson
+ *  Borrowed from Galeon, renamed, and simplified to only use iso-codes with no
+ *  fallback method.
+ *
+ *  Copyright (C) 2004 Christian Persch
+ *  Copyright (C) 2004 Crispin Flowerday
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ *
+ */
+
+#include "../../config.h"
+
+#include "sexy-iso-codes.h"
+
+#include <glib/gi18n.h>
+
+#include <string.h>
+
+#include <libxml/xmlreader.h>
+
+static GHashTable *iso_639_table = NULL;
+static GHashTable *iso_3166_table = NULL;
+
+#define ISO_639_DOMAIN	"iso_639"
+#define ISO_3166_DOMAIN	"iso_3166"
+
+#ifdef HAVE_ISO_CODES
+
+#define ISOCODESLOCALEDIR "/share/locale"
+
+static void
+read_iso_639_entry (xmlTextReaderPtr reader,
+		    GHashTable *table)
+{
+	xmlChar *code, *name;
+
+	code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_1_code");
+	name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
+
+	/* Get iso-639-2 code */
+	if (code == NULL || code[0] == '\0')
+	{
+		xmlFree (code);
+		/* FIXME: use the 2T or 2B code? */
+		code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_2T_code");
+	}
+
+	if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
+	{
+		g_hash_table_insert (table, code, name);
+	}
+	else
+	{
+		xmlFree (code);
+		xmlFree (name);
+	}
+}
+
+static void
+read_iso_3166_entry (xmlTextReaderPtr reader,
+		     GHashTable *table)
+{
+	xmlChar *code, *name;
+
+	code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "alpha_2_code");
+	name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
+
+	if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
+	{
+		char *lcode;
+
+		lcode = g_ascii_strdown ((char *) code, -1);
+		xmlFree (code);
+
+		g_hash_table_insert (table, lcode, name);
+	}
+	else
+	{
+		xmlFree (code);
+		xmlFree (name);
+	}
+
+}
+
+typedef enum
+{
+	STATE_START,
+	STATE_STOP,
+	STATE_ENTRIES,
+} ParserState;
+
+static gboolean
+load_iso_entries (int iso,
+		  GFunc read_entry_func,
+		  gpointer user_data)
+{
+	xmlTextReaderPtr reader;
+	ParserState state = STATE_START;
+	xmlChar iso_entries[32], iso_entry[32];
+	char *filename;
+	int ret = -1;
+
+	filename = g_strdup_printf (".\\share\\xml\\iso-codes\\iso_%d.xml", iso);
+	reader = xmlNewTextReaderFilename (filename);
+	if (reader == NULL) goto out;
+
+	xmlStrPrintf (iso_entries, sizeof (iso_entries),
+				  (xmlChar *)"iso_%d_entries", iso);
+	xmlStrPrintf (iso_entry, sizeof (iso_entry),
+				  (xmlChar *)"iso_%d_entry", iso);
+
+	ret = xmlTextReaderRead (reader);
+
+	while (ret == 1)
+	{
+		const xmlChar *tag;
+		xmlReaderTypes type;
+
+		tag = xmlTextReaderConstName (reader);
+		type = xmlTextReaderNodeType (reader);
+
+		if (state == STATE_ENTRIES &&
+		    type == XML_READER_TYPE_ELEMENT &&
+		    xmlStrEqual (tag, iso_entry))
+		{
+			read_entry_func (reader, user_data);
+		}
+		else if (state == STATE_START &&
+			 type == XML_READER_TYPE_ELEMENT &&
+			 xmlStrEqual (tag, iso_entries))
+		{
+			state = STATE_ENTRIES;
+		}
+		else if (state == STATE_ENTRIES &&
+			 type == XML_READER_TYPE_END_ELEMENT &&
+			 xmlStrEqual (tag, iso_entries))
+		{
+			state = STATE_STOP;
+		}
+		else if (type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE ||
+			 type == XML_READER_TYPE_WHITESPACE ||
+			 type == XML_READER_TYPE_TEXT ||
+			 type == XML_READER_TYPE_COMMENT)
+		{
+			/* eat it */
+		}
+		else
+		{
+			/* ignore it */
+		}
+
+		ret = xmlTextReaderRead (reader);
+	}
+
+	xmlFreeTextReader (reader);
+
+out:
+	if (ret < 0 || state != STATE_STOP)
+	{
+		/* This is not critical, we will fallback to our own code */
+		g_free (filename);
+		return FALSE;
+	}
+
+	g_free (filename);
+
+	return TRUE;
+}
+
+#endif /* HAVE_ISO_CODES */
+
+
+static void
+ensure_iso_codes_initialised (void)
+{
+	static gboolean initialised = FALSE;
+
+	if (initialised == TRUE)
+	{
+		return;
+	}
+	initialised = TRUE;
+
+#if defined (ENABLE_NLS) && defined (HAVE_ISO_CODES)
+	bindtextdomain (ISO_639_DOMAIN, ISOCODESLOCALEDIR);
+	bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
+
+	bindtextdomain(ISO_3166_DOMAIN, ISOCODESLOCALEDIR);
+	bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
+#endif
+
+	iso_639_table = g_hash_table_new_full (g_str_hash, g_str_equal,
+					       (GDestroyNotify) xmlFree,
+					       (GDestroyNotify) xmlFree);
+
+	iso_3166_table = g_hash_table_new_full (g_str_hash, g_str_equal,
+						(GDestroyNotify) g_free,
+						(GDestroyNotify) xmlFree);
+	
+#ifdef HAVE_ISO_CODES
+	load_iso_entries (639, (GFunc) read_iso_639_entry, iso_639_table);
+	load_iso_entries (3166, (GFunc) read_iso_3166_entry, iso_3166_table);
+#endif
+}
+
+
+static char *
+get_iso_name_for_lang_code (const char *code)
+{
+	char **str;
+	char *name = NULL;
+	const char *langname, *localename;
+	int len;
+
+	str = g_strsplit (code, "_", -1);
+
+	/* count the entries */
+	for (len = 0; str[len]; len++ ) /* empty */;
+
+	g_return_val_if_fail (len != 0, NULL);
+
+	langname = (const char *) g_hash_table_lookup (iso_639_table, str[0]);
+
+	if (len == 1 && langname != NULL)
+	{
+		name = g_strdup (dgettext (ISO_639_DOMAIN, langname));
+	}
+	else if (len == 2 && langname != NULL)
+	{
+		localename = (const char *) g_hash_table_lookup (iso_3166_table, str[1]);
+
+		if (localename != NULL)
+		{
+			/* translators: the first %s is the language name, and the
+			 * second %s is the locale name. Example:
+			 * "French (France)
+			 *
+			 * Also: The text before the "|" is context to help you decide on
+                         * the correct translation. You MUST OMIT it in the translated string.
+			 */
+			name = g_strdup_printf (Q_("language|%s (%s)"),
+						dgettext (ISO_639_DOMAIN, langname),
+						dgettext (ISO_3166_DOMAIN, localename));
+		}
+		else
+		{
+			name = g_strdup_printf (Q_("language|%s (%s)"),
+						dgettext (ISO_639_DOMAIN, langname), str[1]);
+		}
+	}
+
+	g_strfreev (str);
+
+	return name;
+}
+
+/**
+ * gtkspell_iso_codes_lookup_name_for_code:
+ * @code: A language code, e.g. en_CA
+ *
+ * Looks up a name to display to the user for a language code,
+ * this might use the iso-codes package if support was compiled
+ * in, and it is available
+ *
+ * Returns: the UTF-8 string to display to the user, or NULL if 
+ * a name for the code could not be found
+ */
+char *
+gtkspell_iso_codes_lookup_name_for_code (const char *code)
+{
+	char * lcode;
+	char * ret;
+
+	g_return_val_if_fail (code != NULL, NULL);
+
+	ensure_iso_codes_initialised ();
+
+	lcode = g_ascii_strdown (code, -1);
+
+	ret = get_iso_name_for_lang_code (lcode);
+
+	g_free (lcode);
+
+	return ret;
+}
+
diff --git a/src/fe-gtk/sexy-iso-codes.h b/src/fe-gtk/sexy-iso-codes.h
new file mode 100644
index 00000000..e5f37162
--- /dev/null
+++ b/src/fe-gtk/sexy-iso-codes.h
@@ -0,0 +1,37 @@
+/*
+ *  Copyright (C) 2005 Nathan Fredrickson
+ *  Borrowed from Galeon, renamed, and simplified to only use iso-codes with no
+ *  fallback method.
+ *
+ *  Copyright (C) 2004 Christian Persch
+ *  Copyright (C) 2004 Crispin Flowerday
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ *
+ */
+
+#ifndef GTKSPELL_ISO_CODES_H
+#define GTKSPELL_ISO_CODES_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+char *  gtkspell_iso_codes_lookup_name_for_code (const char *code);
+
+G_END_DECLS
+
+#endif
diff --git a/src/fe-gtk/sexy-marshal.c b/src/fe-gtk/sexy-marshal.c
new file mode 100644
index 00000000..10a629f2
--- /dev/null
+++ b/src/fe-gtk/sexy-marshal.c
@@ -0,0 +1,129 @@
+
+#include	<glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:STRING (./marshal.list:1) */
+void
+sexy_marshal_BOOLEAN__STRING (GClosure     *closure,
+                              GValue       *return_value,
+                              guint         n_param_values,
+                              const GValue *param_values,
+                              gpointer      invocation_hint,
+                              gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__STRING) (gpointer     data1,
+                                                    gpointer     arg_1,
+                                                    gpointer     data2);
+  register GMarshalFunc_BOOLEAN__STRING callback;
+  register GCClosure *cc = (GCClosure*) closure;
+  register gpointer data1, data2;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 2);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__STRING) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_string (param_values + 1),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* OBJECT:OBJECT,OBJECT (./marshal.list:2) */
+void
+sexy_marshal_OBJECT__OBJECT_OBJECT (GClosure     *closure,
+                                    GValue       *return_value,
+                                    guint         n_param_values,
+                                    const GValue *param_values,
+                                    gpointer      invocation_hint,
+                                    gpointer      marshal_data)
+{
+  typedef GObject* (*GMarshalFunc_OBJECT__OBJECT_OBJECT) (gpointer     data1,
+                                                          gpointer     arg_1,
+                                                          gpointer     arg_2,
+                                                          gpointer     data2);
+  register GMarshalFunc_OBJECT__OBJECT_OBJECT callback;
+  register GCClosure *cc = (GCClosure*) closure;
+  register gpointer data1, data2;
+  GObject* v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_OBJECT__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_object (param_values + 1),
+                       g_marshal_value_peek_object (param_values + 2),
+                       data2);
+
+  g_value_take_object (return_value, v_return);
+}
+
diff --git a/src/fe-gtk/sexy-marshal.h b/src/fe-gtk/sexy-marshal.h
new file mode 100644
index 00000000..f41eccbe
--- /dev/null
+++ b/src/fe-gtk/sexy-marshal.h
@@ -0,0 +1,28 @@
+
+#ifndef __sexy_marshal_MARSHAL_H__
+#define __sexy_marshal_MARSHAL_H__
+
+#include	<glib-object.h>
+
+G_BEGIN_DECLS
+
+/* BOOLEAN:STRING (./marshal.list:1) */
+extern void sexy_marshal_BOOLEAN__STRING (GClosure     *closure,
+                                          GValue       *return_value,
+                                          guint         n_param_values,
+                                          const GValue *param_values,
+                                          gpointer      invocation_hint,
+                                          gpointer      marshal_data);
+
+/* OBJECT:OBJECT,OBJECT (./marshal.list:2) */
+extern void sexy_marshal_OBJECT__OBJECT_OBJECT (GClosure     *closure,
+                                                GValue       *return_value,
+                                                guint         n_param_values,
+                                                const GValue *param_values,
+                                                gpointer      invocation_hint,
+                                                gpointer      marshal_data);
+
+G_END_DECLS
+
+#endif /* __sexy_marshal_MARSHAL_H__ */
+
diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c
index d67ffe2d..8f21e977 100644
--- a/src/fe-gtk/sexy-spell-entry.c
+++ b/src/fe-gtk/sexy-spell-entry.c
@@ -26,10 +26,17 @@
 #include <gtk/gtk.h>
 #include "sexy-spell-entry.h"
 #include <string.h>
+#include <fcntl.h>
 #include <glib/gi18n.h>
 #include <sys/types.h>
-/*#include "gtkspell-iso-codes.h"
-#include "sexy-marshal.h"*/
+#include <sys/stat.h>
+#include "sexy-iso-codes.h"
+#include "sexy-marshal.h"
+
+#include "typedef.h"
+
+#include "../common/cfgfiles.h"
+#include "../common/xchatc.h"
 
 /*
  * Bunch of poop to make enchant into a runtime dependency rather than a
@@ -134,12 +141,10 @@ initialize_enchant ()
 	GModule *enchant;
 	gpointer funcptr;
 
-	enchant = g_module_open("libenchant", 0);
+	enchant = g_module_open("libenchant.dll", 0);
 	if (enchant == NULL)
 	{
-		enchant = g_module_open("libenchant.so.1", 0);
-		if (enchant == NULL)
-			return;
+		return;
 	}
 
 	have_enchant = TRUE;
@@ -207,14 +212,14 @@ sexy_spell_entry_class_init(SexySpellEntryClass *klass)
 	 * Returns: %FALSE to indicate that the word should be marked as
 	 * correct.
 	 */
-/*	signals[WORD_CHECK] = g_signal_new("word_check",
+	signals[WORD_CHECK] = g_signal_new("word_check",
 					   G_TYPE_FROM_CLASS(object_class),
 					   G_SIGNAL_RUN_LAST,
 					   G_STRUCT_OFFSET(SexySpellEntryClass, word_check),
 					   (GSignalAccumulator) spell_accumulator, NULL,
 					   sexy_marshal_BOOLEAN__STRING,
 					   G_TYPE_BOOLEAN,
-					   1, G_TYPE_STRING);*/
+					   1, G_TYPE_STRING);
 }
 
 static void
@@ -260,8 +265,42 @@ gtk_entry_find_position (GtkEntry *entry, gint x)
 static void
 insert_underline(SexySpellEntry *entry, guint start, guint end)
 {
-	PangoAttribute *ucolor = pango_attr_underline_color_new (65535, 0, 0);
-	PangoAttribute *unline = pango_attr_underline_new (PANGO_UNDERLINE_ERROR);
+	int fh, l;
+	int red, green, blue;
+	struct stat st;
+	char *cfg;
+	PangoAttribute *ucolor;
+	PangoAttribute *unline;
+
+	fh = xchat_open_file ("colors.conf", O_RDONLY, 0, 0);
+
+	if (fh != -1)
+	{
+		fstat (fh, &st);
+		cfg = malloc (st.st_size + 1);
+
+		if (cfg)
+		{
+			cfg[0] = '\0';
+			l = read (fh, cfg, st.st_size);
+			if (l >= 0)
+			{
+				cfg[l] = '\0';
+			}
+
+			cfg_get_color (cfg, "color_265", &red, &green, &blue);
+			free (cfg);
+		}
+
+		close (fh);
+	} else
+	{
+		red = 65535;
+		green = blue = 0;
+	}
+
+	ucolor = pango_attr_underline_color_new (red, green, blue);
+	unline = pango_attr_underline_new (PANGO_UNDERLINE_ERROR);
 
 	ucolor->start_index = start;
 	unline->start_index = start;
@@ -457,10 +496,6 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word)
 	if (entry->priv->dict_list == NULL)
 		return topmenu;
 
-#if 1
-	dict = (struct EnchantDict *) entry->priv->dict_list->data;
-	build_suggestion_menu(entry, topmenu, dict, word);
-#else
 	/* Suggestions */
 	if (g_slist_length(entry->priv->dict_list) == 1) {
 		dict = (struct EnchantDict *) entry->priv->dict_list->data;
@@ -489,7 +524,6 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word)
 			build_suggestion_menu(entry, menu, dict, word);
 		}
 	}
-#endif
 
 	/* Separator */
 	mi = gtk_separator_menu_item_new ();
@@ -503,11 +537,6 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word)
 
 	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
 
-#if 1
-	dict = (struct EnchantDict *) entry->priv->dict_list->data;
-	g_object_set_data(G_OBJECT(mi), "enchant-dict", dict);
-	g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(add_to_dictionary), entry);
-#else
 	if (g_slist_length(entry->priv->dict_list) == 1) {
 		dict = (struct EnchantDict *) entry->priv->dict_list->data;
 		g_object_set_data(G_OBJECT(mi), "enchant-dict", dict);
@@ -539,7 +568,6 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word)
 			gtk_menu_shell_append(GTK_MENU_SHELL(menu), submi);
 		}
 	}
-#endif
 
 	gtk_widget_show_all(mi);
 	gtk_menu_shell_append(GTK_MENU_SHELL(topmenu), mi);
@@ -721,11 +749,7 @@ word_misspelled(SexySpellEntry *entry, int start, int end)
 
 	g_strlcpy(word, text + start, end - start + 1);
 
-#if 0
 	g_signal_emit(entry, signals[WORD_CHECK], 0, word, &ret);
-#else
-	ret = default_word_check (entry, word);
-#endif
 
 	g_free(word);
 	return ret;
@@ -921,10 +945,10 @@ void
 sexy_spell_entry_activate_default_languages(SexySpellEntry *entry)
 {
 #if GLIB_CHECK_VERSION (2, 6, 0)
-	const gchar* const *langs;
+	/*const gchar* const *langs;
 	int i;
-	gchar *lastprefix = NULL;
-	GSList *enchant_langs;
+	gchar *lastprefix = NULL;*/
+	GSList *enchant_langs, *i;
 
 	if (!have_enchant)
 		return;
@@ -933,14 +957,14 @@ sexy_spell_entry_activate_default_languages(SexySpellEntry *entry)
 		entry->priv->broker = enchant_broker_init();
 
 
-	langs = g_get_language_names ();
+	/*langs = g_get_language_names ();
 
 	if (langs == NULL)
-		return;
+		return;*/
 
 	enchant_langs = sexy_spell_entry_get_languages(entry);
 
-	for (i = 0; langs[i]; i++) {
+	/*for (i = 0; langs[i]; i++) {
 		if ((g_strncasecmp(langs[i], "C", 1) != 0) &&
 		    (strlen(langs[i]) >= 2) &&
 		    enchant_has_lang(langs[i], enchant_langs)) {
@@ -952,10 +976,19 @@ sexy_spell_entry_activate_default_languages(SexySpellEntry *entry)
 		}
 	}
 	if (lastprefix != NULL)
-		g_free(lastprefix);
+		g_free(lastprefix);*/
+
+	for (i = enchant_langs; i; i = g_slist_next (i))
+	{
+		if (strstr (prefs.spell_langs, i->data) != NULL)
+		{
+			sexy_spell_entry_activate_language_internal (entry, i->data, NULL);
+		}
+	}
 
 	g_slist_foreach(enchant_langs, (GFunc) g_free, NULL);
 	g_slist_free(enchant_langs);
+	g_slist_free (i);
 
 	/* If we don't have any languages activated, use "en" */
 	if (entry->priv->dict_list == NULL)
@@ -1083,8 +1116,8 @@ gchar *
 sexy_spell_entry_get_language_name(const SexySpellEntry *entry,
 								   const gchar *lang)
 {
-	/*if (have_enchant)
-		return gtkspell_iso_codes_lookup_name_for_code(lang);*/
+	if (have_enchant)
+		return gtkspell_iso_codes_lookup_name_for_code(lang);
 	return NULL;
 }
 
diff --git a/src/fe-gtk/typedef.h b/src/fe-gtk/typedef.h
new file mode 100644
index 00000000..b20612ea
--- /dev/null
+++ b/src/fe-gtk/typedef.h
@@ -0,0 +1,11 @@
+#ifndef SSIZE_T_DEFINED
+#ifdef ssize_t
+#undef ssize_t
+#endif
+#ifdef _WIN64
+typedef __int64          ssize_t;
+#else
+typedef _W64 int         ssize_t;
+#endif
+#define SSIZE_T_DEFINED
+#endif
diff --git a/src/fe-gtk/xchat.exe.manifest b/src/fe-gtk/xchat.exe.manifest
new file mode 100644
index 00000000..13685d98
--- /dev/null
+++ b/src/fe-gtk/xchat.exe.manifest
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+  <assemblyIdentity
+    name="XChat"
+    processorArchitecture="*"
+    version="1.0.0.0"
+    type="win32"
+  />
+  <description>XChat IRC client</description>
+  <dependency>
+    <dependentAssembly>
+      <assemblyIdentity
+        type="win32"
+        name="Microsoft.Windows.Common-Controls"
+        version="6.0.0.0"
+        processorArchitecture="*"
+        publicKeyToken="6595b64144ccf1df"
+        language="*"
+      />
+    </dependentAssembly>
+  </dependency>
+</assembly>
diff --git a/src/fe-gtk/xchat.rc b/src/fe-gtk/xchat.rc
new file mode 100644
index 00000000..28676b83
--- /dev/null
+++ b/src/fe-gtk/xchat.rc
@@ -0,0 +1,28 @@
+#include <winver.h>

+#include "../../config.h"

+#include "../../resource.h"

+

+1 24 "xchat.exe.manifest"

+

+XC_ICON ICON "../../xchat.ico" 

+

+VS_VERSION_INFO VERSIONINFO

+	FILEVERSION    COMMA_VERSION

+	PRODUCTVERSION COMMA_VERSION

+	BEGIN

+		BLOCK "StringFileInfo"

+		BEGIN

+			BLOCK "040904B0"

+			BEGIN

+				

+				VALUE "FileDescription", "XChat-WDK IRC Client"

+				VALUE "ProductName", "XChat-WDK" 

+				VALUE "ProductVersion", PACKAGE_VERSION

+				VALUE "FileVersion", PACKAGE_VERSION

+			END

+		END

+		BLOCK "VarFileInfo"

+		BEGIN

+			VALUE "Translation", 0x0409, 0x04B0

+		END

+	END

diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c
index fa9803c7..5a83062b 100644
--- a/src/fe-gtk/xtext.c
+++ b/src/fe-gtk/xtext.c
@@ -42,7 +42,6 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <time.h>
-#include <unistd.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtksignal.h>
 #include <gtk/gtkselection.h>
@@ -67,6 +66,8 @@
 #endif
 
 #include "xtext.h"
+#include "../common/xchat.h"
+#include "../common/xchatc.h"
 
 #define charlen(str) g_utf8_skip[*(guchar *)(str)]
 
@@ -998,7 +999,11 @@ gtk_xtext_realize (GtkWidget * widget)
 
 	gdk_window_set_user_data (widget->window, widget);
 
+#if GTK_CHECK_VERSION(2,24,0)
+	xtext->depth = gdk_window_get_visual (widget->window)->depth;
+#else
 	xtext->depth = gdk_drawable_get_visual (widget->window)->depth;
+#endif
 
 	val.subwindow_mode = GDK_INCLUDE_INFERIORS;
 	val.graphics_exposures = 0;
@@ -1941,7 +1946,7 @@ gtk_xtext_check_mark_stamp (GtkXText *xtext, GdkModifierType mask)
 {
 	gboolean redraw = FALSE;
 
-	if ((mask & GDK_SHIFT_MASK))
+	if (mask & GDK_SHIFT_MASK || prefs.autocopy_stamp)
 	{
 		if (!xtext->mark_stamp)
 		{
@@ -2106,7 +2111,16 @@ gtk_xtext_set_clip_owner (GtkWidget * xtext, GdkEventButton * event)
 		free (str);
 	}
 
-	gtk_selection_owner_set (xtext, GDK_SELECTION_PRIMARY, event->time);
+	if (event)
+	{
+		gtk_selection_owner_set (xtext, GDK_SELECTION_PRIMARY, event->time);
+	}
+}
+
+void
+gtk_xtext_copy_selection (GtkXText *xtext)
+{
+	gtk_xtext_set_clip_owner (xtext, NULL);
 }
 
 static void
@@ -2182,9 +2196,12 @@ gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event)
 		if (xtext->buffer->last_ent_start)
 		{
 			xtext->color_paste = FALSE;
-			if (event->state & GDK_CONTROL_MASK)
+			if (event->state & GDK_CONTROL_MASK || prefs.autocopy_color)
 				xtext->color_paste = TRUE;
-			gtk_xtext_set_clip_owner (GTK_WIDGET (xtext), event);
+			if (prefs.autocopy_text)
+			{
+				gtk_xtext_set_clip_owner (GTK_WIDGET (xtext), event);
+			}
 		}
 
 		if (xtext->select_start_x == event->x &&
@@ -2249,7 +2266,10 @@ gtk_xtext_button_press (GtkWidget * widget, GdkEventButton * event)
 			ent->mark_end = offset + len;
 			gtk_xtext_selection_render (xtext, ent, offset, ent, offset + len);
 			xtext->word_or_line_select = TRUE;
-			gtk_xtext_set_clip_owner (GTK_WIDGET (xtext), event);
+			if (prefs.autocopy_text)
+			{
+				gtk_xtext_set_clip_owner (GTK_WIDGET (xtext), event);
+			}
 		}
 
 		return FALSE;
@@ -2265,7 +2285,10 @@ gtk_xtext_button_press (GtkWidget * widget, GdkEventButton * event)
 			ent->mark_end = ent->str_len;
 			gtk_xtext_selection_render (xtext, ent, 0, ent, ent->str_len);
 			xtext->word_or_line_select = TRUE;
-			gtk_xtext_set_clip_owner (GTK_WIDGET (xtext), event);
+			if (prefs.autocopy_text)
+			{
+				gtk_xtext_set_clip_owner (GTK_WIDGET (xtext), event);
+			}
 		}
 
 		return FALSE;
@@ -3836,7 +3859,7 @@ gtk_xtext_load_trans (GtkXText * xtext)
 	PaintDesktop (hdc);
 	ReleaseDC (hwnd, hdc);
 
-	gdk_window_get_size (GTK_WIDGET (xtext)->window, &width, &height);
+	gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height);
 	img = gdk_image_get (GTK_WIDGET (xtext)->window, 0, 0, width+128, height);
 	xtext->pixmap = win32_tint (xtext, img, img->width, img->height);
 
diff --git a/src/fe-gtk/xtext.h b/src/fe-gtk/xtext.h
index a37ddc32..90fa1bca 100644
--- a/src/fe-gtk/xtext.h
+++ b/src/fe-gtk/xtext.h
@@ -270,6 +270,7 @@ void gtk_xtext_set_wordwrap (GtkXText *xtext, gboolean word_wrap);
 xtext_buffer *gtk_xtext_buffer_new (GtkXText *xtext);
 void gtk_xtext_buffer_free (xtext_buffer *buf);
 void gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render);
+void gtk_xtext_copy_selection (GtkXText *xtext);
 GType gtk_xtext_get_type (void);
 
 #endif
diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c
index 2bc2e649..f3c1ff05 100644
--- a/src/fe-text/fe-text.c
+++ b/src/fe-text/fe-text.c
@@ -22,60 +22,51 @@
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
 #endif
+#ifdef WIN32
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#else
+#include <unistd.h>
 #include <sys/time.h>
+#endif
 #include <sys/types.h>
-#include <unistd.h>
 #include <ctype.h>
+#include <glib.h>
 #include "../common/xchat.h"
 #include "../common/xchatc.h"
+#include "../common/cfgfiles.h"
 #include "../common/outbound.h"
 #include "../common/util.h"
 #include "../common/fe.h"
 #include "fe-text.h"
 
 
-static GSList *tmr_list;		  /* timer list */
-static int tmr_list_count;
-static GSList *se_list;			  /* socket event list */
-static int se_list_count;
 static int done = FALSE;		  /* finished ? */
 
 
 static void
 send_command (char *cmd)
 {
-	handle_multiline (sess_list->data, cmd, TRUE, FALSE);
+	handle_multiline (current_tab, cmd, TRUE, FALSE);
 }
 
-static void
-read_stdin (void)
+static gboolean
+handle_line (GIOChannel *channel, GIOCondition cond, gpointer data)
 {
-	int len, i = 0;
-	static int pos = 0;
-	static char inbuf[1024];
-	char tmpbuf[512];
-
-	len = read (STDIN_FILENO, tmpbuf, sizeof tmpbuf - 1);
-
-	while (i < len)
-	{
-		switch (tmpbuf[i])
-		{
-		case '\r':
-			break;
 
-		case '\n':
-			inbuf[pos] = 0;
-			pos = 0;
-			send_command (inbuf);
-			break;
+	gchar *str_return;
+	gsize length, terminator_pos;
+	GError *error = NULL;
+	GIOStatus result;
 
-		default:
-			inbuf[pos] = tmpbuf[i];
-			if (pos < (sizeof inbuf - 2))
-				pos++;
-		}
-		i++;
+	result = g_io_channel_read_line(channel, &str_return, &length, &terminator_pos, &error);
+	if (result == G_IO_STATUS_ERROR) {
+		return FALSE;
+	}
+	else {
+		send_command(str_return);
+		g_free(str_return);
+		return TRUE;
 	}
 }
 
@@ -87,12 +78,13 @@ fe_new_window (struct session *sess, int focus)
 	char buf[512];
 
 	sess->gui = malloc (4);
+	current_sess = sess;
 
 	if (!sess->server->front_session)
 		sess->server->front_session = sess;
 	if (!sess->server->server_session)
 		sess->server->server_session = sess;
-	if (!current_tab)
+	if (!current_tab || focus)
 		current_tab = sess;
 
 	if (done_intro)
@@ -101,7 +93,7 @@ fe_new_window (struct session *sess, int focus)
 
 	snprintf (buf, sizeof (buf),
 				"\n"
-				" \017xchat \00310"PACKAGE_VERSION"\n"
+				" \017XChat-Text \00310"PACKAGE_VERSION"\n"
 				" \017Running on \00310%s \017glib \00310%d.%d.%d\n"
 				" \017This binary compiled \00310"__DATE__"\017\n",
 				get_cpu_str(),
@@ -133,15 +125,21 @@ get_stamp_str (time_t tim, char *dest, int size)
 }
 
 static int
-timecat (char *buf)
+timecat (char *buf, time_t stamp)
 {
 	char stampbuf[64];
 
-	get_stamp_str (time (0), stampbuf, sizeof (stampbuf));
+	/* set the stamp to the current time if not provided */
+	if (!stamp)
+		stamp = time (0);
+
+	get_stamp_str (stamp, stampbuf, sizeof (stampbuf));
 	strcat (buf, stampbuf);
 	return strlen (stampbuf);
 }
 
+/* Windows doesn't handle ANSI codes in cmd.exe, need to not display them */
+#ifndef WIN32
 /*                       0  1  2  3  4  5  6  7   8   9   10 11  12  13  14 15 */
 static const short colconv[] = { 0, 7, 4, 2, 1, 3, 5, 11, 13, 12, 6, 16, 14, 15, 10, 7 };
 
@@ -157,7 +155,7 @@ fe_print_text (struct session *sess, char *text, time_t stamp)
 	if (prefs.timestamp)
 	{
 		newtext[0] = 0;
-		j += timecat (newtext);
+		j += timecat (newtext, stamp);
 	}
 	while (i < len)
 	{
@@ -165,7 +163,7 @@ fe_print_text (struct session *sess, char *text, time_t stamp)
 		{
 			dotime = FALSE;
 			newtext[j] = 0;
-			j += timecat (newtext);
+			j += timecat (newtext, stamp);
 		}
 		switch (text[i])
 		{
@@ -179,8 +177,7 @@ fe_print_text (struct session *sess, char *text, time_t stamp)
 				j++;
 				newtext[j] = 'm';
 				j++;
-				i--;
-				goto jump2;
+				goto endloop;
 			}
 			k = 0;
 			comma = FALSE;
@@ -226,13 +223,16 @@ fe_print_text (struct session *sess, char *text, time_t stamp)
 						comma = TRUE;
 						break;
 					default:
-						goto jump;
+						goto endloop;
 					}
 					k = 0;
 				}
 				i++;
 			}
 			break;
+		/* don't actually want hidden text */
+		case '\010':				  /* hidden */
+			break;
 		case '\026':				  /* REVERSE */
 			if (reverse)
 			{
@@ -296,120 +296,246 @@ fe_print_text (struct session *sess, char *text, time_t stamp)
 			newtext[j] = text[i];
 			j++;
 		}
-	 jump2:
 		i++;
-	 jump:
-		i += 0;
+		endloop:
+			;
 	}
+
+	/* make sure last character is a new line */
+	if (text[i-1] != '\n')
+		newtext[j++] = '\n';
+
 	newtext[j] = 0;
 	write (STDOUT_FILENO, newtext, j);
 	free (newtext);
 }
-
+#else
+/* The win32 version for cmd.exe */
 void
-fe_timeout_remove (int tag)
+fe_print_text (struct session *sess, char *text, time_t stamp)
 {
-	timerevent *te;
-	GSList *list;
+	int dotime = FALSE;
+	int comma, k, i = 0, j = 0, len = strlen (text);
+
+	unsigned char *newtext = malloc (len + 1024);
 
-	list = tmr_list;
-	while (list)
+	if (prefs.timestamp)
 	{
-		te = (timerevent *) list->data;
-		if (te->tag == tag)
+		newtext[0] = 0;
+		j += timecat (newtext, stamp);
+	}
+	while (i < len)
+	{
+		if (dotime && text[i] != 0)
 		{
-			tmr_list = g_slist_remove (tmr_list, te);
-			free (te);
-			return;
+			dotime = FALSE;
+			newtext[j] = 0;
+			j += timecat (newtext, stamp);
 		}
-		list = list->next;
+		switch (text[i])
+		{
+		case 3:
+			i++;
+			if (!isdigit (text[i]))
+			{
+				goto endloop;
+			}
+			k = 0;
+			comma = FALSE;
+			while (i < len)
+			{
+				if (text[i] >= '0' && text[i] <= '9' && k < 2)
+				{
+					k++;
+				} else
+				{
+					switch (text[i])
+					{
+					case ',':
+						comma = TRUE;
+						break;
+					default:
+						goto endloop;
+					}
+					k = 0;
+
+				}
+				i++;
+			}
+			break;
+		/* don't actually want hidden text */
+		case '\010':				  /* hidden */
+		case '\026':				  /* REVERSE */
+		case '\037':				  /* underline */
+		case '\002':				  /* bold */
+		case '\017':				  /* reset all */
+			break;
+		case '\007':
+			if (!prefs.filterbeep)
+			{
+				newtext[j] = text[i];
+				j++;
+			}
+			break;
+		case '\t':
+			newtext[j] = ' ';
+			j++;
+			break;
+		case '\n':
+			newtext[j] = '\r';
+			j++;
+			if (prefs.timestamp)
+				dotime = TRUE;
+		default:
+			newtext[j] = text[i];
+			j++;
+		}
+		i++;
+		endloop:
+			;
 	}
+
+	/* make sure last character is a new line */
+	if (text[i-1] != '\n')
+		newtext[j++] = '\n';
+
+	newtext[j] = 0;
+	write (STDOUT_FILENO, newtext, j);
+	free (newtext);
+}
+#endif
+
+void
+fe_timeout_remove (int tag)
+{
+	g_source_remove (tag);
 }
 
 int
 fe_timeout_add (int interval, void *callback, void *userdata)
 {
-	struct timeval now;
-	timerevent *te = malloc (sizeof (timerevent));
-
-	tmr_list_count++;				  /* this overflows at 2.2Billion, who cares!! */
-
-	te->tag = tmr_list_count;
-	te->interval = interval;
-	te->callback = callback;
-	te->userdata = userdata;
-
-	gettimeofday (&now, NULL);
-	te->next_call = now.tv_sec * 1000 + (now.tv_usec / 1000) + te->interval;
-
-	tmr_list = g_slist_prepend (tmr_list, te);
-
-	return te->tag;
+	return g_timeout_add (interval, (GSourceFunc) callback, userdata);
 }
 
 void
 fe_input_remove (int tag)
 {
-	socketevent *se;
-	GSList *list;
-
-	list = se_list;
-	while (list)
-	{
-		se = (socketevent *) list->data;
-		if (se->tag == tag)
-		{
-			se_list = g_slist_remove (se_list, se);
-			free (se);
-			return;
-		}
-		list = list->next;
-	}
+	g_source_remove (tag);
 }
 
 int
 fe_input_add (int sok, int flags, void *func, void *data)
 {
-	socketevent *se = malloc (sizeof (socketevent));
+	int tag, type = 0;
+	GIOChannel *channel;
 
-	se_list_count++;				  /* this overflows at 2.2Billion, who cares!! */
+	channel = g_io_channel_unix_new (sok);
 
-	se->tag = se_list_count;
-	se->sok = sok;
-	se->rread = flags & FIA_READ;
-	se->wwrite = flags & FIA_WRITE;
-	se->eexcept = flags & FIA_EX;
-	se->callback = func;
-	se->userdata = data;
-	se_list = g_slist_prepend (se_list, se);
+	if (flags & FIA_READ)
+		type |= G_IO_IN | G_IO_HUP | G_IO_ERR;
+	if (flags & FIA_WRITE)
+		type |= G_IO_OUT | G_IO_ERR;
+	if (flags & FIA_EX)
+		type |= G_IO_PRI;
 
-	return se->tag;
+	tag = g_io_add_watch (channel, type, (GIOFunc) func, data);
+	g_io_channel_unref (channel);
+
+	return tag;
 }
 
+/* === command-line parameter parsing : requires glib 2.6 === */
+
+static char *arg_cfgdir = NULL;
+static gint arg_show_autoload = 0;
+static gint arg_show_config = 0;
+static gint arg_show_version = 0;
+
+static const GOptionEntry gopt_entries[] = 
+{
+ {"no-auto",	'a', 0, G_OPTION_ARG_NONE,	&arg_dont_autoconnect, N_("Don't auto connect to servers"), NULL},
+ {"cfgdir",	'd', 0, G_OPTION_ARG_STRING,	&arg_cfgdir, N_("Use a different config directory"), "PATH"},
+ {"no-plugins",	'n', 0, G_OPTION_ARG_NONE,	&arg_skip_plugins, N_("Don't auto load any plugins"), NULL},
+ {"plugindir",	'p', 0, G_OPTION_ARG_NONE,	&arg_show_autoload, N_("Show plugin auto-load directory"), NULL},
+ {"configdir",	'u', 0, G_OPTION_ARG_NONE,	&arg_show_config, N_("Show user config directory"), NULL},
+ {"url",	 0,  0, G_OPTION_ARG_STRING,	&arg_url, N_("Open an irc://server:port/channel URL"), "URL"},
+ {"version",	'v', 0, G_OPTION_ARG_NONE,	&arg_show_version, N_("Show version information"), NULL},
+ {NULL}
+};
+
 int
 fe_args (int argc, char *argv[])
 {
-	if (argc > 1)
+	GError *error = NULL;
+	GOptionContext *context;
+
+#ifdef ENABLE_NLS
+	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+#endif
+
+	context = g_option_context_new (NULL);
+	g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE);
+	g_option_context_parse (context, &argc, &argv, &error);
+
+	if (error)
+	{
+		if (error->message)
+			printf ("%s\n", error->message);
+		return 1;
+	}
+
+	g_option_context_free (context);
+
+	if (arg_show_version)
+	{
+		printf (PACKAGE_TARNAME" "PACKAGE_VERSION"\n");
+		return 0;
+	}
+
+	if (arg_show_autoload)
 	{
-		if (!strcasecmp (argv[1], "--version") || !strcasecmp (argv[1], "-v"))
+#ifdef WIN32
+		/* see the chdir() below */
+		char *sl, *exe = strdup (argv[0]);
+		sl = strrchr (exe, '\\');
+		if (sl)
 		{
-			puts (PACKAGE_VERSION);
-			return 0;
+			*sl = 0;
+			printf ("%s\\plugins\n", exe);
 		}
+#else
+		printf ("%s\n", XCHATLIBDIR"/plugins");
+#endif
+		return 0;
 	}
+
+	if (arg_show_config)
+	{
+		printf ("%s\n", get_xdir_fs ());
+		return 0;
+	}
+
+	if (arg_cfgdir)	/* we want filesystem encoding */
+	{
+		xdir_fs = strdup (arg_cfgdir);
+		if (xdir_fs[strlen (xdir_fs) - 1] == '/')
+			xdir_fs[strlen (xdir_fs) - 1] = 0;
+		g_free (arg_cfgdir);
+	}
+
 	return -1;
 }
 
 void
 fe_init (void)
 {
-	se_list = 0;
-	se_list_count = 0;
-	tmr_list = 0;
-	tmr_list_count = 0;
+	/* the following should be default generated, not enfoced in binary */
 	prefs.autosave = 0;
 	prefs.use_server_tab = 0;
 	prefs.autodialog = 0;
+	/* except for these, there is no lag meter, there is no server list */
 	prefs.lagometer = 0;
 	prefs.slist_skip = 1;
 }
@@ -417,129 +543,29 @@ fe_init (void)
 void
 fe_main (void)
 {
-	struct timeval timeout, now;
-	socketevent *se;
-	timerevent *te;
-	fd_set rd, wd, ex;
-	GSList *list;
-	guint64 shortest, delay;
+	GIOChannel *keyboard_input;
 
-	if (!sess_list)
-		new_ircwindow (NULL, NULL, SESS_SERVER, 0);
+	main_loop = g_main_loop_new(NULL, FALSE);
 
-#ifdef ENABLE_NLS
-	bindtextdomain (GETTEXT_PACKAGE, PREFIX"/share/locale");
-	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-	textdomain (GETTEXT_PACKAGE);
+	/* Keyboard Entry Setup */
+#ifdef G_OS_WIN32
+	keyboard_input = g_io_channel_win32_new_fd(STDIN_FILENO);
+#else
+	keyboard_input = g_io_channel_unix_new(STDIN_FILENO);
 #endif
 
-	while (!done)
-	{
-		FD_ZERO (&rd);
-		FD_ZERO (&wd);
-		FD_ZERO (&ex);
-
-		list = se_list;
-		while (list)
-		{
-			se = (socketevent *) list->data;
-			if (se->rread)
-				FD_SET (se->sok, &rd);
-			if (se->wwrite)
-				FD_SET (se->sok, &wd);
-			if (se->eexcept)
-				FD_SET (se->sok, &ex);
-			list = list->next;
-		}
-
-		FD_SET (STDIN_FILENO, &rd);	/* for reading keyboard */
-
-		/* find the shortest timeout event */
-		shortest = 0;
-		list = tmr_list;
-		while (list)
-		{
-			te = (timerevent *) list->data;
-			if (te->next_call < shortest || shortest == 0)
-				shortest = te->next_call;
-			list = list->next;
-		}
-		gettimeofday (&now, NULL);
-		delay = shortest - ((now.tv_sec * 1000) + (now.tv_usec / 1000));
-		timeout.tv_sec = delay / 1000;
-		timeout.tv_usec = (delay % 1000) * 1000;
-
-		select (FD_SETSIZE, &rd, &wd, &ex, &timeout);
-
-		if (FD_ISSET (STDIN_FILENO, &rd))
-			read_stdin ();
-
-		/* set all checked flags to false */
-		list = se_list;
-		while (list)
-		{
-			se = (socketevent *) list->data;
-			se->checked = 0;
-			list = list->next;
-		}
-
-		/* check all the socket callbacks */
-		list = se_list;
-		while (list)
-		{
-			se = (socketevent *) list->data;
-			se->checked = 1;
-			if (se->rread && FD_ISSET (se->sok, &rd))
-			{
-				se->callback (NULL, 1, se->userdata);
-			} else if (se->wwrite && FD_ISSET (se->sok, &wd))
-			{
-				se->callback (NULL, 2, se->userdata);
-			} else if (se->eexcept && FD_ISSET (se->sok, &ex))
-			{
-				se->callback (NULL, 4, se->userdata);
-			}
-			list = se_list;
-			if (list)
-			{
-				se = (socketevent *) list->data;
-				while (se->checked)
-				{
-					list = list->next;
-					if (!list)
-						break;
-					se = (socketevent *) list->data;
-				}
-			}
-		}
+	g_io_add_watch(keyboard_input, G_IO_IN, handle_line, NULL);
 
-		/* now check our list of timeout events, some might need to be called! */
-		gettimeofday (&now, NULL);
-		list = tmr_list;
-		while (list)
-		{
-			te = (timerevent *) list->data;
-			list = list->next;
-			if (now.tv_sec * 1000 + (now.tv_usec / 1000) >= te->next_call)
-			{
-				/* if the callback returns 0, it must be removed */
-				if (te->callback (te->userdata) == 0)
-				{
-					fe_timeout_remove (te->tag);
-				} else
-				{
-					te->next_call = now.tv_sec * 1000 + (now.tv_usec / 1000) + te->interval;
-				}
-			}
-		}
+	g_main_loop_run(main_loop);
 
-	}
+	return;
 }
 
 void
 fe_exit (void)
 {
 	done = TRUE;
+	g_main_loop_quit(main_loop);
 }
 
 void
@@ -793,10 +819,23 @@ fe_get_int (char *prompt, int def, void *callback, void *ud)
 void
 fe_idle_add (void *func, void *data)
 {
+	g_idle_add (func, data);
 }
 void
 fe_ctrl_gui (session *sess, fe_gui_action action, int arg)
 {
+	/* only one action type handled for now, but could add more */
+	switch (action)
+	{
+	/* gui focus is really the only case xchat-text needs to wory about */
+	case FE_GUI_FOCUS:
+		current_sess = sess;
+		current_tab = sess;
+		sess->server->front_session = sess;
+		break;
+	default:
+		break;
+	}
 }
 int
 fe_gui_info (session *sess, int info_type)
diff --git a/src/fe-text/fe-text.h b/src/fe-text/fe-text.h
index b8afa284..e4f6f6c0 100644
--- a/src/fe-text/fe-text.h
+++ b/src/fe-text/fe-text.h
@@ -1,29 +1 @@
-
-typedef int (*socket_callback) (void *source, int condition, void *user_data);
-typedef int (*timer_callback) (void *user_data);
-
-struct socketeventRec
-{
-	socket_callback callback;
-	void *userdata;
-	int sok;
-	int tag;
-	int rread:1;
-	int wwrite:1;
-	int eexcept:1;
-	int checked:1;
-};
-
-typedef struct socketeventRec socketevent;
-
-
-struct timerRec
-{
-	timer_callback callback;
-	void *userdata;
-	int interval;
-	int tag;
-	guint64 next_call;	/* miliseconds */
-};
-
-typedef struct timerRec timerevent;
+GMainLoop *main_loop;
diff --git a/src/fe-text/makefile.mak b/src/fe-text/makefile.mak
new file mode 100644
index 00000000..59d277d3
--- /dev/null
+++ b/src/fe-text/makefile.mak
@@ -0,0 +1,20 @@
+include "..\makeinc.mak"

+

+COMLIB = ..\common\xchatcommon.lib

+PROG = xchat-text.exe

+

+!ifdef X64

+PLATOBJ = msvcrt_win2003.obj

+!else

+PLATOBJ = msvcrt_winxp.obj

+!endif

+

+all: fe-text.obj

+	link /out:$(PROG) /subsystem:console /nologo $(PLATOBJ) $(LIBS) $(COMLIB) fe-text.obj

+

+fe-text.obj: fe-text.c makefile.mak

+	cl $(CFLAGS) $(GLIB) fe-text.c

+

+clean:

+	@del *.obj

+	@del $(PROG)

diff --git a/src/gtk2-prefs/callbacks.cpp b/src/gtk2-prefs/callbacks.cpp
new file mode 100644
index 00000000..9cc5c928
--- /dev/null
+++ b/src/gtk2-prefs/callbacks.cpp
@@ -0,0 +1,224 @@
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <iostream>
+
+#include "callbacks.h"
+#include "interface.h"
+#include "support.h"
+
+#include "main.h"
+
+
+
+extern GtkWidget* g_main_window;
+
+void
+on_main_showpreviewtoggle_toggled               (GtkToggleButton *togglebutton,
+                                        gpointer         user_data)
+{
+	if (gtk_toggle_button_get_active (togglebutton)) {
+		gtk_widget_show(lookup_widget(g_main_window, "main_previewhbox"));
+		gtk_button_set_label(GTK_BUTTON(togglebutton), "Hide preview <<");
+		gtk_window_resize(GTK_WINDOW(g_main_window), 700, 330);
+	} else {
+		gtk_widget_hide(lookup_widget(g_main_window, "main_previewhbox"));
+		gtk_button_set_label(GTK_BUTTON(togglebutton), "Show preview >>");
+		gtk_window_resize(GTK_WINDOW(g_main_window), 300, 330);
+	}
+
+}
+
+
+/*
+extern GtkWidget* g_fontsel_dialog;
+
+
+void
+on_fontsel_dialog_response             (GtkDialog       *dialog,
+                                        gint             id,
+                                        gpointer         user_data)
+{
+
+	switch(id) {
+		case GTK_RESPONSE_OK:
+		{
+			const char* font = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG(dialog));
+			std::string f = (font ? font : "");
+			set_theme(get_selected_theme(), f);
+			break;
+		}
+//		case GTK_RESPONSE_CANCEL:
+//			gtk_widget_destroy(g_fontsel_dialog);
+//			g_fontsel_dialog = 0;
+//			return;
+
+	}
+	gtk_widget_destroy(g_fontsel_dialog);
+	g_fontsel_dialog = 0;
+
+}
+
+
+gboolean
+on_fontsel_dialog_delete_event         (GtkWidget       *widget,
+                                        GdkEvent        *event,
+                                        gpointer         user_data)
+{
+	gtk_widget_destroy(g_fontsel_dialog);
+	g_fontsel_dialog = 0;
+
+	return FALSE;
+}
+
+
+void
+on_main_fontselectbutton_clicked       (GtkButton       *button,
+                                        gpointer         user_data)
+{
+	g_fontsel_dialog = create_fontsel_dialog();
+	gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(g_fontsel_dialog), get_current_font().c_str());
+	gtk_widget_show(g_fontsel_dialog);
+}
+*/
+
+
+
+
+
+void
+on_main_ok_button_clicked              (GtkButton       *button,
+                                        gpointer         user_data)
+{
+	if (save_current_theme())
+		gtk_main_quit();
+}
+
+
+void
+on_main_cancel_button_clicked          (GtkButton       *button,
+                                        gpointer         user_data)
+{
+	gtk_main_quit();
+}
+
+
+void
+on_main_reset_button_clicked           (GtkButton       *button,
+                                        gpointer         user_data)
+{
+	set_theme(get_orig_theme(), get_orig_font());
+}
+
+
+gboolean
+on_main_window_delete_event            (GtkWidget       *widget,
+                                        GdkEvent        *event,
+                                        gpointer         user_data)
+{
+	program_shutdown();
+	return true;
+}
+
+
+void
+on_main_use_default_font_radio_toggled (GtkToggleButton *togglebutton,
+                                        gpointer         user_data)
+{
+	bool default_font = gtk_toggle_button_get_active(togglebutton);
+
+	gtk_widget_set_sensitive(lookup_widget(g_main_window, "main_font_selector_button"), !default_font);
+
+	apply_theme(get_selected_theme(), get_selected_font());
+}
+
+
+void
+on_main_font_selector_button_font_set  (GtkFontButton   *fontbutton,
+                                        gpointer         user_data)
+{
+	apply_theme(get_selected_theme(), get_selected_font());
+}
+
+
+void
+on_new2_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_open2_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_save2_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_save_as2_activate                   (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_quit2_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_cut2_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_copy2_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_paste2_activate                     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_delete2_activate                    (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_about2_activate                     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+
+}
+
diff --git a/src/gtk2-prefs/callbacks.h b/src/gtk2-prefs/callbacks.h
new file mode 100644
index 00000000..5759aebc
--- /dev/null
+++ b/src/gtk2-prefs/callbacks.h
@@ -0,0 +1,71 @@
+#include <gtk/gtk.h>
+
+
+void
+on_main_showpreviewtoggle_toggled               (GtkToggleButton *togglebutton,
+                                        gpointer         user_data);
+
+void
+on_main_ok_button_clicked              (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_main_cancel_button_clicked          (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_main_reset_button_clicked           (GtkButton       *button,
+                                        gpointer         user_data);
+
+gboolean
+on_main_window_delete_event            (GtkWidget       *widget,
+                                        GdkEvent        *event,
+                                        gpointer         user_data);
+
+void
+on_main_use_default_font_radio_toggled (GtkToggleButton *togglebutton,
+                                        gpointer         user_data);
+
+void
+on_main_font_selector_button_font_set  (GtkFontButton   *fontbutton,
+                                        gpointer         user_data);
+
+void
+on_new2_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_open2_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_save2_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_save_as2_activate                   (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_quit2_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_cut2_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_copy2_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_paste2_activate                     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_delete2_activate                    (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_about2_activate                     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
diff --git a/src/gtk2-prefs/config.h b/src/gtk2-prefs/config.h
new file mode 100644
index 00000000..4501a33b
--- /dev/null
+++ b/src/gtk2-prefs/config.h
@@ -0,0 +1,59 @@
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* For gmessages.h error message */
+#define G_HAVE_ISO_VARARGS
+
+/* For mkdir */
+#define HAVE_DIRECT_H 1
+
+/* Name of package */
+#define PACKAGE gtk2-prefs
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME gtk2-prefs
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING gtk2-prefs 0.4.1
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME gtk2-prefs
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION 0.4.1
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION 0.4.1
diff --git a/src/gtk2-prefs/interface.cpp b/src/gtk2-prefs/interface.cpp
new file mode 100644
index 00000000..18b66bb6
--- /dev/null
+++ b/src/gtk2-prefs/interface.cpp
@@ -0,0 +1,836 @@
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <string.h>
+#include <stdio.h>
+
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include "callbacks.h"
+#include "interface.h"
+#include "support.h"
+
+#define GLADE_HOOKUP_OBJECT(component,widget,name) \
+  g_object_set_data_full (G_OBJECT (component), name, \
+    gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
+
+#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
+  g_object_set_data (G_OBJECT (component), name, widget)
+
+GtkWidget*
+create_main_window (void)
+{
+  GtkWidget *main_window;
+  GtkWidget *main_hbox;
+  GtkWidget *vbox1;
+  GtkWidget *hbox1;
+  GtkWidget *frame2;
+  GtkWidget *alignment3;
+  GtkWidget *scrolledwindow3;
+  GtkWidget *main_themelist;
+  GtkWidget *label1234;
+  GtkWidget *frame3;
+  GtkWidget *alignment4;
+  GtkWidget *vbox7;
+  GtkWidget *hbox8;
+  GtkWidget *vbox9;
+  GtkWidget *main_use_default_font_radio;
+  GSList *main_use_default_font_radio_group = NULL;
+  GtkWidget *main_use_custom_font_radio;
+  GtkWidget *alignment5;
+  GtkWidget *vbox10;
+  GtkWidget *hbox9;
+  GtkWidget *vbox11;
+  GtkWidget *main_font_selector_button;
+  GtkWidget *label669;
+  GtkWidget *vbox13;
+  GtkWidget *hbox6666;
+  GtkWidget *main_use_system_config_checkbutton;
+  GtkWidget *main_showpreviewtoggle;
+  GtkWidget *hbuttonbox1;
+  GtkWidget *hbox7;
+  GtkWidget *hbox6665;
+  GtkWidget *image2;
+  GtkWidget *label2;
+  GtkWidget *vbox6;
+  GtkWidget *hbox5;
+  GtkWidget *main_ok_button;
+  GtkWidget *main_cancel_button;
+  GtkWidget *main_reset_button;
+  GtkWidget *alignment2;
+  GtkWidget *hbox6;
+  GtkWidget *image1;
+  GtkWidget *label667;
+  GtkWidget *main_previewhbox;
+  GtkWidget *vseparator2;
+  GtkWidget *frame4;
+  GtkWidget *alignment6;
+  GtkWidget *vbox12;
+  GtkWidget *main_previewbook;
+  GtkWidget *table1;
+  GtkWidget *vbox2;
+  GtkWidget *checkbutton1;
+  GtkWidget *checkbutton2;
+  GtkWidget *button4;
+  GtkWidget *togglebutton1;
+  GtkObject *spinbutton1_adj;
+  GtkWidget *spinbutton1;
+  GtkWidget *vbox4;
+  GtkWidget *menubar2;
+  GtkWidget *menuitem5;
+  GtkWidget *menuitem5_menu;
+  GtkWidget *new2;
+  GtkWidget *open2;
+  GtkWidget *save2;
+  GtkWidget *save_as2;
+  GtkWidget *separatormenuitem2;
+  GtkWidget *quit2;
+  GtkWidget *menuitem6;
+  GtkWidget *menuitem6_menu;
+  GtkWidget *cut2;
+  GtkWidget *copy2;
+  GtkWidget *paste2;
+  GtkWidget *delete2;
+  GtkWidget *menuitem8;
+  GtkWidget *menuitem8_menu;
+  GtkWidget *about2;
+  GtkWidget *combobox1;
+  GtkWidget *comboboxentry1;
+  GtkWidget *hscale1;
+  GtkWidget *scrolledwindow1;
+  GtkWidget *preview_treeview;
+  GtkWidget *statusbar1;
+  GtkWidget *progressbar1;
+  GtkWidget *vseparator1;
+  GtkWidget *frame1;
+  GtkWidget *vbox3;
+  GtkWidget *radiobutton1;
+  GSList *radiobutton1_group = NULL;
+  GtkWidget *radiobutton2;
+  GtkWidget *radiobutton3;
+  GtkWidget *label6;
+  GtkWidget *label4;
+  GtkWidget *scrolledwindow2;
+  GtkWidget *textview1;
+  GtkWidget *label5;
+  GtkWidget *vbox5;
+  GtkWidget *hbox4;
+  GtkWidget *about_label;
+  GtkWidget *label666;
+  GtkWidget *label670;
+  GtkAccelGroup *accel_group;
+  GtkTooltips *tooltips;
+
+  tooltips = gtk_tooltips_new ();
+
+  accel_group = gtk_accel_group_new ();
+
+  main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_widget_set_name (main_window, "main_window");
+  gtk_window_set_title (GTK_WINDOW (main_window), "GTK+ Preference Tool");
+
+  main_hbox = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (main_hbox, "main_hbox");
+  gtk_widget_show (main_hbox);
+  gtk_container_add (GTK_CONTAINER (main_window), main_hbox);
+  gtk_widget_set_size_request (main_hbox, 310, 320);
+
+  vbox1 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox1, "vbox1");
+  gtk_widget_show (vbox1);
+  gtk_box_pack_start (GTK_BOX (main_hbox), vbox1, TRUE, TRUE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox1), 3);
+
+  hbox1 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (hbox1, "hbox1");
+  gtk_widget_show (hbox1);
+  gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);
+
+  frame2 = gtk_frame_new (NULL);
+  gtk_widget_set_name (frame2, "frame2");
+  gtk_widget_show (frame2);
+  gtk_box_pack_start (GTK_BOX (hbox1), frame2, TRUE, TRUE, 0);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_NONE);
+
+  alignment3 = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_widget_set_name (alignment3, "alignment3");
+  gtk_widget_show (alignment3);
+  gtk_container_add (GTK_CONTAINER (frame2), alignment3);
+  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment3), 0, 0, 12, 0);
+
+  scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_set_name (scrolledwindow3, "scrolledwindow3");
+  gtk_widget_show (scrolledwindow3);
+  gtk_container_add (GTK_CONTAINER (alignment3), scrolledwindow3);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow3), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow3), GTK_SHADOW_IN);
+
+  main_themelist = gtk_tree_view_new ();
+  gtk_widget_set_name (main_themelist, "main_themelist");
+  gtk_widget_show (main_themelist);
+  gtk_container_add (GTK_CONTAINER (scrolledwindow3), main_themelist);
+  GTK_WIDGET_SET_FLAGS (main_themelist, GTK_CAN_DEFAULT);
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (main_themelist), FALSE);
+
+  label1234 = gtk_label_new ("<b>Theme</b>");
+  gtk_widget_set_name (label1234, "label1234");
+  gtk_widget_show (label1234);
+  gtk_frame_set_label_widget (GTK_FRAME (frame2), label1234);
+  gtk_label_set_use_markup (GTK_LABEL (label1234), TRUE);
+
+  frame3 = gtk_frame_new (NULL);
+  gtk_widget_set_name (frame3, "frame3");
+  gtk_widget_show (frame3);
+  gtk_box_pack_start (GTK_BOX (vbox1), frame3, FALSE, FALSE, 9);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame3), GTK_SHADOW_NONE);
+
+  alignment4 = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_widget_set_name (alignment4, "alignment4");
+  gtk_widget_show (alignment4);
+  gtk_container_add (GTK_CONTAINER (frame3), alignment4);
+  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment4), 0, 0, 12, 0);
+
+  vbox7 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox7, "vbox7");
+  gtk_widget_show (vbox7);
+  gtk_container_add (GTK_CONTAINER (alignment4), vbox7);
+
+  hbox8 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (hbox8, "hbox8");
+  gtk_widget_show (hbox8);
+  gtk_box_pack_start (GTK_BOX (vbox7), hbox8, FALSE, FALSE, 0);
+
+  vbox9 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox9, "vbox9");
+  gtk_widget_show (vbox9);
+  gtk_box_pack_start (GTK_BOX (hbox8), vbox9, TRUE, TRUE, 0);
+
+  main_use_default_font_radio = gtk_radio_button_new_with_mnemonic (NULL, "Use theme default font");
+  gtk_widget_set_name (main_use_default_font_radio, "main_use_default_font_radio");
+  gtk_widget_show (main_use_default_font_radio);
+  gtk_box_pack_start (GTK_BOX (vbox9), main_use_default_font_radio, FALSE, FALSE, 0);
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (main_use_default_font_radio), main_use_default_font_radio_group);
+  main_use_default_font_radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (main_use_default_font_radio));
+
+  main_use_custom_font_radio = gtk_radio_button_new_with_mnemonic (NULL, "Use custom font:");
+  gtk_widget_set_name (main_use_custom_font_radio, "main_use_custom_font_radio");
+  gtk_widget_show (main_use_custom_font_radio);
+  gtk_box_pack_start (GTK_BOX (vbox9), main_use_custom_font_radio, FALSE, FALSE, 0);
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (main_use_custom_font_radio), main_use_default_font_radio_group);
+  main_use_default_font_radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (main_use_custom_font_radio));
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (main_use_custom_font_radio), TRUE);
+
+  alignment5 = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_widget_set_name (alignment5, "alignment5");
+  gtk_widget_show (alignment5);
+  gtk_box_pack_start (GTK_BOX (vbox9), alignment5, TRUE, TRUE, 0);
+  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment5), 0, 0, 12, 0);
+
+  vbox10 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox10, "vbox10");
+  gtk_widget_show (vbox10);
+  gtk_container_add (GTK_CONTAINER (alignment5), vbox10);
+
+  hbox9 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (hbox9, "hbox9");
+  gtk_widget_show (hbox9);
+  gtk_box_pack_start (GTK_BOX (vbox10), hbox9, FALSE, FALSE, 0);
+
+  vbox11 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox11, "vbox11");
+  gtk_widget_show (vbox11);
+  gtk_box_pack_start (GTK_BOX (hbox9), vbox11, TRUE, TRUE, 0);
+
+  main_font_selector_button = gtk_font_button_new ();
+  gtk_widget_set_name (main_font_selector_button, "main_font_selector_button");
+  gtk_widget_show (main_font_selector_button);
+  gtk_box_pack_start (GTK_BOX (vbox11), main_font_selector_button, FALSE, FALSE, 0);
+
+  label669 = gtk_label_new ("<b>Font</b>");
+  gtk_widget_set_name (label669, "label669");
+  gtk_widget_show (label669);
+  gtk_frame_set_label_widget (GTK_FRAME (frame3), label669);
+  gtk_label_set_use_markup (GTK_LABEL (label669), TRUE);
+
+  vbox13 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox13, "vbox13");
+  gtk_widget_show (vbox13);
+  gtk_box_pack_start (GTK_BOX (vbox1), vbox13, FALSE, FALSE, 0);
+
+  hbox6666 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (hbox6666, "hbox6666");
+  gtk_widget_show (hbox6666);
+  gtk_box_pack_start (GTK_BOX (vbox13), hbox6666, TRUE, TRUE, 0);
+
+  /* main_use_system_config_checkbutton = gtk_check_button_new_with_mnemonic ("Apply for all users");
+  gtk_widget_set_name (main_use_system_config_checkbutton, "main_use_system_config_checkbutton");
+  gtk_widget_show (main_use_system_config_checkbutton);
+  gtk_box_pack_start (GTK_BOX (hbox6666), main_use_system_config_checkbutton, FALSE, FALSE, 12);
+  gtk_tooltips_set_tip (tooltips, main_use_system_config_checkbutton, "If this is enabled, the program will update the system-wide configuration file. NOT RECOMMENDED!", NULL); */
+
+  main_showpreviewtoggle = gtk_toggle_button_new_with_mnemonic ("Show preview >>");
+  gtk_widget_set_name (main_showpreviewtoggle, "main_showpreviewtoggle");
+  gtk_widget_show (main_showpreviewtoggle);
+  gtk_box_pack_end (GTK_BOX (hbox6666), main_showpreviewtoggle, FALSE, FALSE, 2);
+
+  hbuttonbox1 = gtk_hbutton_box_new ();
+  gtk_widget_set_name (hbuttonbox1, "hbuttonbox1");
+  gtk_widget_show (hbuttonbox1);
+  gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, FALSE, FALSE, 0);
+
+  hbox7 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (hbox7, "hbox7");
+  gtk_widget_show (hbox7);
+  gtk_box_pack_start (GTK_BOX (vbox1), hbox7, FALSE, TRUE, 6);
+
+  hbox6665 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (hbox6665, "hbox6665");
+  gtk_widget_show (hbox6665);
+  gtk_box_pack_start (GTK_BOX (hbox7), hbox6665, TRUE, FALSE, 0);
+
+  image2 = gtk_image_new_from_stock ("gtk-dialog-info", GTK_ICON_SIZE_LARGE_TOOLBAR);
+  gtk_widget_set_name (image2, "image2");
+  gtk_widget_show (image2);
+  gtk_box_pack_start (GTK_BOX (hbox6665), image2, FALSE, FALSE, 0);
+
+  label2 = gtk_label_new ("You should restart your programs\nfor this change to take effect.");
+  gtk_widget_set_name (label2, "label2");
+  gtk_widget_show (label2);
+  gtk_box_pack_start (GTK_BOX (hbox6665), label2, FALSE, FALSE, 0);
+  gtk_label_set_line_wrap (GTK_LABEL (label2), TRUE);
+  gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
+
+  vbox6 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox6, "vbox6");
+  gtk_widget_show (vbox6);
+  gtk_box_pack_start (GTK_BOX (vbox1), vbox6, FALSE, FALSE, 0);
+
+  hbox5 = gtk_hbox_new (TRUE, 0);
+  gtk_widget_set_name (hbox5, "hbox5");
+  gtk_widget_show (hbox5);
+  gtk_box_pack_start (GTK_BOX (vbox6), hbox5, FALSE, FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox5), 4);
+
+  main_ok_button = gtk_button_new_from_stock ("gtk-ok");
+  gtk_widget_set_name (main_ok_button, "main_ok_button");
+  gtk_widget_show (main_ok_button);
+  gtk_box_pack_end (GTK_BOX (hbox5), main_ok_button, TRUE, TRUE, 4);
+  GTK_WIDGET_SET_FLAGS (main_ok_button, GTK_CAN_DEFAULT);
+
+  main_cancel_button = gtk_button_new_from_stock ("gtk-cancel");
+  gtk_widget_set_name (main_cancel_button, "main_cancel_button");
+  gtk_widget_show (main_cancel_button);
+  gtk_box_pack_end (GTK_BOX (hbox5), main_cancel_button, TRUE, TRUE, 4);
+  GTK_WIDGET_SET_FLAGS (main_cancel_button, GTK_CAN_DEFAULT);
+
+  main_reset_button = gtk_button_new ();
+  gtk_widget_set_name (main_reset_button, "main_reset_button");
+  gtk_widget_show (main_reset_button);
+  gtk_box_pack_end (GTK_BOX (hbox5), main_reset_button, TRUE, TRUE, 4);
+
+  alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
+  gtk_widget_set_name (alignment2, "alignment2");
+  gtk_widget_show (alignment2);
+  gtk_container_add (GTK_CONTAINER (main_reset_button), alignment2);
+
+  hbox6 = gtk_hbox_new (FALSE, 2);
+  gtk_widget_set_name (hbox6, "hbox6");
+  gtk_widget_show (hbox6);
+  gtk_container_add (GTK_CONTAINER (alignment2), hbox6);
+
+  image1 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_BUTTON);
+  gtk_widget_set_name (image1, "image1");
+  gtk_widget_show (image1);
+  gtk_box_pack_start (GTK_BOX (hbox6), image1, FALSE, FALSE, 0);
+
+  label667 = gtk_label_new_with_mnemonic ("_Reset");
+  gtk_widget_set_name (label667, "label667");
+  gtk_widget_show (label667);
+  gtk_box_pack_start (GTK_BOX (hbox6), label667, FALSE, FALSE, 0);
+
+  main_previewhbox = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (main_previewhbox, "main_previewhbox");
+  gtk_box_pack_start (GTK_BOX (main_hbox), main_previewhbox, TRUE, TRUE, 0);
+
+  vseparator2 = gtk_vseparator_new ();
+  gtk_widget_set_name (vseparator2, "vseparator2");
+  gtk_widget_show (vseparator2);
+  gtk_box_pack_start (GTK_BOX (main_previewhbox), vseparator2, FALSE, TRUE, 4);
+
+  frame4 = gtk_frame_new (NULL);
+  gtk_widget_set_name (frame4, "frame4");
+  gtk_widget_show (frame4);
+  gtk_box_pack_start (GTK_BOX (main_previewhbox), frame4, TRUE, TRUE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (frame4), 3);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame4), GTK_SHADOW_NONE);
+
+  alignment6 = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_widget_set_name (alignment6, "alignment6");
+  gtk_widget_show (alignment6);
+  gtk_container_add (GTK_CONTAINER (frame4), alignment6);
+
+  vbox12 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox12, "vbox12");
+  gtk_widget_show (vbox12);
+  gtk_container_add (GTK_CONTAINER (alignment6), vbox12);
+
+  main_previewbook = gtk_notebook_new ();
+  gtk_widget_set_name (main_previewbook, "main_previewbook");
+  gtk_widget_show (main_previewbook);
+  gtk_box_pack_start (GTK_BOX (vbox12), main_previewbook, TRUE, TRUE, 0);
+
+  table1 = gtk_table_new (3, 3, FALSE);
+  gtk_widget_set_name (table1, "table1");
+  gtk_widget_show (table1);
+  gtk_container_add (GTK_CONTAINER (main_previewbook), table1);
+  gtk_container_set_border_width (GTK_CONTAINER (table1), 5);
+
+  vbox2 = gtk_vbox_new (FALSE, 4);
+  gtk_widget_set_name (vbox2, "vbox2");
+  gtk_widget_show (vbox2);
+  gtk_table_attach (GTK_TABLE (table1), vbox2, 0, 1, 0, 1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
+
+  checkbutton1 = gtk_check_button_new_with_mnemonic ("check button 1");
+  gtk_widget_set_name (checkbutton1, "checkbutton1");
+  gtk_widget_show (checkbutton1);
+  gtk_box_pack_start (GTK_BOX (vbox2), checkbutton1, FALSE, FALSE, 0);
+
+  checkbutton2 = gtk_check_button_new_with_mnemonic ("check button 2");
+  gtk_widget_set_name (checkbutton2, "checkbutton2");
+  gtk_widget_show (checkbutton2);
+  gtk_box_pack_start (GTK_BOX (vbox2), checkbutton2, FALSE, FALSE, 0);
+
+  button4 = gtk_button_new_with_mnemonic ("button");
+  gtk_widget_set_name (button4, "button4");
+  gtk_widget_show (button4);
+  gtk_box_pack_start (GTK_BOX (vbox2), button4, FALSE, FALSE, 0);
+
+  togglebutton1 = gtk_toggle_button_new_with_mnemonic ("toggle button");
+  gtk_widget_set_name (togglebutton1, "togglebutton1");
+  gtk_widget_show (togglebutton1);
+  gtk_box_pack_start (GTK_BOX (vbox2), togglebutton1, FALSE, FALSE, 0);
+
+  spinbutton1_adj = gtk_adjustment_new (0, 0, 100, 1, 10, 10);
+  spinbutton1 = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton1_adj), 1, 0);
+  gtk_widget_set_name (spinbutton1, "spinbutton1");
+  gtk_widget_show (spinbutton1);
+  gtk_box_pack_start (GTK_BOX (vbox2), spinbutton1, FALSE, FALSE, 0);
+
+  vbox4 = gtk_vbox_new (FALSE, 4);
+  gtk_widget_set_name (vbox4, "vbox4");
+  gtk_widget_show (vbox4);
+  gtk_table_attach (GTK_TABLE (table1), vbox4, 2, 3, 0, 1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (GTK_FILL), 0, 0);
+
+  menubar2 = gtk_menu_bar_new ();
+  gtk_widget_set_name (menubar2, "menubar2");
+  gtk_widget_show (menubar2);
+  gtk_box_pack_start (GTK_BOX (vbox4), menubar2, FALSE, FALSE, 0);
+
+  menuitem5 = gtk_menu_item_new_with_mnemonic ("_File");
+  gtk_widget_set_name (menuitem5, "menuitem5");
+  gtk_widget_show (menuitem5);
+  gtk_container_add (GTK_CONTAINER (menubar2), menuitem5);
+
+  menuitem5_menu = gtk_menu_new ();
+  gtk_widget_set_name (menuitem5_menu, "menuitem5_menu");
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem5), menuitem5_menu);
+
+  new2 = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
+  gtk_widget_set_name (new2, "new2");
+  gtk_widget_show (new2);
+  gtk_container_add (GTK_CONTAINER (menuitem5_menu), new2);
+
+  open2 = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
+  gtk_widget_set_name (open2, "open2");
+  gtk_widget_show (open2);
+  gtk_container_add (GTK_CONTAINER (menuitem5_menu), open2);
+
+  save2 = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
+  gtk_widget_set_name (save2, "save2");
+  gtk_widget_show (save2);
+  gtk_container_add (GTK_CONTAINER (menuitem5_menu), save2);
+
+  save_as2 = gtk_image_menu_item_new_from_stock ("gtk-save-as", accel_group);
+  gtk_widget_set_name (save_as2, "save_as2");
+  gtk_widget_show (save_as2);
+  gtk_container_add (GTK_CONTAINER (menuitem5_menu), save_as2);
+
+  separatormenuitem2 = gtk_separator_menu_item_new ();
+  gtk_widget_set_name (separatormenuitem2, "separatormenuitem2");
+  gtk_widget_show (separatormenuitem2);
+  gtk_container_add (GTK_CONTAINER (menuitem5_menu), separatormenuitem2);
+  gtk_widget_set_sensitive (separatormenuitem2, FALSE);
+
+  quit2 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
+  gtk_widget_set_name (quit2, "quit2");
+  gtk_widget_show (quit2);
+  gtk_container_add (GTK_CONTAINER (menuitem5_menu), quit2);
+
+  menuitem6 = gtk_menu_item_new_with_mnemonic ("_Edit");
+  gtk_widget_set_name (menuitem6, "menuitem6");
+  gtk_widget_show (menuitem6);
+  gtk_container_add (GTK_CONTAINER (menubar2), menuitem6);
+
+  menuitem6_menu = gtk_menu_new ();
+  gtk_widget_set_name (menuitem6_menu, "menuitem6_menu");
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem6), menuitem6_menu);
+
+  cut2 = gtk_image_menu_item_new_from_stock ("gtk-cut", accel_group);
+  gtk_widget_set_name (cut2, "cut2");
+  gtk_widget_show (cut2);
+  gtk_container_add (GTK_CONTAINER (menuitem6_menu), cut2);
+
+  copy2 = gtk_image_menu_item_new_from_stock ("gtk-copy", accel_group);
+  gtk_widget_set_name (copy2, "copy2");
+  gtk_widget_show (copy2);
+  gtk_container_add (GTK_CONTAINER (menuitem6_menu), copy2);
+
+  paste2 = gtk_image_menu_item_new_from_stock ("gtk-paste", accel_group);
+  gtk_widget_set_name (paste2, "paste2");
+  gtk_widget_show (paste2);
+  gtk_container_add (GTK_CONTAINER (menuitem6_menu), paste2);
+
+  delete2 = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
+  gtk_widget_set_name (delete2, "delete2");
+  gtk_widget_show (delete2);
+  gtk_container_add (GTK_CONTAINER (menuitem6_menu), delete2);
+
+  menuitem8 = gtk_menu_item_new_with_mnemonic ("_Help");
+  gtk_widget_set_name (menuitem8, "menuitem8");
+  gtk_widget_show (menuitem8);
+  gtk_container_add (GTK_CONTAINER (menubar2), menuitem8);
+
+  menuitem8_menu = gtk_menu_new ();
+  gtk_widget_set_name (menuitem8_menu, "menuitem8_menu");
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem8), menuitem8_menu);
+
+  about2 = gtk_menu_item_new_with_mnemonic ("_About");
+  gtk_widget_set_name (about2, "about2");
+  gtk_widget_show (about2);
+  gtk_container_add (GTK_CONTAINER (menuitem8_menu), about2);
+
+  combobox1 = gtk_combo_box_new_text ();
+  gtk_widget_set_name (combobox1, "combobox1");
+  gtk_widget_show (combobox1);
+  gtk_box_pack_start (GTK_BOX (vbox4), combobox1, FALSE, FALSE, 0);
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), "item 1");
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), "item 2");
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), "item 3");
+
+  comboboxentry1 = gtk_combo_box_entry_new_text ();
+  gtk_widget_set_name (comboboxentry1, "comboboxentry1");
+  gtk_widget_show (comboboxentry1);
+  gtk_box_pack_start (GTK_BOX (vbox4), comboboxentry1, FALSE, FALSE, 0);
+  gtk_widget_set_size_request (comboboxentry1, 80, 25);
+  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), "item 1");
+  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), "item 2");
+  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), "item 3");
+
+  hscale1 = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (15, 0, 50, 1, 0, 0)));
+  gtk_widget_set_name (hscale1, "hscale1");
+  gtk_widget_show (hscale1);
+  gtk_box_pack_start (GTK_BOX (vbox4), hscale1, TRUE, TRUE, 0);
+  gtk_scale_set_digits (GTK_SCALE (hscale1), 0);
+
+  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_set_name (scrolledwindow1, "scrolledwindow1");
+  gtk_widget_show (scrolledwindow1);
+  gtk_table_attach (GTK_TABLE (table1), scrolledwindow1, 2, 3, 1, 2,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (GTK_FILL), 0, 0);
+
+  preview_treeview = gtk_tree_view_new ();
+  gtk_widget_set_name (preview_treeview, "preview_treeview");
+  gtk_widget_show (preview_treeview);
+  gtk_container_add (GTK_CONTAINER (scrolledwindow1), preview_treeview);
+  gtk_tree_view_set_reorderable (GTK_TREE_VIEW (preview_treeview), TRUE);
+
+  statusbar1 = gtk_statusbar_new ();
+  gtk_widget_set_name (statusbar1, "statusbar1");
+  gtk_widget_show (statusbar1);
+  gtk_table_attach (GTK_TABLE (table1), statusbar1, 1, 3, 2, 3,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_widget_set_size_request (statusbar1, 6, 20);
+
+  progressbar1 = gtk_progress_bar_new ();
+  gtk_widget_set_name (progressbar1, "progressbar1");
+  gtk_widget_show (progressbar1);
+  gtk_table_attach (GTK_TABLE (table1), progressbar1, 0, 1, 2, 3,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_widget_set_size_request (progressbar1, 80, 20);
+  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progressbar1), 0.56);
+  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progressbar1), "56%");
+
+  vseparator1 = gtk_vseparator_new ();
+  gtk_widget_set_name (vseparator1, "vseparator1");
+  gtk_widget_show (vseparator1);
+  gtk_table_attach (GTK_TABLE (table1), vseparator1, 1, 2, 0, 2,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (GTK_FILL), 5, 0);
+
+  frame1 = gtk_frame_new (NULL);
+  gtk_widget_set_name (frame1, "frame1");
+  gtk_widget_show (frame1);
+  gtk_table_attach (GTK_TABLE (table1), frame1, 0, 1, 1, 2,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (GTK_EXPAND), 0, 0);
+  gtk_frame_set_label_align (GTK_FRAME (frame1), 0.5, 0.5);
+
+  vbox3 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox3, "vbox3");
+  gtk_widget_show (vbox3);
+  gtk_container_add (GTK_CONTAINER (frame1), vbox3);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox3), 5);
+
+  radiobutton1 = gtk_radio_button_new_with_mnemonic (NULL, "radio 1");
+  gtk_widget_set_name (radiobutton1, "radiobutton1");
+  gtk_widget_show (radiobutton1);
+  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton1, FALSE, FALSE, 0);
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton1), radiobutton1_group);
+  radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton1));
+
+  radiobutton2 = gtk_radio_button_new_with_mnemonic (NULL, "radio 2");
+  gtk_widget_set_name (radiobutton2, "radiobutton2");
+  gtk_widget_show (radiobutton2);
+  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton2, FALSE, FALSE, 0);
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton2), radiobutton1_group);
+  radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton2));
+
+  radiobutton3 = gtk_radio_button_new_with_mnemonic (NULL, "radio 3");
+  gtk_widget_set_name (radiobutton3, "radiobutton3");
+  gtk_widget_show (radiobutton3);
+  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton3, FALSE, FALSE, 0);
+  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton3), radiobutton1_group);
+  radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton3));
+
+  label6 = gtk_label_new ("frame");
+  gtk_widget_set_name (label6, "label6");
+  gtk_widget_show (label6);
+  gtk_frame_set_label_widget (GTK_FRAME (frame1), label6);
+  gtk_misc_set_padding (GTK_MISC (label6), 1, 0);
+
+  label4 = gtk_label_new ("Common widgets");
+  gtk_widget_set_name (label4, "label4");
+  gtk_widget_show (label4);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (main_previewbook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (main_previewbook), 0), label4);
+
+  scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_set_name (scrolledwindow2, "scrolledwindow2");
+  gtk_widget_show (scrolledwindow2);
+  gtk_container_add (GTK_CONTAINER (main_previewbook), scrolledwindow2);
+
+  textview1 = gtk_text_view_new ();
+  gtk_widget_set_name (textview1, "textview1");
+  gtk_widget_show (textview1);
+  gtk_container_add (GTK_CONTAINER (scrolledwindow2), textview1);
+  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview1), GTK_WRAP_WORD);
+  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview1), 8);
+  gtk_text_view_set_right_margin (GTK_TEXT_VIEW (textview1), 8);
+  gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1)), "You can type some text here.\nYou can also click the right mouse button for a popup menu.", -1);
+
+  label5 = gtk_label_new ("Text area");
+  gtk_widget_set_name (label5, "label5");
+  gtk_widget_show (label5);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (main_previewbook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (main_previewbook), 1), label5);
+
+  vbox5 = gtk_vbox_new (FALSE, 0);
+  gtk_widget_set_name (vbox5, "vbox5");
+  gtk_widget_show (vbox5);
+  gtk_container_add (GTK_CONTAINER (main_previewbook), vbox5);
+
+  hbox4 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_name (hbox4, "hbox4");
+  gtk_widget_show (hbox4);
+  gtk_box_pack_start (GTK_BOX (vbox5), hbox4, TRUE, TRUE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox4), 7);
+
+  about_label = gtk_label_new ("");
+  gtk_widget_set_name (about_label, "about_label");
+  gtk_widget_show (about_label);
+  gtk_box_pack_start (GTK_BOX (hbox4), about_label, FALSE, FALSE, 0);
+  gtk_label_set_line_wrap (GTK_LABEL (about_label), TRUE);
+
+  label666 = gtk_label_new ("About");
+  gtk_widget_set_name (label666, "label666");
+  gtk_widget_show (label666);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (main_previewbook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (main_previewbook), 2), label666);
+
+  label670 = gtk_label_new ("<b>Preview</b>");
+  gtk_widget_set_name (label670, "label670");
+  gtk_widget_show (label670);
+  gtk_frame_set_label_widget (GTK_FRAME (frame4), label670);
+  gtk_label_set_use_markup (GTK_LABEL (label670), TRUE);
+
+  g_signal_connect ((gpointer) main_window, "delete_event",
+                    G_CALLBACK (on_main_window_delete_event),
+                    NULL);
+  g_signal_connect ((gpointer) main_use_default_font_radio, "toggled",
+                    G_CALLBACK (on_main_use_default_font_radio_toggled),
+                    NULL);
+  g_signal_connect ((gpointer) main_font_selector_button, "font_set",
+                    G_CALLBACK (on_main_font_selector_button_font_set),
+                    NULL);
+  g_signal_connect ((gpointer) main_showpreviewtoggle, "toggled",
+                    G_CALLBACK (on_main_showpreviewtoggle_toggled),
+                    NULL);
+  g_signal_connect ((gpointer) main_ok_button, "clicked",
+                    G_CALLBACK (on_main_ok_button_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) main_cancel_button, "clicked",
+                    G_CALLBACK (on_main_cancel_button_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) main_reset_button, "clicked",
+                    G_CALLBACK (on_main_reset_button_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) new2, "activate",
+                    G_CALLBACK (on_new2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) open2, "activate",
+                    G_CALLBACK (on_open2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) save2, "activate",
+                    G_CALLBACK (on_save2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) save_as2, "activate",
+                    G_CALLBACK (on_save_as2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) quit2, "activate",
+                    G_CALLBACK (on_quit2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) cut2, "activate",
+                    G_CALLBACK (on_cut2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) copy2, "activate",
+                    G_CALLBACK (on_copy2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) paste2, "activate",
+                    G_CALLBACK (on_paste2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) delete2, "activate",
+                    G_CALLBACK (on_delete2_activate),
+                    NULL);
+  g_signal_connect ((gpointer) about2, "activate",
+                    G_CALLBACK (on_about2_activate),
+                    NULL);
+
+  /* Store pointers to all widgets, for use by lookup_widget(). */
+  GLADE_HOOKUP_OBJECT_NO_REF (main_window, main_window, "main_window");
+  GLADE_HOOKUP_OBJECT (main_window, main_hbox, "main_hbox");
+  GLADE_HOOKUP_OBJECT (main_window, vbox1, "vbox1");
+  GLADE_HOOKUP_OBJECT (main_window, hbox1, "hbox1");
+  GLADE_HOOKUP_OBJECT (main_window, frame2, "frame2");
+  GLADE_HOOKUP_OBJECT (main_window, alignment3, "alignment3");
+  GLADE_HOOKUP_OBJECT (main_window, scrolledwindow3, "scrolledwindow3");
+  GLADE_HOOKUP_OBJECT (main_window, main_themelist, "main_themelist");
+  GLADE_HOOKUP_OBJECT (main_window, label1234, "label1234");
+  GLADE_HOOKUP_OBJECT (main_window, frame3, "frame3");
+  GLADE_HOOKUP_OBJECT (main_window, alignment4, "alignment4");
+  GLADE_HOOKUP_OBJECT (main_window, vbox7, "vbox7");
+  GLADE_HOOKUP_OBJECT (main_window, hbox8, "hbox8");
+  GLADE_HOOKUP_OBJECT (main_window, vbox9, "vbox9");
+  GLADE_HOOKUP_OBJECT (main_window, main_use_default_font_radio, "main_use_default_font_radio");
+  GLADE_HOOKUP_OBJECT (main_window, main_use_custom_font_radio, "main_use_custom_font_radio");
+  GLADE_HOOKUP_OBJECT (main_window, alignment5, "alignment5");
+  GLADE_HOOKUP_OBJECT (main_window, vbox10, "vbox10");
+  GLADE_HOOKUP_OBJECT (main_window, hbox9, "hbox9");
+  GLADE_HOOKUP_OBJECT (main_window, vbox11, "vbox11");
+  GLADE_HOOKUP_OBJECT (main_window, main_font_selector_button, "main_font_selector_button");
+  GLADE_HOOKUP_OBJECT (main_window, label669, "label669");
+  GLADE_HOOKUP_OBJECT (main_window, vbox13, "vbox13");
+  GLADE_HOOKUP_OBJECT (main_window, hbox6666, "hbox6666");
+  /* GLADE_HOOKUP_OBJECT (main_window, main_use_system_config_checkbutton, "main_use_system_config_checkbutton"); */
+  GLADE_HOOKUP_OBJECT (main_window, main_showpreviewtoggle, "main_showpreviewtoggle");
+  GLADE_HOOKUP_OBJECT (main_window, hbuttonbox1, "hbuttonbox1");
+  GLADE_HOOKUP_OBJECT (main_window, hbox7, "hbox7");
+  GLADE_HOOKUP_OBJECT (main_window, hbox6665, "hbox6665");
+  GLADE_HOOKUP_OBJECT (main_window, image2, "image2");
+  GLADE_HOOKUP_OBJECT (main_window, label2, "label2");
+  GLADE_HOOKUP_OBJECT (main_window, vbox6, "vbox6");
+  GLADE_HOOKUP_OBJECT (main_window, hbox5, "hbox5");
+  GLADE_HOOKUP_OBJECT (main_window, main_ok_button, "main_ok_button");
+  GLADE_HOOKUP_OBJECT (main_window, main_cancel_button, "main_cancel_button");
+  GLADE_HOOKUP_OBJECT (main_window, main_reset_button, "main_reset_button");
+  GLADE_HOOKUP_OBJECT (main_window, alignment2, "alignment2");
+  GLADE_HOOKUP_OBJECT (main_window, hbox6, "hbox6");
+  GLADE_HOOKUP_OBJECT (main_window, image1, "image1");
+  GLADE_HOOKUP_OBJECT (main_window, label667, "label667");
+  GLADE_HOOKUP_OBJECT (main_window, main_previewhbox, "main_previewhbox");
+  GLADE_HOOKUP_OBJECT (main_window, vseparator2, "vseparator2");
+  GLADE_HOOKUP_OBJECT (main_window, frame4, "frame4");
+  GLADE_HOOKUP_OBJECT (main_window, alignment6, "alignment6");
+  GLADE_HOOKUP_OBJECT (main_window, vbox12, "vbox12");
+  GLADE_HOOKUP_OBJECT (main_window, main_previewbook, "main_previewbook");
+  GLADE_HOOKUP_OBJECT (main_window, table1, "table1");
+  GLADE_HOOKUP_OBJECT (main_window, vbox2, "vbox2");
+  GLADE_HOOKUP_OBJECT (main_window, checkbutton1, "checkbutton1");
+  GLADE_HOOKUP_OBJECT (main_window, checkbutton2, "checkbutton2");
+  GLADE_HOOKUP_OBJECT (main_window, button4, "button4");
+  GLADE_HOOKUP_OBJECT (main_window, togglebutton1, "togglebutton1");
+  GLADE_HOOKUP_OBJECT (main_window, spinbutton1, "spinbutton1");
+  GLADE_HOOKUP_OBJECT (main_window, vbox4, "vbox4");
+  GLADE_HOOKUP_OBJECT (main_window, menubar2, "menubar2");
+  GLADE_HOOKUP_OBJECT (main_window, menuitem5, "menuitem5");
+  GLADE_HOOKUP_OBJECT (main_window, menuitem5_menu, "menuitem5_menu");
+  GLADE_HOOKUP_OBJECT (main_window, new2, "new2");
+  GLADE_HOOKUP_OBJECT (main_window, open2, "open2");
+  GLADE_HOOKUP_OBJECT (main_window, save2, "save2");
+  GLADE_HOOKUP_OBJECT (main_window, save_as2, "save_as2");
+  GLADE_HOOKUP_OBJECT (main_window, separatormenuitem2, "separatormenuitem2");
+  GLADE_HOOKUP_OBJECT (main_window, quit2, "quit2");
+  GLADE_HOOKUP_OBJECT (main_window, menuitem6, "menuitem6");
+  GLADE_HOOKUP_OBJECT (main_window, menuitem6_menu, "menuitem6_menu");
+  GLADE_HOOKUP_OBJECT (main_window, cut2, "cut2");
+  GLADE_HOOKUP_OBJECT (main_window, copy2, "copy2");
+  GLADE_HOOKUP_OBJECT (main_window, paste2, "paste2");
+  GLADE_HOOKUP_OBJECT (main_window, delete2, "delete2");
+  GLADE_HOOKUP_OBJECT (main_window, menuitem8, "menuitem8");
+  GLADE_HOOKUP_OBJECT (main_window, menuitem8_menu, "menuitem8_menu");
+  GLADE_HOOKUP_OBJECT (main_window, about2, "about2");
+  GLADE_HOOKUP_OBJECT (main_window, combobox1, "combobox1");
+  GLADE_HOOKUP_OBJECT (main_window, comboboxentry1, "comboboxentry1");
+  GLADE_HOOKUP_OBJECT (main_window, hscale1, "hscale1");
+  GLADE_HOOKUP_OBJECT (main_window, scrolledwindow1, "scrolledwindow1");
+  GLADE_HOOKUP_OBJECT (main_window, preview_treeview, "preview_treeview");
+  GLADE_HOOKUP_OBJECT (main_window, statusbar1, "statusbar1");
+  GLADE_HOOKUP_OBJECT (main_window, progressbar1, "progressbar1");
+  GLADE_HOOKUP_OBJECT (main_window, vseparator1, "vseparator1");
+  GLADE_HOOKUP_OBJECT (main_window, frame1, "frame1");
+  GLADE_HOOKUP_OBJECT (main_window, vbox3, "vbox3");
+  GLADE_HOOKUP_OBJECT (main_window, radiobutton1, "radiobutton1");
+  GLADE_HOOKUP_OBJECT (main_window, radiobutton2, "radiobutton2");
+  GLADE_HOOKUP_OBJECT (main_window, radiobutton3, "radiobutton3");
+  GLADE_HOOKUP_OBJECT (main_window, label6, "label6");
+  GLADE_HOOKUP_OBJECT (main_window, label4, "label4");
+  GLADE_HOOKUP_OBJECT (main_window, scrolledwindow2, "scrolledwindow2");
+  GLADE_HOOKUP_OBJECT (main_window, textview1, "textview1");
+  GLADE_HOOKUP_OBJECT (main_window, label5, "label5");
+  GLADE_HOOKUP_OBJECT (main_window, vbox5, "vbox5");
+  GLADE_HOOKUP_OBJECT (main_window, hbox4, "hbox4");
+  GLADE_HOOKUP_OBJECT (main_window, about_label, "about_label");
+  GLADE_HOOKUP_OBJECT (main_window, label666, "label666");
+  GLADE_HOOKUP_OBJECT (main_window, label670, "label670");
+  GLADE_HOOKUP_OBJECT_NO_REF (main_window, tooltips, "tooltips");
+
+  gtk_widget_grab_default (main_themelist);
+  gtk_window_add_accel_group (GTK_WINDOW (main_window), accel_group);
+
+  return main_window;
+}
+
diff --git a/src/gtk2-prefs/interface.h b/src/gtk2-prefs/interface.h
new file mode 100644
index 00000000..11c79152
--- /dev/null
+++ b/src/gtk2-prefs/interface.h
@@ -0,0 +1,5 @@
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+GtkWidget* create_main_window (void);
diff --git a/src/gtk2-prefs/main.cpp b/src/gtk2-prefs/main.cpp
new file mode 100644
index 00000000..42e425c2
--- /dev/null
+++ b/src/gtk2-prefs/main.cpp
@@ -0,0 +1,616 @@
+/***************************************************************************
+                          main.cpp  -  description
+                             -------------------
+    begin                : Wed Jan  1 19:06:46 GMT+4 2003
+    copyright            : (C) 2003 - 2005 by Alex Shaduri
+    email                : ashaduri '@' gmail.com
+ ***************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+#include <sstream>
+#include <gtk/gtk.h>
+
+#ifdef _WIN32
+#include "win32util.h"
+#include <io.h>
+#else
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "interface.h"
+#include "callbacks.h"
+#include "support.h"
+
+#include "main.h"
+
+
+// ------------------------------------------------------
+
+
+
+GtkWidget* g_main_window = 0;
+// GtkWidget* g_fontsel_dialog = 0;
+
+
+static std::string s_tmp_file;
+
+
+
+// ------------------------------------------------------
+
+
+
+static std::string gchar_to_string(gchar* gstr)
+{
+	std::string str = (gstr ? gstr : "");
+	g_free(gstr);
+	return str;
+}
+
+
+
+std::string get_home_dir()
+{
+	std::string dir;
+
+	if (g_get_home_dir())
+		dir = g_get_home_dir();
+
+#ifdef _WIN32
+	if (dir == "") {
+		dir = win32_get_registry_value_string(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal");
+	}
+	if (dir == "") {
+		dir = win32_get_registry_value_string(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "User");
+	}
+#endif
+
+	return dir;
+
+}
+
+
+
+
+// ------------------------------------------------------
+
+
+static std::string s_orig_theme;
+static std::string s_orig_font;
+
+std::string& get_orig_theme()
+{
+	return s_orig_theme;
+}
+
+
+std::string& get_orig_font()
+{
+	return s_orig_font;
+}
+
+
+// ------------------------------------------------------
+
+
+std::string get_current_theme()
+{
+
+	GtkSettings* settings = gtk_settings_get_default();
+	gchar* theme;
+	g_object_get(settings, "gtk-theme-name", &theme, NULL);
+
+	return gchar_to_string(theme);
+}
+
+
+
+
+std::string get_current_font()
+{
+	return gchar_to_string(pango_font_description_to_string(gtk_rc_get_style(g_main_window)->font_desc));
+}
+
+
+
+// ------------------------------------------------------
+
+
+
+std::string get_selected_theme()
+{
+	GtkTreeView* treeview = GTK_TREE_VIEW(lookup_widget(g_main_window, "main_themelist"));
+	GtkTreeModel* model = gtk_tree_view_get_model(treeview);
+	GtkTreeSelection* selection = gtk_tree_view_get_selection(treeview);
+
+	GtkTreeIter iter;
+	gtk_tree_selection_get_selected(selection, 0, &iter);
+
+	gchar* theme_name;
+	gtk_tree_model_get(model, &iter, 0, &theme_name, -1);
+// 	std::cout << theme_name << "\n";
+	return gchar_to_string(theme_name);
+}
+
+
+
+std::string get_selected_font()
+{
+// 	GtkWidget* fontentry = lookup_widget(g_main_window, "main_fontentry");
+// 	return gtk_entry_get_text(GTK_ENTRY(fontentry));
+
+	bool default_font = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(g_main_window, "main_use_default_font_radio")));
+
+	if (default_font)
+		return "";
+
+	GtkWidget* fontbutton = lookup_widget(g_main_window, "main_font_selector_button");
+	return gtk_font_button_get_font_name(GTK_FONT_BUTTON(fontbutton));
+}
+
+
+// ------------------------------------------------------
+
+
+
+static void themelist_selection_changed_cb(GtkTreeSelection* selection, gpointer data)
+{
+	if (gtk_tree_selection_get_selected (selection, 0, 0))
+		apply_theme(get_selected_theme(), get_current_font());
+}
+
+
+
+// ------------------------------------------------------
+
+
+
+static void populate_with_themes(GtkWidget* w)
+{
+
+	std::string search_path = gchar_to_string(gtk_rc_get_theme_dir());
+	//std::string search_path = gchar_to_string(g_build_filename("lib", "gtk-2.0", "2.10.0", "engines", NULL));
+
+	if (search_path.size() && search_path[search_path.size() -1] != G_DIR_SEPARATOR)
+		search_path += G_DIR_SEPARATOR_S;
+
+	GDir* gdir = g_dir_open(search_path.c_str(), 0, NULL);
+	if (gdir == NULL)
+		return;
+
+
+	char* name;
+	GList* glist = 0;
+
+	while ( (name = const_cast<char*>(g_dir_read_name(gdir))) != NULL ) {
+		std::string filename = name;
+
+//		if (g_ascii_strup(fname.c_str(), -1) == "Default")
+//			continue;
+
+		std::string fullname = search_path + filename;
+		std::string rc = fullname; rc += G_DIR_SEPARATOR_S; rc += "gtk-2.0"; rc += G_DIR_SEPARATOR_S; rc += "gtkrc";
+
+		bool is_dir = 0;
+		if (g_file_test(fullname.c_str(), G_FILE_TEST_IS_DIR))
+			is_dir = 1;
+
+		if (is_dir && g_file_test(rc.c_str(), G_FILE_TEST_IS_REGULAR)) {
+			glist = g_list_insert_sorted(glist, g_strdup(filename.c_str()), (GCompareFunc)strcmp);
+		}
+	}
+
+	g_dir_close(gdir);
+
+
+
+
+	// ---------------- tree
+
+
+	GtkTreeView* treeview = GTK_TREE_VIEW(w);
+	GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
+	gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(store));
+
+	GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes (
+												"Theme", gtk_cell_renderer_text_new(),
+												"text", 0,
+												NULL);
+	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+
+	GtkTreeIter   iter;
+
+	int i =0, curr=0;
+	while (char* theme = (char*)g_list_nth_data(glist, i)) {
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter, 0, theme, -1);
+
+		if (strcmp(theme, get_current_theme().c_str()) == 0) {
+			curr = i;
+		}
+
+		++i;
+	}
+
+
+	GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+
+	// set the default theme
+
+	// THIS IS IMPORTANT!!!
+	gtk_widget_grab_focus(w);
+
+	std::stringstream str;
+	str << curr;
+	GtkTreePath* selpath = gtk_tree_path_new_from_string (str.str().c_str());
+	if (selpath) {
+		gtk_tree_selection_select_path(selection, selpath);
+		gtk_tree_view_scroll_to_cell(treeview, selpath, NULL, true, 0.5, 0.0);
+		gtk_tree_path_free(selpath);
+	}
+
+	g_signal_connect (G_OBJECT (selection), "changed",
+                  G_CALLBACK (themelist_selection_changed_cb), NULL);
+
+	g_object_unref (G_OBJECT (store));
+
+
+	// ---------------- font
+
+// 	GtkWidget* fontentry = lookup_widget(g_main_window, "main_fontentry");
+// 	gtk_entry_set_text(GTK_ENTRY(fontentry), get_current_font().c_str());
+
+	GtkWidget* fontbutton = lookup_widget(g_main_window, "main_font_selector_button");
+	gtk_font_button_set_font_name(GTK_FONT_BUTTON(fontbutton), get_current_font().c_str());
+
+
+}
+
+
+
+
+// ------------------------------------------------------
+
+#ifdef _WIN32
+static void redirect_to_file (const gchar* log_domain, GLogLevelFlags log_level,
+									const gchar* message, gpointer user_data)
+{
+	/* only write logs if running in portable mode, otherwise
+	   we would get a permission error in program files */
+	if ((_access( "portable-mode", 0 )) != -1)
+	{
+		std::fstream f;
+		f.open("gtk2-prefs.log", std::ios::app);
+		f << message << "\n";
+		f.close();
+	}
+}
+#endif
+
+// ------------------------------------------------------
+
+
+
+
+int main(int argc, char *argv[])
+{
+
+	// work around pango weirdness
+#ifdef _WIN32
+	// no longer needed as of pango 1.2.5, but won't do any harm
+// 	putenv("PANGO_WIN32_NO_UNISCRIBE=1");
+#endif
+
+
+
+
+	std::string user = g_get_user_name();
+	std::string tmp = g_get_tmp_dir();
+	std::string tmp_file = tmp + G_DIR_SEPARATOR_S + "gtk_prefs_tmprc_" + user;
+	s_tmp_file = tmp_file;
+	gtk_rc_add_default_file(tmp_file.c_str());
+
+
+
+	gtk_init (&argc, &argv);
+
+	// redirect gtk warnings to file when in win32
+#if defined _WIN32 && !defined DEBUG
+	g_log_set_handler ("GLib", GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+                     | G_LOG_FLAG_RECURSION), redirect_to_file, NULL);
+	g_log_set_handler ("GModule", GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+                     | G_LOG_FLAG_RECURSION), redirect_to_file, NULL);
+	g_log_set_handler ("GLib-GObject", GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+                     | G_LOG_FLAG_RECURSION), redirect_to_file, NULL);
+	g_log_set_handler ("GThread", GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+                     | G_LOG_FLAG_RECURSION), redirect_to_file, NULL);
+	g_log_set_handler ("Gtk", GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+                     | G_LOG_FLAG_RECURSION), redirect_to_file, NULL);
+	g_log_set_handler ("Gdk", GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+                     | G_LOG_FLAG_RECURSION), redirect_to_file, NULL);
+	g_log_set_handler ("GdkPixbuf", GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+                     | G_LOG_FLAG_RECURSION), redirect_to_file, NULL);
+#endif
+
+
+	add_pixmap_directory(".");
+
+	g_main_window = create_main_window();
+
+
+	populate_with_themes(lookup_widget(g_main_window, "main_themelist"));
+
+
+	std::string about_text = std::string("GTK+ Preference Tool") + "\n\
+\n\
+by Alex Shaduri <ashaduri@gmail.com>\n\
+\n\
+  The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose.  This software is provided \"AS IS\", and you, its user, assume the entire risk as to its quality and accuracy.\n\
+\n\
+  This is free software, and you are welcome to redistribute it under terms of GNU General Public License v2.";
+
+
+	gtk_label_set_text(GTK_LABEL(lookup_widget(g_main_window, "about_label")), about_text.c_str());
+
+
+	GtkTreeView* treeview = GTK_TREE_VIEW(lookup_widget(g_main_window, "preview_treeview"));
+	GtkTreeStore *store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_INT);
+	gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(store));
+
+
+	GtkTreeViewColumn* column1 = gtk_tree_view_column_new_with_attributes ("Text", gtk_cell_renderer_text_new(), "text", 0, NULL);
+	gtk_tree_view_column_set_sizing(column1, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+	gtk_tree_view_column_set_resizable(column1, true);
+	gtk_tree_view_column_set_reorderable (column1, true);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column1);
+
+	GtkTreeViewColumn* column2 = gtk_tree_view_column_new_with_attributes ("Number", gtk_cell_renderer_text_new(), "text", 1, NULL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column2);
+
+
+	GtkTreeIter   iter1, iter2;
+
+	gtk_tree_store_append (store, &iter1, NULL);
+	gtk_tree_store_set (store, &iter1, 0, "Parent 2", 1, 66, -1);
+
+	gtk_tree_store_append (store, &iter1, NULL);
+	gtk_tree_store_set (store, &iter1, 0, "Parent 1", 1, 65, -1);
+
+	gtk_tree_store_append (store, &iter2, &iter1);
+	gtk_tree_store_set (store, &iter2, 0, "Child 1", 1, 67, -1);
+
+	gtk_tree_view_column_set_sort_column_id(column1, 0);
+	gtk_tree_view_column_set_sort_order (column1, GTK_SORT_ASCENDING);
+	gtk_tree_view_column_set_sort_indicator(column1, true);
+	gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), 0, GTK_SORT_ASCENDING);
+
+	g_object_unref (G_OBJECT (store));
+
+
+	get_orig_theme() = get_current_theme();
+	get_orig_font() = get_current_font();
+
+
+	gtk_widget_show (g_main_window);
+
+
+	gtk_main();
+
+	return EXIT_SUCCESS;
+
+}
+
+
+
+// -------------------------------
+
+
+
+void set_theme(const std::string& theme_name, const std::string& font)
+{
+	// set widgets accordingly
+
+	// tree
+	GtkTreeView* treeview = GTK_TREE_VIEW(lookup_widget(g_main_window, "main_themelist"));
+	GtkTreeModel* model = gtk_tree_view_get_model(treeview);
+	GtkTreeSelection* selection = gtk_tree_view_get_selection(treeview);
+
+	GtkTreeIter iter;
+	gtk_tree_model_get_iter_first(model, &iter);
+
+	while(gtk_tree_model_iter_next(model, &iter)) {
+
+		gchar* text;
+		gtk_tree_model_get (model, &iter, 0, &text, -1);
+		std::string theme = gchar_to_string(text);
+
+		if (theme_name == theme) {
+			gtk_tree_selection_select_iter(selection, &iter);
+			break;
+		}
+
+	}
+
+
+	// font
+// 	GtkWidget* fontentry = lookup_widget(g_main_window, "main_fontentry");
+// 	gtk_entry_set_text(GTK_ENTRY(fontentry), font.c_str());
+
+	if (font != "") {
+		GtkWidget* fontbutton = lookup_widget(g_main_window, "main_font_selector_button");
+		gtk_font_button_set_font_name(GTK_FONT_BUTTON(fontbutton), get_current_font().c_str());
+	}
+
+
+	apply_theme(get_selected_theme(), get_selected_font());
+
+}
+
+
+
+
+void apply_theme(const std::string& theme_name, const std::string& font)
+{
+
+	std::stringstream strstr;
+	strstr << "gtk-theme-name = \"" << theme_name << "\"\n";
+
+	if (font != "")
+		strstr << "style \"user-font\"\n{\nfont_name=\"" << font << "\"\n}\nwidget_class \"*\" style \"user-font\"";
+
+// 	std::cout << strstr.str() << "\n\n\n";
+	std::fstream f;
+	f.open(s_tmp_file.c_str(), std::ios::out);
+		f << strstr.str();
+	f.close();
+
+
+	GtkSettings* settings = gtk_settings_get_default();
+
+  	gtk_rc_reparse_all_for_settings (settings, true);
+// 	gtk_rc_parse_string(strstr.str().c_str());
+//  	gtk_rc_parse("/root/.gtk-tmp");
+//  	gtk_rc_reset_styles(settings);
+
+	unlink(s_tmp_file.c_str());
+
+	while (gtk_events_pending())
+		gtk_main_iteration();
+
+
+}
+
+
+
+
+#ifdef _WIN32
+#ifdef HAVE_DIRECT_H
+#include <direct.h>
+#define mkdir(a) _mkdir(a)
+#else
+#define mkdir(a, b) mkdir(a)
+#endif
+#endif
+
+
+bool save_current_theme()
+{
+
+	std::string conf_file = "";
+
+	if ((_access( "portable-mode", 0 )) != -1) {
+
+		char* themes_dir_c = gtk_rc_get_theme_dir();
+		char* conf_file_c = g_build_filename("etc", "gtk-2.0", "gtkrc", NULL);
+
+		conf_file = (conf_file_c ? conf_file_c : "");
+
+		// file doesn't exist, try to get it from gtk.
+		if (!g_file_test(conf_file.c_str(), G_FILE_TEST_EXISTS)) {
+
+			gchar** rc_files = gtk_rc_get_default_files();
+			if (rc_files[0] != 0) {
+				conf_file = rc_files[0];
+			}
+
+		}
+
+
+		g_free(themes_dir_c);
+		g_free(conf_file_c);
+
+
+		// mkdir a directory, only one level deep
+		char* etc = g_path_get_dirname(conf_file.c_str());
+		if (!g_file_test(etc, G_FILE_TEST_IS_DIR)) {
+			mkdir(etc, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+		}
+		g_free(etc);
+
+
+	} else {
+
+		conf_file = get_home_dir();
+
+		if (conf_file[conf_file.length()-1] != G_DIR_SEPARATOR)
+			conf_file += G_DIR_SEPARATOR_S;
+
+		conf_file += ".gtkrc-2.0";
+
+	}
+
+
+
+	// ask
+
+	GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	GtkWidget* dialog = gtk_dialog_new_with_buttons ("Query", GTK_WINDOW(window),
+											GtkDialogFlags(GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL),
+											GTK_STOCK_NO, GTK_RESPONSE_REJECT,
+											GTK_STOCK_YES, GTK_RESPONSE_ACCEPT,
+											NULL);
+	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
+	GtkWidget* hbox = gtk_hbox_new(1, 1);
+	gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
+
+	gtk_container_add (GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
+	gtk_container_add (GTK_CONTAINER(hbox),
+			gtk_label_new((std::string("\n\nThe file \"") + conf_file +  "\" will be overwritten.\nAre you sure?\n\n").c_str()));
+
+	gtk_widget_show_all (dialog);
+
+	bool ret = 0;
+	gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+	switch (result) {
+		case GTK_RESPONSE_ACCEPT:
+			ret = 1;
+			break;
+	}
+	gtk_widget_destroy(dialog);
+	gtk_widget_destroy(window);
+
+	if (!ret)  // the user pressed "No".
+		return false;
+
+
+	std::string font = get_selected_font();
+
+	std::fstream f;
+	f.open(conf_file.c_str(), std::ios::out);
+		f << "# Auto-written by gtk2_prefs. Do not edit.\n\n";
+		f << "gtk-theme-name = \"" << get_selected_theme() << "\"\n";
+
+		if (font != "")
+			f << "style \"user-font\"\n{\n\tfont_name=\"" << font << "\"\n}\nwidget_class \"*\" style \"user-font\"";
+	f.close();
+
+
+	return true;
+
+}
+
+
+
+
+void program_shutdown()
+{
+	gtk_main_quit();
+}
+
+
+
+
+
diff --git a/src/gtk2-prefs/main.h b/src/gtk2-prefs/main.h
new file mode 100644
index 00000000..ab4e5cbd
--- /dev/null
+++ b/src/gtk2-prefs/main.h
@@ -0,0 +1,32 @@
+/***************************************************************************
+                          main.cpp  -  description
+                             -------------------
+    begin                : Wed Jan  1 2003
+    copyright            : (C) 2003 - 2005 by Alex Shaduri
+    email                : ashaduri '@' gmail.com
+ ***************************************************************************/
+
+#ifndef _MAIN_H_
+#define _MAIN_H_
+
+
+#include <string>
+
+
+std::string& get_orig_theme();
+std::string& get_orig_font();
+
+std::string get_current_theme();
+std::string get_current_font();
+
+std::string get_selected_theme();
+std::string get_selected_font();
+
+void set_theme(const std::string& theme_name, const std::string& font);
+void apply_theme(const std::string& theme_name, const std::string& font);
+bool save_current_theme();
+
+void program_shutdown();
+
+
+#endif
diff --git a/src/gtk2-prefs/makefile.mak b/src/gtk2-prefs/makefile.mak
new file mode 100644
index 00000000..1eeeb565
--- /dev/null
+++ b/src/gtk2-prefs/makefile.mak
@@ -0,0 +1,24 @@
+include "..\makeinc.mak"
+
+TARGET = gtk2-prefs.exe
+
+PREF_OBJECTS = \
+callbacks.obj \
+interface.obj \
+support.obj \
+win32util.obj \
+main.obj
+
+CPPFLAGS = $(CPPFLAGS) /D_STL70_ /D_STATIC_CPPLIB /EHsc /DHAVE_CONFIG_H
+
+all: $(PREF_OBJECTS) $(TARGET)
+
+.cpp.obj:
+	$(CC) $(CPPFLAGS) $(GLIB) $(GTK) /I. /c $<
+	
+$(TARGET): $(PREF_OBJECTS)
+	$(LINK) /out:$(TARGET) /entry:mainCRTStartup $(LDFLAGS) $(PREF_OBJECTS) ntstc_msvcrt.lib $(LIBS)
+
+clean:
+	del $(TARGET)
+	del *.obj
diff --git a/src/gtk2-prefs/support.cpp b/src/gtk2-prefs/support.cpp
new file mode 100644
index 00000000..bb19f284
--- /dev/null
+++ b/src/gtk2-prefs/support.cpp
@@ -0,0 +1,146 @@
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <string.h>
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+
+#include "support.h"
+
+GtkWidget*
+lookup_widget                          (GtkWidget       *widget,
+                                        const gchar     *widget_name)
+{
+  GtkWidget *parent, *found_widget;
+
+  for (;;)
+    {
+      if (GTK_IS_MENU (widget))
+        parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
+      else
+        parent = widget->parent;
+      if (!parent)
+        parent = (GtkWidget*)g_object_get_data (G_OBJECT (widget), "GladeParentKey");
+      if (parent == NULL)
+        break;
+      widget = parent;
+    }
+
+  found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
+                                                 widget_name);
+  if (!found_widget)
+    g_warning ("Widget not found: %s", widget_name);
+  return found_widget;
+}
+
+static GList *pixmaps_directories = NULL;
+
+/* Use this function to set the directory containing installed pixmaps. */
+void
+add_pixmap_directory                   (const gchar     *directory)
+{
+  pixmaps_directories = g_list_prepend (pixmaps_directories,
+                                        g_strdup (directory));
+}
+
+/* This is an internally used function to find pixmap files. */
+static gchar*
+find_pixmap_file                       (const gchar     *filename)
+{
+  GList *elem;
+
+  /* We step through each of the pixmaps directory to find it. */
+  elem = pixmaps_directories;
+  while (elem)
+    {
+      gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
+                                         G_DIR_SEPARATOR_S, filename);
+      if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+        return pathname;
+      g_free (pathname);
+      elem = elem->next;
+    }
+  return NULL;
+}
+
+/* This is an internally used function to create pixmaps. */
+GtkWidget*
+create_pixmap                          (GtkWidget       *widget,
+                                        const gchar     *filename)
+{
+  gchar *pathname = NULL;
+  GtkWidget *pixmap;
+
+  if (!filename || !filename[0])
+      return gtk_image_new ();
+
+  pathname = find_pixmap_file (filename);
+
+  if (!pathname)
+    {
+      g_warning ("Couldn't find pixmap file: %s", filename);
+      return gtk_image_new ();
+    }
+
+  pixmap = gtk_image_new_from_file (pathname);
+  g_free (pathname);
+  return pixmap;
+}
+
+/* This is an internally used function to create pixmaps. */
+GdkPixbuf*
+create_pixbuf                          (const gchar     *filename)
+{
+  gchar *pathname = NULL;
+  GdkPixbuf *pixbuf;
+  GError *error = NULL;
+
+  if (!filename || !filename[0])
+      return NULL;
+
+  pathname = find_pixmap_file (filename);
+
+  if (!pathname)
+    {
+      g_warning ("Couldn't find pixmap file: %s", filename);
+      return NULL;
+    }
+
+  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
+  if (!pixbuf)
+    {
+      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
+               pathname, error->message);
+      g_error_free (error);
+    }
+  g_free (pathname);
+  return pixbuf;
+}
+
+/* This is used to set ATK action descriptions. */
+void
+glade_set_atk_action_description       (AtkAction       *action,
+                                        const gchar     *action_name,
+                                        const gchar     *description)
+{
+  gint n_actions, i;
+
+  n_actions = atk_action_get_n_actions (action);
+  for (i = 0; i < n_actions; i++)
+    {
+      if (!strcmp (atk_action_get_name (action, i), action_name))
+        atk_action_set_description (action, i, description);
+    }
+}
+
diff --git a/src/gtk2-prefs/support.h b/src/gtk2-prefs/support.h
new file mode 100644
index 00000000..2dea079c
--- /dev/null
+++ b/src/gtk2-prefs/support.h
@@ -0,0 +1,44 @@
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+/*
+ * Public Functions.
+ */
+
+/*
+ * This function returns a widget in a component created by Glade.
+ * Call it with the toplevel widget in the component (i.e. a window/dialog),
+ * or alternatively any widget in the component, and the name of the widget
+ * you want returned.
+ */
+GtkWidget*  lookup_widget              (GtkWidget       *widget,
+                                        const gchar     *widget_name);
+
+
+/* Use this function to set the directory containing installed pixmaps. */
+void        add_pixmap_directory       (const gchar     *directory);
+
+
+/*
+ * Private Functions.
+ */
+
+/* This is used to create the pixmaps used in the interface. */
+GtkWidget*  create_pixmap              (GtkWidget       *widget,
+                                        const gchar     *filename);
+
+/* This is used to create the pixbufs used in the interface. */
+GdkPixbuf*  create_pixbuf              (const gchar     *filename);
+
+/* This is used to set ATK action descriptions. */
+void        glade_set_atk_action_description (AtkAction       *action,
+                                              const gchar     *action_name,
+                                              const gchar     *description);
+
diff --git a/src/gtk2-prefs/sys_win32.h b/src/gtk2-prefs/sys_win32.h
new file mode 100644
index 00000000..0a106690
--- /dev/null
+++ b/src/gtk2-prefs/sys_win32.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+                          sys_win32.h  -  description
+                             -------------------
+    begin                : Wed Oct 22 2003
+    copyright            : (C) 2003 by Alex Shaduri, Irakli A. Elizbarashvili
+    email                : alex_sh@land.ru
+ ***************************************************************************/
+#ifndef SYS_WIN32_H
+#define SYS_WIN32_H
+
+
+
+
+
+#ifdef _WIN32
+
+#	define WIN32_LEAN_AND_MEAN
+#	include <windows.h>
+
+#endif
+
+
+
+
+
+
+
+#endif
diff --git a/src/gtk2-prefs/win32util.cpp b/src/gtk2-prefs/win32util.cpp
new file mode 100644
index 00000000..79cab17d
--- /dev/null
+++ b/src/gtk2-prefs/win32util.cpp
@@ -0,0 +1,80 @@
+/***************************************************************************
+                          win32util.cpp  -  description
+                             -------------------
+    begin                : Tue Jan 14 2003
+    copyright            : (C) 2003 by Alex Shaduri
+    email                : alex_sh@land.ru
+ ***************************************************************************/
+
+#ifdef _WIN32
+
+#include <string>
+#include "sys_win32.h"
+#include "win32util.h"
+
+
+
+
+
+std::string win32_get_registry_value_string(HKEY base, const std::string& keydir, const std::string& key)
+{
+
+	HKEY reg_key = NULL;
+	DWORD type;
+	DWORD nbytes;
+	char* result = NULL;
+//HKEY_CURRENT_USER
+	nbytes = 0;
+	if ( RegOpenKeyEx ( base, keydir.c_str(), 0, KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS
+			&& RegQueryValueEx (reg_key, key.c_str(), 0, &type, NULL, &nbytes) == ERROR_SUCCESS ) {
+		result = (char*)malloc(nbytes + 1);
+		RegQueryValueEx (reg_key,  key.c_str(), 0, &type, (BYTE*)result, &nbytes);
+		result[nbytes] = '\0';
+	}
+
+	if (reg_key != NULL)
+		RegCloseKey (reg_key);
+
+	std::string ret = "";
+
+	if (result) {
+		ret = result;
+	}
+
+	return ret;
+
+}
+
+
+
+
+void win32_set_registry_value_string(HKEY base, const std::string& keydir, const std::string& key, const std::string& value)
+{
+
+	HKEY reg_key = NULL;
+	DWORD nbytes;
+
+	nbytes = value.length() + 1;
+
+	if ( RegOpenKeyEx ( base, keydir.c_str(), 0, KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS) {
+		RegSetValueEx (reg_key,  key.c_str(), 0, REG_SZ, (const BYTE*)(value.c_str()), nbytes);
+	}
+
+	if (reg_key != NULL)
+		RegCloseKey (reg_key);
+
+}
+
+
+
+
+
+
+
+#endif
+
+
+
+
+
+
diff --git a/src/gtk2-prefs/win32util.h b/src/gtk2-prefs/win32util.h
new file mode 100644
index 00000000..8c194a19
--- /dev/null
+++ b/src/gtk2-prefs/win32util.h
@@ -0,0 +1,26 @@
+/***************************************************************************
+                          win32util.h  -  description
+                             -------------------
+    begin                : Tue Jan 14 2003
+    copyright            : (C) 2003 by Alex Shaduri
+    email                : alex_sh@land.ru
+ ***************************************************************************/
+#ifndef WIN32UTIL_H
+#define WIN32UTIL_H
+
+#ifdef _WIN32
+
+#include <string>
+#include "sys_win32.h"
+
+
+
+std::string win32_get_registry_value_string(HKEY base, const std::string& keydir, const std::string& key);
+void win32_set_registry_value_string(HKEY base, const std::string& keydir, const std::string& key, const std::string& value);
+
+
+
+
+#endif //_WIN32
+
+#endif // WIN32UTIL_H
diff --git a/src/makefile.mak b/src/makefile.mak
new file mode 100644
index 00000000..6e6cf95c
--- /dev/null
+++ b/src/makefile.mak
@@ -0,0 +1,23 @@
+all:
+	@cd pixmaps
+	@-$(MAKE) /nologo /s /f makefile.mak $@
+	@cd ..\common
+	@-$(MAKE) /nologo /s /f makefile.mak $@
+	@cd ..\fe-gtk
+	@-$(MAKE) /nologo /s /f makefile.mak $@
+	@cd ..\fe-text
+	@-$(MAKE) /nologo /s /f makefile.mak $@
+#	@cd ..\gtk2-prefs
+#	@-$(MAKE) /nologo /s /f makefile.mak $@
+
+clean:
+	@cd pixmaps
+	@-$(MAKE) /nologo /s /f makefile.mak clean $@
+	@cd ..\common
+	@-$(MAKE) /nologo /s /f makefile.mak clean $@
+	@cd ..\fe-gtk
+	@-$(MAKE) /nologo /s /f makefile.mak clean $@
+	@cd ..\fe-text
+	@-$(MAKE) /nologo /s /f makefile.mak clean $@
+#	@cd ..\gtk2-prefs
+#	@-$(MAKE) /nologo /s /f makefile.mak clean $@
diff --git a/src/makeinc.skel.mak b/src/makeinc.skel.mak
new file mode 100644
index 00000000..1ccb0d32
--- /dev/null
+++ b/src/makeinc.skel.mak
@@ -0,0 +1,44 @@
+CC = cl
+LINK = link
+CFLAGS = $(CFLAGS) /Ox /c /MD /MP /W0 /nologo
+CFLAGS = $(CFLAGS) /DWIN32 /DG_DISABLE_CAST_CHECKS /DG_DISABLE_DEPRECATED /DGDK_PIXBUF_DISABLE_DEPRECATED /DGDK_DISABLE_DEPRECATED /DHAVE_STRTOULL /Dstrtoull=_strtoui64 /Dstrcasecmp=stricmp /Dstrncasecmp=strnicmp
+CFLAGS = $(CFLAGS) /I$(DEV)\include
+CPPFLAGS = /c /MD /W0 /nologo /DWIN32
+LDFLAGS = /subsystem:windows /nologo
+LIBS = $(LIBS) gdi32.lib shell32.lib user32.lib advapi32.lib imm32.lib ole32.lib winmm.lib ws2_32.lib wininet.lib comdlg32.lib libeay32.lib ssleay32.lib
+
+GLIB = /I$(DEV)\include\glib-2.0 /I$(DEV)\lib\glib-2.0\include /I$(DEV)\include\libxml2
+GTK = /I$(DEV)\include\gtk-2.0 /I$(DEV)\lib\gtk-2.0\include /I$(DEV)\include\atk-1.0 /I$(DEV)\include\cairo /I$(DEV)\include\pango-1.0 /I$(DEV)\include\gdk-pixbuf-2.0
+LIBS = $(LIBS) /libpath:$(DEV)\lib gtk-win32-2.0.lib gdk-win32-2.0.lib atk-1.0.lib gio-2.0.lib gdk_pixbuf-2.0.lib pangowin32-1.0.lib pangocairo-1.0.lib pango-1.0.lib cairo.lib gobject-2.0.lib gmodule-2.0.lib glib-2.0.lib intl.lib libxml2.lib
+
+LUALIB = lua51
+LUAOUTPUT = xclua.dll
+
+PERL512LIB = perl512
+PERL512OUTPUT = xcperl-512.dll
+PERL514LIB = perl514
+PERL514OUTPUT = xcperl-514.dll
+
+PYTHONLIB = python27
+PYTHONOUTPUT = xcpython.dll
+
+TCLLIB = tcl85
+TCLOUTPUT = xctcl.dll
+
+!ifdef X64
+CFLAGS = $(CFLAGS) /favor:AMD64 /D_WIN64
+CPPFLAGS = $(CPPFLAGS) /favor:AMD64 /D_WIN64
+LDFLAGS = $(LDFLAGS) msvcrt_win2003.obj
+
+PERL512PATH = c:\mozilla-build\perl-5.12-x64
+PERL514PATH = c:\mozilla-build\perl-5.14-x64
+PYTHONPATH = c:\mozilla-build\python-2.7-x64
+TCLPATH = c:\mozilla-build\tcl-8.5-x64
+!else
+LDFLAGS = $(LDFLAGS) msvcrt_winxp.obj
+
+PERL512PATH = c:\mozilla-build\perl-5.12-x86
+PERL514PATH = c:\mozilla-build\perl-5.14-x86
+PYTHONPATH = c:\mozilla-build\python-2.7-x86
+TCLPATH = c:\mozilla-build\tcl-8.5-x86
+!endif
diff --git a/src/pixmaps/makefile.mak b/src/pixmaps/makefile.mak
new file mode 100644
index 00000000..f9535dbe
--- /dev/null
+++ b/src/pixmaps/makefile.mak
@@ -0,0 +1,18 @@
+CONV = gdk-pixbuf-csource
+
+LIST =	bookpng book.png \
+			hoppng hop.png \
+			oppng op.png \
+			purplepng purple.png \
+			redpng red.png \
+			trayfilepng fileoffer.png \
+			trayhilightpng highlight.png \
+			traymsgpng message.png \
+			voicepng voice.png \
+			xchatpng ..\..\xchat.png
+
+all: 
+	@$(CONV) --build-list $(LIST) > inline_pngs.h
+
+clean:
+	@del *.h