diff --git a/src/Makefile.am b/src/Makefile.am
index 4b1b4c4..380a1c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -140,6 +140,7 @@ empathy_chat_SOURCES =						\
 	empathy-chat-window.c empathy-chat-window.h		\
 	empathy-invite-participant-dialog.c empathy-invite-participant-dialog.h \
 	empathy-chat.c \
+	gedit-close-button.c gedit-close-button.h \
 	$(NULL)
 
 empathy_handwritten_source = \
@@ -156,6 +157,7 @@ empathy_handwritten_source = \
 	empathy-preferences.c empathy-preferences.h			\
 	empathy-status-icon.c empathy-status-icon.h			\
 	empathy-chat-manager.c empathy-chat-manager.h			\
+	gedit-close-button.c gedit-close-button.h \
 	empathy.c
 
 empathy_SOURCES =							\
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 3e97425..799a825 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -59,6 +59,7 @@
 #include "empathy-chat-window.h"
 #include "empathy-about-dialog.h"
 #include "empathy-invite-participant-dialog.h"
+#include "gedit-close-button.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_CHAT
 #include <libempathy/empathy-debug.h>
@@ -260,8 +261,6 @@ chat_window_create_label (EmpathyChatWindow *window,
 	GtkWidget            *hbox;
 	GtkWidget            *name_label;
 	GtkWidget            *status_image;
-	GtkWidget            *close_button;
-	GtkWidget            *close_image;
 	GtkWidget            *event_box;
 	GtkWidget            *event_box_hbox;
 	PangoAttrList        *attr_list;
@@ -312,8 +311,9 @@ chat_window_create_label (EmpathyChatWindow *window,
 	gtk_box_pack_start (GTK_BOX (hbox), event_box, TRUE, TRUE, 0);
 
 	if (is_tab_label) {
-		close_button = gtk_button_new ();
-		gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
+		GtkWidget            *close_button;
+
+		close_button = gedit_close_button_new ();
 		g_object_set_data (G_OBJECT (chat), "chat-window-tab-close-button", close_button);
 
 		/* We don't want focus/keynav for the button to avoid clutter, and
@@ -322,13 +322,6 @@ chat_window_create_label (EmpathyChatWindow *window,
 		gtk_widget_set_can_focus (close_button, FALSE);
 		gtk_widget_set_can_default (close_button, FALSE);
 
-		/* Set the name to make the special rc style match. */
-		gtk_widget_set_name (close_button, "empathy-close-button");
-
-		close_image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
-
-		gtk_container_add (GTK_CONTAINER (close_button), close_image);
-
 		gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
 
 		g_signal_connect (close_button,
@@ -1911,16 +1904,6 @@ empathy_chat_window_class_init (EmpathyChatWindowClass *klass)
 	object_class->finalize = chat_window_finalize;
 
 	g_type_class_add_private (object_class, sizeof (EmpathyChatWindowPriv));
-
-	/* Set up a style for the close button with no focus padding. */
-	gtk_rc_parse_string (
-		"style \"empathy-close-button-style\"\n"
-		"{\n"
-		"  GtkWidget::focus-padding = 0\n"
-		"  xthickness = 0\n"
-		"  ythickness = 0\n"
-		"}\n"
-		"widget \"*.empathy-close-button\" style \"empathy-close-button-style\"");
 }
 
 static void
diff --git a/src/gedit-close-button.c b/src/gedit-close-button.c
new file mode 100644
index 0000000..6a9021a
--- /dev/null
+++ b/src/gedit-close-button.c
@@ -0,0 +1,80 @@
+/*
+ * gedit-close-button.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Paolo Borelli
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * gedit is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * gedit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "gedit-close-button.h"
+
+struct _GeditCloseButtonClassPrivate
+{
+	GtkCssProvider *css;
+};
+
+G_DEFINE_TYPE_WITH_CODE (GeditCloseButton, gedit_close_button, GTK_TYPE_BUTTON,
+                         g_type_add_class_private (g_define_type_id, sizeof (GeditCloseButtonClassPrivate)))
+
+static void
+gedit_close_button_class_init (GeditCloseButtonClass *klass)
+{
+	static const gchar button_style[] =
+		"* {\n"
+		  "-GtkButton-default-border : 0;\n"
+		  "-GtkButton-default-outside-border : 0;\n"
+		  "-GtkButton-inner-border: 0;\n"
+		  "-GtkWidget-focus-line-width : 0;\n"
+		  "-GtkWidget-focus-padding : 0;\n"
+		  "padding: 0;\n"
+		"}";
+
+	klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClassPrivate);
+
+	klass->priv->css = gtk_css_provider_new ();
+	gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL);
+}
+
+static void
+gedit_close_button_init (GeditCloseButton *button)
+{
+	GtkStyleContext *context;
+	GtkWidget *image;
+
+	image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
+	                                  GTK_ICON_SIZE_MENU);
+	gtk_widget_show (image);
+
+	gtk_container_add (GTK_CONTAINER (button), image);
+
+	/* make it small */
+	context = gtk_widget_get_style_context (GTK_WIDGET (button));
+	gtk_style_context_add_provider (context,
+	                                GTK_STYLE_PROVIDER (GEDIT_CLOSE_BUTTON_GET_CLASS (button)->priv->css),
+		                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+}
+
+GtkWidget *
+gedit_close_button_new ()
+{
+	return GTK_WIDGET (g_object_new (GEDIT_TYPE_CLOSE_BUTTON,
+	                                 "relief", GTK_RELIEF_NONE,
+	                                 "focus-on-click", FALSE,
+	                                 NULL));
+}
+
+/* ex:set ts=8 noet: */
diff --git a/src/gedit-close-button.h b/src/gedit-close-button.h
new file mode 100644
index 0000000..791a730
--- /dev/null
+++ b/src/gedit-close-button.h
@@ -0,0 +1,60 @@
+/*
+ * gedit-close-button.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Paolo Borelli
+ *
+ * gedit is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * gedit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __GEDIT_CLOSE_BUTTON_H__
+#define __GEDIT_CLOSE_BUTTON_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_CLOSE_BUTTON			(gedit_close_button_get_type ())
+#define GEDIT_CLOSE_BUTTON(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButton))
+#define GEDIT_CLOSE_BUTTON_CONST(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButton const))
+#define GEDIT_CLOSE_BUTTON_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClass))
+#define GEDIT_IS_CLOSE_BUTTON(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_CLOSE_BUTTON))
+#define GEDIT_IS_CLOSE_BUTTON_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_CLOSE_BUTTON))
+#define GEDIT_CLOSE_BUTTON_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClass))
+
+typedef struct _GeditCloseButton		GeditCloseButton;
+typedef struct _GeditCloseButtonClass		GeditCloseButtonClass;
+typedef struct _GeditCloseButtonClassPrivate	GeditCloseButtonClassPrivate;
+
+struct _GeditCloseButton
+{
+	GtkButton parent;
+};
+
+struct _GeditCloseButtonClass
+{
+	GtkButtonClass parent_class;
+
+	GeditCloseButtonClassPrivate *priv;
+};
+
+GType		  gedit_close_button_get_type (void) G_GNUC_CONST;
+
+GtkWidget	 *gedit_close_button_new      (void);
+
+G_END_DECLS
+
+#endif /* __GEDIT_CLOSE_BUTTON_H__ */
+/* ex:set ts=8 noet: */
