[xchat-gnome] Bug 677043 - [PATCH][GTK3] Ongoing migration to gtk3



commit 3a22cb15c7259605e716ddae3152d96d231e96ad
Author: Giuseppe Musacchio <thatlemon gmail com>
Date:   Mon Jun 4 15:48:10 2012 +0530

    Bug 677043 - [PATCH][GTK3] Ongoing migration to gtk3
    
    Heading slowly towards gnome3 based release.

 configure.ac                               |   18 +-
 data/xchat-gnome.glade                     |    5 -
 src/common/inbound.c                       |    6 +-
 src/common/userlist.c                      |   17 +
 src/common/xchat.c                         |    2 +
 src/common/xchat.h                         |    5 +
 src/fe-gnome/Makefile.am                   |    9 -
 src/fe-gnome/channel-list-window.c         |    2 +-
 src/fe-gnome/conversation-panel.c          |  125 +--
 src/fe-gnome/conversation-panel.h          |    1 -
 src/fe-gnome/dcc-window.c                  |   12 +-
 src/fe-gnome/fe-gnome.c                    |   24 +-
 src/fe-gnome/find-bar.c                    |    2 +-
 src/fe-gnome/image-utils.c                 |  188 ---
 src/fe-gnome/image-utils.h                 |   43 -
 src/fe-gnome/irc-network-editor.c          |    4 +-
 src/fe-gnome/main-window.c                 |   31 +-
 src/fe-gnome/navigation-tree.c             |    6 +-
 src/fe-gnome/palette.c                     |   34 +-
 src/fe-gnome/palette.h                     |    1 -
 src/fe-gnome/preferences-page-colors.c     |    1 -
 src/fe-gnome/preferences-page-spellcheck.c |   18 +-
 src/fe-gnome/text-entry.c                  |  512 +-------
 src/fe-gnome/text-entry.h                  |    9 +-
 src/fe-gnome/userlist-gui.c                |   34 +-
 src/fe-gnome/userlist.c                    |   13 +-
 src/fe-gnome/userlist.h                    |    2 +-
 src/fe-gnome/util.c                        |   16 +-
 src/fe-gnome/xtext.c                       | 1923 ++++------------------------
 src/fe-gnome/xtext.h                       |   56 +-
 src/libeggsmclient/eggsmclient-private.h   |    2 +-
 src/libeggsmclient/eggsmclient-xsmp.c      |    2 +-
 32 files changed, 496 insertions(+), 2627 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d8af13b..a129491 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,14 +19,13 @@ if test -z "$enable_maintainer_mode"; then
 fi
 AM_MAINTAINER_MODE([enable])
 
-GLIB_REQUIRED=2.18.0
-GTK_REQUIRED=2.24.0
+GLIB_REQUIRED=2.32.0
+GTK_REQUIRED=3.4.2
 GCONF_REQUIRED=2.8.0
-DBUS_REQUIRED=0.60
-DBUS_GLIB_REQUIRED=0.60
-LIBSEXY_REQUIRED=0.1.11
+DBUS_REQUIRED=1.4
+DBUS_GLIB_REQUIRED=0.98
 LIBNOTIFY_REQUIRED=0.7
-LIBCANBERRAGTK_REQUIRED=0.3
+LIBCANBERRAGTK_REQUIRED=0.29
 SM_REQUIRED=1.0.0
 
 # Check for programs
@@ -64,14 +63,13 @@ PKG_CHECK_MODULES([DEPENDENCIES], [\
                   glib-2.0 >= $GLIB_REQUIRED \
                   gio-2.0 >= $GLIB_REQUIRED \
                   gmodule-2.0  >= $GLIB_REQUIRED \
-                  gtk+-2.0 >= $GTK_REQUIRED \
+                  gtk+-3.0 >= $GTK_REQUIRED \
                   gconf-2.0 >= $GCONF_REQUIRED \
-                  libsexy >= $LIBSEXY_REQUIRED \
                   ])
 
 #EggSMClient replacing GnomeClient in libgnome
 PKG_CHECK_MODULES([EGG_SMCLIENT], [\
-                  gtk+-2.0 >= $GTK_REQUIRED \
+                  gtk+-3.0 >= $GTK_REQUIRED \
                   sm >= $SM_REQUIRED \
                   ice \
                   ])
@@ -138,7 +136,7 @@ AC_ARG_ENABLE([canberra],
 AC_MSG_RESULT([$enable_canberra])
 
 if test "$enable_canberra" = "yes"; then
-  PKG_CHECK_MODULES([LIBCANBERRAGTK],[libcanberra-gtk >= $LIBCANBERRAGTK_REQUIRED])
+  PKG_CHECK_MODULES([LIBCANBERRAGTK],[libcanberra-gtk3 >= $LIBCANBERRAGTK_REQUIRED])
 fi
 
 AM_CONDITIONAL([ENABLE_LIBCANBERRA],[test "x$enable_canberra" = "xyes"])
diff --git a/data/xchat-gnome.glade b/data/xchat-gnome.glade
index 5661781..483cff3 100644
--- a/data/xchat-gnome.glade
+++ b/data/xchat-gnome.glade
@@ -260,7 +260,6 @@
                         <child>
                           <object class="TopicLabel" id="topic_label">
                             <property name="visible">True</property>
-                            <property name="creation_function">topic_label_new</property>
                           </object>
                         </child>
                         <child>
@@ -293,7 +292,6 @@
                     <child>
                       <object class="ConversationPanel" id="conversation_panel">
                         <property name="visible">True</property>
-                        <property name="creation_function">conversation_panel_new</property>
                       </object>
                       <packing>
                         <property name="position">1</property>
@@ -319,7 +317,6 @@
                         <child>
                           <object class="TextEntry" id="text_entry">
                             <property name="visible">True</property>
-                            <property name="creation_function">text_entry_new</property>
                           </object>
                           <packing>
                             <property name="position">1</property>
@@ -370,7 +367,6 @@
           <object class="FindBar" id="find_bar">
             <property name="height_request">32</property>
             <property name="visible">True</property>
-            <property name="creation_function">find_bar_new</property>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -381,7 +377,6 @@
           <object class="StatusBar" id="status_bar">
             <property name="height_request">21</property>
             <property name="visible">True</property>
-            <property name="creation_function">status_bar_new</property>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/src/common/inbound.c b/src/common/inbound.c
index f70d7d0..b6008a6 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -703,7 +703,7 @@ inbound_join (server *serv, char *chan, char *user, char *ip)
 	session *sess = find_channel (serv, chan);
 	if (sess)
 	{
-		if (!sess->hide_join_part)
+		if (!sess->hide_join_part && !sess->conference_mode)
 			EMIT_SIGNAL (XP_TE_JOIN, sess, user, chan, ip, NULL, 0);
 		userlist_add (sess, user, ip);
 	}
@@ -726,7 +726,7 @@ inbound_part (server *serv, char *chan, char *user, char *ip, char *reason)
 	session *sess = find_channel (serv, chan);
 	if (sess)
 	{
-		if (!sess->hide_join_part)
+		if (!sess->hide_join_part && !sess->conference_mode)
 		{
 			if (*reason)
 				EMIT_SIGNAL (XP_TE_PARTREASON, sess, user, ip, chan, reason, 0);
@@ -766,7 +766,7 @@ inbound_quit (server *serv, char *nick, char *ip, char *reason)
  				was_on_front_session = TRUE;
 			if (userlist_remove (sess, nick))
 			{
-				if (!sess->hide_join_part)
+				if (!sess->hide_join_part && !sess->conference_mode)
 					EMIT_SIGNAL (XP_TE_QUIT, sess, nick, reason, ip, NULL, 0);
 			} else if (sess->type == SESS_DIALOG && !serv->p_cmp (sess->channel, nick))
 			{
diff --git a/src/common/userlist.c b/src/common/userlist.c
index 1362298..c875857 100644
--- a/src/common/userlist.c
+++ b/src/common/userlist.c
@@ -167,6 +167,8 @@ userlist_free (session *sess)
 	sess->hops = 0;
 	sess->voices = 0;
 	sess->total = 0;
+
+	sess->conference_mode = FALSE;
 }
 
 void
@@ -331,6 +333,14 @@ userlist_remove (struct session *sess, char *name)
 	if (user->hop)
 		sess->hops--;
 	sess->total--;
+
+	/* Conference mode is enabled */
+	if (sess->conference_treshold > 0)
+	{
+		if (sess->total < sess->conference_treshold)
+			sess->conference_mode = FALSE;
+	}
+
 	fe_userlist_numbers (sess);
 	fe_userlist_remove (sess, user);
 
@@ -384,6 +394,13 @@ userlist_add (struct session *sess, char *name, char *hostname)
 
 	sess->total++;
 
+	/* Conference mode is enabled */
+	if (sess->conference_treshold > 0)
+	{
+		if (sess->total >= sess->conference_treshold)
+			sess->conference_mode = TRUE;
+	}
+
 	/* most ircds don't support multiple modechars infront of the nickname
       for /NAMES - though they should. */
 	while (prefix_chars)
diff --git a/src/common/xchat.c b/src/common/xchat.c
index dd4cd90..de1a7ba 100644
--- a/src/common/xchat.c
+++ b/src/common/xchat.c
@@ -337,6 +337,8 @@ session_new (server *serv, char *from, int type, int focus)
 	sess->scrollfd = -1;
 	sess->type = type;
 	sess->hide_join_part = prefs.confmode;
+	sess->conference_treshold = -1; /* -1 means disabled */
+	sess->conference_mode = FALSE;
 
 	if (from != NULL)
 		safe_strcpy (sess->channel, from, CHANLEN);
diff --git a/src/common/xchat.h b/src/common/xchat.h
index 51f8db4..29afd7b 100644
--- a/src/common/xchat.h
+++ b/src/common/xchat.h
@@ -327,6 +327,11 @@ typedef struct session
 	int scrollfd;							/* scrollback filedes */
 	int scrollwritten;					/* number of lines written */
 
+	int conference_treshold;
+	int conference_mode;				/* conference mode, automatically ignores
+										   part/connect msg when the channel has
+										   more than n users */
+
 	char lastnick[NICKLEN];			  /* last nick you /msg'ed */
 
 	struct history history;
diff --git a/src/fe-gnome/Makefile.am b/src/fe-gnome/Makefile.am
index 1288ab9..35cda54 100644
--- a/src/fe-gnome/Makefile.am
+++ b/src/fe-gnome/Makefile.am
@@ -1,8 +1,3 @@
-if USE_MMX
-mmx_cmod_S = mmx_cmod.S
-mmx_cmod_h = mmx_cmod.h
-endif
-
 schemadir	= $(GCONF_SCHEMA_FILE_DIR)
 schema_in_files	= apps_xchat.schemas.in
 schema_DATA	= $(schema_in_files:.schemas.in=.schemas)
@@ -20,8 +15,6 @@ endif
 bin_PROGRAMS = xchat-gnome
 
 xchat_gnome_SOURCES =				\
-	$(mmx_cmod_S)				\
-	$(mmx_cmod_h)				\
 	about.c					\
 	about.h					\
 	channel-list-window.c			\
@@ -37,8 +30,6 @@ xchat_gnome_SOURCES =				\
 	find-bar.h				\
 	gui.c					\
 	gui.h					\
-	image-utils.c				\
-	image-utils.h				\
 	irc-network-editor.c			\
 	irc-network-editor.h			\
 	irc-network.c				\
diff --git a/src/fe-gnome/channel-list-window.c b/src/fe-gnome/channel-list-window.c
index 112311a..a7be33d 100644
--- a/src/fe-gnome/channel-list-window.c
+++ b/src/fe-gnome/channel-list-window.c
@@ -101,7 +101,7 @@ channel_list_window_delete_event (GtkWidget *widget, GdkEvent *event, ChannelLis
 static gboolean
 channel_list_window_key_press (GtkWidget *widget, GdkEventKey *event, ChannelListWindow *win)
 {
-	if (event->keyval == GDK_Escape) {
+	if (event->keyval == GDK_KEY_Escape) {
 		g_signal_stop_emission_by_name (widget, "key-press-event");
 		channel_list_window_delete (win);
 		return TRUE;
diff --git a/src/fe-gnome/conversation-panel.c b/src/fe-gnome/conversation-panel.c
index 2374a2e..1d13596 100644
--- a/src/fe-gnome/conversation-panel.c
+++ b/src/fe-gnome/conversation-panel.c
@@ -132,12 +132,6 @@ static void     on_default_copy_activate              (GtkAction              *a
 static gboolean uri_is_text                           (gchar                  *uri);
 static gboolean check_file_size                       (gchar                  *uri);
 GtkWidget* get_user_vbox_infos                        (struct User            *user);
-static void redraw_transparency                       (ConversationPanel      *panel);
-#ifdef USE_XLIB
-static GdkFilterReturn root_event_cb                  (GdkXEvent              *xev,
-                                                       GdkEventProperty       *event,
-                                                       ConversationPanel      *panel);
-#endif
 
 struct _fe_lastlog_info
 {
@@ -218,7 +212,7 @@ conversation_panel_init (ConversationPanel *panel)
 
 	panel->priv = g_new0 (ConversationPanelPriv, 1);
 	panel->priv->xtext     = gtk_xtext_new (colors, prefs.indent_nicks);
-	panel->priv->scrollbar = gtk_vscrollbar_new (GTK_XTEXT (panel->priv->xtext)->adj);
+	panel->priv->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, GTK_XTEXT (panel->priv->xtext)->adj);
 	frame                  = gtk_frame_new (NULL);
 
 	panel->priv->buffers            = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) gtk_xtext_buffer_free);
@@ -260,11 +254,6 @@ conversation_panel_init (ConversationPanel *panel)
         gtk_drag_dest_add_uri_targets (panel->priv->xtext);
         gtk_drag_dest_add_text_targets (panel->priv->xtext);
 
-#ifdef USE_XLIB
-	gdk_window_set_events (gdk_get_default_root_window (), GDK_PROPERTY_CHANGE_MASK);
-	gdk_window_add_filter (gdk_get_default_root_window (), (GdkFilterFunc)root_event_cb, panel);
-#endif
-
 	conversation_panel_set_show_marker (panel, prefs.show_marker);
 }
 
@@ -297,7 +286,6 @@ conversation_panel_realize (GtkWidget *widget)
 	panel  = CONVERSATION_PANEL (widget);
 	client = gconf_client_get_default ();
 
-	palette_alloc (panel->priv->xtext);
 	gtk_xtext_set_palette(GTK_XTEXT(panel->priv->xtext), colors);
 	gtk_xtext_set_max_lines(GTK_XTEXT(panel->priv->xtext), 3000);
 	gtk_xtext_set_indent(GTK_XTEXT(panel->priv->xtext), prefs.indent_nicks);
@@ -559,64 +547,14 @@ conversation_panel_font_changed (GConfClient *client, guint cnxn_id, GConfEntry
 	conversation_panel_set_font (panel);
 
 	adj = GTK_XTEXT (panel->priv->xtext)->adj;
-	gtk_adjustment_set_value (adj, adj->upper - adj->page_size);
+	gtk_adjustment_set_value (adj, gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj));
 	gtk_xtext_refresh (GTK_XTEXT (panel->priv->xtext), FALSE);
 }
 
 static void
 conversation_panel_set_background (ConversationPanel *panel)
 {
-	GConfClient *client;
-	gint         background_type;
-
-	client = gconf_client_get_default ();
-	background_type = gconf_client_get_int (client, "/apps/xchat/main_window/background_type", NULL);
-	if (background_type == 0) {
-		gtk_xtext_set_tint (GTK_XTEXT (panel->priv->xtext), 0, 0, 0);
-		gtk_xtext_set_background (GTK_XTEXT (panel->priv->xtext), NULL, FALSE);
-		gtk_xtext_set_alpha (GTK_XTEXT (panel->priv->xtext), 1.0);
-	} else if (background_type == 1) {
-		gchar *filename = gconf_client_get_string (client, "/apps/xchat/main_window/background_image", NULL);
-		gtk_xtext_set_tint (GTK_XTEXT (panel->priv->xtext), 0, 0, 0);
-		gtk_xtext_set_background (GTK_XTEXT (panel->priv->xtext), NULL, FALSE);
-		gtk_xtext_set_alpha (GTK_XTEXT (panel->priv->xtext), 1.0);
-		if (filename) {
-			GdkPixbuf *pixbuf;
-			pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
-			if (pixbuf) {
-				gint width, height;
-				cairo_t *context;
-				GdkPixmap *image;
-
-				width  = gdk_pixbuf_get_width  (pixbuf);
-				height = gdk_pixbuf_get_height (pixbuf);
-
-				image = gdk_pixmap_new (GDK_DRAWABLE (panel->priv->xtext->window), width, height, -1);
-				context = gdk_cairo_create (GDK_DRAWABLE (image));
-				gdk_cairo_set_source_pixbuf (context, pixbuf, 0, 0);
-				cairo_paint (context);
-				cairo_destroy (context);
-
-				gtk_xtext_set_background (GTK_XTEXT (panel->priv->xtext), image, FALSE);
-				g_object_unref (pixbuf);
-				g_object_unref (image);
-			}
-			g_free (filename);
-		}
-	} else {
-		float transparency = gconf_client_get_float (client, "/apps/xchat/main_window/background_transparency", NULL);
-		int value = 255 - ((int) (transparency * 255));
-
-		if (gdk_drawable_get_depth (gui.main_window->window) == 32) {
-			gtk_xtext_set_tint (GTK_XTEXT (panel->priv->xtext), 0, 0, 0);
-			gtk_xtext_set_background (GTK_XTEXT (panel->priv->xtext), NULL, FALSE);
-			gtk_xtext_set_alpha (GTK_XTEXT (panel->priv->xtext), transparency);
-		} else {
-			gtk_xtext_set_tint (GTK_XTEXT (panel->priv->xtext), value, value, value);
-			gtk_xtext_set_background (GTK_XTEXT (panel->priv->xtext), NULL, TRUE);
-		}
-	}
-	g_object_unref (client);
+	gtk_xtext_set_alpha (GTK_XTEXT (panel->priv->xtext), 1.0);
 }
 
 static void
@@ -755,7 +693,11 @@ static void
 drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
                     GtkSelectionData *selection_data, guint info, guint time, ConversationPanel *panel)
 {
-        if (gtk_targets_include_uri (&selection_data->target, 1)) {
+	GdkAtom target;
+
+	target = gtk_selection_data_get_target (selection_data);
+
+	if (gtk_targets_include_uri (&target, 1)) {
 		gchar **uris;
 		gint nb_uri;
 
@@ -776,7 +718,7 @@ drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
 		g_free (uris); /* String in uris will be freed in free_dropped_files */
 		panel->priv->dropped_files = g_slist_reverse (panel->priv->dropped_files);
 
-		if (context->action == GDK_ACTION_ASK) {
+		if (gdk_drag_context_get_actions (context) == GDK_ACTION_ASK) {
 			/* Display the context menu */
 			GtkWidget *menu, *entry;
 
@@ -819,7 +761,7 @@ drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
 				}
 			}
 		}
-	} else if (gtk_targets_include_text (&selection_data->target, 1)) {
+	} else if (gtk_targets_include_text (&target, 1)) {
 		char *txt;
 
                 txt = (char *) gtk_selection_data_get_text (selection_data);
@@ -973,7 +915,6 @@ conversation_panel_new (void)
 void
 conversation_panel_update_colors (ConversationPanel *panel)
 {
-	palette_alloc (panel->priv->xtext);
 	gtk_xtext_set_palette (GTK_XTEXT (panel->priv->xtext), colors);
 	gtk_xtext_refresh     (GTK_XTEXT (panel->priv->xtext), FALSE);
 }
@@ -1200,10 +1141,9 @@ conversation_panel_lastlog_foreach (GtkXText *xtext, char *text, fe_lastlog_info
 void
 conversation_panel_lastlog (ConversationPanel *panel, struct session *sess, struct session *lsess, char *sstr)
 {
-	xtext_buffer *buffer, *lbuffer;
+	xtext_buffer *buffer;
 
 	buffer  = g_hash_table_lookup (panel->priv->buffers, sess);
-	lbuffer = g_hash_table_lookup (panel->priv->buffers, lsess);
 
 	if (gtk_xtext_is_empty (buffer)) {
 		conversation_panel_print (panel, lsess, _("Search buffer is empty.\n"), TRUE, time(NULL));
@@ -1237,8 +1177,8 @@ conversation_panel_page_up (ConversationPanel *panel)
 	int end, value;
 
 	adj = GTK_XTEXT(panel->priv->xtext)->adj;
-	end = adj->upper - adj->lower - adj->page_size;
-	value = adj->value - (adj->page_size - 1);
+	end = gtk_adjustment_get_upper (adj) - gtk_adjustment_get_lower (adj) - gtk_adjustment_get_page_size (adj);
+	value = gtk_adjustment_get_value (adj) - (gtk_adjustment_get_page_size (adj) - 1);
 	if (value < 0) {
 		value = 0;
 	}
@@ -1255,8 +1195,8 @@ conversation_panel_page_down (ConversationPanel *panel)
 	int value, end;
 
 	adj = GTK_XTEXT(panel->priv->xtext)->adj;
-	end = adj->upper - adj->lower - adj->page_size;
-	value = adj->value + (adj->page_size - 1);
+	end = gtk_adjustment_get_upper (adj) - gtk_adjustment_get_lower (adj) - gtk_adjustment_get_page_size (adj);
+	value = gtk_adjustment_get_value (adj) + (gtk_adjustment_get_page_size (adj) - 1);
 	if (value < 0) {
 		value = 0;
 	}
@@ -1273,41 +1213,6 @@ conversation_panel_copy_selection (ConversationPanel *panel)
 }
 
 void
-conversation_panel_queue_tdraw (ConversationPanel *panel)
-{
-	if (GTK_XTEXT (panel->priv->xtext)->transparent) {
-		gtk_widget_queue_draw (panel->priv->xtext);
-	}
-}
-
-static void
-redraw_transparency (ConversationPanel *panel)
-{
-	if (GTK_XTEXT (panel->priv->xtext)->transparent) {
-		gtk_xtext_refresh (GTK_XTEXT (panel->priv->xtext), 1);
-	}
-}
-
-#ifdef USE_XLIB
-static GdkFilterReturn
-root_event_cb (GdkXEvent *xev, GdkEventProperty *event, ConversationPanel *panel)
-{
-	static Atom at = None;
-	XEvent *xevent = (XEvent *)xev;
-
-	if (xevent->type == PropertyNotify) {
-		if (at == None) {
-			at = XInternAtom (xevent->xproperty.display, "_XROOTPMAP_ID", True);
-		}
-		if (at == xevent->xproperty.atom) {
-			redraw_transparency (panel);
-		}
-	}
-	return GDK_FILTER_CONTINUE;
-}
-#endif
-
-void
 conversation_panel_check_marker_visibility (ConversationPanel *panel)
 {
 	gtk_xtext_check_marker_visibility (GTK_XTEXT (panel->priv->xtext));
diff --git a/src/fe-gnome/conversation-panel.h b/src/fe-gnome/conversation-panel.h
index eed6c66..3b68fa9 100644
--- a/src/fe-gnome/conversation-panel.h
+++ b/src/fe-gnome/conversation-panel.h
@@ -79,7 +79,6 @@ gpointer   conversation_panel_search                  (ConversationPanel *panel,
 void       conversation_panel_page_up                 (ConversationPanel *panel);
 void       conversation_panel_page_down               (ConversationPanel *panel);
 void	   conversation_panel_copy_selection          (ConversationPanel *panel);
-void       conversation_panel_queue_tdraw             (ConversationPanel *panel);
 void	   conversation_panel_check_marker_visibility (ConversationPanel *panel);
 void       conversation_panel_set_show_marker         (ConversationPanel *panel,
                                                        gboolean           show_marker);
diff --git a/src/fe-gnome/dcc-window.c b/src/fe-gnome/dcc-window.c
index 7caf17c..a198e2c 100644
--- a/src/fe-gnome/dcc-window.c
+++ b/src/fe-gnome/dcc-window.c
@@ -110,7 +110,7 @@ dcc_window_init (DccWindow *window)
 	gtk_tree_view_set_model (GTK_TREE_VIEW (window->transfer_list), GTK_TREE_MODEL (window->transfer_store));
 
 	gtk_container_set_border_width (GTK_CONTAINER (window), 12);
-	gtk_widget_reparent (window->toplevel, window);
+	gtk_widget_reparent (window->toplevel, GTK_WIDGET (window));
 
 
 	gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
@@ -236,8 +236,8 @@ dcc_window_add (DccWindow *window, struct DCC *dcc)
 	}
 
 	done_text = g_strdup_printf ("%d %%", done);
-	size = g_format_size_for_display (dcc->size);
-	pos = g_format_size_for_display (dcc->pos);
+	size = g_format_size (dcc->size);
+	pos = g_format_size (dcc->pos);
 	info_text = g_strdup_printf (_("<b>%s</b>\n<small>from %s</small>\n%s of %s"), dcc->file, dcc->nick, pos, size);
 	g_free (size);
 	g_free (pos);
@@ -274,9 +274,9 @@ dcc_window_update (DccWindow *window, struct DCC *dcc)
 			if (ptr == dcc) {
 				gint done = (gint) ((((float)dcc->pos) / ((float) dcc->size)) * 100);
 				gchar *done_text = g_strdup_printf ("%d %%", done);
-				gchar *size = g_format_size_for_display (dcc->size);
-				gchar *pos = g_format_size_for_display (dcc->pos);
-				gchar *speed = g_format_size_for_display (dcc->cps);
+				gchar *size = g_format_size (dcc->size);
+				gchar *pos = g_format_size (dcc->pos);
+				gchar *speed = g_format_size (dcc->cps);
 				gchar *info_text;
 				gchar *remaining_text;
 
diff --git a/src/fe-gnome/fe-gnome.c b/src/fe-gnome/fe-gnome.c
index e6d97ae..19428f1 100644
--- a/src/fe-gnome/fe-gnome.c
+++ b/src/fe-gnome/fe-gnome.c
@@ -382,7 +382,11 @@ fe_is_chanwindow (struct server *serv)
 void
 fe_add_chan_list (struct server *serv, char *chan, char *users, char *topic)
 {
-	channel_list_append (serv, chan, users, topic);
+	char *clean_topic;
+
+	clean_topic = strip_color (topic, -1, STRIP_ALL);
+	channel_list_append (serv, chan, users, clean_topic);
+	free (clean_topic);
 }
 
 void
@@ -876,9 +880,9 @@ fe_get_str (char *msg, char *def, void *callback, void *userdata)
 	GtkWidget *label;
 
 	dialog = gtk_dialog_new_with_buttons (msg, NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
-	gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->vbox), TRUE);
+	gtk_box_set_homogeneous (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), TRUE);
 	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
-	hbox = gtk_hbox_new (TRUE, 0);
+	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 
 	g_object_set_data (G_OBJECT (dialog), "cb", callback);
 	g_object_set_data (G_OBJECT (dialog), "ud", userdata);
@@ -893,7 +897,7 @@ fe_get_str (char *msg, char *def, void *callback, void *userdata)
 
 	g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (get_str_response), entry);
 
-	gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
+	gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox);
 
 	gtk_widget_show_all (dialog);
 }
@@ -931,18 +935,18 @@ fe_get_int (char *msg, int def, void *callback, void *userdata)
 	GtkAdjustment *adj;
 
 	dialog = gtk_dialog_new_with_buttons (msg, NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
-	gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->vbox), TRUE);
+	gtk_box_set_homogeneous (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), TRUE);
 	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
-	hbox = gtk_hbox_new (TRUE, 0);
+	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 
 	g_object_set_data (G_OBJECT (dialog), "cb", callback);
 	g_object_set_data (G_OBJECT (dialog), "ud", userdata);
 
 	spin = gtk_spin_button_new (NULL, 1, 0);
 	adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
-	adj->lower = 0;
-	adj->upper = 1024;
-	adj->step_increment = 1;
+	gtk_adjustment_set_lower (adj, 0);
+	gtk_adjustment_set_upper (adj, 1024);
+	gtk_adjustment_set_step_increment (adj, 1);
 	gtk_adjustment_changed (adj);
 	gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), def);
 	gtk_box_pack_end (GTK_BOX (hbox), spin, 0, 0, 0);
@@ -952,7 +956,7 @@ fe_get_int (char *msg, int def, void *callback, void *userdata)
 
 	g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (get_number_response), spin);
 
-	gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
+	gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox);
 
 	gtk_widget_show_all (dialog);
 }
diff --git a/src/fe-gnome/find-bar.c b/src/fe-gnome/find-bar.c
index d4ef5e9..ff6c3d0 100644
--- a/src/fe-gnome/find-bar.c
+++ b/src/fe-gnome/find-bar.c
@@ -159,7 +159,7 @@ find_bar_search_changed (GtkWidget *entry, FindBar *bar)
 static gboolean
 find_bar_key_press (GtkWidget *entry, GdkEventKey *event, FindBar *bar)
 {
-	if (event->keyval == GDK_Escape) {
+	if (event->keyval == GDK_KEY_Escape) {
 		find_bar_close (bar);
 	}
 	return FALSE;
diff --git a/src/fe-gnome/irc-network-editor.c b/src/fe-gnome/irc-network-editor.c
index 03805b8..b284068 100644
--- a/src/fe-gnome/irc-network-editor.c
+++ b/src/fe-gnome/irc-network-editor.c
@@ -342,7 +342,7 @@ irc_network_editor_init (IrcNetworkEditor *dialog)
 
 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
 
-	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+	/*gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);*/
 
 	server_selection   = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->servers));
 	autojoin_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->autojoin_channels));
@@ -527,7 +527,6 @@ apply_changes (IrcNetworkEditor *e)
 	GSList *s;
 	GtkTreeIter iter;
 	gchar *t1 = NULL, *t2, *t3;
-	gchar *channels;
 
 	net = e->network;
 
@@ -578,7 +577,6 @@ apply_changes (IrcNetworkEditor *e)
 			t1 = t3;
 		}
 	}
-	channels = t1;
 
 	net->autojoin = serialize_autojoin (e);
 
diff --git a/src/fe-gnome/main-window.c b/src/fe-gnome/main-window.c
index 4c5e969..1776a53 100644
--- a/src/fe-gnome/main-window.c
+++ b/src/fe-gnome/main-window.c
@@ -85,7 +85,6 @@ static gboolean on_resize (GtkWidget *widget, GdkEventConfigure *event, gpointer
 static gboolean on_hpane_move (GtkPaned *widget, GParamSpec *param_spec, gpointer data);
 
 static gboolean on_main_window_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data);
-static gboolean on_main_window_configure (GtkWidget *widget, GdkEventConfigure *event, gpointer data);
 
 static gboolean on_main_window_window_state (GtkWidget *widget, GdkEventWindowState *event, gpointer data);
 
@@ -151,17 +150,16 @@ initialize_main_window (void)
 	GtkSizeGroup *group;
 	GtkAction *action;
 	GConfClient *client;
-	GdkColormap *colormap;
+	GdkVisual *visual;
 
 	gui.main_window = GTK_WIDGET (gtk_builder_get_object (gui.xml, "xchat-gnome"));
 
-	colormap = gdk_screen_get_rgba_colormap (gtk_widget_get_screen (gui.main_window));
-	if (colormap != NULL)
-		gtk_widget_set_colormap (gui.main_window, colormap);
+	visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (gui.main_window));
+	if (visual != NULL)
+		gtk_widget_set_visual (gui.main_window, visual);
 
 	g_signal_connect (G_OBJECT (gui.main_window), "delete-event",    G_CALLBACK (on_main_window_close),     NULL);
 	g_signal_connect (G_OBJECT (gui.main_window), "focus-in-event",  G_CALLBACK (on_main_window_focus_in),  NULL);
-	g_signal_connect (G_OBJECT (gui.main_window), "configure-event", G_CALLBACK (on_main_window_configure), NULL);
 	g_signal_connect (G_OBJECT (gui.main_window), "window-state-event", G_CALLBACK (on_main_window_window_state), NULL);
 
 	/* hook up the menus */
@@ -210,11 +208,11 @@ initialize_main_window (void)
 
 		/* Add the two accelerators */
 		closure = g_cclosure_new (G_CALLBACK (on_pgup), NULL, NULL);
-		gtk_accel_group_connect (pg_accel, GDK_Page_Up, 0, GTK_ACCEL_VISIBLE, closure);
+		gtk_accel_group_connect (pg_accel, GDK_KEY_Page_Up, 0, GTK_ACCEL_VISIBLE, closure);
 		g_closure_unref (closure);
 
 		closure = g_cclosure_new (G_CALLBACK (on_pgdn), NULL, NULL);
-		gtk_accel_group_connect (pg_accel, GDK_Page_Down, 0, GTK_ACCEL_VISIBLE, closure);
+		gtk_accel_group_connect (pg_accel, GDK_KEY_Page_Down, 0, GTK_ACCEL_VISIBLE, closure);
 		g_closure_unref (closure);
 
 		/* Add the accelgroup to the main window. */
@@ -237,7 +235,7 @@ initialize_main_window (void)
 	/* connect nickname button */
 	gtk_button_set_use_underline (GTK_BUTTON (gui.nick_button), FALSE);
 	g_signal_connect (G_OBJECT (gui.nick_button), "clicked",   G_CALLBACK (on_nickname_clicked), NULL);
-	g_signal_connect (G_OBJECT (GTK_BIN (gui.nick_button)->child), "style-set", G_CALLBACK (nickname_style_set),  NULL);
+	g_signal_connect (G_OBJECT (gtk_bin_get_child (GTK_BIN (gui.nick_button))), "style-set", G_CALLBACK (nickname_style_set),  NULL);
     
     client = gconf_client_get_default ();
     
@@ -710,7 +708,7 @@ set_nickname_label (struct server *serv, char *newnick)
 		return;
 	}
 
-	label = GTK_LABEL (GTK_BIN (gui.nick_button)->child);
+	label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (gui.nick_button)));
 
 	if (serv == NULL) {
 		gtk_label_set_text (label, "");
@@ -742,7 +740,7 @@ set_nickname_color (struct server *serv)
 		GdkColor *color;
 
 		l = pango_attr_list_new ();
-		label = GTK_LABEL (GTK_BIN (gui.nick_button)->child);
+		label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (gui.nick_button)));
 
 		style = gtk_widget_get_style (GTK_WIDGET (label));
 
@@ -771,21 +769,14 @@ on_main_window_focus_in (GtkWidget * widget, GdkEventFocus * event, gpointer dat
 }
 
 static gboolean
-on_main_window_configure (GtkWidget *widget, GdkEventConfigure *event, gpointer data)
-{
-	conversation_panel_queue_tdraw (CONVERSATION_PANEL (gui.conversation_panel));
-	return FALSE;
-}
-
-static gboolean
 on_main_window_window_state (GtkWidget *widget, GdkEventWindowState *event, gpointer data)
 {
 	if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED)
 	{
 		if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
-			gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (gui.status_bar), FALSE);
+			gtk_window_set_has_resize_grip (GTK_WINDOW (widget), FALSE);
 		else
-			gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (gui.status_bar), TRUE);
+			gtk_window_set_has_resize_grip (GTK_WINDOW (widget), TRUE);
 	}
 
 	return FALSE;
diff --git a/src/fe-gnome/navigation-tree.c b/src/fe-gnome/navigation-tree.c
index 04d6a3e..45f28c9 100644
--- a/src/fe-gnome/navigation-tree.c
+++ b/src/fe-gnome/navigation-tree.c
@@ -745,7 +745,7 @@ navigation_tree_add_accels (NavTree *navtree, GtkWindow *window)
 		closure = g_cclosure_new (G_CALLBACK (jump_to_discussion), GINT_TO_POINTER (i), NULL);
 
 		// Connect up the accelerator.
-		gtk_accel_group_connect (discussion_accel, GDK_1 + i, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE, closure);
+		gtk_accel_group_connect (discussion_accel, GDK_KEY_1 + i, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE, closure);
 
 		// Delete the reference to the GClosure.
 		g_closure_unref (closure);
@@ -772,11 +772,11 @@ navigation_tree_add_accels (NavTree *navtree, GtkWindow *window)
 	 * put it in. It's easy enough to delete it later.
 	 */
 	closure = g_cclosure_new (G_CALLBACK (go_next_discussion), NULL, NULL);
-	gtk_accel_group_connect (discussion_accel, GDK_Page_Down, GDK_MOD1_MASK | GDK_CONTROL_MASK , GTK_ACCEL_VISIBLE, closure);
+	gtk_accel_group_connect (discussion_accel, GDK_KEY_Page_Down, GDK_MOD1_MASK | GDK_CONTROL_MASK , GTK_ACCEL_VISIBLE, closure);
 	g_closure_unref (closure);
 
 	closure = g_cclosure_new (G_CALLBACK (go_previous_discussion), NULL, NULL);
-	gtk_accel_group_connect (discussion_accel, GDK_Page_Up, GDK_MOD1_MASK | GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE, closure);
+	gtk_accel_group_connect (discussion_accel, GDK_KEY_Page_Up, GDK_MOD1_MASK | GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE, closure);
 	g_closure_unref (closure);
 
 	// Add the accelgroup to the main window.
diff --git a/src/fe-gnome/palette.c b/src/fe-gnome/palette.c
index c5d24cb..d191200 100644
--- a/src/fe-gnome/palette.c
+++ b/src/fe-gnome/palette.c
@@ -234,13 +234,18 @@ static void
 extract_theme_colors (void)
 {
 		GtkWidget* w;
+		GtkStyle *style;
+
 		w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 		gtk_widget_ensure_style (w);
-		theme_colors[0] = w->style->text[GTK_STATE_NORMAL];
-		theme_colors[1] = w->style->base[GTK_STATE_NORMAL];
-		theme_colors[2] = w->style->text[GTK_STATE_SELECTED];
-		theme_colors[3] = w->style->base[GTK_STATE_SELECTED];
-		theme_colors[4] = w->style->text[GTK_STATE_INSENSITIVE];
+		style = gtk_widget_get_style (w);
+
+		theme_colors[0] = style->text[GTK_STATE_NORMAL];
+		theme_colors[1] = style->base[GTK_STATE_NORMAL];
+		theme_colors[2] = style->text[GTK_STATE_SELECTED];
+		theme_colors[3] = style->base[GTK_STATE_SELECTED];
+		theme_colors[4] = style->text[GTK_STATE_INSENSITIVE];
+
 		optimize_palette (theme_colors[1]);
 		gtk_widget_destroy (w);
 }
@@ -266,7 +271,7 @@ load_palette (int selection)
 		extract_theme_colors();
 	}
 
-	for (i = 0; i < 32; i++)
+	for (i = 0; i < 32; i++) 
 		colors[i] = palette_schemes[selection][i];
 }
 
@@ -392,20 +397,3 @@ palette_save (void)
 	}
 }
 
-void
-palette_alloc (GtkWidget *widget)
-{
-	static gboolean done = FALSE;
-	GdkColormap *cmap;
-	int i;
-
-	cmap = gtk_widget_get_colormap (widget);
-
-	if (done)
-		gdk_colormap_free_colors (cmap, colors, 40);
-
-	for (i = 0; i < 40; i++)
-		gdk_colormap_alloc_color (cmap, &colors[i], FALSE, TRUE);
-
-	done = TRUE;
-}
diff --git a/src/fe-gnome/palette.h b/src/fe-gnome/palette.h
index 5c3b818..70e3f9f 100644
--- a/src/fe-gnome/palette.h
+++ b/src/fe-gnome/palette.h
@@ -27,7 +27,6 @@ extern const GdkColor *palette_schemes[];
 extern GdkColor custom_colors[9];
 extern GdkColor custom_palette[32];
 
-void palette_alloc (GtkWidget *widget);
 void load_colors (int selection);
 void load_palette (int selection);
 void palette_init (void);
diff --git a/src/fe-gnome/preferences-page-colors.c b/src/fe-gnome/preferences-page-colors.c
index 5e8d4d8..78bad2a 100644
--- a/src/fe-gnome/preferences-page-colors.c
+++ b/src/fe-gnome/preferences-page-colors.c
@@ -254,7 +254,6 @@ preferences_page_colors_new (gpointer prefs_dialog, GtkBuilder *xml)
 	gtk_list_store_append (p->page_store, &iter);
 	gtk_list_store_set (p->page_store, &iter, 0, PREFERENCES_PAGE (page)->icon, 1, _("Colors"), 2, 1, -1);
 
-	page->combo = gtk_combo_box_new_text ();
 	page->combo = gtk_combo_box_text_new ();
 	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (page->combo), _("Black on White"));
 	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (page->combo), _("White on Black"));
diff --git a/src/fe-gnome/preferences-page-spellcheck.c b/src/fe-gnome/preferences-page-spellcheck.c
index a37d768..5bd7ef9 100644
--- a/src/fe-gnome/preferences-page-spellcheck.c
+++ b/src/fe-gnome/preferences-page-spellcheck.c
@@ -28,12 +28,6 @@
 #include "util.h"
 #include "gui.h"
 
-#warning "temporary hack until sexy-spell-entry is removed"
-#undef GTK_DISABLE_SINGLE_INCLUDES
-#include <libsexy/sexy-spell-entry.h>
-#define GTK_DISABLE_SINGLE_INCLUDES
-
-
 G_DEFINE_TYPE(PreferencesPageSpellcheck, preferences_page_spellcheck, PREFERENCES_PAGE_TYPE)
 
 enum
@@ -68,7 +62,7 @@ language_changed (GtkCellRendererToggle *toggle, gchar *pathstr, PreferencesPage
 	GSList *languages;
 	GConfClient *client;
 	GError *err = NULL;
-
+#if 0
 	result = TRUE;
 	path = gtk_tree_path_new_from_string (pathstr);
 	if (gtk_tree_model_get_iter (GTK_TREE_MODEL (page->spellcheck_store), &iter, path)) {
@@ -106,6 +100,7 @@ language_changed (GtkCellRendererToggle *toggle, gchar *pathstr, PreferencesPage
 	}
 
 	gtk_tree_path_free (path);
+#endif
 }
 
 static void
@@ -127,7 +122,7 @@ gconf_languages_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry,
 	gboolean active;
 	GError *err = NULL;
 	GSList *new_languages, *old_languages;
-
+#if 0
 	/* First we use the new languages list
 	 *
 	 * FIXME: This suck because it should be done in text-entry.c
@@ -166,6 +161,7 @@ gconf_languages_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry,
 
 	g_slist_foreach (new_languages, (GFunc) g_free, NULL);
 	g_slist_free (new_languages);
+#endif
 }
 
 PreferencesPageSpellcheck *
@@ -184,7 +180,8 @@ preferences_page_spellcheck_new (gpointer prefs_dialog, GtkBuilder *xml)
 	gtk_list_store_append (p->page_store, &iter);
 	gtk_list_store_set (p->page_store, &iter, 0, PREFERENCES_PAGE (page)->icon, 1, _("Spell checking"), 2, 7, -1);
 
-	languages = sexy_spell_entry_get_languages (SEXY_SPELL_ENTRY (gui.text_entry));
+	/*languages = sexy_spell_entry_get_languages (SEXY_SPELL_ENTRY (gui.text_entry));*/
+	languages == NULL;
 	if (languages == NULL) {
 		label = gtk_label_new (_("In order to get spell-checking, you need to have libenchant installed with at least one dictionary."));
 		gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
@@ -234,7 +231,7 @@ preferences_page_spellcheck_new (gpointer prefs_dialog, GtkBuilder *xml)
 
 	page->nh[0] = gconf_client_notify_add (p->gconf, "/apps/xchat/spellcheck/enabled", (GConfClientNotifyFunc) gconf_enabled_changed, page->enable_spellcheck, NULL, NULL);
 	page->nh[1] = gconf_client_notify_add (p->gconf, "/apps/xchat/spellcheck/languages", (GConfClientNotifyFunc) gconf_languages_changed, page->spellcheck_store, NULL, NULL);
-
+#if 0
 	/* Populate the model */
 	for (l = languages; l != NULL; l = l->next) {
 		gboolean active;
@@ -258,6 +255,7 @@ preferences_page_spellcheck_new (gpointer prefs_dialog, GtkBuilder *xml)
 			                    -1);
 		}
 	}
+#endif
 	g_slist_free (languages);
 
 	enabled = gconf_client_get_bool (p->gconf, "/apps/xchat/spellcheck/enabled", NULL);
diff --git a/src/fe-gnome/text-entry.c b/src/fe-gnome/text-entry.c
index d527830..df52424 100644
--- a/src/fe-gnome/text-entry.c
+++ b/src/fe-gnome/text-entry.c
@@ -37,43 +37,25 @@ static void       text_entry_finalize          (GObject        *object);
 static gboolean   text_entry_key_press         (GtkWidget      *widget,
                                                 GdkEventKey    *event,
                                                 gpointer        data);
-static void       text_entry_grab_focus        (GtkWidget      *widget);
-
-static gboolean   text_entry_spell_check       (TextEntry      *entry,
-                                                gchar          *text,
-                                                gpointer        data);
-static void       enable_spellcheck_changed    (GConfClient    *client,
-		                                guint           cnxn_id,
-					        GConfEntry     *gconf_entry,
-					        TextEntry      *entry);
 static void       text_entry_activate          (GtkWidget      *widget,
                                                 gpointer        data);
 static void       text_entry_history_up        (GtkEntry       *entry);
 static void       text_entry_history_down      (GtkEntry       *entry);
-static gboolean   text_entry_tab_complete      (GtkEntry       *entry);
 static void       text_entry_populate_popup    (GtkEntry       *entry,
                                                 GtkMenu        *menu,
                                                 gpointer        data);
-
-static gboolean   tab_complete_command         (GtkEntry       *entry);
-static gboolean   tab_complete_nickname        (GtkEntry       *entry,
-                                                int             start);
 static GtkWidget *get_color_icon               (int             c,
                                                 GtkStyle       *style);
 static void       color_code_activate          (GtkMenuItem    *item,
                                                 gpointer        data);
 
-static SexySpellEntryClass *parent_class = NULL;
-G_DEFINE_TYPE (TextEntry, text_entry, SEXY_TYPE_SPELL_ENTRY);
-
-gpointer *entry_parent_class;
+static GtkEntryClass *parent_class = NULL;
+G_DEFINE_TYPE (TextEntry, text_entry, GTK_TYPE_ENTRY);
 
 struct _TextEntryPriv
 {
-	GCompletion    *command_completion;
-
-	GHashTable     *entries;
-	struct session *current;
+	GHashTable          *current_text;
+	struct session      *session;
 };
 
 static void
@@ -84,94 +66,20 @@ text_entry_class_init (TextEntryClass *klass)
 
 	parent_class = g_type_class_peek_parent (klass);
 
-	entry_parent_class = g_type_class_peek_parent (g_type_class_peek (GTK_TYPE_ENTRY));
-
 	gobject_class->finalize = text_entry_finalize;
-
-	widget_class->grab_focus = text_entry_grab_focus;
-}
-
-/* copied from eel-glib-extensions.c */
-
-static GList *
-g_list_from_g_slist (GSList *slist)
-{
-	GList *list;
-	GSList *node;
-
-	list = NULL;
-	for (node = slist; node != NULL; node = node->next) {
-		list = g_list_prepend (list, node->data);
-	}
-	return g_list_reverse (list);
 }
 
 static void
 text_entry_init (TextEntry *entry)
 {
-	GList *items = NULL;
-	int i;
-	GConfClient *client;
-	gboolean enable_spellcheck;
-	GSList *languages;
-	GError *err  = NULL;
-	GList *real_command_list;
-
 	g_signal_connect_after (G_OBJECT (entry), "key_press_event",         G_CALLBACK (text_entry_key_press),         NULL);
 	g_signal_connect       (G_OBJECT (entry), "activate",                G_CALLBACK (text_entry_activate),          NULL);
 	g_signal_connect       (G_OBJECT (entry), "populate-popup",          G_CALLBACK (text_entry_populate_popup),    NULL);
-	g_signal_connect_after (G_OBJECT (entry), "word-check",              G_CALLBACK (text_entry_spell_check),       NULL);
 
 	entry->priv = g_new0 (TextEntryPriv, 1);
 
-	entry->priv->entries = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
-
-	/* Initialize & populate a GCompletion for commands */
-	entry->priv->command_completion = g_completion_new (NULL);
-	real_command_list = g_list_from_g_slist (command_list);
-	g_completion_add_items (entry->priv->command_completion, real_command_list);
-	g_list_free (real_command_list);
-	for (i = 0; xc_cmds[i].name != NULL; i++) {
-		items = g_list_prepend (items, xc_cmds[i].name);
-	}
-	items = g_list_reverse (items);
-	g_completion_add_items (entry->priv->command_completion, items);
-	g_list_free (items);
-
-	/* Setup spellchecking */
-	client = gconf_client_get_default ();
-
-	enable_spellcheck = gconf_client_get_bool (client, "/apps/xchat/spellcheck/enabled", NULL);
-	languages = gconf_client_get_list (client, "/apps/xchat/spellcheck/languages", GCONF_VALUE_STRING, NULL);
-
-	if (languages != NULL) {
-		sexy_spell_entry_set_active_languages (SEXY_SPELL_ENTRY (entry), languages, &err);
-
-		if (err) {
-			g_printerr (_("Error in spellchecking configuration: %s\n"), err->message);
-			g_error_free (err);
-		}
-
-		g_slist_foreach (languages, (GFunc) g_free, NULL);
-		g_slist_free (languages);
-	} else {
-		if (enable_spellcheck) {
-			/* We use libsexy default languages and set it in gconf */
-			languages = sexy_spell_entry_get_active_languages (SEXY_SPELL_ENTRY (entry));
-			gconf_client_set_list (client, "/apps/xchat/spellcheck/languages",
-					       GCONF_VALUE_STRING, languages, NULL);
-
-			g_slist_foreach (languages, (GFunc) g_free, NULL);
-			g_slist_free (languages);
-		}
-	}
-
-	sexy_spell_entry_set_checked (SEXY_SPELL_ENTRY (entry), enable_spellcheck);
-
-	gconf_client_notify_add (client, "/apps/xchat/spellcheck/enabled",
-	                         (GConfClientNotifyFunc) enable_spellcheck_changed, entry, NULL, NULL);
-
-	g_object_unref (client);
+	/* Save the current input for each session */
+	entry->priv->current_text = g_hash_table_new (NULL, NULL);
 
 	gtk_widget_show (GTK_WIDGET (entry));
 }
@@ -183,13 +91,8 @@ text_entry_finalize (GObject *object)
 
 	entry = TEXT_ENTRY (object);
 
-	if (entry->priv->entries) {
-		g_hash_table_destroy (entry->priv->entries);
-	}
-	if (entry->priv->command_completion) {
-		g_completion_free (entry->priv->command_completion);
-	}
-	if (entry->priv) {
+	if (entry->priv)
+	{
 		g_free (entry->priv);
 	}
 
@@ -199,67 +102,22 @@ text_entry_finalize (GObject *object)
 static gboolean
 text_entry_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-	guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-	gboolean handled = FALSE;
+	if (event->state & gtk_accelerator_get_default_mod_mask ())
+		return FALSE;
 
-	switch (event->keyval) {
-	case GDK_Down:
-		if (state == 0) {
+	switch (event->keyval) 
+	{
+		case GDK_KEY_Down:
 			text_entry_history_down (GTK_ENTRY (widget));
-			handled = TRUE;
-		}
-		break;
-	case GDK_Up:
-		if (state == 0) {
+			return TRUE;
+		case GDK_KEY_Up:
 			text_entry_history_up (GTK_ENTRY (widget));
-			handled = TRUE;
-		}
-		break;
-	case GDK_Tab:
-		if (state  == 0) {
-			handled = text_entry_tab_complete (GTK_ENTRY (widget));
-		}
-		break;
-	default:
-		break;
-	}
-
-	return handled;
-}
-
-static void
-text_entry_grab_focus (GtkWidget *widget)
-{
-	/* GtkEntry's grab_focus selects the contents and therefore
-	 * claims PRIMARY. So we bypass it; see bug #345356 and bug #347067.
-	 */
-	GTK_WIDGET_CLASS (entry_parent_class)->grab_focus (widget);
-}
-
-static gboolean
-text_entry_spell_check (TextEntry *entry, gchar *text, gpointer data)
-{
-	GtkTreeModel *store = GTK_TREE_MODEL (userlist_get_store (u, entry->priv->current));
-	GtkTreeIter iter;
-
-	if (gtk_tree_model_get_iter_first (store, &iter) == FALSE) {
-		return TRUE;
-	}
-	do {
-		gchar *nick;
-		gboolean match = FALSE;
-
-		gtk_tree_model_get (store, &iter, 1, &nick, -1);
-		if (strncmp (text, nick, strlen (nick)) == 0) {
-			match = TRUE;
-		}
-
-		g_free (nick);
-		if (match) {
+			return TRUE;
+		case GDK_KEY_Tab:
+			return TRUE;
+		default:
 			return FALSE;
-		}
-	} while (gtk_tree_model_iter_next (store, &iter));
-	return TRUE;
+	}
 }
 
 static void
@@ -267,8 +125,8 @@ text_entry_activate (GtkWidget *widget, gpointer data)
 {
 	char *entry_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
 	gtk_entry_set_text (GTK_ENTRY (widget), "");
-	if (TEXT_ENTRY (widget)->priv->current != NULL) {
-		handle_multiline (TEXT_ENTRY (widget)->priv->current, (char *) entry_text, TRUE, FALSE);
+	if (TEXT_ENTRY (widget)->priv->session != NULL) {
+		handle_multiline (TEXT_ENTRY (widget)->priv->session, (char *) entry_text, TRUE, FALSE);
 	}
 	g_free (entry_text);
 }
@@ -280,11 +138,11 @@ text_entry_history_up (GtkEntry *entry)
 	char *new_line;
 
 	text_entry = TEXT_ENTRY (entry);
-	if (text_entry->priv->current == NULL) {
+	if (text_entry->priv->session == NULL) {
 		return;
 	}
 
-	new_line = history_up (&(text_entry->priv->current->history), (char *)entry->text);
+	new_line = history_up (&(text_entry->priv->session->history), (char *)gtk_entry_get_text (entry));
 	if (new_line) {
 		gtk_entry_set_text (entry, new_line);
 		gtk_editable_set_position (GTK_EDITABLE (entry), -1);
@@ -298,69 +156,17 @@ text_entry_history_down (GtkEntry *entry)
 	char *new_line;
 
 	text_entry = TEXT_ENTRY (entry);
-	if (text_entry->priv->current == NULL) {
+	if (text_entry->priv->session == NULL) {
 		return;
 	}
 
-	new_line = history_down (&(text_entry->priv->current->history));
+	new_line = history_down (&(text_entry->priv->session->history));
 	if (new_line) {
 		gtk_entry_set_text (entry, new_line);
 		gtk_editable_set_position (GTK_EDITABLE (entry), -1);
 	}
 }
 
-static gboolean
-text_entry_tab_complete (GtkEntry *entry)
-{
-	const char *text;
-	gint cursor_pos;
-	gchar *p;
-
-	text = gtk_entry_get_text (entry);
-	cursor_pos = gtk_editable_get_position (GTK_EDITABLE (entry));
-
-	if (cursor_pos == 0) {
-		return TRUE;
-	}
-
-	/* If we're directly after a space, we have nothing to tab complete */
-	p = g_utf8_offset_to_pointer (text, cursor_pos - 1);
-	if (p[0] == ' ') {
-		return TRUE;
-	}
-
-	/* search from cursor backwards to find /, #, ' ' or start */
-	p = g_utf8_offset_to_pointer (text, cursor_pos);
-	while ((p = g_utf8_find_prev_char (text, p))) {
-		/* check if we can match a channel */
-		/* FIXME: implement
-		if (p[0] == '#') {
-			if (text == p || g_ascii_strcasecmp (g_utf8_prev_char (p), " ") == 0) {
-				tab_complete_channel (entry, g_utf8_pointer_to_offset (text, p));
-				return;
-			}
-		}
-		*/
-
-		/* check if we can match a command */
-		if (text == p && p[0] == '/') {
-			return tab_complete_command (entry);
-		}
-
-		/* check if we can match a nickname */
-		if (p[0] == ' ') {
-			return tab_complete_nickname (entry,
-					g_utf8_pointer_to_offset (text, p) + 1);
-		}
-		/* finally try nickname after all preceeding failed */
-		if (text == p) {
-			return tab_complete_nickname (entry, 0);
-		}
-	}
-
-	return TRUE;
-}
-
 static void
 text_entry_populate_popup (GtkEntry *entry, GtkMenu *menu, gpointer data)
 {
@@ -442,205 +248,34 @@ text_entry_populate_popup (GtkEntry *entry, GtkMenu *menu, gpointer data)
 	gtk_widget_show_all (submenu);
 }
 
-static gboolean
-tab_complete_command (GtkEntry *entry)
-{
-	TextEntry *text_entry;
-	int cursor, length, pos;
-	char *prefix, *new_prefix = NULL, *printtext, *npt = NULL;
-	const gchar *text;
-	GList *options, *list;
-
-	text_entry = TEXT_ENTRY (entry);
-
-	cursor = gtk_editable_get_position (GTK_EDITABLE (entry));
-	prefix = g_new0 (char, cursor);
-	text = gtk_entry_get_text (entry);
-	prefix = g_ascii_strup (&text[1], cursor - 1);
-	length = strlen (text);
-
-	options = g_completion_complete (text_entry->priv->command_completion, prefix, &new_prefix);
-
-	if (g_list_length (options) == 0) {
-		/* no matches */
-		g_free (prefix);
-		return TRUE;
-	}
-
-	if (g_list_length (options) == 1) {
-		/* one match */
-
-		if (length - cursor == 0) {
-			/* at the end of the entry, just insert */
-			npt = g_strdup_printf ("/%s ", (char *) options->data);
-			pos = strlen (npt);
-		} else {
-			npt = g_strdup_printf ("/%s %s", (char *) options->data, &text[cursor]);
-			pos = strlen ((char *) options->data) + 2;
-		}
-		gtk_entry_set_text (entry, npt);
-		gtk_editable_set_position (GTK_EDITABLE (entry), pos);
-		g_free (npt);
-		g_free (prefix);
-		g_free (new_prefix);
-		return TRUE;
-	} else {
-		/* more than one match - print a list of options
-		 * to the window and update the prefix
-		 */
-		list = options;
-		printtext = g_strdup ((char *) list->data);
-		for (list = g_list_next (list); list; list = g_list_next (list)) {
-			npt = g_strdup_printf ("%s %s", printtext, (char *) list->data);
-			g_free (printtext);
-			printtext = npt;
-		}
-		conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->current, printtext, TRUE, time (NULL));
-		g_free (printtext);
-
-		if (new_prefix && strcasecmp (prefix, new_prefix) != 0) {
-			/* insert the new prefix into the entry */
-			npt = g_strdup_printf ("/%s%s", new_prefix, &text[cursor]);
-			gtk_entry_set_text (entry, npt);
-			g_free (npt);
-			gtk_editable_set_position (GTK_EDITABLE (entry), strlen (new_prefix) + 1);
-		}
-		g_free (prefix);
-		g_free (new_prefix);
-		return TRUE;
-	}
-
-	return TRUE;
-}
-
-static gboolean
-tab_complete_nickname (GtkEntry *entry, gint start)
+static GtkWidget *
+get_color_icon (int c, GtkStyle *style)
 {
-	GCompletion *completion;
-	int cursor, length;
-	char *text, *at_cursor, *at_start;
-	GList *list;
-	char *printtext, *npt;
-	GList *options;
-	gchar *new_prefix;
-	gchar *prefix;
-	TextEntry *text_entry;
+	GtkWidget *icon;
+	GdkPixbuf *pixbuf;
+	cairo_surface_t *canvas;
+	cairo_t *cr;
 
-	completion = userlist_get_completion (u, TEXT_ENTRY (entry)->priv->current);
-	g_completion_set_compare (completion, (GCompletionStrncmpFunc) strncasecmp);
-	text = g_strdup (gtk_entry_get_text (entry));
-	length = g_utf8_strlen (text, -1);
-	cursor = gtk_editable_get_position (GTK_EDITABLE (entry));
-	at_start = g_utf8_offset_to_pointer (text, start);
-	at_cursor = g_utf8_offset_to_pointer (text, cursor);
+	canvas = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 16, 16);
+	cr = cairo_create (canvas);
 
-	text_entry = TEXT_ENTRY (entry);
+	gdk_cairo_set_source_color (cr, &style->dark[GTK_STATE_NORMAL]);
+	cairo_rectangle (cr, 0, 0, 16, 16);
+	cairo_fill (cr);
 
-	/* pointer arithmetic for byte size allocation */
-	prefix = g_new0 (char, at_cursor - at_start + 1);
-	g_utf8_strncpy (prefix, at_start, cursor - start);
-	options = g_completion_complete_utf8 (completion, prefix, &new_prefix);
+	gdk_cairo_set_source_color (cr, &colors[c]);
+	cairo_rectangle (cr, 1, 1, 14, 14);
+	cairo_fill (cr);
 
-	if (g_list_length (options) == 0) {
-		/* no matches */
-		g_free (text);
-		g_free (prefix);
-		return TRUE;
-	}
+	cairo_destroy (cr);
 
-	if (g_list_length (options) == 1) {
-		int pos;
-
-		/* one match */
-		if (length - cursor == 0) {
-			/* at the end of the entry, just insert */
-
-			if (start != 0) {
-				gchar *p;
-				p = g_new0 (char, at_start - text + 1);
-				g_utf8_strncpy (p, text, start);
-				npt = g_strdup_printf ("%s%s", p, (char *) options->data);
-				g_free (p);
-				pos = g_utf8_strlen ((char *) options->data, -1) + start;
-			} else {
-				npt = g_strdup_printf ("%s%s ", (char *) options->data, prefs.nick_suffix);
-				pos = g_utf8_strlen ((char *) options->data, -1) + 2;
-			}
-		} else {
-			/* somewhere in the middle of the entry */
-
-			if (start != 0) {
-				gchar *p;
-				p = g_new0 (char, at_start - text + 1);
-				g_utf8_strncpy (p, text, start);
-				npt = g_strdup_printf ("%s%s%s", p, (char *) options->data, at_cursor);
-				g_free (p);
-				pos = g_utf8_strlen ((char *) options->data, -1) + start;
-			} else {
-				npt = g_strdup_printf ("%s%s %s", (char *) options->data, prefs.nick_suffix, at_cursor);
-				pos = g_utf8_strlen ((char *) options->data, -1) + 2;
-			}
-		}
-		gtk_entry_set_text (entry, npt);
-		gtk_editable_set_position (GTK_EDITABLE (entry), pos);
-		g_free (npt);
-		g_free (text);
-		g_free (prefix);
-		return TRUE;
-	} else {
-		/* more than one match - print a list of options
-		 * to the window and update the prefix
-		 */
-		list = options;
-		printtext = g_strdup ((char *) list->data);
-		for (list = g_list_next (list); list; list = g_list_next (list)) {
-			npt = g_strdup_printf ("%s %s", printtext, (char *) list->data);
-			g_free (printtext);
-			printtext = npt;
-		}
-		conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->current, printtext, TRUE, time (NULL));
-		g_free (printtext);
-
-		if (strcasecmp (prefix, new_prefix) != 0) {
-			/* insert the new prefix into the entry */
-			gchar *p;
-			p = g_new0 (char, at_start - text + 1);
-		       	g_utf8_strncpy (p, text, start);
-			npt = g_strdup_printf ("%s%s%s", p, new_prefix, at_cursor);
-			g_free (p);
-			gtk_entry_set_text (entry, npt);
-			g_free (npt);
-			gtk_editable_set_position (GTK_EDITABLE (entry), start + g_utf8_strlen (new_prefix, -1));
-		}
-		g_free (text);
-		g_free (prefix);
-		return TRUE;
-	}
-	return TRUE;
-}
+	pixbuf = gdk_pixbuf_get_from_surface (canvas, 0, 0, 16, 16);
+	icon = gtk_image_new_from_pixbuf (pixbuf);
 
-static GtkWidget *
-get_color_icon (int c, GtkStyle *style)
-{
-	GtkWidget *image;
-	GdkPixmap *pixmap;
-	cairo_t *context;
+	cairo_surface_destroy (canvas);
+	g_object_unref (pixbuf);
 
-	pixmap = gdk_pixmap_new (NULL, 16, 16, 24);
-
-	context = gdk_cairo_create (GDK_DRAWABLE (pixmap));
-	gdk_cairo_set_source_color (context, &style->dark[GTK_STATE_NORMAL]);
-	cairo_rectangle (context, 0, 0, 16, 16);
-	cairo_fill (context);
-	gdk_cairo_set_source_color (context, &colors[c]);
-	cairo_rectangle (context, 1, 1, 14, 14);
-	cairo_fill (context);
-	cairo_destroy (context);
-
-	image = gtk_image_new_from_pixmap (pixmap, NULL);
-	g_object_unref (pixmap);
-
-	return image;
+	return icon;
 }
 
 static void
@@ -665,14 +300,14 @@ text_entry_set_current (TextEntry *entry, struct session *sess)
 {
 	TextEntryPriv *priv = entry->priv;
 	GtkWidget *widget = GTK_WIDGET (entry);
-	GtkEditable *editable = GTK_EDITABLE (entry);
 	GtkClipboard *clipboard;
-	char *selection = NULL, *text = NULL;
+	char *selection = NULL;
+	char *text = NULL;
 	int start, end;
 
 	g_return_if_fail (gtk_widget_get_realized (widget));
 
-	if (sess == priv->current) {
+	if (sess == priv->session) {
 		return;
 	}
 
@@ -685,22 +320,26 @@ text_entry_set_current (TextEntry *entry, struct session *sess)
 	g_assert (clipboard != NULL);
 
 	if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (entry) &&
-	    gtk_editable_get_selection_bounds (editable, &start, &end)) {
-		selection = gtk_editable_get_chars (editable, start, end);
+	    gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end)) {
+		selection = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
+	}
+
+	if (priv->session)
+	{
+		g_hash_table_replace (priv->current_text, priv->session, 
+				g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))));
 	}
 
-	if (sess != NULL) {
-		g_hash_table_insert (priv->entries,
-		                     priv->current,
-		                     g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))));
-		text = g_hash_table_lookup (priv->entries, sess);
+	priv->session = sess;
+	
+	if (priv->session)
+	{
+		text = g_hash_table_lookup (priv->current_text, priv->session);
 	}
 
 	gtk_entry_set_text (GTK_ENTRY (entry), text ? text : "");
 	gtk_editable_set_position (GTK_EDITABLE (entry), -1);
 
-	priv->current = sess;
-
 	/* Restore the selection (note that it's not owned by us anymore!) */
 	if (selection) {
 		gtk_clipboard_set_text (clipboard, selection, strlen (selection));
@@ -711,32 +350,9 @@ text_entry_set_current (TextEntry *entry, struct session *sess)
 void
 text_entry_remove_session (TextEntry *entry, struct session *sess)
 {
-	g_hash_table_remove (entry->priv->entries, sess);
-	if (sess == entry->priv->current) {
+	g_hash_table_remove (entry->priv->current_text, sess);
+	if (sess == entry->priv->session) {
 		gtk_entry_set_text (GTK_ENTRY (entry), "");
 	}
 }
 
-static void
-enable_spellcheck_changed (GConfClient *client, guint cnxn_id, GConfEntry *gconf_entry, TextEntry *entry)
-{
-	GSList *langs;
-	gboolean enabled;
-
-	enabled = gconf_value_get_bool (gconf_entry->value);
-	sexy_spell_entry_set_checked (SEXY_SPELL_ENTRY (entry), enabled);
-
-	if (enabled) {
-		langs = sexy_spell_entry_get_active_languages (SEXY_SPELL_ENTRY (entry));
-		if (langs == NULL) {
-			/* No langs activated: we use the defaults */
-			sexy_spell_entry_activate_default_languages (SEXY_SPELL_ENTRY (entry));
-			langs = sexy_spell_entry_get_active_languages (SEXY_SPELL_ENTRY (entry));
-			gconf_client_set_list (client, "/apps/xchat/spellcheck/languages",
-					       GCONF_VALUE_STRING, langs, NULL);
-		}
-
-		g_slist_foreach (langs, (GFunc) g_free, NULL);
-		g_slist_free (langs);
-	}
-}
diff --git a/src/fe-gnome/text-entry.h b/src/fe-gnome/text-entry.h
index 4477fb1..cdca09a 100644
--- a/src/fe-gnome/text-entry.h
+++ b/src/fe-gnome/text-entry.h
@@ -21,11 +21,6 @@
 #ifndef XCHAT_GNOME_TEXTENTRY_H
 #define XCHAT_GNOME_TEXTENTRY_H
 
-#warning "temporary hack until sexy-spell-entry is removed"
-#undef GTK_DISABLE_SINGLE_INCLUDES
-#include <libsexy/sexy-spell-entry.h>
-#define GTK_DISABLE_SINGLE_INCLUDES
-
 #include "../common/xchat.h"
 
 G_BEGIN_DECLS
@@ -42,14 +37,14 @@ typedef struct _TextEntryPriv  TextEntryPriv;
 
 struct _TextEntry
 {
-	SexySpellEntry  parent;
+	GtkEntry  parent;
 
 	TextEntryPriv  *priv;
 };
 
 struct _TextEntryClass
 {
-	SexySpellEntryClass parent_class;
+	GtkEntryClass parent_class;
 };
 
 GType      text_entry_get_type       (void) G_GNUC_CONST;
diff --git a/src/fe-gnome/userlist-gui.c b/src/fe-gnome/userlist-gui.c
index e34186d..9d9f816 100644
--- a/src/fe-gnome/userlist-gui.c
+++ b/src/fe-gnome/userlist-gui.c
@@ -258,6 +258,7 @@ userlist_gui_show (void)
 	GdkScreen      *screen;
 	GtkRequisition  request;
 	GtkWidget      *anchor_widget;
+	GtkAllocation   allocation;
 
 	if (!gtk_widget_get_visible (gui.userlist_toggle)) {
 		return;
@@ -275,20 +276,20 @@ userlist_gui_show (void)
 	else
 		anchor_widget = gui.main_window;
 
-	gdk_window_get_origin (anchor_widget->window, &toggle_x, &toggle_y);
+	gdk_window_get_origin (gtk_widget_get_window (anchor_widget), &toggle_x, &toggle_y);
 
 	screen = gtk_widget_get_screen (anchor_widget);
 	monitor = gdk_screen_get_monitor_at_point (screen, toggle_x, toggle_y);
 	gdk_screen_get_monitor_geometry (screen, monitor, &monitor_rect);
 
+	gtk_widget_get_allocation (anchor_widget, &allocation);
+
 	if (gtk_widget_get_direction (anchor_widget) == GTK_TEXT_DIR_RTL) {
-		toggle_x += anchor_widget->allocation.x +
-		            anchor_widget->allocation.width - request.width;
+		toggle_x += allocation.x + allocation.width - request.width;
 	} else {
-		toggle_x += anchor_widget->allocation.width;
+		toggle_x += allocation.width;
 	}
-	toggle_y += anchor_widget->allocation.y +
-	            anchor_widget->allocation.height;
+	toggle_y += allocation.y + allocation.height;
 
 	/* Buffer of 20 pixels.  Would be nice to know exactly how much space
 	 * the rest of the window's UI goop used up, but oh well.
@@ -345,7 +346,7 @@ userlist_window_event (GtkWidget *window, GdkEvent *event, gpointer data)
 {
 	switch (event->type) {
 	case GDK_KEY_PRESS:
-		if (((GdkEventKey *)event)->keyval == GDK_Escape) {
+		if (((GdkEventKey *)event)->keyval == GDK_KEY_Escape) {
 			userlist_gui_hide ();
 			break;
 		}
@@ -371,14 +372,12 @@ userlist_grab (void)
 		return;
 	}
 
-	have_grab = (gdk_pointer_grab (gui.userlist_window->window, TRUE,
-	                               GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
-				       GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK |
-				       GDK_LEAVE_NOTIFY_MASK,
-	                               NULL, NULL, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS);
+	have_grab = (gdk_pointer_grab (gtk_widget_get_window (gui.userlist_window), TRUE,
+		GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK,
+	    NULL, NULL, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS);
 
 	if (have_grab) {
-		have_grab = (gdk_keyboard_grab (gui.userlist_window->window, TRUE, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS);
+		have_grab = (gdk_keyboard_grab (gtk_widget_get_window (gui.userlist_window), TRUE, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS);
 		if (have_grab == FALSE) {
 			/* something bad happened */
 			gdk_pointer_ungrab (GDK_CURRENT_TIME);
@@ -400,10 +399,13 @@ static gboolean
 userlist_button_release (GtkWidget *widget, GdkEventButton *button, gpointer data)
 {
 	gint x, y, width, height;
+	GdkWindow *w;
+
+	w = gtk_widget_get_window (gui.userlist_window);
 
-	gdk_window_get_root_origin (gui.userlist_window->window, &x, &y);
-	width = gdk_window_get_width  (gui.userlist_window->window);
-	height = gdk_window_get_height  (gui.userlist_window->window);
+	gdk_window_get_root_origin (w, &x, &y);
+	width = gdk_window_get_width (w);
+	height = gdk_window_get_height (w);
 
 	/* If the event happened on top of the userlist window, we don't want to
 	 * close it */
diff --git a/src/fe-gnome/userlist.c b/src/fe-gnome/userlist.c
index ad306da..1534ae6 100644
--- a/src/fe-gnome/userlist.c
+++ b/src/fe-gnome/userlist.c
@@ -37,7 +37,6 @@ static GObjectClass *parent_class = NULL;
 typedef struct
 {
 	GtkListStore *liststore;
-	GCompletion *completion;
 	GList *completion_items;
 } Store;
 
@@ -85,7 +84,6 @@ static gboolean
 destroy_store (session *session, Store *store, gpointer data)
 {
 	g_object_unref (store->liststore);
-	g_completion_free (store->completion);
 	g_free (store);
 	return TRUE;
 }
@@ -120,7 +118,6 @@ create_userlist (Userlist *userlist, session *sess)
 	Store *store = g_new (Store, 1);
 
 	store->liststore = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_COLOR);
-	store->completion = g_completion_new (NULL);
 	store->completion_items = NULL;
 
 	g_hash_table_insert (userlist->stores, sess, store);
@@ -159,7 +156,6 @@ userlist_insert (Userlist *userlist, session *sess, struct User *newuser, int ro
 	gtk_list_store_set (store->liststore, &iter, 0, icon, 1, newuser->nick, 2, newuser, 3, newuser->away ? &colors[40] : NULL, -1);
 
 	item = g_list_append (NULL, newuser->nick);
-	g_completion_add_items (store->completion, item);
 	store->completion_items = g_list_concat (store->completion_items, item);
 
 	userlist_set_user_button (userlist, sess);
@@ -201,7 +197,6 @@ userlist_remove_user (Userlist *userlist, session *sess, struct User *user)
 
 	item = g_list_find_custom (store->completion_items, user->nick, (GCompareFunc) strcmp);
 	store->completion_items = g_list_remove_link (store->completion_items, item);
-	g_completion_remove_items (store->completion, item);
 	g_list_free (item);
 
 	userlist_set_user_button (userlist, sess);
@@ -224,13 +219,11 @@ userlist_update (Userlist *userlist, session *sess, struct User *user)
 
 	item = g_list_find_custom (store->completion_items, nick, (GCompareFunc) strcmp);
 	store->completion_items = g_list_remove_link (store->completion_items, item);
-	g_completion_remove_items (store->completion, item);
 	g_list_free (item);
 
 	gtk_list_store_set (store->liststore, iter, 1, user->nick, 3, user->away ? &colors[40] : NULL, -1);
 
 	item = g_list_append (NULL, user->nick);
-	g_completion_add_items (store->completion, item);
 	store->completion_items = g_list_concat (store->completion_items, item);
 
 	g_free (nick);
@@ -262,7 +255,6 @@ userlist_clear_all (Userlist *userlist, session *sess)
 		store = create_userlist (userlist, sess);
 	}
 
-	g_completion_clear_items (store->completion);
 	gtk_list_store_clear (store->liststore);
 }
 
@@ -275,7 +267,6 @@ userlist_erase (Userlist *userlist, session *sess)
 	}
 
 	g_object_unref (store->liststore);
-	g_completion_free (store->completion);
 	g_free (store);
 	g_hash_table_remove (userlist->stores, sess);
 }
@@ -290,12 +281,12 @@ userlist_get_store (Userlist *userlist, session *sess)
 	return store->liststore;
 }
 
-GCompletion*
+GList*
 userlist_get_completion (Userlist *userlist, session *sess)
 {
 	Store *store = g_hash_table_lookup (userlist->stores, sess);
 	g_assert (store != NULL);
-	return store->completion;
+	return store->completion_items;
 }
 
 void
diff --git a/src/fe-gnome/userlist.h b/src/fe-gnome/userlist.h
index d52b2a9..2c745bf 100644
--- a/src/fe-gnome/userlist.h
+++ b/src/fe-gnome/userlist.h
@@ -59,7 +59,7 @@ void          userlist_move            (Userlist *userlist, session *sess, struc
 void          userlist_clear_all       (Userlist *userlist, session *sess);
 void          userlist_erase           (Userlist *userlist, session *sess);
 GtkListStore* userlist_get_store       (Userlist *userlist, session *sess);
-GCompletion*  userlist_get_completion  (Userlist *userlist, session *sess);
+GList*        userlist_get_completion  (Userlist *userlist, session *sess);
 void	      userlist_set_user_button (Userlist *userlist, session *sess);
 
 G_END_DECLS
diff --git a/src/fe-gnome/util.c b/src/fe-gnome/util.c
index a7540c5..5197a74 100644
--- a/src/fe-gnome/util.c
+++ b/src/fe-gnome/util.c
@@ -46,7 +46,7 @@ error_dialog (const gchar *header, const gchar *message)
 gboolean
 dialog_escape_key_handler_destroy (GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-	if (event->keyval == GDK_Escape) {
+	if (event->keyval == GDK_KEY_Escape) {
 		g_signal_stop_emission_by_name (widget, "key-press-event");
 		gtk_widget_destroy (widget);
 		return TRUE;
@@ -58,7 +58,7 @@ dialog_escape_key_handler_destroy (GtkWidget *widget, GdkEventKey *event, gpoint
 gboolean
 dialog_escape_key_handler_hide (GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-	if (event->keyval == GDK_Escape) {
+	if (event->keyval == GDK_KEY_Escape) {
 		g_signal_stop_emission_by_name (widget, "key-press-event");
 		gtk_widget_hide (widget);
 		return TRUE;
@@ -74,17 +74,19 @@ menu_position_under_widget (GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
 {
 	GtkWidget *w = GTK_WIDGET (user_data);
 	GtkRequisition requisition;
+	GtkAllocation allocation;
 
-	gdk_window_get_origin (w->window, x, y);
+	gdk_window_get_origin (gtk_widget_get_window (w), x, y);
 	gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
+	gtk_widget_get_allocation (w, &allocation);
 
 	if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL) {
-		*x += w->allocation.x + w->allocation.width - requisition.width;
+		*x += allocation.x + allocation.width - requisition.width;
 	} else {
-		*x += w->allocation.x;
+		*x += allocation.x;
 	}
 
-	*y += w->allocation.y + w->allocation.height;
+	*y += allocation.y + allocation.height;
 
 	*push_in = TRUE;
 }
@@ -107,7 +109,7 @@ menu_position_under_tree_view (GtkMenu *menu, gint *x, gint *y, gboolean *push_i
 		GtkTreePath *path;
 		GdkRectangle rect;
 
-		gdk_window_get_origin (GTK_WIDGET (tree)->window, x, y);
+		gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (tree)), x, y);
 
 		path = gtk_tree_model_get_path (model, &iter);
 		gtk_tree_view_get_cell_area (tree, path,
diff --git a/src/fe-gnome/xtext.c b/src/fe-gnome/xtext.c
index 1f57f38..93b201f 100644
--- a/src/fe-gnome/xtext.c
+++ b/src/fe-gnome/xtext.c
@@ -22,17 +22,14 @@
  */
 
 #define XCHAT							/* using xchat */
-#define TINT_VALUE 195				/* 195/255 of the brightness. */
 #define MOTION_MONITOR				/* URL hilights. */
 #define SMOOTH_SCROLL				/* line-by-line or pixel scroll? */
-#define SCROLL_HACK					/* use XCopyArea scroll, or full redraw? */
 #undef COLOR_HILIGHT				/* Color instead of underline? */
 /* Italic is buggy because it assumes drawing an italic string will have
    identical extents to the normal font. This is only true some of the
    time, so we can't use this hack yet. */
 #undef ITALIC							/* support Italic? */
 #define GDK_MULTIHEAD_SAFE
-#define USE_DB							/* double buffer */
 
 #define MARGIN 2						/* dont touch. */
 #define REFRESH_TIMEOUT 20
@@ -45,44 +42,18 @@
 #include <unistd.h>
 #include <gtk/gtk.h>
 
-#ifdef XCHAT
-#include "../../config.h"			/* can define USE_XLIB here */
-#else
-#define USE_XLIB
-#endif
-
-#ifdef USE_XLIB
-#include <gdk/gdkx.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#endif
-
-#ifdef USE_MMX
-#include "mmx_cmod.h"
-#endif
+#include "../../config.h"
 
 #include "xtext.h"
 #include "xg-marshal.h"
 
 #define charlen(str) g_utf8_skip[*(guchar *)(str)]
 
-#ifdef WIN32
-#include <windows.h>
-#include <gdk/gdkwin32.h>
-#endif
-
 /* is delimiter */
 #define is_del(c) \
 	(c == ' ' || c == '\n' || c == ')' || c == '(' || \
 	 c == '>' || c == '<' || c == ATTR_RESET || c == ATTR_BOLD || c == 0)
 
-#ifdef SCROLL_HACK
-/* force scrolling off */
-#define dontscroll(buf) (buf)->last_pixel_pos = 0x7fffffff
-#else
-#define dontscroll(buf)
-#endif
-
 static GtkWidgetClass *parent_class = NULL;
 
 struct textentry
@@ -128,10 +99,6 @@ int xtext_get_stamp_str (time_t, char **);
 #endif
 static void gtk_xtext_render_page (GtkXText * xtext);
 static void gtk_xtext_calc_lines (xtext_buffer *buf, int);
-#if defined(USE_XLIB) || defined(WIN32)
-static void gtk_xtext_load_trans (GtkXText * xtext);
-static void gtk_xtext_free_trans (GtkXText * xtext);
-#endif
 static char *gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret);
 static textentry *gtk_xtext_nth (GtkXText *xtext, int line, int *subline);
 static void gtk_xtext_adjustment_changed (GtkAdjustment * adj,
@@ -180,40 +147,57 @@ gtk_xtext_text_width_8bit (GtkXText *xtext, unsigned char *str, int len)
 	return width;
 }
 
-static void
-xtext_color_to_cairo(GtkXText *xtext, gulong pixel, double *rgb)
+/* Inlined for speed sake */
+static inline GdkColor 
+xtext_palette_lookup (GtkXText *xtext, int index)
 {
-	GdkColor color;
-	GdkColormap * colormap = gtk_widget_get_colormap (&xtext->widget);
-	gdk_colormap_query_color (colormap, pixel, &color);
-	rgb[0] = color.red / 65535.0;
-	rgb[1] = color.green / 65535.0;
-	rgb[2] = color.blue / 65535.0;
+    return xtext->palette[index];
 }
 
-static void
-xtext_draw_rectangle (GtkXText *xtext, cairo_t *cr, gulong pixel, int x, int y, int width, int height)
+static inline void
+xtext_set_source_color (cairo_t *cr, GdkColor *color, gdouble alpha)
 {
-	GdkRectangle rect = { x, y, width, height };
-	double color[3];
-
-	xtext_color_to_cairo (xtext, pixel, color);
+    cairo_set_source_rgba (cr, color->red / 65535.0, color->green / 65535.0,
+        color->blue / 65535.0, alpha);
+}
 
+static inline void
+xtext_draw_rectangle (GtkXText *xtext, cairo_t *cr, GdkColor *color, int x, int y, int width, int height)
+{
 	cairo_save (cr);
-	cairo_set_source_rgba (cr, color[0], color[1], color[2], xtext->alpha);
+
+    xtext_set_source_color (cr, color, xtext->alpha);
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
-	gdk_cairo_rectangle (cr, &rect);
+	cairo_rectangle (cr, (double)x, (double)y, (double)width, (double)height);
 	cairo_fill (cr);
+
 	cairo_restore (cr);
+}
+
+static inline void
+xtext_draw_line (GtkXText *xtext, cairo_t *cr, GdkColor *color, int x1, int y1, int x2, int y2)
+{
+    cairo_save (cr);
+
+    /* Disable antialiasing for crispy 1-pixel lines */
+    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+    gdk_cairo_set_source_color (cr, color);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+    cairo_set_line_width (cr, 1.0);
+    cairo_move_to (cr, x1, y1);
+    cairo_line_to (cr, x2, y2);
+    cairo_stroke (cr);
 
+    cairo_restore (cr);
 }
 
-static void
+static inline void
 xtext_draw_bg (GtkXText *xtext, int x, int y, int width, int height)
 {
 	cairo_t *cr;
-	cr = gdk_cairo_create (xtext->widget.window);
-	xtext_draw_rectangle(xtext, cr, xtext->palette[XTEXT_BG], x, y, width, height);
+	cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
+    xtext_draw_rectangle(xtext, cr, &xtext->palette[XTEXT_BG], x, y, width, height);
 	cairo_destroy (cr);
 }
 
@@ -223,216 +207,6 @@ gtk_xtext_set_alpha (GtkXText *xtext, double alpha)
 	xtext->alpha = alpha;
 }
 
-/* ========================================= */
-/* ========== XFT 1 and 2 BACKEND ========== */
-/* ========================================= */
-
-#ifdef USE_XFT
-
-static void
-backend_font_close (GtkXText *xtext)
-{
-	XftFontClose (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->font);
-#ifdef ITALIC
-	XftFontClose (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->ifont);
-#endif
-}
-
-static void
-backend_init (GtkXText *xtext)
-{
-	if (xtext->xftdraw == NULL)
-	{
-		xtext->xftdraw = XftDrawCreate (
-			GDK_WINDOW_XDISPLAY (xtext->draw_buf),
-			GDK_WINDOW_XWINDOW (xtext->draw_buf),
-			GDK_VISUAL_XVISUAL (gdk_drawable_get_visual (xtext->draw_buf)),
-			GDK_COLORMAP_XCOLORMAP (gdk_drawable_get_colormap (xtext->draw_buf)));
-		XftDrawSetSubwindowMode (xtext->xftdraw, IncludeInferiors);
-	}
-}
-
-static void
-backend_deinit (GtkXText *xtext)
-{
-	if (xtext->xftdraw)
-	{
-		XftDrawDestroy (xtext->xftdraw);
-		xtext->xftdraw = NULL;
-	}
-}
-
-static XftFont *
-backend_font_open_real (Display *xdisplay, char *name, gboolean italics)
-{
-	XftFont *font = NULL;
-	PangoFontDescription *fontd;
-	int weight, slant, screen = DefaultScreen (xdisplay);
-
-	fontd = pango_font_description_from_string (name);
-
-	if (pango_font_description_get_size (fontd) != 0)
-	{
-		weight = pango_font_description_get_weight (fontd);
-		/* from pangoft2-fontmap.c */
-		if (weight < (PANGO_WEIGHT_NORMAL + PANGO_WEIGHT_LIGHT) / 2)
-			weight = XFT_WEIGHT_LIGHT;
-		else if (weight < (PANGO_WEIGHT_NORMAL + 600) / 2)
-			weight = XFT_WEIGHT_MEDIUM;
-		else if (weight < (600 + PANGO_WEIGHT_BOLD) / 2)
-			weight = XFT_WEIGHT_DEMIBOLD;
-		else if (weight < (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2)
-			weight = XFT_WEIGHT_BOLD;
-		else
-			weight = XFT_WEIGHT_BLACK;
-
-		slant = pango_font_description_get_style (fontd);
-		if (slant == PANGO_STYLE_ITALIC)
-			slant = XFT_SLANT_ITALIC;
-		else if (slant == PANGO_STYLE_OBLIQUE)
-			slant = XFT_SLANT_OBLIQUE;
-		else
-			slant = XFT_SLANT_ROMAN;
-
-		font = XftFontOpen (xdisplay, screen,
-						XFT_FAMILY, XftTypeString, pango_font_description_get_family (fontd),
-						XFT_CORE, XftTypeBool, False,
-						XFT_SIZE, XftTypeDouble, (double)pango_font_description_get_size (fontd)/PANGO_SCALE,
-						XFT_WEIGHT, XftTypeInteger, weight,
-						XFT_SLANT, XftTypeInteger, italics ? XFT_SLANT_ITALIC : slant,
-						NULL);
-	}
-	pango_font_description_free (fontd);
-
-	if (font == NULL)
-	{
-		font = XftFontOpenName (xdisplay, screen, name);
-		if (font == NULL)
-			font = XftFontOpenName (xdisplay, screen, "sans-11");
-	}
-
-	return font;
-}
-
-static void
-backend_font_open (GtkXText *xtext, char *name)
-{
-	Display *dis = GDK_WINDOW_XDISPLAY (xtext->draw_buf);
-
-	xtext->font = backend_font_open_real (dis, name, FALSE);
-#ifdef ITALIC
-	xtext->ifont = backend_font_open_real (dis, name, TRUE);
-#endif
-}
-
-inline static int
-backend_get_char_width (GtkXText *xtext, unsigned char *str, int *mbl_ret)
-{
-	XGlyphInfo ext;
-
-	if (*str < 128)
-	{
-		*mbl_ret = 1;
-		return xtext->fontwidth[*str];
-	}
-
-	*mbl_ret = charlen (str);
-	XftTextExtentsUtf8 (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->font, str, *mbl_ret, &ext);
-
-	return ext.xOff;
-}
-
-static int
-backend_get_text_width (GtkXText *xtext, guchar *str, int len, int is_mb)
-{
-	XGlyphInfo ext;
-
-	if (!is_mb)
-		return gtk_xtext_text_width_8bit (xtext, str, len);
-
-	XftTextExtentsUtf8 (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->font, str, len, &ext);
-	return ext.xOff;
-}
-
-static void
-backend_draw_text (GtkXText *xtext, int dofill, GdkGC *gc, int x, int y,
-						 char *str, int len, int str_width, int is_mb)
-{
-	/*Display *xdisplay = GDK_WINDOW_XDISPLAY (xtext->draw_buf);*/
-	void (*draw_func) (XftDraw *, XftColor *, XftFont *, int, int, XftChar8 *, int) = (void *)XftDrawString8;
-	XftFont *font;
-
-	/* if all ascii, use String8 to avoid the conversion penalty */
-	if (is_mb)
-		draw_func = (void *)XftDrawStringUtf8;
-
-	if (dofill)
-	{
-/*		register GC xgc = GDK_GC_XGC (gc);
-		XSetForeground (xdisplay, xgc, xtext->xft_bg->pixel);
-		XFillRectangle (xdisplay, GDK_WINDOW_XWINDOW (xtext->draw_buf), xgc, x,
-							 y - xtext->font->ascent, str_width, xtext->fontsize);*/
-		XftDrawRect (xtext->xftdraw, xtext->xft_bg, x,
-						 y - xtext->font->ascent, str_width, xtext->fontsize);
-	}
-
-	font = xtext->font;
-#ifdef ITALIC
-	if (xtext->italics)
-		font = xtext->ifont;
-#endif
-
-	draw_func (xtext->xftdraw, xtext->xft_fg, font, x, y, str, len);
-
-	if (xtext->overdraw)
-		draw_func (xtext->xftdraw, xtext->xft_fg, font, x, y, str, len);
-
-	if (xtext->bold)
-		draw_func (xtext->xftdraw, xtext->xft_fg, font, x + 1, y, str, len);
-}
-
-/*static void
-backend_set_clip (GtkXText *xtext, GdkRectangle *area)
-{
-	gdk_gc_set_clip_rectangle (xtext->fgc, area);
-	gdk_gc_set_clip_rectangle (xtext->bgc, area);
-}
-
-static void
-backend_clear_clip (GtkXText *xtext)
-{
-	gdk_gc_set_clip_rectangle (xtext->fgc, NULL);
-	gdk_gc_set_clip_rectangle (xtext->bgc, NULL);
-}*/
-
-/*static void
-backend_set_clip (GtkXText *xtext, GdkRectangle *area)
-{
-	Region reg;
-	XRectangle rect;
-
-	rect.x = area->x;
-	rect.y = area->y;
-	rect.width = area->width;
-	rect.height = area->height;
-
-	reg = XCreateRegion ();
-	XUnionRectWithRegion (&rect, reg, reg);
-	XftDrawSetClip (xtext->xftdraw, reg);
-	XDestroyRegion (reg);
-
-	gdk_gc_set_clip_rectangle (xtext->fgc, area);
-}
-
-static void
-backend_clear_clip (GtkXText *xtext)
-{
-	XftDrawSetClip (xtext->xftdraw, NULL);
-	gdk_gc_set_clip_rectangle (xtext->fgc, NULL);
-}
-*/
-#else	/* !USE_XFT */
-
 /* ======================================= */
 /* ============ PANGO BACKEND ============ */
 /* ======================================= */
@@ -553,10 +327,7 @@ backend_get_char_width (GtkXText *xtext, unsigned char *str, int *mbl_ret)
 /* simplified version of gdk_draw_layout_line_with_colors() */
 
 static void 
-xtext_draw_layout_line (cairo_t          *cr,
-								gint              x, 
-								gint              y,
-								PangoLayoutLine  *line)
+xtext_draw_layout_line (cairo_t *cr, int x, int y, PangoLayoutLine  *line)
 {
 	cairo_save (cr);
 	cairo_move_to (cr, x, y);
@@ -565,16 +336,13 @@ xtext_draw_layout_line (cairo_t          *cr,
 }
 
 static void
-backend_draw_text (GtkXText *xtext, int dofill, GdkGC *gc, int x, int y,
+backend_draw_text (GtkXText *xtext, int dofill, int x, int y,
 						 char *str, int len, int str_width, int is_mb)
 {
-	GdkGCValues val;
-	GdkColor col;
 	PangoLayoutLine *line;
 	cairo_t *cr;
-	double colors[3];
 
-	cr = gdk_cairo_create (xtext->draw_buf);
+	cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
 
 #ifdef ITALIC
 	if (xtext->italics)
@@ -582,35 +350,18 @@ backend_draw_text (GtkXText *xtext, int dofill, GdkGC *gc, int x, int y,
 #endif
 
 	pango_layout_set_text (xtext->layout, str, len);
-	gdk_gc_get_values (gc, &val);
 
 	if (dofill)
 	{
-#ifdef WIN32
-		if (xtext->transparent && !xtext->backcolor)
-			win32_draw_bg (xtext, x, y - xtext->font->ascent, str_width,
-								xtext->fontsize);
-		else
-#endif
-		{
-			col.pixel = val.background.pixel;
-
-			xtext_draw_rectangle (xtext, cr, col.pixel, x, y -
-								  xtext->font->ascent, str_width, xtext->fontsize);
-
-		}
+		xtext_draw_rectangle (xtext, cr, &xtext->text_bg, x, y - xtext->font->ascent, 
+				str_width, xtext->fontsize);
 	}
 
-	col.pixel = val.foreground.pixel;
-	xtext_color_to_cairo (xtext, col.pixel, colors);
-	cairo_set_source_rgb (cr, colors[0], colors[1], colors[2]);
+    gdk_cairo_set_source_color (cr, &xtext->text_fg);
 	line = pango_layout_get_lines (xtext->layout)->data;
 
 	xtext_draw_layout_line (cr, x, y, line);
 
-	if (xtext->overdraw)
-		xtext_draw_layout_line (cr, x, y, line);
-
 	if (xtext->bold)
 		xtext_draw_layout_line (cr, x + 1, y, line);
 
@@ -622,59 +373,9 @@ backend_draw_text (GtkXText *xtext, int dofill, GdkGC *gc, int x, int y,
 	cairo_destroy (cr);
 }
 
-/*static void
-backend_set_clip (GtkXText *xtext, GdkRectangle *area)
-{
-	gdk_gc_set_clip_rectangle (xtext->fgc, area);
-	gdk_gc_set_clip_rectangle (xtext->bgc, area);
-}
-
-static void
-backend_clear_clip (GtkXText *xtext)
-{
-	gdk_gc_set_clip_rectangle (xtext->fgc, NULL);
-	gdk_gc_set_clip_rectangle (xtext->bgc, NULL);
-}*/
-
-#endif /* !USE_PANGO */
-
-static void
-xtext_set_fg (GtkXText *xtext, GdkGC *gc, int index)
-{
-	GdkColor col;
-
-	col.pixel = xtext->palette[index];
-	gdk_gc_set_foreground (gc, &col);
-
-#ifdef USE_XFT
-	if (gc == xtext->fgc)
-		xtext->xft_fg = &xtext->color[index];
-	else
-		xtext->xft_bg = &xtext->color[index];
-#endif
-}
-
-#ifdef USE_XFT
-
-#define xtext_set_bg(xt,gc,index) xt->xft_bg = &xt->color[index]
-
-#else
-
-static void
-xtext_set_bg (GtkXText *xtext, GdkGC *gc, int index)
-{
-	GdkColor col;
-
-	col.pixel = xtext->palette[index];
-	gdk_gc_set_background (gc, &col);
-}
-
-#endif
-
 static void
 gtk_xtext_init (GtkXText * xtext)
 {
-	xtext->pixmap = NULL;
 	xtext->io_tag = 0;
 	xtext->add_io_tag = 0;
 	xtext->scroll_tag = 0;
@@ -688,15 +389,9 @@ gtk_xtext_init (GtkXText * xtext)
 	xtext->italics = FALSE;
 	xtext->hidden = FALSE;
 	xtext->font = NULL;
-#ifdef USE_XFT
-	xtext->xftdraw = NULL;
-#else
 	xtext->layout = NULL;
-#endif
 	xtext->jump_out_offset = 0;
 	xtext->jump_in_offset = 0;
-	xtext->ts_x = 0;
-	xtext->ts_y = 0;
 	xtext->clip_x = 0;
 	xtext->clip_x2 = 1000000;
 	xtext->clip_y = 0;
@@ -711,8 +406,6 @@ gtk_xtext_init (GtkXText * xtext)
 	xtext->recycle = FALSE;
 	xtext->dont_render = FALSE;
 	xtext->dont_render2 = FALSE;
-	xtext->overdraw = FALSE;
-	xtext->tint_red = xtext->tint_green = xtext->tint_blue = TINT_VALUE;
 
 	xtext->adj = (GtkAdjustment *) gtk_adjustment_new (0, 0, 1, 1, 1, 1);
 	g_object_ref (G_OBJECT (xtext->adj));
@@ -733,34 +426,33 @@ gtk_xtext_init (GtkXText * xtext)
 		gtk_selection_add_targets (GTK_WIDGET (xtext), GDK_SELECTION_PRIMARY,
 											targets, n_targets);
 	}
-
-	if (getenv ("XCHAT_OVERDRAW"))
-		xtext->overdraw = TRUE;
 }
 
 static void
 gtk_xtext_adjustment_set (xtext_buffer *buf, int fire_signal)
 {
 	GtkAdjustment *adj = buf->xtext->adj;
+	GtkAllocation allocation;
+	int val;
 
 	if (buf->xtext->buffer == buf)
 	{
-		adj->lower = 0;
-		adj->upper = buf->num_lines;
+		gtk_adjustment_set_lower (adj, 0);
+		gtk_adjustment_set_upper (adj, buf->num_lines? buf->num_lines: 1);
+
+		gtk_widget_get_allocation (GTK_WIDGET(buf->xtext), &allocation);
 
-		if (adj->upper == 0)
-			adj->upper = 1;
+		gtk_adjustment_set_page_size (adj,
+			(allocation.height - buf->xtext->font->descent) / buf->xtext->fontsize);
+		gtk_adjustment_set_page_increment (adj, gtk_adjustment_get_page_size (adj));
 
-		adj->page_size =
-			(GTK_WIDGET (buf->xtext)->allocation.height -
-			 buf->xtext->font->descent) / buf->xtext->fontsize;
-		adj->page_increment = adj->page_size;
+		val = gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj);
 
-		if (adj->value > adj->upper - adj->page_size)
-			adj->value = adj->upper - adj->page_size;
+		if (gtk_adjustment_get_value (adj) > val)
+			gtk_adjustment_set_value (adj, val);
 
-		if (adj->value < 0)
-			adj->value = 0;
+		if (gtk_adjustment_get_value (adj) < 0)
+			gtk_adjustment_set_value (adj, 0);
 
 		if (fire_signal)
 			gtk_adjustment_changed (adj);
@@ -779,18 +471,18 @@ static void
 gtk_xtext_adjustment_changed (GtkAdjustment * adj, GtkXText * xtext)
 {
 #ifdef SMOOTH_SCROLL
-	if (xtext->buffer->old_value != xtext->adj->value)
+	if (xtext->buffer->old_value != gtk_adjustment_get_value (xtext->adj))
 #else
-	if ((int) xtext->buffer->old_value != (int) xtext->adj->value)
+	if ((int) xtext->buffer->old_value != (int) gtk_adjustment_get_value (xtext->adj))
 #endif
 	{
-		if (xtext->adj->value >= xtext->adj->upper - xtext->adj->page_size)
+		if (gtk_adjustment_get_value (xtext->adj) >= gtk_adjustment_get_upper (xtext->adj) - gtk_adjustment_get_page_size (xtext->adj))
 			xtext->buffer->scrollbar_down = TRUE;
 		else
 			xtext->buffer->scrollbar_down = FALSE;
 
-		if (xtext->adj->value + 1 == xtext->buffer->old_value ||
-			 xtext->adj->value - 1 == xtext->buffer->old_value)	/* clicked an arrow? */
+		if (gtk_adjustment_get_value (xtext->adj) + 1 == xtext->buffer->old_value ||
+			gtk_adjustment_get_value (xtext->adj) - 1 == xtext->buffer->old_value)	/* clicked an arrow? */
 		{
 			if (xtext->io_tag)
 			{
@@ -807,7 +499,7 @@ gtk_xtext_adjustment_changed (GtkAdjustment * adj, GtkXText * xtext)
 															xtext);
 		}
 	}
-	xtext->buffer->old_value = adj->value;
+	xtext->buffer->old_value = gtk_adjustment_get_value (adj);
 }
 
 GtkWidget *
@@ -822,14 +514,13 @@ gtk_xtext_new (GdkColor palette[], int separator)
 	xtext->orig_buffer = xtext->buffer;
 	xtext->alpha = 1.0;
 
-	gtk_widget_set_double_buffered (GTK_WIDGET (xtext), FALSE);
 	gtk_xtext_set_palette (xtext, palette);
 
 	return GTK_WIDGET (xtext);
 }
 
 static void
-gtk_xtext_destroy (GtkObject * object)
+gtk_xtext_destroy (GObject * object)
 {
 	GtkXText *xtext = GTK_XTEXT (object);
 
@@ -851,17 +542,6 @@ gtk_xtext_destroy (GtkObject * object)
 		xtext->io_tag = 0;
 	}
 
-	if (xtext->pixmap)
-	{
-#if defined(USE_XLIB) || defined(WIN32)
-		if (xtext->transparent)
-			gtk_xtext_free_trans (xtext);
-		else
-#endif
-			g_object_unref (xtext->pixmap);
-		xtext->pixmap = NULL;
-	}
-
 	if (xtext->font)
 	{
 		backend_font_close (xtext);
@@ -877,42 +557,6 @@ gtk_xtext_destroy (GtkObject * object)
 		xtext->adj = NULL;
 	}
 
-	if (xtext->bgc)
-	{
-		g_object_unref (xtext->bgc);
-		xtext->bgc = NULL;
-	}
-
-	if (xtext->fgc)
-	{
-		g_object_unref (xtext->fgc);
-		xtext->fgc = NULL;
-	}
-
-	if (xtext->light_gc)
-	{
-		g_object_unref (xtext->light_gc);
-		xtext->light_gc = NULL;
-	}
-
-	if (xtext->dark_gc)
-	{
-		g_object_unref (xtext->dark_gc);
-		xtext->dark_gc = NULL;
-	}
-
-	if (xtext->thin_gc)
-	{
-		g_object_unref (xtext->thin_gc);
-		xtext->thin_gc = NULL;
-	}
-
-	if (xtext->marker_gc)
-	{
-		g_object_unref (xtext->marker_gc);
-		xtext->marker_gc = NULL;
-	}
-
 	if (xtext->hand_cursor)
 	{
 		gdk_cursor_unref (xtext->hand_cursor);
@@ -931,8 +575,8 @@ gtk_xtext_destroy (GtkObject * object)
 		xtext->orig_buffer = NULL;
 	}
 
-	if (GTK_OBJECT_CLASS (parent_class)->destroy)
-		(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+	if (G_OBJECT_CLASS (parent_class)->dispose)
+		G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
 static void
@@ -941,7 +585,7 @@ gtk_xtext_unrealize (GtkWidget * widget)
 	backend_deinit (GTK_XTEXT (widget));
 
 	/* if there are still events in the queue, this'll avoid segfault */
-	gdk_window_set_user_data (widget->window, NULL);
+	gdk_window_set_user_data (gtk_widget_get_window (widget), NULL);
 
 	if (parent_class->unrealize)
 		(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
@@ -952,17 +596,18 @@ gtk_xtext_realize (GtkWidget * widget)
 {
 	GtkXText *xtext;
 	GdkWindowAttr attributes;
-	GdkGCValues val;
-	GdkColor col;
-	GdkColormap *cmap;
+	GdkWindow *w;
+	GtkAllocation allocation;
 
 	gtk_widget_set_realized (widget, TRUE);
 	xtext = GTK_XTEXT (widget);
 
-	attributes.x = widget->allocation.x;
-	attributes.y = widget->allocation.y;
-	attributes.width = widget->allocation.width;
-	attributes.height = widget->allocation.height;
+	gtk_widget_get_allocation (widget, &allocation);
+
+	attributes.x = allocation.x;
+	attributes.y = allocation.y;
+	attributes.width = allocation.width;
+	attributes.height = allocation.height;
 	attributes.wclass = GDK_INPUT_OUTPUT;
 	attributes.window_type = GDK_WINDOW_CHILD;
 	attributes.event_mask = gtk_widget_get_events (widget) |
@@ -973,88 +618,53 @@ gtk_xtext_realize (GtkWidget * widget)
 		| GDK_POINTER_MOTION_MASK;
 #endif
 
-	cmap = gtk_widget_get_colormap (widget);
-	attributes.colormap = cmap;
 	attributes.visual = gtk_widget_get_visual (widget);
 
-	widget->window = gdk_window_new (widget->parent->window, &attributes,
-					GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL |
-					GDK_WA_COLORMAP);
-
-	gdk_window_set_user_data (widget->window, widget);
-
-	xtext->depth = gdk_drawable_get_depth (widget->window);
+	w = gdk_window_new (gtk_widget_get_parent_window (widget), 
+			&attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL);
+	gtk_widget_set_window (widget, w);
 
-	val.subwindow_mode = GDK_INCLUDE_INFERIORS;
-	val.graphics_exposures = 0;
-
-	xtext->bgc = gdk_gc_new_with_values (widget->window, &val,
-						GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
-	xtext->fgc = gdk_gc_new_with_values (widget->window, &val,
-						GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
-	xtext->light_gc = gdk_gc_new_with_values (widget->window, &val,
-						GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
-	xtext->dark_gc = gdk_gc_new_with_values (widget->window, &val,
-						GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
-	xtext->thin_gc = gdk_gc_new_with_values (widget->window, &val,
-						GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
-	xtext->marker_gc = gdk_gc_new_with_values (widget->window, &val,
-						GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
+	gdk_window_set_user_data (w, widget);
 
 	/* for the separator bar (light) */
-	col.red = 0xffff; col.green = 0xffff; col.blue = 0xffff;
-	gdk_colormap_alloc_color (cmap, &col, FALSE, TRUE);
-	gdk_gc_set_foreground (xtext->light_gc, &col);
+	xtext->light_gc.red   = 0xffff; 
+    xtext->light_gc.green = 0xffff; 
+    xtext->light_gc.blue  = 0xffff;
 
 	/* for the separator bar (dark) */
-	col.red = 0x1111; col.green = 0x1111; col.blue = 0x1111;
-	gdk_colormap_alloc_color (cmap, &col, FALSE, TRUE);
-	gdk_gc_set_foreground (xtext->dark_gc, &col);
+	xtext->dark_gc.red    = 0x1111; 
+    xtext->dark_gc.green  = 0x1111; 
+    xtext->dark_gc.blue   = 0x1111;
 
 	/* for the separator bar (thinline) */
-	col.red = 0x8e38; col.green = 0x8e38; col.blue = 0x9f38;
-	gdk_colormap_alloc_color (cmap, &col, FALSE, TRUE);
-	gdk_gc_set_foreground (xtext->thin_gc, &col);
+	xtext->thin_gc.red    = 0x8e38; 
+    xtext->thin_gc.green  = 0x8e38; 
+    xtext->thin_gc.blue   = 0x9f38;
 
 	/* for the marker bar (marker) */
-	col.pixel = xtext->palette[XTEXT_MARKER];
-	gdk_gc_set_foreground (xtext->marker_gc, &col);
-
-	xtext_set_fg (xtext, xtext->fgc, XTEXT_FG);
-	xtext_set_bg (xtext, xtext->fgc, XTEXT_BG);
-	xtext_set_fg (xtext, xtext->bgc, XTEXT_BG);
+	xtext->marker_gc = xtext_palette_lookup (xtext, XTEXT_MARKER);
 
-	/* draw directly to window */
-	xtext->draw_buf = widget->window;
-
-#if defined(USE_XLIB) || defined(WIN32)
-	if (xtext->transparent)
-	{
-		gtk_xtext_load_trans (xtext);
-	} else
-#endif
-	if (xtext->pixmap)
-	{
-		gdk_gc_set_tile (xtext->bgc, xtext->pixmap);
-		gdk_gc_set_ts_origin (xtext->bgc, 0, 0);
-		xtext->ts_x = xtext->ts_y = 0;
-		gdk_gc_set_fill (xtext->bgc, GDK_TILED);
-	}
+    xtext->text_fg = xtext_palette_lookup (xtext, XTEXT_FG);
+    xtext->text_bg = xtext_palette_lookup (xtext, XTEXT_BG);
 
-	xtext->hand_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_HAND1);
-	xtext->resize_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_LEFT_SIDE);
+	xtext->hand_cursor = gdk_cursor_new_for_display (gdk_window_get_display (w), GDK_HAND1);
+	xtext->resize_cursor = gdk_cursor_new_for_display (gdk_window_get_display (w), GDK_LEFT_SIDE);
 
-	gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
-	widget->style = gtk_style_attach (widget->style, widget->window);
+	gtk_widget_set_style (widget, gtk_style_attach (gtk_widget_get_style (widget), w));
 
 	backend_init (xtext);
 }
 
 static void
-gtk_xtext_size_request (GtkWidget * widget, GtkRequisition * requisition)
+gtk_xtext_get_preferred_width (GtkWidget * widget, gint *minimal_width, gint *natural_width)
+{
+	*minimal_width = *natural_width = 200;
+}
+
+static void
+gtk_xtext_get_preferred_height (GtkWidget * widget, gint *minimal_height, gint *natural_height)
 {
-	requisition->width = 200;
-	requisition->height = 90;
+	*minimal_height = *natural_height = 90;
 }
 
 static void
@@ -1062,26 +672,19 @@ gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
 {
 	GtkXText *xtext = GTK_XTEXT (widget);
 	int height_only = FALSE;
-	int do_trans = TRUE;
 
 	if (allocation->width == xtext->buffer->window_width)
 		height_only = TRUE;
 
-	if (allocation->x == widget->allocation.x &&
-		 allocation->y == widget->allocation.y && xtext->avoid_trans)
-		do_trans = FALSE;
-
-	xtext->avoid_trans = FALSE;
-
-	widget->allocation = *allocation;
+	gtk_widget_set_allocation (widget, allocation);
 	if (gtk_widget_get_realized (widget))
 	{
 		xtext->buffer->window_width = allocation->width;
 		xtext->buffer->window_height = allocation->height;
 
-		gdk_window_move_resize (widget->window, allocation->x, allocation->y,
-										allocation->width, allocation->height);
-		dontscroll (xtext->buffer);	/* force scrolling off */
+		gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+			allocation->width, allocation->height);
+
 		if (!height_only)
 			gtk_xtext_calc_lines (xtext->buffer, FALSE);
 		else
@@ -1089,16 +692,9 @@ gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
 			xtext->buffer->pagetop_ent = NULL;
 			gtk_xtext_adjustment_set (xtext->buffer, FALSE);
 		}
-#if defined(USE_XLIB) || defined(WIN32)
-		if (do_trans && xtext->transparent && xtext->shaded)
-		{
-			gtk_xtext_free_trans (xtext);
-			gtk_xtext_load_trans (xtext);
-		}
-#endif
 		if (xtext->buffer->scrollbar_down)
-			gtk_adjustment_set_value (xtext->adj, xtext->adj->upper -
-											  xtext->adj->page_size);
+			gtk_adjustment_set_value (xtext->adj, gtk_adjustment_get_upper (xtext->adj) -
+				gtk_adjustment_get_page_size (xtext->adj));
 	}
 }
 
@@ -1209,7 +805,7 @@ gtk_xtext_find_x (GtkXText * xtext, int x, textentry * ent, int subline,
 	else
 		indent = xtext->buffer->indent;
 
-	if (line > xtext->adj->page_size || line < 0)
+	if (line > gtk_adjustment_get_page_size (xtext->adj) || line < 0)
 		return 0;
 
 	if (xtext->buffer->grid_dirty || line > 255)
@@ -1244,7 +840,7 @@ gtk_xtext_find_char (GtkXText * xtext, int x, int y, int *off,
 	int subline;
 
 	line = (y + xtext->pixel_offset) / xtext->fontsize;
-	ent = gtk_xtext_nth (xtext, line + (int)xtext->adj->value, &subline);
+	ent = gtk_xtext_nth (xtext, line + gtk_adjustment_get_value (xtext->adj), &subline);
 	if (!ent)
 		return 0;
 
@@ -1258,12 +854,15 @@ static void
 gtk_xtext_draw_sep (GtkXText * xtext, int y)
 {
 	int x, height;
-	GdkGC *light, *dark;
+	GdkColor *light, *dark;
+	GtkAllocation allocation;
+    cairo_t *cr;
 
 	if (y == -1)
 	{
 		y = 0;
-		height = GTK_WIDGET (xtext)->allocation.height;
+		gtk_widget_get_allocation (GTK_WIDGET (xtext), &allocation);
+		height = allocation.height;
 	} else
 	{
 		height = xtext->fontsize;
@@ -1272,31 +871,35 @@ gtk_xtext_draw_sep (GtkXText * xtext, int y)
 	/* draw the separator line */
 	if (xtext->separator && xtext->buffer->indent)
 	{
-		light = xtext->light_gc;
-		dark = xtext->dark_gc;
+        light = &xtext->light_gc;
+		dark = &xtext->dark_gc;
 
 		x = xtext->buffer->indent - ((xtext->space_width + 1) / 2);
 		if (x < 1)
 			return;
 
+		cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
+
 		if (xtext->thinline)
 		{
 			if (xtext->moving_separator)
-				gdk_draw_line (xtext->draw_buf, light, x, y, x, y + height);
+                xtext_draw_line (xtext, cr, light, x, y, x, y + height);
 			else
-				gdk_draw_line (xtext->draw_buf, xtext->thin_gc, x, y, x, y + height);
+                xtext_draw_line (xtext, cr, &xtext->thin_gc, x, y, x, y + height);
 		} else
 		{
 			if (xtext->moving_separator)
 			{
-				gdk_draw_line (xtext->draw_buf, light, x - 1, y, x - 1, y + height);
-				gdk_draw_line (xtext->draw_buf, dark, x, y, x, y + height);
+				xtext_draw_line (xtext, cr, light, x - 1, y, x - 1, y + height);
+				xtext_draw_line (xtext, cr, dark, x, y, x, y + height);
 			} else
 			{
-				gdk_draw_line (xtext->draw_buf, dark, x - 1, y, x - 1, y + height);
-				gdk_draw_line (xtext->draw_buf, light, x, y, x, y + height);
+				xtext_draw_line (xtext, cr, dark, x - 1, y, x - 1, y + height);
+				xtext_draw_line (xtext, cr, light, x, y, x, y + height);
 			}
 		}
+
+        cairo_destroy (cr);
 	}
 }
 
@@ -1304,6 +907,8 @@ static void
 gtk_xtext_draw_marker (GtkXText * xtext, textentry * ent, int y)
 {
 	int x, width, render_y;
+	GtkAllocation allocation;
+    cairo_t *cr;
 
 	if (!xtext->marker) return;
 
@@ -1317,112 +922,28 @@ gtk_xtext_draw_marker (GtkXText * xtext, textentry * ent, int y)
 	}
 	else return;
 
+	cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
+
+	gtk_widget_get_allocation (GTK_WIDGET(xtext), &allocation);
+
 	x = 0;
-	width = GTK_WIDGET (xtext)->allocation.width;
+	width = allocation.width;
 
-	gdk_draw_line (xtext->draw_buf, xtext->marker_gc, x, render_y, x + width, render_y);
+	xtext_draw_line (xtext, cr, &xtext->marker_gc, x, render_y, x + width, render_y);
 
 	if (gtk_window_has_toplevel_focus (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (xtext)))))
 	{
 		xtext->buffer->marker_seen = TRUE;
 	}
-}
-
-static void
-gtk_xtext_paint (GtkWidget *widget, GdkRectangle *area)
-{
-	GtkXText *xtext = GTK_XTEXT (widget);
-	textentry *ent_start, *ent_end;
-	int x, y;
-
-#if defined(USE_XLIB) || defined(WIN32)
-	if (xtext->transparent)
-	{
-		gdk_window_get_origin (widget->window, &x, &y);
-		/* update transparency only if it moved */
-		if (xtext->last_win_x != x || xtext->last_win_y != y)
-		{
-			xtext->last_win_x = x;
-			xtext->last_win_y = y;
-#if !defined(USE_SHM) && !defined(WIN32)
-			if (xtext->shaded)
-			{
-				xtext->recycle = TRUE;
-				gtk_xtext_load_trans (xtext);
-				xtext->recycle = FALSE;
-			} else
-#endif
-			{
-				gtk_xtext_free_trans (xtext);
-				gtk_xtext_load_trans (xtext);
-			}
-		}
-	}
-#endif
-
-	if (area->x == 0 && area->y == 0 &&
-		 area->height == widget->allocation.height &&
-		 area->width == widget->allocation.width)
-	{
-		dontscroll (xtext->buffer);	/* force scrolling off */
-		gtk_xtext_render_page (xtext);
-		return;
-	}
-
-	ent_start = gtk_xtext_find_char (xtext, area->x, area->y, NULL, NULL);
-	if (!ent_start)
-	{
-		xtext_draw_bg (xtext, area->x, area->y, area->width, area->height);
-		goto xit;
-	}
-	ent_end = gtk_xtext_find_char (xtext, area->x + area->width,
-											 area->y + area->height, NULL, NULL);
-	if (!ent_end)
-		ent_end = xtext->buffer->text_last;
-
-	/* can't set a clip here, because fgc/bgc are used to draw the DB too */
-/*	backend_set_clip (xtext, area);*/
-	xtext->clip_x = area->x;
-	xtext->clip_x2 = area->x + area->width;
-	xtext->clip_y = area->y;
-	xtext->clip_y2 = area->y + area->height;
-
-	/* y is the last pixel y location it rendered text at */
-	y = gtk_xtext_render_ents (xtext, ent_start, ent_end);
-
-	if (y && y < widget->allocation.height && !ent_end->next)
-	{
-		GdkRectangle rect;
-
-		rect.x = 0;
-		rect.y = y;
-		rect.width = widget->allocation.width;
-		rect.height = widget->allocation.height - y;
-
-		/* fill any space below the last line that also intersects with
-			the exposure rectangle */
-		if (gdk_rectangle_intersect (area, &rect, &rect))
-		{
-			xtext_draw_bg (xtext, rect.x, rect.y, rect.width, rect.height);
-		}
-	}
-
-	/*backend_clear_clip (xtext);*/
-	xtext->clip_x = 0;
-	xtext->clip_x2 = 1000000;
-	xtext->clip_y = 0;
-	xtext->clip_y2 = 1000000;
 
-xit:
-	x = xtext->buffer->indent - ((xtext->space_width + 1) / 2);
-	if (area->x <= x)
-		gtk_xtext_draw_sep (xtext, -1);
+    cairo_destroy (cr);
 }
 
 static gboolean
-gtk_xtext_expose (GtkWidget * widget, GdkEventExpose * event)
+gtk_xtext_draw (GtkWidget * widget, cairo_t *cr)
 {
-	gtk_xtext_paint (widget, &event->area);
+	gtk_xtext_render_page (GTK_XTEXT (widget));
+
 	return FALSE;
 }
 
@@ -1644,7 +1165,7 @@ gtk_xtext_selection_draw (GtkXText * xtext, GdkEventMotion * event, gboolean ren
 	ent_start = gtk_xtext_find_char (xtext, low_x, low_y, &offset_start, &tmp);
 	if (!ent_start)
 	{
-		if (xtext->adj->value != xtext->buffer->old_value)
+		if (gtk_adjustment_get_value (xtext->adj) != xtext->buffer->old_value)
 			gtk_xtext_render_page (xtext);
 		return;
 	}
@@ -1655,7 +1176,7 @@ gtk_xtext_selection_draw (GtkXText * xtext, GdkEventMotion * event, gboolean ren
 		ent_end = xtext->buffer->text_last;
 		if (!ent_end)
 		{
-			if (xtext->adj->value != xtext->buffer->old_value)
+			if (gtk_adjustment_get_value (xtext->adj) != xtext->buffer->old_value)
 				gtk_xtext_render_page (xtext);
 			return;
 		}
@@ -1712,13 +1233,12 @@ gtk_xtext_scrolldown_timeout (GtkXText * xtext)
 {
 	int p_y, win_height;
 
-	gdk_window_get_pointer (GTK_WIDGET (xtext)->window, 0, &p_y, 0);
-	win_height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+	gdk_window_get_pointer (gtk_widget_get_window (GTK_WIDGET(xtext)), 0, &p_y, 0);
+	win_height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(xtext)));
 
-	if (p_y > win_height &&
-		 xtext->adj->value < (xtext->adj->upper - xtext->adj->page_size))
+	if (p_y > win_height && gtk_adjustment_get_value (xtext->adj) < (gtk_adjustment_get_upper (xtext->adj) - gtk_adjustment_get_page_size (xtext->adj)))
 	{
-		xtext->adj->value++;
+		gtk_adjustment_set_value (xtext->adj, gtk_adjustment_get_value (xtext->adj) + 1);
 		gtk_adjustment_changed (xtext->adj);
 		gtk_xtext_render_page (xtext);
 		return 1;
@@ -1733,11 +1253,11 @@ gtk_xtext_scrollup_timeout (GtkXText * xtext)
 {
 	int p_y;
 
-	gdk_window_get_pointer (GTK_WIDGET (xtext)->window, 0, &p_y, 0);
+	gdk_window_get_pointer (gtk_widget_get_window (GTK_WIDGET(xtext)), 0, &p_y, 0);
 
-	if (p_y < 0 && xtext->adj->value > 0.0)
+	if (p_y < 0 && gtk_adjustment_get_value (xtext->adj) > 0.0)
 	{
-		xtext->adj->value--;
+		gtk_adjustment_set_value (xtext->adj, gtk_adjustment_get_value (xtext->adj) - 1);
 		gtk_adjustment_changed (xtext->adj);
 		gtk_xtext_render_page (xtext);
 		return 1;
@@ -1753,22 +1273,22 @@ gtk_xtext_selection_update (GtkXText * xtext, GdkEventMotion * event, int p_y, g
 	int win_height;
 	int moved;
 
-	win_height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+	win_height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(xtext)));
 
 	/* selecting past top of window, scroll up! */
-	if (p_y < 0 && xtext->adj->value >= 0)
+	if (p_y < 0 && gtk_adjustment_get_value (xtext->adj) >= 0)
 	{
 		if (!xtext->scroll_tag)
 			xtext->scroll_tag = g_timeout_add (100,
 															(GSourceFunc)
-														 	gtk_xtext_scrollup_timeout,
+															gtk_xtext_scrollup_timeout,
 															xtext);
 		return;
 	}
 
 	/* selecting past bottom of window, scroll down! */
 	if (p_y > win_height &&
-		 xtext->adj->value < (xtext->adj->upper - xtext->adj->page_size))
+		 gtk_adjustment_get_value (xtext->adj) < (gtk_adjustment_get_upper (xtext->adj) - gtk_adjustment_get_page_size (xtext->adj)))
 	{
 		if (!xtext->scroll_tag)
 			xtext->scroll_tag = g_timeout_add (100,
@@ -1778,9 +1298,9 @@ gtk_xtext_selection_update (GtkXText * xtext, GdkEventMotion * event, int p_y, g
 		return;
 	}
 
-	moved = (int)xtext->adj->value - xtext->select_start_adj;
+	moved = gtk_adjustment_get_value (xtext->adj) - xtext->select_start_adj;
 	xtext->select_start_y -= (moved * xtext->fontsize);
-	xtext->select_start_adj = xtext->adj->value;
+	xtext->select_start_adj = gtk_adjustment_get_value (xtext->adj);
 	gtk_xtext_selection_draw (xtext, event, render);
 }
 
@@ -1869,7 +1389,7 @@ gtk_xtext_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
 		xtext->hilight_start = -1;
 		xtext->hilight_end = -1;
 		xtext->cursor_hand = FALSE;
-		gdk_window_set_cursor (widget->window, 0);
+		gdk_window_set_cursor (gtk_widget_get_window (widget), 0);
 		xtext->hilight_ent = NULL;
 	}
 
@@ -1879,7 +1399,7 @@ gtk_xtext_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
 		xtext->hilight_start = -1;
 		xtext->hilight_end = -1;
 		xtext->cursor_resize = FALSE;
-		gdk_window_set_cursor (widget->window, 0);
+		gdk_window_set_cursor (gtk_widget_get_window (widget), 0);
 		xtext->hilight_ent = NULL;
 	}
 
@@ -1918,15 +1438,18 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
 {
 	GtkXText *xtext = GTK_XTEXT (widget);
 	GdkModifierType mask;
+	GtkAllocation allocation;
 	int redraw, tmp, x, y, offset, len, line_x;
 	char *word;
 	textentry *word_ent;
 
-	gdk_window_get_pointer (widget->window, &x, &y, &mask);
+	gdk_window_get_pointer (gtk_widget_get_window (widget), &x, &y, &mask);
+
+	gtk_widget_get_allocation (widget, &allocation);
 
 	if (xtext->moving_separator)
 	{
-		if (x < (3 * widget->allocation.width) / 5 && x > 15)
+		if (x < (3 * allocation.width) / 5 && x > 15)
 		{
 			tmp = xtext->buffer->indent;
 			xtext->buffer->indent = x;
@@ -1935,8 +1458,8 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
 			{
 				gtk_xtext_recalc_widths (xtext->buffer, FALSE);
 				if (xtext->buffer->scrollbar_down)
-					gtk_adjustment_set_value (xtext->adj, xtext->adj->upper -
-													  xtext->adj->page_size);
+					gtk_adjustment_set_value (xtext->adj, gtk_adjustment_get_upper (xtext->adj) -
+													  gtk_adjustment_get_page_size (xtext->adj));
 				if (!xtext->io_tag)
 					xtext->io_tag = g_timeout_add (REFRESH_TIMEOUT,
 																(GSourceFunc)
@@ -1951,7 +1474,7 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
 	{
 		redraw = gtk_xtext_check_mark_stamp (xtext, mask);
 		gtk_grab_add (widget);
-		/*gdk_pointer_grab (widget->window, TRUE,
+		/*gdk_pointer_grab (gtk_widget_get_window (widget), TRUE,
 									GDK_BUTTON_RELEASE_MASK |
 									GDK_BUTTON_MOTION_MASK, NULL, NULL, 0);*/
 		xtext->select_end_x = x;
@@ -1978,8 +1501,7 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
 		{
 			if (!xtext->cursor_resize)
 			{
-				gdk_window_set_cursor (GTK_WIDGET (xtext)->window,
-										  		xtext->resize_cursor);
+				gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(xtext)), xtext->resize_cursor);
 				xtext->cursor_resize = TRUE;
 			}
 			return FALSE;
@@ -1992,7 +1514,7 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
 	word = gtk_xtext_get_word (xtext, x, y, &word_ent, &offset, &len);
 
 	if (!word || (xtext->current_word != NULL &&
-	              strcmp (word, xtext->current_word) != 0)) {
+				  strcmp (word, xtext->current_word) != 0)) {
 		if (xtext->current_word) {
 			g_signal_emit (G_OBJECT (xtext), xtext_signals[WORD_LEAVE], 0, xtext->current_word);
 			g_free (xtext->current_word);
@@ -2011,8 +1533,7 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
 			{
 				if (!xtext->cursor_hand)
 				{
-					gdk_window_set_cursor (GTK_WIDGET (xtext)->window,
-											  		xtext->hand_cursor);
+					gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(xtext)), xtext->hand_cursor);
 					xtext->cursor_hand = TRUE;
 				}
 
@@ -2036,7 +1557,7 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
 			}
 
 			if (!xtext->current_word ||
-			    strcmp (word, xtext->current_word) != 0) {
+				strcmp (word, xtext->current_word) != 0) {
 				xtext->current_word = g_strdup (word);
 				g_signal_emit (G_OBJECT (xtext), xtext_signals[WORD_ENTER], 0, xtext->current_word);
 			}
@@ -2109,14 +1630,17 @@ static gboolean
 gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event)
 {
 	GtkXText *xtext = GTK_XTEXT (widget);
+	GtkAllocation allocation;
 	char *word;
 	int old;
 
+	gtk_widget_get_allocation (widget, &allocation);
+
 	if (xtext->moving_separator)
 	{
 		xtext->moving_separator = FALSE;
 		old = xtext->buffer->indent;
-		if (event->x < (4 * widget->allocation.width) / 5 && event->x > 15)
+		if (event->x < (4 * allocation.width) / 5 && event->x > 15)
 			xtext->buffer->indent = event->x;
 		gtk_xtext_fix_indent (xtext->buffer);
 		if (xtext->buffer->indent != old)
@@ -2164,7 +1688,6 @@ gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event)
 		}
 	}
 
-
 	return FALSE;
 }
 
@@ -2177,7 +1700,7 @@ gtk_xtext_button_press (GtkWidget * widget, GdkEventButton * event)
 	char *word;
 	int line_x, x, y, offset, len;
 
-	gdk_window_get_pointer (widget->window, &x, &y, &mask);
+	gdk_window_get_pointer (gtk_widget_get_window (widget), &x, &y, &mask);
 
 	if (event->button == 3 || event->button == 2) /* right/middle click */
 	{
@@ -2245,7 +1768,7 @@ gtk_xtext_button_press (GtkWidget * widget, GdkEventButton * event)
 	xtext->button_down = TRUE;
 	xtext->select_start_x = x;
 	xtext->select_start_y = y;
-	xtext->select_start_adj = xtext->adj->value;
+	xtext->select_start_adj = gtk_adjustment_get_value (xtext->adj);
 
 	return TRUE;
 }
@@ -2255,10 +1778,8 @@ gtk_xtext_button_press (GtkWidget * widget, GdkEventButton * event)
 static gboolean
 gtk_xtext_selection_kill (GtkXText *xtext, GdkEventSelection *event)
 {
-#ifndef WIN32
 	if (xtext->buffer->last_ent_start)
 		gtk_xtext_unselect (xtext);
-#endif
 	return TRUE;
 }
 
@@ -2383,17 +1904,19 @@ gtk_xtext_selection_get (GtkWidget * widget,
 	case TARGET_TEXT:
 	case TARGET_COMPOUND_TEXT:
 		{
+#if 0
 			GdkAtom encoding;
 			gint format;
 			gint new_length;
 
- 			gdk_string_to_compound_text_for_display (
-							gdk_window_get_display (widget->window),
+			gdk_string_to_compound_text_for_display (
+							gdk_window_get_display (gtk_widget_get_window (widget)),
 							stripped, &encoding, &format, &new_text,
 							&new_length);
 			gtk_selection_data_set (selection_data_ptr, encoding, format,
 						new_text, new_length);
 			gdk_free_compound_text (new_text);
+#endif
 		}
 		break;
 	default:
@@ -2414,16 +1937,16 @@ gtk_xtext_scroll (GtkWidget *widget, GdkEventScroll *event)
 
 	if (event->direction == GDK_SCROLL_UP)		/* mouse wheel pageUp */
 	{
-		new_value = xtext->adj->value - (xtext->adj->page_increment / 10);
-		if (new_value < xtext->adj->lower)
-			new_value = xtext->adj->lower;
+		new_value = gtk_adjustment_get_value (xtext->adj) - (gtk_adjustment_get_page_increment (xtext->adj) / 10);
+		if (new_value < gtk_adjustment_get_lower (xtext->adj))
+			new_value = gtk_adjustment_get_lower (xtext->adj);
 		gtk_adjustment_set_value (xtext->adj, new_value);
 	}
 	else if (event->direction == GDK_SCROLL_DOWN)	/* mouse wheel pageDn */
 	{
-		new_value = xtext->adj->value + (xtext->adj->page_increment / 10);
-		if (new_value > (xtext->adj->upper - xtext->adj->page_size))
-			new_value = xtext->adj->upper - xtext->adj->page_size;
+		new_value = gtk_adjustment_get_value (xtext->adj) + (gtk_adjustment_get_page_increment (xtext->adj) / 10);
+		if (new_value > (gtk_adjustment_get_upper (xtext->adj) - gtk_adjustment_get_page_size (xtext->adj)))
+			new_value = gtk_adjustment_get_upper (xtext->adj) - gtk_adjustment_get_page_size (xtext->adj);
 		gtk_adjustment_set_value (xtext->adj, new_value);
 	}
 
@@ -2433,11 +1956,9 @@ gtk_xtext_scroll (GtkWidget *widget, GdkEventScroll *event)
 static void
 gtk_xtext_class_init (GtkXTextClass * class)
 {
-	GtkObjectClass *object_class;
 	GtkWidgetClass *widget_class;
 	GtkXTextClass *xtext_class;
 
-	object_class = (GtkObjectClass *) class;
 	widget_class = (GtkWidgetClass *) class;
 	xtext_class = (GtkXTextClass *) class;
 
@@ -2445,7 +1966,7 @@ gtk_xtext_class_init (GtkXTextClass * class)
 
 	xtext_signals[WORD_CLICK] =
 		g_signal_new ("word_click",
-							G_TYPE_FROM_CLASS (object_class),
+							G_TYPE_FROM_CLASS (widget_class),
 							G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
 							G_STRUCT_OFFSET (GtkXTextClass, word_click),
 							NULL, NULL,
@@ -2454,34 +1975,35 @@ gtk_xtext_class_init (GtkXTextClass * class)
 							2, G_TYPE_POINTER, G_TYPE_POINTER);
 	xtext_signals[WORD_ENTER] =
 		g_signal_new ("word_enter",
-		              G_TYPE_FROM_CLASS (object_class),
-		              G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
-		              G_STRUCT_OFFSET (GtkXTextClass, word_enter),
-		              NULL, NULL,
-		              xg_marshal_VOID__POINTER,
-		              G_TYPE_NONE,
-		              1, G_TYPE_POINTER);
+					  G_TYPE_FROM_CLASS (widget_class),
+					  G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+					  G_STRUCT_OFFSET (GtkXTextClass, word_enter),
+					  NULL, NULL,
+					  xg_marshal_VOID__POINTER,
+					  G_TYPE_NONE,
+					  1, G_TYPE_POINTER);
 	xtext_signals[WORD_LEAVE] =
 		g_signal_new ("word_leave",
-		              G_TYPE_FROM_CLASS (object_class),
-		              G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
-		              G_STRUCT_OFFSET (GtkXTextClass, word_leave),
-		              NULL, NULL,
-		              xg_marshal_VOID__POINTER,
-		              G_TYPE_NONE,
-		              1, G_TYPE_POINTER);
-	object_class->destroy = gtk_xtext_destroy;
+					  G_TYPE_FROM_CLASS (widget_class),
+					  G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+					  G_STRUCT_OFFSET (GtkXTextClass, word_leave),
+					  NULL, NULL,
+					  xg_marshal_VOID__POINTER,
+					  G_TYPE_NONE,
+					  1, G_TYPE_POINTER);
+	widget_class->destroy = gtk_xtext_destroy;
 
 	widget_class->realize = gtk_xtext_realize;
 	widget_class->unrealize = gtk_xtext_unrealize;
-	widget_class->size_request = gtk_xtext_size_request;
+	widget_class->get_preferred_width = gtk_xtext_get_preferred_width;
+	widget_class->get_preferred_height = gtk_xtext_get_preferred_height;
 	widget_class->size_allocate = gtk_xtext_size_allocate;
 	widget_class->button_press_event = gtk_xtext_button_press;
 	widget_class->button_release_event = gtk_xtext_button_release;
 	widget_class->motion_notify_event = gtk_xtext_motion_notify;
 	widget_class->selection_clear_event = (void *)gtk_xtext_selection_kill;
 	widget_class->selection_get = gtk_xtext_selection_get;
-	widget_class->expose_event = gtk_xtext_expose;
+	widget_class->draw = gtk_xtext_draw;
 	widget_class->scroll_event = gtk_xtext_scroll;
 #ifdef MOTION_MONITOR
 	widget_class->leave_notify_event = gtk_xtext_leave_notify;
@@ -2609,11 +2131,11 @@ gtk_xtext_text_width (GtkXText *xtext, unsigned char *text, int len,
 
 static int
 gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str,
-								int len, GdkGC *gc, int is_mb)
+								int len, int is_mb)
 {
 	int str_width, dofill;
-	GdkDrawable *pix = NULL;
 	int dest_x, dest_y;
+    cairo_t *cr;
 
 	dest_x = dest_y = 0;
 
@@ -2641,101 +2163,24 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str,
 #endif
 	}
 
-#ifdef USE_DB
-#ifdef WIN32
-	if (!xtext->transparent)
-#endif
-	{
-		pix = gdk_pixmap_new (xtext->draw_buf, str_width, xtext->fontsize, xtext->depth);
-		if (pix)
-		{
-#ifdef USE_XFT
-			XftDrawChange (xtext->xftdraw, GDK_WINDOW_XWINDOW (pix));
-#endif
-			dest_x = x;
-			dest_y = y - xtext->font->ascent;
-
-			gdk_gc_set_ts_origin (xtext->bgc, xtext->ts_x - x, xtext->ts_y - dest_y);
-
-			x = 0;
-			y = xtext->font->ascent;
-			xtext->draw_buf = pix;
-		}
-	}
-#endif
-
 	dofill = TRUE;
 
-	/* backcolor is always handled by XDrawImageString */
-	if (!xtext->backcolor && xtext->pixmap)
-	{
-	/* draw the background pixmap behind the text - CAUSES FLICKER HERE!! */
-		xtext_draw_bg (xtext, x, y - xtext->font->ascent, str_width,
-							xtext->fontsize);
-		dofill = FALSE;	/* already drawn the background */
-	}
-
-	backend_draw_text (xtext, dofill, gc, x, y, (char *) str, len, str_width, is_mb);
-
-#ifdef USE_DB
-	if (pix)
-	{
-		GdkRectangle clip;
-		GdkRectangle dest;
-
-		gdk_gc_set_ts_origin (xtext->bgc, xtext->ts_x, xtext->ts_y);
-		xtext->draw_buf = GTK_WIDGET (xtext)->window;
-#ifdef USE_XFT
-		XftDrawChange (xtext->xftdraw, GDK_WINDOW_XWINDOW (xtext->draw_buf));
-#endif
-#if 0
-		gdk_draw_drawable (xtext->draw_buf, xtext->bgc, pix, 0, 0, dest_x,
-								 dest_y, str_width, xtext->fontsize);
-#else
-		clip.x = xtext->clip_x;
-		clip.y = xtext->clip_y;
-		clip.width = xtext->clip_x2 - xtext->clip_x;
-		clip.height = xtext->clip_y2 - xtext->clip_y;
-
-		dest.x = dest_x;
-		dest.y = dest_y;
-		dest.width = str_width;
-		dest.height = xtext->fontsize;
-
-		if (gdk_rectangle_intersect (&clip, &dest, &dest))
-			/* dump the DB to window, but only within the clip_x/x2/y/y2 */
-			gdk_draw_drawable (xtext->draw_buf, xtext->bgc, pix,
-									 dest.x - dest_x, dest.y - dest_y,
-									 dest.x, dest.y, dest.width, dest.height);
-#endif
-		g_object_unref (pix);
-	}
-#endif
+	backend_draw_text (xtext, dofill, x, y, (char *) str, len, str_width, is_mb);
 
 	if (xtext->underline)
 	{
-#ifdef USE_XFT
-		GdkColor col;
-#endif
-
 #ifndef COLOR_HILIGHT
 dounder:
 #endif
+		y++;
+		dest_x = x;
 
-#ifdef USE_XFT
-		col.pixel = xtext->xft_fg->pixel;
-		gdk_gc_set_foreground (gc, &col);
-#endif
-		if (pix)
-			y = dest_y + xtext->font->ascent + 1;
-		else
-		{
-			y++;
-			dest_x = x;
-		}
-		/* draw directly to window, it's out of the range of our DB */
-		gdk_draw_line (xtext->draw_buf, gc, dest_x, y, dest_x + str_width - 1, y);
-	}
+        /* The cairo_t context has to be created here due to spaghetti-goto jump */
+		cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
+        xtext_draw_line (xtext, cr, &xtext->text_fg, 
+                dest_x + 1, y + 1, dest_x + str_width - 1, y + 1);
+        cairo_destroy (cr);
+    }
 
 	return str_width;
 }
@@ -2754,9 +2199,9 @@ gtk_xtext_reset (GtkXText * xtext, int mark, int attribs)
 	{
 		xtext->backcolor = FALSE;
 		if (xtext->col_fore != XTEXT_FG)
-			xtext_set_fg (xtext, xtext->fgc, XTEXT_FG);
+            xtext->text_fg = xtext_palette_lookup (xtext, XTEXT_FG);
 		if (xtext->col_back != XTEXT_BG)
-			xtext_set_bg (xtext, xtext->fgc, XTEXT_BG);
+            xtext->text_bg = xtext_palette_lookup (xtext, XTEXT_BG);
 	}
 	xtext->col_fore = XTEXT_FG;
 	xtext->col_back = XTEXT_BG;
@@ -2772,7 +2217,6 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 							 unsigned char *str, int len, int win_width, int indent,
 							 int line, int left_only, int *x_size_ret)
 {
-	GdkGC *gc;
 	int i = 0, x = indent, j = 0;
 	unsigned char *pstr = str;
 	int col_num, tmp;
@@ -2787,13 +2231,11 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 	if (line < 255 && line >= 0)
 		xtext->buffer->grid_offset[line] = offset;
 
-	gc = xtext->fgc;				  /* our foreground GC */
-
 	if (ent->mark_start != -1 &&
 		 ent->mark_start <= i + offset && ent->mark_end > i + offset)
 	{
-		xtext_set_bg (xtext, gc, XTEXT_MARK_BG);
-		xtext_set_fg (xtext, gc, XTEXT_MARK_FG);
+        xtext->text_bg = xtext_palette_lookup (xtext, XTEXT_MARK_BG);
+        xtext->text_fg = xtext_palette_lookup (xtext, XTEXT_MARK_FG);
 		xtext->backcolor = TRUE;
 		mark = TRUE;
 	}
@@ -2804,7 +2246,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 		if (!xtext->un_hilight)
 		{
 #ifdef COLOR_HILIGHT
-			xtext_set_bg (xtext, gc, 2);
+            xtext->text_bg = xtext_palette_lookup (xtext, 2);
 #else
 			xtext->underline = TRUE;
 #endif
@@ -2844,13 +2286,13 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 #ifdef MOTION_MONITOR
 		if (xtext->hilight_ent == ent && xtext->hilight_start == (i + offset))
 		{
-			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 			pstr += j;
 			j = 0;
 			if (!xtext->un_hilight)
 			{
 #ifdef COLOR_HILIGHT
-				xtext_set_bg (xtext, gc, 2);
+                xtext->text_bg = xtext_palette_lookup (xtext, 2); 
 #else
 				xtext->underline = TRUE;
 #endif
@@ -2878,7 +2320,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 						col_num = col_num % XTEXT_MIRC_COLS;
 					xtext->col_fore = col_num;
 					if (!mark)
-						xtext_set_fg (xtext, gc, col_num);
+                        xtext->text_fg = xtext_palette_lookup (xtext, col_num);
 				}
 			} else
 			{
@@ -2907,7 +2349,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 						else
 							xtext->backcolor = TRUE;
 						if (!mark)
-							xtext_set_bg (xtext, gc, col_num);
+                            xtext->text_bg = xtext_palette_lookup (xtext, col_num);
 						xtext->col_back = col_num;
 					} else
 					{
@@ -2916,14 +2358,14 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 						else
 							col_num = col_num % XTEXT_MIRC_COLS;
 						if (!mark)
-							xtext_set_fg (xtext, gc, col_num);
+                            xtext->text_fg = xtext_palette_lookup (xtext, col_num);
 						xtext->col_fore = col_num;
 					}
 					xtext->parsing_backcolor = FALSE;
 				} else
 				{
 					/* got a \003<non-digit>... i.e. reset colors */
-					x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+					x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 					pstr += j;
 					j = 0;
 					gtk_xtext_reset (xtext, mark, FALSE);
@@ -2936,7 +2378,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 			/*case ATTR_BEEP:*/
 				break;
 			case ATTR_REVERSE:
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				pstr += j + 1;
 				j = 0;
 				tmp = xtext->col_fore;
@@ -2944,8 +2386,8 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 				xtext->col_back = tmp;
 				if (!mark)
 				{
-					xtext_set_fg (xtext, gc, xtext->col_fore);
-					xtext_set_bg (xtext, gc, xtext->col_back);
+                    xtext->text_fg = xtext_palette_lookup (xtext, xtext->col_fore);
+                    xtext->text_bg = xtext_palette_lookup (xtext, xtext->col_back);
 				}
 				if (xtext->col_back != XTEXT_BG)
 					xtext->backcolor = TRUE;
@@ -2953,37 +2395,37 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 					xtext->backcolor = FALSE;
 				break;
 			case ATTR_BOLD:
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				xtext->bold = !xtext->bold;
 				pstr += j + 1;
 				j = 0;
 				break;
 			case ATTR_UNDERLINE:
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				xtext->underline = !xtext->underline;
 				pstr += j + 1;
 				j = 0;
 				break;
 			case ATTR_ITALICS:
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				xtext->italics = !xtext->italics;
 				pstr += j + 1;
 				j = 0;
 				break;
 			case ATTR_HIDDEN:
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				xtext->hidden = (!xtext->hidden) & (!xtext->ignore_hidden);
 				pstr += j + 1;
 				j = 0;
 				break;
 			case ATTR_RESET:
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				pstr += j + 1;
 				j = 0;
 				gtk_xtext_reset (xtext, mark, !xtext->in_hilight);
 				break;
 			case ATTR_COLOR:
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				xtext->parsing_color = TRUE;
 				pstr += j + 1;
 				j = 0;
@@ -3010,13 +2452,13 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 			/* we've reached the end of the left part? */
 			if ((pstr-str)+j == ent->left_len)
 			{
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				pstr += j;
 				j = 0;
 			}
 			else if ((pstr-str)+j == ent->left_len+1)
 			{
-				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+				x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 				pstr += j;
 				j = 0;
 			}
@@ -3025,7 +2467,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 		/* have we been told to stop rendering at this point? */
 		if (xtext->jump_out_offset > 0 && xtext->jump_out_offset <= (i + offset))
 		{
-			gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+			gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 			ret = 0;	/* skip the rest of the lines, we're done. */
 			j = 0;
 			break;
@@ -3033,7 +2475,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 
 		if (xtext->jump_in_offset > 0 && xtext->jump_in_offset == (i + offset))
 		{
-			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 			pstr += j;
 			j = 0;
 			xtext->dont_render2 = FALSE;
@@ -3042,17 +2484,17 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 #ifdef MOTION_MONITOR
 		if (xtext->hilight_ent == ent && xtext->hilight_end == (i + offset))
 		{
-			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 			pstr += j;
 			j = 0;
 #ifdef COLOR_HILIGHT
 			if (mark)
 			{
-				xtext_set_bg (xtext, gc, XTEXT_MARK_BG);
+                xtext->text_bg = xtext_palette_lookup (xtext, XTEXT_MARK_BG);
 				xtext->backcolor = TRUE;
 			} else
 			{
-				xtext_set_bg (xtext, gc, xtext->col_back);
+                xtext->text_bg = xtext_palette_lookup (xtext, xtext->col_back);
 				if (xtext->col_back != XTEXT_BG)
 					xtext->backcolor = TRUE;
 				else
@@ -3073,22 +2515,22 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 
 		if (!mark && ent->mark_start == (i + offset))
 		{
-			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 			pstr += j;
 			j = 0;
-			xtext_set_bg (xtext, gc, XTEXT_MARK_BG);
-			xtext_set_fg (xtext, gc, XTEXT_MARK_FG);
+            xtext->text_bg = xtext_palette_lookup (xtext, XTEXT_MARK_BG);
+            xtext->text_fg = xtext_palette_lookup (xtext, XTEXT_MARK_FG);
 			xtext->backcolor = TRUE;
 			mark = TRUE;
 		}
 
 		if (mark && ent->mark_end == (i + offset))
 		{
-			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+			x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 			pstr += j;
 			j = 0;
-			xtext_set_bg (xtext, gc, xtext->col_back);
-			xtext_set_fg (xtext, gc, xtext->col_fore);
+            xtext->text_bg = xtext_palette_lookup (xtext, xtext->col_back);
+            xtext->text_fg = xtext_palette_lookup (xtext, xtext->col_fore);
 			if (xtext->col_back != XTEXT_BG)
 				xtext->backcolor = TRUE;
 			else
@@ -3099,12 +2541,12 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 	}
 
 	if (j)
-		x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb);
+		x += gtk_xtext_render_flush (xtext, x, y, pstr, j, ent->mb);
 
 	if (mark)
 	{
-		xtext_set_bg (xtext, gc, xtext->col_back);
-		xtext_set_fg (xtext, gc, xtext->col_fore);
+        xtext->text_bg = xtext_palette_lookup (xtext, xtext->col_back);
+        xtext->text_fg = xtext_palette_lookup (xtext, xtext->col_fore);
 		if (xtext->col_back != XTEXT_BG)
 			xtext->backcolor = TRUE;
 		else
@@ -3137,626 +2579,6 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
 	return ret;
 }
 
-#ifdef USE_XLIB
-
-/* get the desktop/root window */
-
-static Window desktop_window = None;
-
-static Window
-get_desktop_window (Display *xdisplay, Window the_window)
-{
-	Atom prop, type;
-	int format;
-	unsigned long length, after;
-	unsigned char *data;
-	unsigned int nchildren;
-	Window w, root, *children, parent;
-
-	prop = XInternAtom (xdisplay, "_XROOTPMAP_ID", True);
-	if (prop == None)
-	{
-		prop = XInternAtom (xdisplay, "_XROOTCOLOR_PIXEL", True);
-		if (prop == None)
-			return None;
-	}
-
-	for (w = the_window; w; w = parent)
-	{
-		if ((XQueryTree (xdisplay, w, &root, &parent, &children,
-				&nchildren)) == False)
-			return None;
-
-		if (nchildren)
-			XFree (children);
-
-		XGetWindowProperty (xdisplay, w, prop, 0L, 1L, False,
-								  AnyPropertyType, &type, &format, &length, &after,
-								  &data);
-		if (data)
-			XFree (data);
-
-		if (type != None)
-			return (desktop_window = w);
-	}
-
-	return (desktop_window = None);
-}
-
-/* find the root window (backdrop) Pixmap */
-
-static Pixmap
-get_pixmap_prop (Display *xdisplay, Window the_window)
-{
-	Atom type;
-	int format;
-	unsigned long length, after;
-	unsigned char *data;
-	Pixmap pix = None;
-	static Atom prop = None;
-
-	if (desktop_window == None)
-		desktop_window = get_desktop_window (xdisplay, the_window);
-	if (desktop_window == None)
-		desktop_window = DefaultRootWindow (xdisplay);
-
-	if (prop == None)
-		prop = XInternAtom (xdisplay, "_XROOTPMAP_ID", True);
-	if (prop == None)
-		return None;
-
-	XGetWindowProperty (xdisplay, desktop_window, prop, 0L, 1L, False,
-							  AnyPropertyType, &type, &format, &length, &after,
-							  &data);
-	if (data)
-	{
-		if (type == XA_PIXMAP)
-			pix = *((Pixmap *) data);
-
-		XFree (data);
-	}
-
-	return pix;
-}
-
-/* slow generic routine, for the depths/bpp we don't know about */
-
-static void
-shade_ximage_generic (GdkVisual *visual, XImage *ximg, int bpl, int w, int h, int rm, int gm, int bm, int bg)
-{
-	int x, y;
-	int bgr = (256 - rm) * (bg & visual->red_mask);
-	int bgg = (256 - gm) * (bg & visual->green_mask);
-	int bgb = (256 - bm) * (bg & visual->blue_mask);
-
-	for (x = 0; x < w; x++)
-	{
-		for (y = 0; y < h; y++)
-		{
-			unsigned long pixel = XGetPixel (ximg, x, y);
-			int r, g, b;
-
-			r = rm * (pixel & visual->red_mask) + bgr;
-			g = gm * (pixel & visual->green_mask) + bgg;
-			b = bm * (pixel & visual->blue_mask) + bgb;
-
-			XPutPixel (ximg, x, y,
-							((r >> 8) & visual->red_mask) |
-							((g >> 8) & visual->green_mask) |
-							((b >> 8) & visual->blue_mask));
-		}
-	}
-}
-
-#endif
-
-/* Fast shading routine. Based on code by Willem Monsuwe <willem stack nl> */
-
-#define SHADE_IMAGE(bytes, type, rmask, gmask, bmask) \
-	unsigned char *ptr; \
-	int x, y; \
-	int bgr = (256 - rm) * (bg & rmask); \
-	int bgg = (256 - gm) * (bg & gmask); \
-	int bgb = (256 - bm) * (bg & bmask); \
-	ptr = (unsigned char *) data + (w * bytes); \
-	for (y = h; --y >= 0;) \
-	{ \
-		for (x = -w; x < 0; x++) \
-		{ \
-			int r, g, b; \
-			b = ((type *) ptr)[x]; \
-			r = rm * (b & rmask) + bgr; \
-			g = gm * (b & gmask) + bgg; \
-			b = bm * (b & bmask) + bgb; \
-			((type *) ptr)[x] = ((r >> 8) & rmask) \
-										| ((g >> 8) & gmask) \
-										| ((b >> 8) & bmask); \
-		} \
-		ptr += bpl; \
-    }
-
-/* RGB 15 */
-static void
-shade_ximage_15 (void *data, int bpl, int w, int h, int rm, int gm, int bm, int bg)
-{
-	SHADE_IMAGE (2, guint16, 0x7c00, 0x3e0, 0x1f);
-}
-
-/* RGB 16 */
-static void
-shade_ximage_16 (void *data, int bpl, int w, int h, int rm, int gm, int bm, int bg)
-{
-	SHADE_IMAGE (2, guint16, 0xf800, 0x7e0, 0x1f);
-}
-
-/* RGB 24 */
-static void
-shade_ximage_24 (void *data, int bpl, int w, int h, int rm, int gm, int bm, int bg)
-{
-	/* 24 has to be a special case, there's no guint24, or 24bit MOV :) */
-	unsigned char *ptr;
-	int x, y;
-	int bgr = (256 - rm) * ((bg & 0xff0000) >> 16);
-	int bgg = (256 - gm) * ((bg & 0xff00) >> 8);
-	int bgb = (256 - bm) * (bg & 0xff);
-
-	ptr = (unsigned char *) data + (w * 3);
-	for (y = h; --y >= 0;)
-	{
-		for (x = -(w * 3); x < 0; x += 3)
-		{
-			int r, g, b;
-
-#if (G_BYTE_ORDER == G_BIG_ENDIAN)
-			r = (ptr[x + 0] * rm + bgr) >> 8;
-			g = (ptr[x + 1] * gm + bgg) >> 8;
-			b = (ptr[x + 2] * bm + bgb) >> 8;
-			ptr[x + 0] = r;
-			ptr[x + 1] = g;
-			ptr[x + 2] = b;
-#else
-			r = (ptr[x + 2] * rm + bgr) >> 8;
-			g = (ptr[x + 1] * gm + bgg) >> 8;
-			b = (ptr[x + 0] * bm + bgb) >> 8;
-			ptr[x + 2] = r;
-			ptr[x + 1] = g;
-			ptr[x + 0] = b;
-#endif
-		}
-		ptr += bpl;
-	}
-}
-
-/* RGB 32 */
-static void
-shade_ximage_32 (void *data, int bpl, int w, int h, int rm, int gm, int bm, int bg)
-{
-	SHADE_IMAGE (4, guint32, 0xff0000, 0xff00, 0xff);
-}
-
-static void
-shade_image (GdkVisual *visual, void *data, int bpl, int bpp, int w, int h,
-				 int rm, int gm, int bm, int bg, int depth)
-{
-	int bg_r, bg_g, bg_b;
-
-	bg_r = bg & visual->red_mask;
-	bg_g = bg & visual->green_mask;
-	bg_b = bg & visual->blue_mask;
-
-#ifdef USE_MMX
-	/* the MMX routines are about 50% faster at 16-bit. */
-	/* only use MMX routines with a pure black background */
-	if (bg_r == 0 && bg_g == 0 && bg_b == 0 && have_mmx ())	/* do a runtime check too! */
-	{
-		switch (depth)
-		{
-		case 15:
-			shade_ximage_15_mmx (data, bpl, w, h, rm, gm, bm);
-			break;
-		case 16:
-			shade_ximage_16_mmx (data, bpl, w, h, rm, gm, bm);
-			break;
-		case 24:
-			if (bpp != 32)
-				goto generic;
-		case 32:
-			shade_ximage_32_mmx (data, bpl, w, h, rm, gm, bm);
-			break;
-		default:
-			goto generic;
-		}
-	} else
-	{
-generic:
-#endif
-		switch (depth)
-		{
-		case 15:
-			shade_ximage_15 (data, bpl, w, h, rm, gm, bm, bg);
-			break;
-		case 16:
-			shade_ximage_16 (data, bpl, w, h, rm, gm, bm, bg);
-			break;
-		case 24:
-			if (bpp != 32)
-			{
-				shade_ximage_24 (data, bpl, w, h, rm, gm, bm, bg);
-				break;
-			}
-		case 32:
-			shade_ximage_32 (data, bpl, w, h, rm, gm, bm, bg);
-		}
-#ifdef USE_MMX
-	}
-#endif
-}
-
-#ifdef USE_XLIB
-
-#ifdef USE_SHM
-
-static XImage *
-get_shm_image (Display *xdisplay, XShmSegmentInfo *shminfo, int x, int y,
-					int w, int h, int depth, Pixmap pix)
-{
-	XImage *ximg;
-
-	shminfo->shmid = -1;
-	shminfo->shmaddr = (char*) -1;
-	ximg = XShmCreateImage (xdisplay, 0, depth, ZPixmap, 0, shminfo, w, h);
-	if (!ximg)
-		return NULL;
-
-	shminfo->shmid = shmget (IPC_PRIVATE, ximg->bytes_per_line * ximg->height,
-									 IPC_CREAT|0600);
-	if (shminfo->shmid == -1)
-	{
-		XDestroyImage (ximg);
-		return NULL;
-	}
-
-	shminfo->readOnly = False;
-	ximg->data = shminfo->shmaddr = (char *)shmat (shminfo->shmid, 0, 0);
-	if (shminfo->shmaddr == ((char *)-1))
-	{
-		shmctl (shminfo->shmid, IPC_RMID, 0);
-		XDestroyImage (ximg);
-		return NULL;
-	}
-
-	XShmAttach (xdisplay, shminfo);
-	XSync (xdisplay, False);
-	shmctl (shminfo->shmid, IPC_RMID, 0);
-	XShmGetImage (xdisplay, pix, ximg, x, y, AllPlanes);
-
-	return ximg;
-}
-
-static XImage *
-get_image (GtkXText *xtext, Display *xdisplay, XShmSegmentInfo *shminfo,
-			  int x, int y, int w, int h, int depth, Pixmap pix)
-{
-	XImage *ximg;
-
-	xtext->shm = 1;
-	ximg = get_shm_image (xdisplay, shminfo, x, y, w, h, depth, pix);
-	if (!ximg)
-	{
-		xtext->shm = 0;
-		ximg = XGetImage (xdisplay, pix, x, y, w, h, -1, ZPixmap);
-	}
-
-	return ximg;
-}
-
-#endif
-
-static GdkPixmap *
-shade_pixmap (GtkXText * xtext, Pixmap p, int x, int y, int w, int h)
-{
-	unsigned int udummy, width, height, depth;
-	int dummy;
-	GdkPixmap *shaded_pix;
-	Window root;
-	Pixmap tmp;
-	XImage *ximg;
-	XGCValues gcv;
-	GC tgc;
-	Display *xdisplay = GDK_WINDOW_XDISPLAY (xtext->draw_buf);
-
-	XGetGeometry (xdisplay, p, &root, &dummy, &dummy, &width, &height,
-					  &udummy, &depth);
-
-	if (width < x + w || height < y + h || x < 0 || y < 0)
-	{
-		gcv.subwindow_mode = IncludeInferiors;
-		gcv.graphics_exposures = False;
-		tgc = XCreateGC (xdisplay, p, GCGraphicsExposures|GCSubwindowMode,
-							  &gcv);
-		tmp = XCreatePixmap (xdisplay, p, w, h, depth);
-		XSetTile (xdisplay, tgc, p);
-		XSetFillStyle (xdisplay, tgc, FillTiled);
-		XSetTSOrigin (xdisplay, tgc, -x, -y);
-		XFillRectangle (xdisplay, tmp, tgc, 0, 0, w, h);
-		XFreeGC (xdisplay, tgc);
-
-#ifdef USE_SHM
-		ximg = get_image (xtext, xdisplay, &xtext->shminfo, 0, 0, w, h, depth, tmp);
-#else
-		ximg = XGetImage (xdisplay, tmp, 0, 0, w, h, -1, ZPixmap);
-#endif
-		XFreePixmap (xdisplay, tmp);
-	} else
-	{
-#ifdef USE_SHM
-		ximg = get_image (xtext, xdisplay, &xtext->shminfo, x, y, w, h, depth, p);
-#else
-		ximg = XGetImage (xdisplay, p, x, y, w, h, -1, ZPixmap);
-#endif
-	}
-
-	if (!ximg)
-		return NULL;
-
-	if (depth <= 14)
-	{
-		shade_ximage_generic (gdk_drawable_get_visual (GTK_WIDGET (xtext)->window),
-									 ximg, ximg->bytes_per_line, w, h, xtext->tint_red,
-									 xtext->tint_green, xtext->tint_blue,
-									 xtext->palette[XTEXT_BG]);
-	} else
-	{
-		shade_image (gdk_drawable_get_visual (GTK_WIDGET (xtext)->window),
-						 ximg->data, ximg->bytes_per_line, ximg->bits_per_pixel,
-						 w, h, xtext->tint_red, xtext->tint_green, xtext->tint_blue,
-						 xtext->palette[XTEXT_BG], depth);
-	}
-
-	if (xtext->recycle)
-		shaded_pix = xtext->pixmap;
-	else
-	{
-#ifdef USE_SHM
-		if (xtext->shm)
-		{
-			shaded_pix = gdk_pixmap_foreign_new_for_display (
-				gdk_drawable_get_display (xtext->draw_buf),
-				XShmCreatePixmap (xdisplay, p, ximg->data, &xtext->shminfo, w, h, depth));
-		} else
-#endif
-		{
-			shaded_pix = gdk_pixmap_new (GTK_WIDGET (xtext)->window, w, h, depth);
-		}
-	}
-
-#ifdef USE_SHM
-	if (!xtext->shm)
-#endif
-		XPutImage (xdisplay, GDK_WINDOW_XWINDOW (shaded_pix),
-					  GDK_GC_XGC (xtext->fgc), ximg, 0, 0, 0, 0, w, h);
-	XDestroyImage (ximg);
-
-	return shaded_pix;
-}
-
-#endif /* !USE_XLIB */
-
-/* free transparency xtext->pixmap */
-#if defined(USE_XLIB) || defined(WIN32)
-
-static void
-gtk_xtext_free_trans (GtkXText * xtext)
-{
-	if (xtext->pixmap)
-	{
-#ifdef USE_SHM
-		if (xtext->shm)
-		{
-			XFreePixmap (GDK_WINDOW_XDISPLAY (xtext->pixmap),
-							 GDK_WINDOW_XWINDOW (xtext->pixmap));
-			XShmDetach (GDK_WINDOW_XDISPLAY (xtext->draw_buf), &xtext->shminfo);
-			shmdt (xtext->shminfo.shmaddr);
-		}
-#endif
-		g_object_unref (xtext->pixmap);
-		xtext->pixmap = NULL;
-		xtext->shm = 0;
-	}
-}
-
-#endif
-
-#ifdef WIN32
-
-static GdkPixmap *
-win32_tint (GtkXText *xtext, GdkImage *img, int width, int height)
-{
-	guchar *pixelp;
-	int x, y;
-	GdkPixmap *pix;
-	GdkVisual *visual = gdk_drawable_get_visual (GTK_WIDGET (xtext)->window);
-	guint32 pixel;
-	int r, g, b;
-
-	if (img->depth <= 14)
-	{
-		/* slow generic routine */
-		for (y = 0; y < height; y++)
-		{
-			for (x = 0; x < width; x++)
-			{
-				if (img->depth == 1)
-				{
-					pixel = (((guchar *) img->mem)[y * img->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
-					goto here;
-				}
-
-				if (img->depth == 4)
-				{
-					pixelp = (guchar *) img->mem + y * img->bpl + (x >> 1);
-					if (x&1)
-					{
-						pixel = (*pixelp) & 0x0F;
-						goto here;
-					}
-
-					pixel = (*pixelp) >> 4;
-					goto here;
-				}
-
-				pixelp = (guchar *) img->mem + y * img->bpl + x * img->bpp;
-
-				switch (img->bpp)
-				{
-				case 1:
-					pixel = *pixelp; break;
-
-				/* Windows is always LSB, no need to check img->byte_order. */
-				case 2:
-					pixel = pixelp[0] | (pixelp[1] << 8); break;
-
-				case 3:
-					pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16); break;
-
-				case 4:
-					pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16); break;
-				}
-
-here:
-				r = (pixel & visual->red_mask) >> visual->red_shift;
-				g = (pixel & visual->green_mask) >> visual->green_shift;
-				b = (pixel & visual->blue_mask) >> visual->blue_shift;
-
-				/* actual tinting is only these 3 lines */
-				pixel = ((r * xtext->tint_red) >> 8) << visual->red_shift |
-							((g * xtext->tint_green) >> 8) << visual->green_shift |
-							((b * xtext->tint_blue) >> 8) << visual->blue_shift;
-
-				if (img->depth == 1)
-					if (pixel & 1)
-						((guchar *) img->mem)[y * img->bpl + (x >> 3)] |= (1 << (7 - (x & 0x7)));
-					else
-						((guchar *) img->mem)[y * img->bpl + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
-				else if (img->depth == 4)
-				{
-					pixelp = (guchar *) img->mem + y * img->bpl + (x >> 1);
-
-					if (x&1)
-					{
-						*pixelp &= 0xF0;
-						*pixelp |= (pixel & 0x0F);
-					} else
-					{
-						*pixelp &= 0x0F;
-						*pixelp |= (pixel << 4);
-					}
-				} else
-				{
-					pixelp = (guchar *) img->mem + y * img->bpl + x * img->bpp;
-
-					/* Windows is always LSB, no need to check img->byte_order. */
-					switch (img->bpp)
-					{
-					case 4:
-						pixelp[3] = 0;
-					case 3:
-						pixelp[2] = ((pixel >> 16) & 0xFF);
-					case 2:
-						pixelp[1] = ((pixel >> 8) & 0xFF);
-					case 1:
-						pixelp[0] = (pixel & 0xFF);
-					}
-				}
-			}
-		}
-	} else
-	{
-		shade_image (visual, img->mem, img->bpl, img->bpp, width, height,
-						 xtext->tint_red, xtext->tint_green, xtext->tint_blue,
-						 xtext->palette[XTEXT_BG], visual->depth);
-	}
-
-	/* no need to dump it to a Pixmap, it's one and the same on win32 */
-	pix = (GdkPixmap *)img;
-
-	return pix;
-}
-
-#endif /* !WIN32 */
-
-/* grab pixmap from root window and set xtext->pixmap */
-#if defined(USE_XLIB) || defined(WIN32)
-
-static void
-gtk_xtext_load_trans (GtkXText * xtext)
-{
-#ifdef WIN32
-	GdkImage *img;
-	int width, height;
-	HDC hdc;
-	HWND hwnd;
-
-	/* if not shaded, we paint directly with PaintDesktop() */
-	if (!xtext->shaded)
-		return;
-
-	hwnd = GDK_WINDOW_HWND (GTK_WIDGET (xtext)->window);
-	hdc = GetDC (hwnd);
-	PaintDesktop (hdc);
-	ReleaseDC (hwnd, hdc);
-
-	gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height);
-	img = gdk_drawable_image_get (GTK_WIDGET (xtext)->window, 0, 0, width+128, height);
-	xtext->pixmap = win32_tint (xtext, img, img->width, img->height);
-
-#else
-
-	Pixmap rootpix;
-	GtkWidget *widget = GTK_WIDGET (xtext);
-	int x, y;
-
-	rootpix = get_pixmap_prop (GDK_WINDOW_XDISPLAY (widget->window), GDK_WINDOW_XWINDOW (widget->window));
-	if (rootpix == None)
-	{
-		if (xtext->error_function)
-			xtext->error_function (0);
-		xtext->transparent = FALSE;
-		return;
-	}
-
-	gdk_window_get_origin (widget->window, &x, &y);
-
-	if (xtext->shaded)
-	{
-		int width, height;
-		width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
-		height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
-
-		xtext->pixmap = shade_pixmap (xtext, rootpix, x, y, width+105, height);
-		if (xtext->pixmap == NULL)
-		{
-			xtext->shaded = 0;
-			goto noshade;
-		}
-		gdk_gc_set_tile (xtext->bgc, xtext->pixmap);
-		gdk_gc_set_ts_origin (xtext->bgc, 0, 0);
-		xtext->ts_x = xtext->ts_y = 0;
-	} else
-	{
-noshade:
-		xtext->pixmap = gdk_pixmap_foreign_new_for_display (gdk_window_get_display (GTK_WIDGET (xtext)->window), rootpix);
-		gdk_gc_set_tile (xtext->bgc, xtext->pixmap);
-		gdk_gc_set_ts_origin (xtext->bgc, -x, -y);
-		xtext->ts_x = -x;
-		xtext->ts_y = -y;
-	}
-	gdk_gc_set_fill (xtext->bgc, GDK_TILED);
-#endif /* !WIN32 */
-}
-
-#endif /* ! XLIB || WIN32 */
-
 /* walk through str until this line doesn't fit anymore */
 
 static int
@@ -3888,7 +2710,7 @@ gtk_xtext_find_subline (GtkXText *xtext, textentry *ent, int line)
 	if (line <= RECORD_WRAPS)
 		return ent->wrap_offset[line - 1];
 
-	win_width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
+	win_width = gdk_window_get_width (gtk_widget_get_window (GTK_WIDGET(xtext)));
 	win_width -= MARGIN;
 
 /*	indent = ent->indent;
@@ -4059,35 +2881,22 @@ gtk_xtext_render_line (GtkXText * xtext, textentry * ent, int line,
 
 	gtk_xtext_draw_marker (xtext, ent, y - xtext->fontsize * (taken + start_subline));
 
+	/*gtk_widget_queue_draw (GTK_WIDGET(xtext));*/
+
 	return taken;
 }
 
 void
 gtk_xtext_set_palette (GtkXText * xtext, GdkColor palette[])
 {
-	int i;
-	GdkColor col;
-
-	for (i = (XTEXT_COLS-1); i >= 0; i--)
-	{
-#ifdef USE_XFT
-		xtext->color[i].color.red = palette[i].red;
-		xtext->color[i].color.green = palette[i].green;
-		xtext->color[i].color.blue = palette[i].blue;
-		xtext->color[i].color.alpha = 0xffff;
-		xtext->color[i].pixel = palette[i].pixel;
-#endif
-		xtext->palette[i] = palette[i].pixel;
-	}
+    memcpy(&xtext->palette, palette, XTEXT_COLS * sizeof(GdkColor));
 
 	if (gtk_widget_get_realized (GTK_WIDGET(xtext)))
 	{
-		xtext_set_fg (xtext, xtext->fgc, XTEXT_FG);
-		xtext_set_bg (xtext, xtext->fgc, XTEXT_BG);
-		xtext_set_fg (xtext, xtext->bgc, XTEXT_BG);
+        xtext->text_fg   = xtext_palette_lookup (xtext, XTEXT_FG);
+        xtext->text_bg   = xtext_palette_lookup (xtext, XTEXT_BG);
 
-		col.pixel = xtext->palette[XTEXT_MARKER];
-		gdk_gc_set_foreground (xtext->marker_gc, &col);
+		xtext->marker_gc = xtext_palette_lookup (xtext, XTEXT_MARKER);
 	}
 	xtext->col_fore = XTEXT_FG;
 	xtext->col_back = XTEXT_BG;
@@ -4108,8 +2917,6 @@ gtk_xtext_fix_indent (xtext_buffer *buf)
 		}
 		buf->indent = j;
 	}
-
-	dontscroll (buf);	/* force scrolling off */
 }
 
 static void
@@ -4185,67 +2992,6 @@ gtk_xtext_set_font (GtkXText *xtext, char *name)
 }
 
 void
-gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap, gboolean trans)
-{
-	GdkGCValues val;
-	gboolean shaded = FALSE;
-
-	if (trans && (xtext->tint_red != 255 || xtext->tint_green != 255 || xtext->tint_blue != 255))
-		shaded = TRUE;
-
-#if !defined(USE_XLIB) && !defined(WIN32)
-	shaded = FALSE;
-	trans = FALSE;
-#endif
-
-	if (xtext->pixmap)
-	{
-#if defined(USE_XLIB) || defined(WIN32)
-		if (xtext->transparent)
-			gtk_xtext_free_trans (xtext);
-		else
-#endif
-			g_object_unref (xtext->pixmap);
-		xtext->pixmap = NULL;
-	}
-
-	xtext->transparent = trans;
-
-#if defined(USE_XLIB) || defined(WIN32)
-	if (trans)
-	{
-		xtext->shaded = shaded;
-		if (gtk_widget_get_realized (GTK_WIDGET (xtext)))
-			gtk_xtext_load_trans (xtext);
-		return;
-	}
-#endif
-
-	dontscroll (xtext->buffer);
-	xtext->pixmap = pixmap;
-
-	if (pixmap != 0)
-	{
-		g_object_ref (pixmap);
-		if (gtk_widget_get_realized (GTK_WIDGET (xtext)))
-		{
-			gdk_gc_set_tile (xtext->bgc, pixmap);
-			gdk_gc_set_ts_origin (xtext->bgc, 0, 0);
-			xtext->ts_x = xtext->ts_y = 0;
-			gdk_gc_set_fill (xtext->bgc, GDK_TILED);
-		}
-	} else if (gtk_widget_get_realized (GTK_WIDGET (xtext)))
-	{
-		g_object_unref (xtext->bgc);
-		val.subwindow_mode = GDK_INCLUDE_INFERIORS;
-		val.graphics_exposures = 0;
-		xtext->bgc = gdk_gc_new_with_values (GTK_WIDGET (xtext)->window,
-								&val, GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
-		xtext_set_fg (xtext, xtext->bgc, XTEXT_BG);
-	}
-}
-
-void
 gtk_xtext_save (GtkXText * xtext, int fh)
 {
 	textentry *ent;
@@ -4307,8 +3053,8 @@ gtk_xtext_calc_lines (xtext_buffer *buf, int fire_signal)
 	int height;
 	int lines;
 
-	width = gdk_window_get_width (GTK_WIDGET (buf->xtext)->window);
-	height = gdk_window_get_height (GTK_WIDGET (buf->xtext)->window);
+	width = gdk_window_get_width (gtk_widget_get_window (GTK_WIDGET(buf->xtext)));
+	height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(buf->xtext)));
 	width -= MARGIN;
 
 	if (width < 30 || height < buf->xtext->fontsize || width < buf->indent + 30)
@@ -4403,8 +3149,8 @@ gtk_xtext_render_ents (GtkXText * xtext, textentry * enta, textentry * entb)
 	if (xtext->buffer->indent < MARGIN)
 		xtext->buffer->indent = MARGIN;	  /* 2 pixels is our left margin */
 
-	width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
-	height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+	width = gdk_window_get_width   (gtk_widget_get_window (GTK_WIDGET(xtext)));
+	height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(xtext)));
 	width -= MARGIN;
 
 	if (width < 32 || height < xtext->fontsize || width < xtext->buffer->indent + 30)
@@ -4483,7 +3229,7 @@ gtk_xtext_render_page (GtkXText * xtext)
 	int width;
 	int height;
 	int subline;
-	int startline = xtext->adj->value;
+	int startline = gtk_adjustment_get_value (xtext->adj);
 
 	if(!gtk_widget_get_realized (GTK_WIDGET (xtext)))
 	  return;
@@ -4491,14 +3237,14 @@ gtk_xtext_render_page (GtkXText * xtext)
 	if (xtext->buffer->indent < MARGIN)
 		xtext->buffer->indent = MARGIN;	  /* 2 pixels is our left margin */
 
-	width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
-	height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+	width = gdk_window_get_width   (gtk_widget_get_window (GTK_WIDGET(xtext)));
+	height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(xtext)));
 
 	if (width < 34 || height < xtext->fontsize || width < xtext->buffer->indent + 32)
 		return;
 
 #ifdef SMOOTH_SCROLL
-	xtext->pixel_offset = (xtext->adj->value - startline) * xtext->fontsize;
+	xtext->pixel_offset = (gtk_adjustment_get_value (xtext->adj) - startline) * xtext->fontsize;
 #else
 	xtext->pixel_offset = 0;
 #endif
@@ -4513,71 +3259,6 @@ gtk_xtext_render_page (GtkXText * xtext)
 	xtext->buffer->pagetop_subline = subline;
 	xtext->buffer->pagetop_line = startline;
 
-#ifdef SCROLL_HACK
-{
-	int pos, overlap;
-	GdkRectangle area;
-
-	if (xtext->buffer->num_lines <= xtext->adj->page_size)
-		dontscroll (xtext->buffer);
-
-#ifdef SMOOTH_SCROLL
-	pos = xtext->adj->value * xtext->fontsize;
-#else
-	pos = startline * xtext->fontsize;
-#endif
-	overlap = xtext->buffer->last_pixel_pos - pos;
-	xtext->buffer->last_pixel_pos = pos;
-
-#ifdef USE_DB
-#ifdef WIN32
-	if (!xtext->transparent && !xtext->pixmap && abs (overlap) < height)
-#else
-	if (!xtext->pixmap && abs (overlap) < height)
-#endif
-#else
-	/* dont scroll PageUp/Down without a DB, it looks ugly */
-#ifdef WIN32
-	if (!xtext->transparent && !xtext->pixmap && abs (overlap) < height - (3*xtext->fontsize))
-#else
-	if (!xtext->pixmap && abs (overlap) < height - (3*xtext->fontsize))
-#endif
-#endif
-	{
-
-
-		if (overlap < 1)	/* DOWN */
-		{
-			int remainder;
-
-			gdk_draw_drawable (xtext->draw_buf, xtext->fgc, xtext->draw_buf,
-									 0, -overlap, 0, 0, width, height + overlap);
-			remainder = ((height - xtext->font->descent) % xtext->fontsize) +
-							xtext->font->descent;
-			area.y = (height + overlap) - remainder;
-			area.height = remainder - overlap;
-		} else
-		{
-			gdk_draw_drawable (xtext->draw_buf, xtext->fgc, xtext->draw_buf,
-									 0, 0, 0, overlap, width, height - overlap);
-			area.y = 0;
-			area.height = overlap;
-		}
-		gdk_gc_set_exposures (xtext->fgc, FALSE);
-
-		if (area.height > 0)
-		{
-			area.x = 0;
-			area.width = width;
-			gtk_xtext_paint (GTK_WIDGET (xtext), &area);
-		}
-		xtext->buffer->grid_dirty = TRUE;
-
-		return;
-	}
-}
-#endif
-
 	xtext->buffer->grid_dirty = FALSE;
 	width -= MARGIN;
 	lines_max = ((height + xtext->pixel_offset) / xtext->fontsize) + 1;
@@ -4608,13 +3289,6 @@ gtk_xtext_refresh (GtkXText * xtext, int do_trans)
 {
 	if (gtk_widget_get_realized (GTK_WIDGET (xtext)))
 	{
-#if defined(USE_XLIB) || defined(WIN32)
-		if (xtext->transparent && do_trans)
-		{
-			gtk_xtext_free_trans (xtext);
-			gtk_xtext_load_trans (xtext);
-		}
-#endif
 		gtk_xtext_render_page (xtext);
 	}
 }
@@ -4638,7 +3312,7 @@ gtk_xtext_remove_top (xtext_buffer *buffer)
 	buffer->old_value -= ent->lines_taken;
 	if (buffer->xtext->buffer == buffer)	/* is it the current buffer? */
 	{
-		buffer->xtext->adj->value -= ent->lines_taken;
+		gtk_adjustment_set_value (buffer->xtext->adj, ent->lines_taken);
 		buffer->xtext->select_start_adj -= ent->lines_taken;
 	}
 
@@ -4671,7 +3345,6 @@ gtk_xtext_clear (xtext_buffer *buf)
 	buf->last_ent_end = NULL;
 	buf->marker_pos = NULL;
 	buf->laststamp[0] = 0;
-	dontscroll (buf);
 
 	while (buf->text_first)
 	{
@@ -4699,7 +3372,7 @@ gtk_xtext_check_ent_visibility (GtkXText * xtext, textentry *find_ent, int add)
 	int line = 0;
 	int height;
 
-	height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+	height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(xtext)));
 
 	lines_max = ((height + xtext->pixel_offset) / xtext->fontsize) + add;
 	ent = xtext->buffer->pagetop_ent;
@@ -4791,10 +3464,10 @@ gtk_xtext_search (GtkXText * xtext, const gchar *text, textentry *start, gboolea
 				if (ent == fent)
 					break;
 			}
-			while (line > xtext->adj->upper - xtext->adj->page_size)
+			while (line > gtk_adjustment_get_upper (xtext->adj) - gtk_adjustment_get_page_size (xtext->adj))
 				line--;
 
-			xtext->adj->value = line;
+			gtk_adjustment_set_value (xtext->adj, line);
 			xtext->buffer->scrollbar_down = FALSE;
 			gtk_adjustment_changed (xtext->adj);
 		}
@@ -4814,18 +3487,18 @@ gtk_xtext_render_page_timeout (GtkXText * xtext)
 	xtext->add_io_tag = 0;
 
 	/* less than a complete page? */
-	if (xtext->buffer->num_lines <= adj->page_size)
+	if (xtext->buffer->num_lines <= gtk_adjustment_get_page_size (adj))
 	{
 		xtext->buffer->old_value = 0;
-		adj->value = 0;
+		gtk_adjustment_set_value (adj, 0);
 		gtk_xtext_render_page (xtext);
 	} else if (xtext->buffer->scrollbar_down)
 	{
 		g_signal_handler_block (xtext->adj, xtext->vc_signal_tag);
 		gtk_xtext_adjustment_set (xtext->buffer, FALSE);
-		gtk_adjustment_set_value (adj, adj->upper - adj->page_size);
+		gtk_adjustment_set_value (adj, gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj));
 		g_signal_handler_unblock (xtext->adj, xtext->vc_signal_tag);
-		xtext->buffer->old_value = adj->value;
+		xtext->buffer->old_value = gtk_adjustment_get_value (adj);
 		gtk_xtext_render_page (xtext);
 	} else
 	{
@@ -4887,7 +3560,6 @@ gtk_xtext_append_entry (xtext_buffer *buf, textentry * ent, time_t stamp)
 		!gtk_window_has_toplevel_focus (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (buf->xtext)))))))
 	{
 		buf->marker_pos = ent;
-		dontscroll (buf); /* force scrolling off */
 		buf->marker_seen = FALSE;
 		buf->reset_marker_pos = FALSE;
 	}
@@ -4899,12 +3571,6 @@ gtk_xtext_append_entry (xtext_buffer *buf, textentry * ent, time_t stamp)
 
 	if (buf->xtext->buffer == buf)
 	{
-#ifdef SCROLL_HACK
-		/* this could be improved */
-		if ((buf->num_lines - 1) <= buf->xtext->adj->page_size)
-			dontscroll (buf);
-#endif
-
 		if (!buf->xtext->add_io_tag)
 		{
 			/* remove scrolling events */
@@ -4920,7 +3586,7 @@ gtk_xtext_append_entry (xtext_buffer *buf, textentry * ent, time_t stamp)
 		}
 	} else if (buf->scrollbar_down)
 	{
-		buf->old_value = buf->num_lines - buf->xtext->adj->page_size;
+		buf->old_value = buf->num_lines - gtk_adjustment_get_page_size (buf->xtext->adj);
 		if (buf->old_value < 0)
 			buf->old_value = 0;
 	}
@@ -5114,17 +3780,6 @@ gtk_xtext_set_time_stamp (xtext_buffer *buf, gboolean time_stamp)
 }
 
 void
-gtk_xtext_set_tint (GtkXText *xtext, int tint_red, int tint_green, int tint_blue)
-{
-	xtext->tint_red = tint_red;
-	xtext->tint_green = tint_green;
-	xtext->tint_blue = tint_blue;
-
-	/*if (xtext->tint_red != 255 || xtext->tint_green != 255 || xtext->tint_blue != 255)
-		shaded = TRUE;*/
-}
-
-void
 gtk_xtext_set_urlcheck_function (GtkXText *xtext, int (*urlcheck_function) (GtkWidget *, char *, int))
 {
 	xtext->urlcheck_function = urlcheck_function;
@@ -5140,7 +3795,6 @@ void
 gtk_xtext_reset_marker_pos (GtkXText *xtext)
 {
 	xtext->buffer->marker_pos = NULL;
-	dontscroll (xtext->buffer); /* force scrolling off */
 	gtk_xtext_render_page (xtext);
 	xtext->buffer->reset_marker_pos = TRUE;
 }
@@ -5171,8 +3825,8 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
 
 	if (!gtk_widget_get_realized (GTK_WIDGET (xtext)))
 		gtk_widget_realize (GTK_WIDGET (xtext));
-	w = gdk_window_get_width (GTK_WIDGET (xtext)->window);
-	h = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+	w = gdk_window_get_width  (gtk_widget_get_window (GTK_WIDGET(xtext)));
+	h = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(xtext)));
 
 	/* after a font change */
 	if (buf->needs_recalc)
@@ -5183,18 +3837,14 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
 
 	/* now change to the new buffer */
 	xtext->buffer = buf;
-	dontscroll (buf);	/* force scrolling off */
-	xtext->adj->value = buf->old_value;
-	xtext->adj->upper = buf->num_lines;
-	if (xtext->adj->upper == 0)
-		xtext->adj->upper = 1;
+	gtk_adjustment_set_value (xtext->adj, buf->old_value);
+	gtk_adjustment_set_upper (xtext->adj, buf->num_lines? buf->num_lines: 1);
 	/* sanity check */
-	else if (xtext->adj->value > xtext->adj->upper - xtext->adj->page_size)
+	if (gtk_adjustment_get_value (xtext->adj) > gtk_adjustment_get_upper (xtext->adj) - 
+			gtk_adjustment_get_page_size (xtext->adj))
 	{
-		/*buf->pagetop_ent = NULL;*/
-		xtext->adj->value = xtext->adj->upper - xtext->adj->page_size;
-		if (xtext->adj->value < 0)
-			xtext->adj->value = 0;
+		int val = gtk_adjustment_get_upper (xtext->adj) - gtk_adjustment_get_page_size (xtext->adj);
+		gtk_adjustment_set_value (xtext->adj, (val > 0)? val: 0);
 	}
 
 	if (render)
@@ -5205,8 +3855,8 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
 			buf->window_width = w;
 			gtk_xtext_calc_lines (buf, FALSE);
 			if (buf->scrollbar_down)
-				gtk_adjustment_set_value (xtext->adj, xtext->adj->upper -
-												  xtext->adj->page_size);
+				gtk_adjustment_set_value (xtext->adj, gtk_adjustment_get_upper (xtext->adj) -
+					gtk_adjustment_get_page_size (xtext->adj));
 		} else if (buf->window_height != h)
 		{
 			buf->window_height = h;
@@ -5216,10 +3866,6 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
 
 		gtk_xtext_render_page (xtext);
 		gtk_adjustment_changed (xtext->adj);
-	} else
-	{
-		/* avoid redoing the transparency */
-		xtext->avoid_trans = TRUE;
 	}
 }
 
@@ -5234,7 +3880,6 @@ gtk_xtext_buffer_new (GtkXText *xtext)
 	buf->xtext = xtext;
 	buf->scrollbar_down = TRUE;
 	buf->indent = xtext->space_width * 2;
-	dontscroll (buf);
 
 	return buf;
 }
diff --git a/src/fe-gnome/xtext.h b/src/fe-gnome/xtext.h
index 7aa6722..ee090a7 100644
--- a/src/fe-gnome/xtext.h
+++ b/src/fe-gnome/xtext.h
@@ -2,17 +2,6 @@
 #define __XTEXT_H__
 
 #include <gtk/gtk.h>
-#ifdef USE_XFT
-#include <X11/Xft/Xft.h>
-#endif
-
-#ifdef USE_SHM
-#include <X11/Xlib.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <X11/extensions/XShm.h>
-#endif
-
 
 #include "../common/xchat.h"
 
@@ -92,13 +81,8 @@ struct _GtkXText
 	xtext_buffer *orig_buffer;
 	xtext_buffer *selection_buffer;
 
-#ifdef USE_SHM
-	XShmSegmentInfo shminfo;
-#endif
-
 	GtkAdjustment *adj;
-	GdkPixmap *pixmap;				/* 0 = use palette[19] */
-	GdkDrawable *draw_buf;			/* points to ->window */
+	
 	GdkCursor *hand_cursor;
 	GdkCursor *resize_cursor;
 
@@ -109,17 +93,14 @@ struct _GtkXText
 	int last_win_h;
 	int last_win_w;
 
-	int tint_red;
-	int tint_green;
-	int tint_blue;
+	GdkColor text_fg;
+	GdkColor text_bg;
 
-	GdkGC *bgc;						  /* backing pixmap */
-	GdkGC *fgc;						  /* text foreground color */
-	GdkGC *light_gc;				  /* sep bar */
-	GdkGC *dark_gc;
-	GdkGC *thin_gc;
-	GdkGC *marker_gc;
-	gulong palette[XTEXT_COLS];
+	GdkColor light_gc;				  /* sep bar */
+	GdkColor dark_gc;
+	GdkColor thin_gc;
+	GdkColor marker_gc;
+	GdkColor palette[XTEXT_COLS];
 
 	gint io_tag;					  /* for delayed refresh events */
 	gint add_io_tag;				  /* "" when adding new text */
@@ -137,8 +118,6 @@ struct _GtkXText
 	int col_fore;
 	int col_back;
 
-	int depth;						  /* gdk window depth */
-
 	char num[8];					  /* for parsing mirc color */
 	int nc;							  /* offset into xtext->num */
 
@@ -148,14 +127,6 @@ struct _GtkXText
 
 	guint16 fontwidth[128];	  /* each char's width, only the ASCII ones */
 
-#ifdef USE_XFT
-	XftColor color[XTEXT_COLS];
-	XftColor *xft_fg;
-	XftColor *xft_bg;				/* both point into color[20] */
-	XftDraw *xftdraw;
-	XftFont *font;
-	XftFont *ifont;				/* italics */
-#else
 	struct pangofont
 	{
 		PangoFontDescription *font;
@@ -164,7 +135,6 @@ struct _GtkXText
 		int descent;
 	} *font, pango_font;
 	PangoLayout *layout;
-#endif
 
 	int fontsize;
 	int space_width;				  /* width (pixels) of the space " " character */
@@ -179,9 +149,6 @@ struct _GtkXText
 	int jump_out_offset;	/* point at which to stop rendering */
 	int jump_in_offset;	/* "" start rendering */
 
-	int ts_x;			/* ts origin for ->bgc GC */
-	int ts_y;
-
 	int clip_x;			/* clipping (x directions) */
 	int clip_x2;		/* from x to x2 */
 
@@ -216,20 +183,15 @@ struct _GtkXText
 	unsigned int in_hilight:1;
 	unsigned int un_hilight:1;
 	unsigned int recycle:1;
-	unsigned int avoid_trans:1;
 	unsigned int indent_changed:1;
-	unsigned int shm:1;
 
 	/* settings/prefs */
 	unsigned int auto_indent:1;
 	unsigned int color_paste:1;
 	unsigned int thinline:1;
-	unsigned int transparent:1;
-	unsigned int shaded:1;
 	unsigned int marker:1;
 	unsigned int separator:1;
 	unsigned int wordwrap:1;
-	unsigned int overdraw:1;
 	unsigned int ignore_hidden:1;	/* rawlog uses this */
 	double alpha;
 
@@ -252,7 +214,6 @@ void gtk_xtext_append_indent (xtext_buffer *buf,
 										time_t stamp);
 int gtk_xtext_set_font (GtkXText *xtext, char *name);
 void gtk_xtext_set_alpha (GtkXText *xtext, double alpha);
-void gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap, gboolean trans);
 void gtk_xtext_set_palette (GtkXText * xtext, GdkColor palette[]);
 void gtk_xtext_clear (xtext_buffer *buf);
 void gtk_xtext_save (GtkXText * xtext, int fh);
@@ -274,7 +235,6 @@ void gtk_xtext_set_show_marker (GtkXText *xtext, gboolean show_marker);
 void gtk_xtext_set_show_separator (GtkXText *xtext, gboolean show_separator);
 void gtk_xtext_set_thin_separator (GtkXText *xtext, gboolean thin_separator);
 void gtk_xtext_set_time_stamp (xtext_buffer *buf, gboolean timestamp);
-void gtk_xtext_set_tint (GtkXText *xtext, int tint_red, int tint_green, int tint_blue);
 void gtk_xtext_set_urlcheck_function (GtkXText *xtext, int (*urlcheck_function) (GtkWidget *, char *, int));
 void gtk_xtext_set_wordwrap (GtkXText *xtext, gboolean word_wrap);
 
diff --git a/src/libeggsmclient/eggsmclient-private.h b/src/libeggsmclient/eggsmclient-private.h
index ccb10bf..41a7637 100644
--- a/src/libeggsmclient/eggsmclient-private.h
+++ b/src/libeggsmclient/eggsmclient-private.h
@@ -20,7 +20,7 @@
 #ifndef __EGG_SM_CLIENT_PRIVATE_H__
 #define __EGG_SM_CLIENT_PRIVATE_H__
 
-#include <gdkconfig.h>
+#include <gtk/gtk.h>
 #include "eggsmclient.h"
 
 G_BEGIN_DECLS
diff --git a/src/libeggsmclient/eggsmclient-xsmp.c b/src/libeggsmclient/eggsmclient-xsmp.c
index 8bebfba..1bc3180 100644
--- a/src/libeggsmclient/eggsmclient-xsmp.c
+++ b/src/libeggsmclient/eggsmclient-xsmp.c
@@ -367,7 +367,7 @@ sm_client_xsmp_startup (EggSMClient *client,
       free (ret_client_id);
 
       gdk_threads_enter ();
-      gdk_set_sm_client_id (xsmp->client_id);
+      gdk_x11_set_sm_client_id (xsmp->client_id);
       gdk_threads_leave ();
 
       g_debug ("Got client ID \"%s\"", xsmp->client_id);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]