[gedit] Use gtknotebook dnd instead of custom dnd code. Fixes bug #456959.



commit 75d88375d25b35d2519276a2d18215994bdf9719
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Sep 28 17:43:11 2010 +0200

    Use gtknotebook dnd instead of custom dnd code. Fixes bug #456959.

 configure.ac                 |    2 +-
 gedit/gedit-marshal.list     |    1 +
 gedit/gedit-multi-notebook.c |   59 ++--
 gedit/gedit-multi-notebook.h |    6 +-
 gedit/gedit-notebook.c       |  875 +++++++++--------------------------------
 gedit/gedit-notebook.h       |   24 +-
 gedit/gedit-window.c         |   51 ++--
 7 files changed, 260 insertions(+), 758 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 65a1c25..dceb02c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,7 +273,7 @@ PKG_CHECK_MODULES(GEDIT, [
 	glib-2.0 >= 2.25.15
 	gthread-2.0 >= 2.13.0
 	gio-2.0 >= 2.25.11
-	gtk+-3.0 >= 2.91.0
+	gtk+-3.0 >= 2.91.1
 	gtksourceview-3.0 >= 2.11.2
 	libpeas-1.0 >= 0.7.0
 	libpeas-gtk-1.0 >= 0.7.0
diff --git a/gedit/gedit-marshal.list b/gedit/gedit-marshal.list
index 72218f5..646d363 100644
--- a/gedit/gedit-marshal.list
+++ b/gedit/gedit-marshal.list
@@ -13,3 +13,4 @@ VOID:UINT,POINTER
 VOID:UINT64,UINT64
 VOID:VOID
 VOID:INT,INT
+OBJECT:OBJECT,OBJECT,INT,INT
diff --git a/gedit/gedit-multi-notebook.c b/gedit/gedit-multi-notebook.c
index 6a83ad9..f491ac8 100644
--- a/gedit/gedit-multi-notebook.c
+++ b/gedit/gedit-multi-notebook.c
@@ -54,7 +54,7 @@ enum
 	TAB_REMOVED,
 	SWITCH_TAB,
 	TAB_CLOSE_REQUEST,
-	TAB_DETACHED,
+	CREATE_WINDOW,
 	TABS_REORDERED,
 	SHOW_POPUP_MENU,
 	LAST_SIGNAL
@@ -177,17 +177,16 @@ gedit_multi_notebook_class_init (GeditMultiNotebookClass *klass)
 			      2,
 			      GEDIT_TYPE_NOTEBOOK,
 			      GEDIT_TYPE_TAB);
-	signals[TAB_DETACHED] =
-		g_signal_new ("tab-detached",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (GeditMultiNotebookClass, tab_detached),
-			      NULL, NULL,
-			      gedit_marshal_VOID__OBJECT_OBJECT,
-			      G_TYPE_NONE,
-			      2,
-			      GEDIT_TYPE_NOTEBOOK,
-			      GEDIT_TYPE_TAB);
+	signals[CREATE_WINDOW] =
+		g_signal_new ("create-window",
+		              G_TYPE_FROM_CLASS (object_class),
+		              G_SIGNAL_RUN_LAST,
+		              G_STRUCT_OFFSET (GeditMultiNotebookClass, create_window),
+		              NULL, NULL,
+		              gedit_marshal_OBJECT__OBJECT_OBJECT_INT_INT,
+		              GTK_TYPE_NOTEBOOK, 4,
+		              GEDIT_TYPE_NOTEBOOK, GTK_TYPE_WIDGET,
+		              G_TYPE_INT, G_TYPE_INT);
 	signals[TABS_REORDERED] =
 		g_signal_new ("tabs-reordered",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -251,18 +250,26 @@ notebook_tab_close_request (GeditNotebook      *notebook,
 		       notebook, tab);
 }
 
-static void
-notebook_tab_detached (GeditNotebook      *notebook,
-		       GeditTab           *tab,
-		       GeditMultiNotebook *mnb)
+static GtkNotebook *
+notebook_create_window (GeditNotebook      *notebook,
+			GtkWidget          *child,
+			gint                x,
+			gint                y,
+			GeditMultiNotebook *mnb)
 {
-	g_signal_emit (G_OBJECT (mnb), signals[TAB_DETACHED], 0,
-		       notebook, tab);
+	GtkNotebook *dest_notebook;
+
+	g_signal_emit (G_OBJECT (mnb), signals[CREATE_WINDOW], 0,
+	               notebook, child, x, y, &dest_notebook);
+
+	return dest_notebook;
 }
 
 static void
-notebook_tabs_reordered (GeditNotebook      *notebook,
-			 GeditMultiNotebook *mnb)
+notebook_page_reordered (GeditNotebook      *notebook,
+		         GtkWidget          *child,
+		         guint               page_num,
+		         GeditMultiNotebook *mnb)
 {
 	g_signal_emit (G_OBJECT (mnb), signals[TABS_REORDERED], 0);
 }
@@ -389,12 +396,12 @@ connect_notebook_signals (GeditMultiNotebook *mnb,
 			  G_CALLBACK (notebook_switch_page),
 			  mnb);
 	g_signal_connect (notebook,
-			  "tabs-reordered",
-			  G_CALLBACK (notebook_tabs_reordered),
+			  "page-reordered",
+			  G_CALLBACK (notebook_page_reordered),
 			  mnb);
 	g_signal_connect (notebook,
-			  "tab-detached",
-			  G_CALLBACK (notebook_tab_detached),
+			  "create-window",
+			  G_CALLBACK (notebook_create_window),
 			  mnb);
 	g_signal_connect (notebook,
 			  "tab-close-request",
@@ -418,9 +425,9 @@ disconnect_notebook_signals (GeditMultiNotebook *mnb,
 					      mnb);
 	g_signal_handlers_disconnect_by_func (notebook, notebook_page_removed,
 					      mnb);
-	g_signal_handlers_disconnect_by_func (notebook, notebook_tabs_reordered,
+	g_signal_handlers_disconnect_by_func (notebook, notebook_page_reordered,
 					      mnb);
-	g_signal_handlers_disconnect_by_func (notebook, notebook_tab_detached,
+	g_signal_handlers_disconnect_by_func (notebook, notebook_create_window,
 					      mnb);
 	g_signal_handlers_disconnect_by_func (notebook, notebook_tab_close_request,
 					      mnb);
diff --git a/gedit/gedit-multi-notebook.h b/gedit/gedit-multi-notebook.h
index 2304a48..19dfb67 100644
--- a/gedit/gedit-multi-notebook.h
+++ b/gedit/gedit-multi-notebook.h
@@ -73,9 +73,11 @@ struct _GeditMultiNotebookClass
 	void	(* tab_close_request)		(GeditMultiNotebook *mnb,
 						 GeditNotebook      *notebook,
 						 GeditTab           *tab);
-	void	(* tab_detached)		(GeditMultiNotebook *mnb,
+	GtkNotebook *	(* create_window)	(GeditMultiNotebook *mnb,
 						 GeditNotebook      *notebook,
-						 GeditTab           *tab);
+						 GtkWidget          *page,
+						 gint                x,
+						 gint                y);
 	void	(* tabs_reordered)		(GeditMultiNotebook *mnb);
 	void	(* show_popup_menu)		(GeditMultiNotebook *mnb,
 						 GdkEvent           *event);
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index b3680a1..428cd5c 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -46,50 +46,30 @@
 #include "gedit-notebook.h"
 #include "gedit-tab.h"
 #include "gedit-tab-label.h"
-#include "gedit-marshal.h"
 #include "gedit-window.h"
 #include "gedit-enum-types.h"
 #include "gedit-settings.h"
 
-#define AFTER_ALL_TABS -1
-#define NOT_IN_APP_WINDOWS -2
-
 #define GEDIT_NOTEBOOK_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_NOTEBOOK, GeditNotebookPrivate))
 
+#define GEDIT_NOTEBOOK_GROUP_NAME "GeditNotebookGroup"
+
 struct _GeditNotebookPrivate
 {
 	GSettings     *ui_settings;
 
 	GList         *focused_pages;
-	gulong         motion_notify_handler_id;
-
-	gint           x_start;
-	gint           y_start;
 
 	GeditNotebookShowTabsModeType show_tabs_mode;
 
 	gint           xthickness;
 
-	guint          drag_in_progress : 1;
 	guint          close_buttons_sensitive : 1;
-	guint          tab_drag_and_drop_enabled : 1;
-	guint          destroy_has_run : 1;
 	guint          collapse_border : 1;
 };
 
 G_DEFINE_TYPE(GeditNotebook, gedit_notebook, GTK_TYPE_NOTEBOOK)
 
-static gboolean gedit_notebook_change_current_page (GtkNotebook   *notebook,
-						    gint           offset);
-
-static void move_current_tab_to_another_notebook  (GeditNotebook  *src,
-						   GeditNotebook  *dest,
-						   GdkEventMotion *event,
-						   gint            dest_position);
-
-/* Local variables */
-static GdkCursor *cursor = NULL;
-
 /* Properties */
 enum
 {
@@ -100,15 +80,12 @@ enum
 /* Signals */
 enum
 {
-	TABS_REORDERED,
-	TAB_DETACHED,
 	TAB_CLOSE_REQUEST,
 	LAST_SIGNAL
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
-
 static void
 update_tabs_visibility (GeditNotebook *notebook,
 			gboolean       before_inserting)
@@ -232,524 +209,231 @@ gedit_notebook_style_set (GtkWidget *widget,
 	GTK_WIDGET_CLASS (gedit_notebook_parent_class)->style_set (widget, previous_style);
 }
 
-static void
-gedit_notebook_class_init (GeditNotebookClass *klass)
+/*
+ * We need to override this because when we don't show the tabs, like in
+ * fullscreen we need to have wrap around too
+ */
+static gboolean
+gedit_notebook_change_current_page (GtkNotebook *notebook,
+				    gint         offset)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
-	GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
-
-	object_class->dispose = gedit_notebook_dispose;
-	object_class->finalize = gedit_notebook_finalize;
-	object_class->get_property = gedit_notebook_get_property;
-	object_class->set_property = gedit_notebook_set_property;
-
-	gtkwidget_class->grab_focus = gedit_notebook_grab_focus;
-	gtkwidget_class->style_set = gedit_notebook_style_set;
-
-	notebook_class->change_current_page = gedit_notebook_change_current_page;
-
-	g_object_class_install_property (object_class, PROP_SHOW_TABS_MODE,
-					 g_param_spec_enum ("show-tabs-mode",
-							    "Show Tabs Mode",
-							    "When tabs should be shown",
-							    GEDIT_TYPE_NOTEBOOK_SHOW_TABS_MODE_TYPE,
-							    GEDIT_NOTEBOOK_SHOW_TABS_ALWAYS,
-							    G_PARAM_READWRITE));
-
-	signals[TAB_DETACHED] =
-		g_signal_new ("tab_detached",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (GeditNotebookClass, tab_detached),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__OBJECT,
-			      G_TYPE_NONE,
-			      1,
-			      GEDIT_TYPE_TAB);
-	signals[TABS_REORDERED] =
-		g_signal_new ("tabs_reordered",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (GeditNotebookClass, tabs_reordered),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-	signals[TAB_CLOSE_REQUEST] =
-		g_signal_new ("tab-close-request",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_LAST,
-			      G_STRUCT_OFFSET (GeditNotebookClass, tab_close_request),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__OBJECT,
-			      G_TYPE_NONE,
-			      1,
-			      GEDIT_TYPE_TAB);
+	gboolean wrap_around;
+	gint current;
 
-	g_type_class_add_private (object_class, sizeof (GeditNotebookPrivate));
-}
+	current = gtk_notebook_get_current_page (notebook);
 
-static GeditNotebook *
-get_notebook_from_widget (GtkWidget *widget)
-{
-	if (widget == NULL)
+	if (current != -1)
 	{
-		return NULL;
-	}
+		current = current + offset;
 
-	while (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
-	{
-		if (GEDIT_IS_NOTEBOOK (widget))
+		g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
+			      "gtk-keynav-wrap-around", &wrap_around,
+			      NULL);
+
+		if (wrap_around)
 		{
-			return GEDIT_NOTEBOOK (widget);
+			if (current < 0)
+			{
+				current = gtk_notebook_get_n_pages (notebook) - 1;
+			}
+			else if (current >= gtk_notebook_get_n_pages (notebook))
+			{
+				current = 0;
+			}
 		}
 
-		widget = gtk_widget_get_parent (GTK_WIDGET (widget));
+		gtk_notebook_set_current_page (notebook, current);
 	}
-
-	return NULL;
-}
-
-static GeditNotebook *
-find_notebook_at_pointer (gint abs_x,
-			  gint abs_y)
-{
-	GdkWindow *win_at_pointer;
-	gpointer widget = NULL;
-	gint x, y;
-
-	/* FIXME multi-head */
-	win_at_pointer = gdk_window_at_pointer (&x, &y);
-	if (win_at_pointer == NULL)
+	else
 	{
-		/* We are outside all windows of the same application */
-		return NULL;
+		gtk_widget_error_bell (GTK_WIDGET (notebook));
 	}
 
-	/* get the GtkWidget which owns the toplevel GdkWindow */
-	gdk_window_get_user_data (win_at_pointer, &widget);
-
-	return get_notebook_from_widget (widget);
-}
-
-static gboolean
-is_in_notebook_window (GeditNotebook *notebook,
-		       gint           abs_x, 
-		       gint           abs_y)
-{
-	GeditNotebook *nb_at_pointer;
-
-	g_return_val_if_fail (notebook != NULL, FALSE);
-
-	nb_at_pointer = find_notebook_at_pointer (abs_x, abs_y);
-
-	return (nb_at_pointer == notebook);
+	return TRUE;
 }
 
-static gint
-find_tab_num_at_pos (GeditNotebook *notebook, 
-		     gint           abs_x, 
-		     gint           abs_y)
+static void
+gedit_notebook_switch_page (GtkNotebook *notebook,
+                            GtkWidget   *page,
+                            guint        page_num)
 {
-	GtkPositionType tab_pos;
-	int page_num = 0;
-	GtkNotebook *nb = GTK_NOTEBOOK (notebook);
-	GtkWidget *page;
+	GeditNotebook *nb = GEDIT_NOTEBOOK (notebook);
 
-	tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));
+	GTK_NOTEBOOK_CLASS (gedit_notebook_parent_class)->switch_page (notebook, page, page_num);
 
-	/* For some reason unfullscreen + quick click can
-	   cause a wrong click event to be reported to the tab */
-	if (!is_in_notebook_window (notebook, abs_x, abs_y))
+	/* Remove the old page, we dont want to grow unnecessarily
+	 * the list */
+	if (nb->priv->focused_pages)
 	{
-		return NOT_IN_APP_WINDOWS;
+		nb->priv->focused_pages =
+			g_list_remove (nb->priv->focused_pages, page);
 	}
 
-	while ((page = gtk_notebook_get_nth_page (nb, page_num)) != NULL)
-	{
-		GtkWidget *tab;
-		gint max_x, max_y;
-		gint x_root, y_root;
-		GtkAllocation allocation;
-
-		tab = gtk_notebook_get_tab_label (nb, page);
-		g_return_val_if_fail (tab != NULL, AFTER_ALL_TABS);
-
-		if (!gtk_widget_get_mapped (tab))
-		{
-			++page_num;
-			continue;
-		}
-
-		gdk_window_get_origin (GDK_WINDOW (gtk_widget_get_window (tab)),
-				       &x_root, &y_root);
-
-		gtk_widget_get_allocation (tab, &allocation);
-		max_x = x_root + allocation.x + allocation.width;
-		max_y = y_root + allocation.y + allocation.height;
-
-		if (((tab_pos == GTK_POS_TOP) || 
-		     (tab_pos == GTK_POS_BOTTOM)) &&
-		    (abs_x <= max_x))
-		{
-			return page_num;
-		}
-		else if (((tab_pos == GTK_POS_LEFT) || 
-		          (tab_pos == GTK_POS_RIGHT)) && 
-		         (abs_y <= max_y))
-		{
-			return page_num;
-		}
+	nb->priv->focused_pages = g_list_append (nb->priv->focused_pages,
+	                                         page);
 
-		++page_num;
-	}
-	
-	return AFTER_ALL_TABS;
+	/* give focus to the tab */
+	gtk_widget_grab_focus (page);
 }
 
-static gint 
-find_notebook_and_tab_at_pos (gint            abs_x, 
-			      gint            abs_y,
-			      GeditNotebook **notebook,
-			      gint           *page_num)
+static void
+on_tab_label_destroyed (GtkWidget *tab_label,
+                        GeditTab  *tab)
 {
-	*notebook = find_notebook_at_pointer (abs_x, abs_y);
-	if (*notebook == NULL)
-	{
-		return NOT_IN_APP_WINDOWS;
-	}
-	
-	*page_num = find_tab_num_at_pos (*notebook, abs_x, abs_y);
-
-	if (*page_num < 0)
-	{
-		return *page_num;
-	}
-	else
-	{
-		return 0;
-	}
+	g_object_set_data (G_OBJECT (tab), "tab-label", NULL);
 }
 
-/**
- * gedit_notebook_move_tab:
- * @src: a #GeditNotebook
- * @dest: a #GeditNotebook
- * @tab: a #GeditTab
- * @dest_position: the position for @tab
- *
- * Moves @tab from @src to @dest.
- * If dest_position is greater than or equal to the number of tabs 
- * of the destination nootebook or negative, tab will be moved to the 
- * end of the tabs.
- */
-void
-gedit_notebook_move_tab (GeditNotebook *src,
-			 GeditNotebook *dest,
-			 GeditTab      *tab,
-			 gint           dest_position)
+static void
+close_button_clicked_cb (GeditTabLabel *tab_label, GeditNotebook *notebook)
 {
-	g_return_if_fail (GEDIT_IS_NOTEBOOK (src));
-	g_return_if_fail (GEDIT_IS_NOTEBOOK (dest));
-	g_return_if_fail (src != dest);
-	g_return_if_fail (GEDIT_IS_TAB (tab));
+	GeditTab *tab;
 
-	/* make sure the tab isn't destroyed while we move it */
-	g_object_ref (tab);
-	gedit_notebook_remove_tab (src, tab);
-	gedit_notebook_add_tab (dest, tab, dest_position, TRUE);
-	g_object_unref (tab);
+	tab = gedit_tab_label_get_tab (tab_label);
+	g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab);
 }
 
-/**
- * gedit_notebook_reorder_tab:
- * @src: a #GeditNotebook
- * @tab: a #GeditTab
- * @dest_position: the position for @tab
- *
- * Reorders the page containing @tab, so that it appears in @dest_position position.
- * If dest_position is greater than or equal to the number of tabs 
- * of the destination notebook or negative, tab will be moved to the 
- * end of the tabs.
- */
-void
-gedit_notebook_reorder_tab (GeditNotebook *src,
-			    GeditTab      *tab,
-			    gint           dest_position)
+static void
+smart_tab_switching_on_closure (GeditNotebook *nb,
+				GeditTab      *tab)
 {
-	gint old_position;
-	
-	g_return_if_fail (GEDIT_IS_NOTEBOOK (src));	
-	g_return_if_fail (GEDIT_IS_TAB (tab));
+	gboolean jump_to;
 
-	old_position = gtk_notebook_page_num (GTK_NOTEBOOK (src), 
-				    	      GTK_WIDGET (tab));
-				    	      
-	if (old_position == dest_position)
-		return;
+	jump_to = GPOINTER_TO_INT (g_object_get_data
+	                           (G_OBJECT (tab), "jump_to"));
 
-	gtk_notebook_reorder_child (GTK_NOTEBOOK (src), 
-				    GTK_WIDGET (tab),
-				    dest_position);
-		
-	if (!src->priv->drag_in_progress)
+	if (!jump_to || !nb->priv->focused_pages)
 	{
-		g_signal_emit (G_OBJECT (src), 
-			       signals[TABS_REORDERED], 
-			       0);
+		gtk_notebook_next_page (GTK_NOTEBOOK (nb));
 	}
-}
-
-static void
-drag_start (GeditNotebook *notebook,
-	    guint32        time)
-{
-	notebook->priv->drag_in_progress = TRUE;
-
-	/* get a new cursor, if necessary */
-	/* FIXME multi-head */
-	if (cursor == NULL)
-		cursor = gdk_cursor_new (GDK_FLEUR);
-
-	/* grab the pointer */
-	gtk_grab_add (GTK_WIDGET (notebook));
-
-	/* FIXME multi-head */
-	if (!gdk_pointer_is_grabbed ())
+	else
 	{
-		gdk_pointer_grab (gtk_widget_get_window (GTK_WIDGET (notebook)),
-				  FALSE,
-				  GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
-				  NULL, 
-				  cursor, 
-				  time);
+		GList *l;
+		GtkWidget *child;
+		int page_num;
+
+		/* activate the last focused tab */
+		l = g_list_last (nb->priv->focused_pages);
+		child = GTK_WIDGET (l->data);
+		page_num = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
+		                                  child);
+		gtk_notebook_set_current_page (GTK_NOTEBOOK (nb),
+		                               page_num);
 	}
 }
 
-static void
-drag_stop (GeditNotebook *notebook)
+static GtkWidget *
+get_tab_label (GeditTab *tab)
 {
-	if (notebook->priv->drag_in_progress)
-	{
-		g_signal_emit (G_OBJECT (notebook), 
-			       signals[TABS_REORDERED], 
-			       0);
-	}
+	GObject *tab_label;
 
-	notebook->priv->drag_in_progress = FALSE;
-	if (notebook->priv->motion_notify_handler_id != 0)
-	{
-		g_signal_handler_disconnect (G_OBJECT (notebook),
-					     notebook->priv->motion_notify_handler_id);
-		notebook->priv->motion_notify_handler_id = 0;
-	}
+	tab_label = g_object_get_data (G_OBJECT (tab), "tab-label");
+
+	return (tab_label != NULL) ? GTK_WIDGET (tab_label) : NULL;
 }
 
-/* This function is only called during dnd, we don't need to emit TABS_REORDERED
- * here, instead we do it on drag_stop
- */
 static void
-move_current_tab (GeditNotebook *notebook,
-	          gint           dest_position)
+gedit_notebook_page_removed (GtkNotebook *notebook,
+                             GtkWidget   *page,
+                             guint        page_num)
 {
-	gint cur_page_num;
+	GeditNotebook *nb = GEDIT_NOTEBOOK (notebook);
+	gint num_pages;
+	gint curr;
+	GtkWidget *tab_label;
 
-	cur_page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+	tab_label = get_tab_label (GEDIT_TAB (page));
 
-	if (dest_position != cur_page_num)
+	if (tab_label != NULL)
 	{
-		GtkWidget *cur_tab;
-		
-		cur_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
-						     cur_page_num);
-						     
-		gedit_notebook_reorder_tab (GEDIT_NOTEBOOK (notebook),
-					    GEDIT_TAB (cur_tab),
-					    dest_position);
+		g_signal_handlers_disconnect_by_func (tab_label,
+		                                      G_CALLBACK (on_tab_label_destroyed),
+		                                      page);
+		g_signal_handlers_disconnect_by_func (tab_label,
+		                                      G_CALLBACK (close_button_clicked_cb),
+		                                      nb);
 	}
-}
 
-static gboolean
-motion_notify_cb (GeditNotebook  *notebook,
-		  GdkEventMotion *event,
-		  gpointer        data)
-{
-	GeditNotebook *dest;
-	gint page_num;
-	gint result;
+	/* Remove the page from the focused pages list */
+	nb->priv->focused_pages =  g_list_remove (nb->priv->focused_pages,
+	                                          page);
 
-	if (notebook->priv->drag_in_progress == FALSE)
-	{
-		if (notebook->priv->tab_drag_and_drop_enabled == FALSE)
-			return FALSE;
-			
-		if (gtk_drag_check_threshold (GTK_WIDGET (notebook),
-					      notebook->priv->x_start,
-					      notebook->priv->y_start,
-					      event->x_root, 
-					      event->y_root))
-		{
-			drag_start (notebook, event->time);
-			return TRUE;
-		}
+	curr = gtk_notebook_get_current_page (notebook);
 
-		return FALSE;
+	if (page_num == curr)
+	{
+		smart_tab_switching_on_closure (nb, GEDIT_TAB (page));
 	}
 
-	result = find_notebook_and_tab_at_pos ((gint)event->x_root,
-					       (gint)event->y_root,
-					       &dest, 
-					       &page_num);
+	num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
 
-	if (result != NOT_IN_APP_WINDOWS)
+	/* If there is no tabs, calling this is pointless */
+	if (num_pages > 0)
 	{
-		if (dest != notebook)
-		{
-			move_current_tab_to_another_notebook (notebook, 
-							      dest,
-						      	      event, 
-						      	      page_num);
-		}
-		else
-		{
-			g_return_val_if_fail (page_num >= -1, FALSE);
-			move_current_tab (notebook, page_num);
-		}
+		update_tabs_visibility (nb, FALSE);
 	}
-
-	return FALSE;
 }
 
 static void
-move_current_tab_to_another_notebook (GeditNotebook  *src,
-				      GeditNotebook  *dest,
-				      GdkEventMotion *event,
-				      gint            dest_position)
+gedit_notebook_page_added (GtkNotebook *notebook,
+                           GtkWidget   *page,
+                           guint        page_num)
 {
-	GeditTab *tab;
-	gint cur_page;
-
-	/* This is getting tricky, the tab was dragged in a notebook
-	 * in another window of the same app, we move the tab
-	 * to that new notebook, and let this notebook handle the
-	 * drag
-	 */
-	g_return_if_fail (GEDIT_IS_NOTEBOOK (dest));
-	g_return_if_fail (dest != src);
-
-	cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (src));
-	tab = GEDIT_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (src), 
-						    cur_page));
-
-	/* stop drag in origin window */
-	/* ungrab the pointer if it's grabbed */
-	drag_stop (src);
-	if (gdk_pointer_is_grabbed ())
-	{
-		gdk_pointer_ungrab (event->time);
-	}
-	gtk_grab_remove (GTK_WIDGET (src));
+	GeditNotebook *nb = GEDIT_NOTEBOOK (notebook);
+	GtkWidget *tab_label;
 
-	gedit_notebook_move_tab (src, dest, tab, dest_position);
+	tab_label = get_tab_label (GEDIT_TAB (page));
 
-	/* start drag handling in dest notebook */
-	dest->priv->motion_notify_handler_id =
-		g_signal_connect (G_OBJECT (dest),
-				  "motion-notify-event",
-				  G_CALLBACK (motion_notify_cb),
-				  NULL);
+	g_signal_connect (tab_label,
+	                  "destroy",
+	                  G_CALLBACK (on_tab_label_destroyed),
+	                  page);
 
-	drag_start (dest, event->time);
+	g_signal_connect (tab_label,
+	                  "close-clicked",
+	                  G_CALLBACK (close_button_clicked_cb),
+	                  nb);
 }
 
-static gboolean
-button_release_cb (GeditNotebook  *notebook,
-		   GdkEventButton *event,
-		   gpointer        data)
+static void
+gedit_notebook_class_init (GeditNotebookClass *klass)
 {
-	if (notebook->priv->drag_in_progress)
-	{
-		gint cur_page_num;
-		GtkWidget *cur_page;
-
-		cur_page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-		cur_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
-						      cur_page_num);
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
+	GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
 
-		/* CHECK: I don't follow the code here -- Paolo  */
-		if (!is_in_notebook_window (notebook, event->x_root, event->y_root) &&
-		    (gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) > 1))
-		{
-			/* Tab was detached */
-			g_signal_emit (G_OBJECT (notebook),
-				       signals[TAB_DETACHED], 
-				       0, 
-				       cur_page);
-		}
+	object_class->dispose = gedit_notebook_dispose;
+	object_class->finalize = gedit_notebook_finalize;
+	object_class->get_property = gedit_notebook_get_property;
+	object_class->set_property = gedit_notebook_set_property;
 
-		/* ungrab the pointer if it's grabbed */
-		if (gdk_pointer_is_grabbed ())
-		{
-			gdk_pointer_ungrab (event->time);
-		}
-		gtk_grab_remove (GTK_WIDGET (notebook));
-	}
+	gtkwidget_class->grab_focus = gedit_notebook_grab_focus;
+	gtkwidget_class->style_set = gedit_notebook_style_set;
 
-	/* This must be called even if a drag isn't happening */
-	drag_stop (notebook);
+	notebook_class->change_current_page = gedit_notebook_change_current_page;
+	notebook_class->switch_page = gedit_notebook_switch_page;
+	notebook_class->page_removed = gedit_notebook_page_removed;
+	notebook_class->page_added = gedit_notebook_page_added;
 
-	return FALSE;
-}
+	g_object_class_install_property (object_class, PROP_SHOW_TABS_MODE,
+					 g_param_spec_enum ("show-tabs-mode",
+							    "Show Tabs Mode",
+							    "When tabs should be shown",
+							    GEDIT_TYPE_NOTEBOOK_SHOW_TABS_MODE_TYPE,
+							    GEDIT_NOTEBOOK_SHOW_TABS_ALWAYS,
+							    G_PARAM_READWRITE));
 
-static gboolean
-button_press_cb (GeditNotebook  *notebook,
-		 GdkEventButton *event,
-		 gpointer        data)
-{
-	gint tab_clicked;
-
-	if (notebook->priv->drag_in_progress)
-		return TRUE;
-
-	tab_clicked = find_tab_num_at_pos (notebook,
-					   event->x_root,
-					   event->y_root);
-					   
-	if ((event->button == 1) && 
-	    (event->type == GDK_BUTTON_PRESS) && 
-	    (tab_clicked >= 0))
-	{
-		notebook->priv->x_start = event->x_root;
-		notebook->priv->y_start = event->y_root;
-		
-		notebook->priv->motion_notify_handler_id =
-			g_signal_connect (G_OBJECT (notebook),
-					  "motion-notify-event",
-					  G_CALLBACK (motion_notify_cb), 
-					  NULL);
-	}
-	else if ((event->type == GDK_BUTTON_PRESS) && 
-		 (event->button == 3))
-	{
-		if (tab_clicked == -1)
-		{
-			// CHECK: do we really need it?
-			
-			/* consume event, so that we don't pop up the context menu when
-			 * the mouse if not over a tab label
-			 */
-			return TRUE;
-		}
-		else
-		{
-			/* Switch to the page the mouse is over, but don't consume the event */
-			gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 
-						       tab_clicked);
-		}
-	}
+	signals[TAB_CLOSE_REQUEST] =
+		g_signal_new ("tab-close-request",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GeditNotebookClass, tab_close_request),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__OBJECT,
+			      G_TYPE_NONE,
+			      1,
+			      GEDIT_TYPE_TAB);
 
-	return FALSE;
+	g_type_class_add_private (object_class, sizeof (GeditNotebookPrivate));
 }
 
 /**
@@ -766,32 +450,6 @@ gedit_notebook_new (void)
 }
 
 static void
-gedit_notebook_switch_page_cb (GtkNotebook *notebook,
-                               GtkWidget   *page,
-                               guint        page_num,
-                               gpointer     data)
-{
-	GeditNotebook *nb = GEDIT_NOTEBOOK (notebook);
-	GtkWidget *child;
-
-	child = gtk_notebook_get_nth_page (notebook, page_num);
-
-	/* Remove the old page, we dont want to grow unnecessarily
-	 * the list */
-	if (nb->priv->focused_pages)
-	{
-		nb->priv->focused_pages =
-			g_list_remove (nb->priv->focused_pages, child);
-	}
-
-	nb->priv->focused_pages = g_list_append (nb->priv->focused_pages,
-						 child);
-
-	/* give focus to the tab */
-	gtk_widget_grab_focus (child);
-}
-
-static void
 gedit_notebook_init (GeditNotebook *notebook)
 {
 	notebook->priv = GEDIT_NOTEBOOK_GET_PRIVATE (notebook);
@@ -800,11 +458,12 @@ gedit_notebook_init (GeditNotebook *notebook)
 
 	notebook->priv->show_tabs_mode = GEDIT_NOTEBOOK_SHOW_TABS_ALWAYS;
 	notebook->priv->close_buttons_sensitive = TRUE;
-	notebook->priv->tab_drag_and_drop_enabled = TRUE;
 	
 	gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
 	gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
 	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE);
+	gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook),
+	                             GEDIT_NOTEBOOK_GROUP_NAME);
 	gtk_container_set_border_width (GTK_CONTAINER (notebook), 0);
 
 	g_settings_bind (notebook->priv->ui_settings,
@@ -812,74 +471,6 @@ gedit_notebook_init (GeditNotebook *notebook)
 			 notebook,
 			 "show-tabs-mode",
 			 G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
-
-	g_signal_connect (notebook,
-			  "button-press-event",
-			  (GCallback)button_press_cb,
-			  NULL);
-	g_signal_connect (notebook,
-			  "button-release-event",
-			  (GCallback)button_release_cb,
-			  NULL);
-	gtk_widget_add_events (GTK_WIDGET (notebook),
-			       GDK_BUTTON1_MOTION_MASK);
-
-	g_signal_connect_after (G_OBJECT (notebook),
-				"switch_page",
-                                G_CALLBACK (gedit_notebook_switch_page_cb),
-                                NULL);
-}
-
-/*
- * We need to override this because when we don't show the tabs, like in
- * fullscreen we need to have wrap around too
- */
-static gboolean
-gedit_notebook_change_current_page (GtkNotebook *notebook,
-				    gint         offset)
-{
-	gboolean wrap_around;
-	gint current;
-	
-	current = gtk_notebook_get_current_page (notebook);
-
-	if (current != -1)
-	{
-		current = current + offset;
-		
-		g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
-			      "gtk-keynav-wrap-around", &wrap_around,
-			      NULL);
-		
-		if (wrap_around)
-		{
-			if (current < 0)
-			{
-				current = gtk_notebook_get_n_pages (notebook) - 1;
-			}
-			else if (current >= gtk_notebook_get_n_pages (notebook))
-			{
-				current = 0;
-			}
-		}
-		
-		gtk_notebook_set_current_page (notebook, current);
-	}
-	else
-	{
-		gtk_widget_error_bell (GTK_WIDGET (notebook));
-	}
-
-	return TRUE;
-}
-
-static void
-close_button_clicked_cb (GeditTabLabel *tab_label, GeditNotebook *notebook)
-{
-	GeditTab *tab;
-
-	tab = gedit_tab_label_get_tab (tab_label);
-	g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab);
 }
 
 static GtkWidget *
@@ -890,42 +481,11 @@ create_tab_label (GeditNotebook *nb,
 
 	tab_label = gedit_tab_label_new (tab);
 
-	g_signal_connect (tab_label,
-			  "close-clicked",
-			  G_CALLBACK (close_button_clicked_cb),
-			  nb);
-
 	g_object_set_data (G_OBJECT (tab), "tab-label", tab_label);
 
 	return tab_label;
 }
 
-static GtkWidget *
-get_tab_label (GeditTab *tab)
-{
-	GtkWidget *tab_label;
-
-	tab_label = GTK_WIDGET (g_object_get_data (G_OBJECT (tab), "tab-label"));
-	g_return_val_if_fail (tab_label != NULL, NULL);
-
-	return tab_label;
-}
-
-static void
-remove_tab_label (GeditNotebook *nb,
-		  GeditTab      *tab)
-{
-	GtkWidget *tab_label;
-
-	tab_label = get_tab_label (tab);
-
-	g_signal_handlers_disconnect_by_func (tab_label,
-					      G_CALLBACK (close_button_clicked_cb),
-					      nb);
-
-	g_object_set_data (G_OBJECT (tab), "tab-label", NULL);
-}
-
 /**
  * gedit_notebook_add_tab:
  * @nb: a #GeditNotebook
@@ -952,6 +512,12 @@ gedit_notebook_add_tab (GeditNotebook *nb,
 				  GTK_WIDGET (tab),
 				  tab_label,
 				  position);
+	gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (nb),
+	                                  GTK_WIDGET (tab),
+	                                  TRUE);
+	gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (nb),
+	                                 GTK_WIDGET (tab),
+	                                 TRUE);
 
 	update_tabs_visibility (nb, FALSE);
 
@@ -971,50 +537,44 @@ gedit_notebook_add_tab (GeditNotebook *nb,
 }
 
 static void
-smart_tab_switching_on_closure (GeditNotebook *nb,
-				GeditTab      *tab)
-{
-	gboolean jump_to;
-
-	jump_to = GPOINTER_TO_INT (g_object_get_data
-				   (G_OBJECT (tab), "jump_to"));
-
-	if (!jump_to || !nb->priv->focused_pages)
-	{
-		gtk_notebook_next_page (GTK_NOTEBOOK (nb));
-	}
-	else
-	{
-		GList *l;
-		GtkWidget *child;
-		int page_num;
-
-		/* activate the last focused tab */
-		l = g_list_last (nb->priv->focused_pages);
-		child = GTK_WIDGET (l->data);
-		page_num = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
-						  child);
-		gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), 
-					       page_num);
-	}
-}
-
-static void
 remove_tab (GeditTab      *tab,
-	    GeditNotebook *nb)
+            GeditNotebook *nb)
 {
 	gint position;
-	gint num_pages;
 
 	position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
 
-	remove_tab_label (nb, tab);
-	num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
 	gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
+}
 
-	/* If there is no tabs, calling this is pointless */
-	if (--num_pages > 0)
-		update_tabs_visibility (nb, FALSE);
+/**
+ * gedit_notebook_move_tab:
+ * @src: a #GeditNotebook
+ * @dest: a #GeditNotebook
+ * @tab: a #GeditTab
+ * @dest_position: the position for @tab
+ *
+ * Moves @tab from @src to @dest.
+ * If dest_position is greater than or equal to the number of tabs
+ * of the destination nootebook or negative, tab will be moved to the
+ * end of the tabs.
+ */
+void
+gedit_notebook_move_tab (GeditNotebook *src,
+                         GeditNotebook *dest,
+                         GeditTab      *tab,
+                         gint           dest_position)
+{
+	g_return_if_fail (GEDIT_IS_NOTEBOOK (src));
+	g_return_if_fail (GEDIT_IS_NOTEBOOK (dest));
+	g_return_if_fail (src != dest);
+	g_return_if_fail (GEDIT_IS_TAB (tab));
+
+	/* make sure the tab isn't destroyed while we move it */
+	g_object_ref (tab);
+	remove_tab (tab, src);
+	gedit_notebook_add_tab (dest, tab, dest_position, TRUE);
+	g_object_unref (tab);
 }
 
 /**
@@ -1028,23 +588,9 @@ void
 gedit_notebook_remove_tab (GeditNotebook *nb,
 			   GeditTab      *tab)
 {
-	gint position, curr;
-
 	g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
 	g_return_if_fail (GEDIT_IS_TAB (tab));
 
-	/* Remove the page from the focused pages list */
-	nb->priv->focused_pages =  g_list_remove (nb->priv->focused_pages,
-						  tab);
-
-	position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
-	curr = gtk_notebook_get_current_page (GTK_NOTEBOOK (nb));
-
-	if (position == curr)
-	{
-		smart_tab_switching_on_closure (nb, tab);
-	}
-
 	remove_tab (tab, nb);
 }
 
@@ -1120,43 +666,6 @@ gedit_notebook_get_close_buttons_sensitive (GeditNotebook *nb)
 	return nb->priv->close_buttons_sensitive;
 }
 
-/**
- * gedit_notebook_set_tab_drag_and_drop_enabled:
- * @nb: a #GeditNotebook
- * @enable: %TRUE to enable the drag and drop
- *
- * Sets whether drag and drop of tabs in the @nb is enabled.
- */
-void
-gedit_notebook_set_tab_drag_and_drop_enabled (GeditNotebook *nb,
-					      gboolean       enable)
-{
-	g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
-	
-	enable = (enable != FALSE);
-	
-	if (enable == nb->priv->tab_drag_and_drop_enabled)
-		return;
-		
-	nb->priv->tab_drag_and_drop_enabled = enable;		
-}
-
-/**
- * gedit_notebook_get_tab_drag_and_drop_enabled:
- * @nb: a #GeditNotebook
- *
- * Whether the drag and drop is enabled in the @nb.
- *
- * Returns: %TRUE if the drag and drop is enabled.
- */
-gboolean	
-gedit_notebook_get_tab_drag_and_drop_enabled (GeditNotebook *nb)
-{
-	g_return_val_if_fail (GEDIT_IS_NOTEBOOK (nb), TRUE);
-	
-	return nb->priv->tab_drag_and_drop_enabled;
-}
-
 void
 gedit_notebook_collapse_border (GeditNotebook *nb,
 				gboolean       collapse)
diff --git a/gedit/gedit-notebook.h b/gedit/gedit-notebook.h
index 79a2215..f9256fa 100644
--- a/gedit/gedit-notebook.h
+++ b/gedit/gedit-notebook.h
@@ -87,9 +87,6 @@ struct _GeditNotebookClass
         GtkNotebookClass parent_class;
 
 	/* Signals */
-	void	 (* tab_detached)	(GeditNotebook *notebook,
-					 GeditTab      *tab);
-	void	 (* tabs_reordered)	(GeditNotebook *notebook);
 	void	 (* tab_close_request)	(GeditNotebook *notebook,
 					 GeditTab      *tab);
 };
@@ -106,20 +103,16 @@ void		gedit_notebook_add_tab		(GeditNotebook *nb,
 						 gint           position,
 						 gboolean       jump_to);
 
+void		gedit_notebook_move_tab		(GeditNotebook *src,
+						 GeditNotebook *dest,
+						 GeditTab      *tab,
+						 gint           dest_position);
+
 void		gedit_notebook_remove_tab	(GeditNotebook *nb,
 						 GeditTab      *tab);
 
 void		gedit_notebook_remove_all_tabs 	(GeditNotebook *nb);
 
-void		gedit_notebook_reorder_tab	(GeditNotebook *src,
-			    			 GeditTab      *tab,
-			    			 gint           dest_position);
-			    			 
-void            gedit_notebook_move_tab		(GeditNotebook *src,
-						 GeditNotebook *dest,
-						 GeditTab      *tab,
-						 gint           dest_position);
-
 void		gedit_notebook_set_close_buttons_sensitive
 						(GeditNotebook *nb,
 						 gboolean       sensitive);
@@ -127,13 +120,6 @@ void		gedit_notebook_set_close_buttons_sensitive
 gboolean	gedit_notebook_get_close_buttons_sensitive
 						(GeditNotebook *nb);
 
-void		gedit_notebook_set_tab_drag_and_drop_enabled
-						(GeditNotebook *nb,
-						 gboolean       enable);
-
-gboolean	gedit_notebook_get_tab_drag_and_drop_enabled
-						(GeditNotebook *nb);
-
 void		gedit_notebook_collapse_border	(GeditNotebook *nb,
 						 gboolean       collapse);
 
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 20f5d7f..dad5a67 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -2249,7 +2249,7 @@ clone_window (GeditWindow *origin)
 	GeditApp  *app;
 	gint panel_page;
 
-	gedit_debug (DEBUG_WINDOW);	
+	gedit_debug (DEBUG_WINDOW);
 
 	app = gedit_app_get_default ();
 
@@ -2286,7 +2286,7 @@ clone_window (GeditWindow *origin)
 	gtk_widget_set_visible (window->priv->side_panel,
 				gtk_widget_get_visible (origin->priv->side_panel));
 	gtk_widget_set_visible (window->priv->bottom_panel,
-                                gtk_widget_get_visible (origin->priv->bottom_panel));
+	                        gtk_widget_get_visible (origin->priv->bottom_panel));
 
 	set_statusbar_style (window, origin);
 	set_toolbar_style (window, origin);
@@ -2775,9 +2775,6 @@ set_sensitivity_according_to_window_state (GeditWindow *window)
 	{
 		gedit_notebook_set_close_buttons_sensitive (notebook,
 							    !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
-							    
-		gedit_notebook_set_tab_drag_and_drop_enabled (notebook,
-							      !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
 		notebook = gedit_multi_notebook_get_nth_notebook (window->priv->multi_notebook,
 								  ++i);
 	}
@@ -3604,7 +3601,10 @@ on_tab_removed (GeditMultiNotebook *multi,
 					      G_CALLBACK (drop_uris_cb),
 					      window);
 	g_signal_handlers_disconnect_by_func (doc,
-					      G_CALLBACK (update_cursor_position_statusbar), 
+					      G_CALLBACK (bracket_matched_cb),
+					      window);
+	g_signal_handlers_disconnect_by_func (doc,
+					      G_CALLBACK (update_cursor_position_statusbar),
 					      window);
 	g_signal_handlers_disconnect_by_func (doc, 
 					      G_CALLBACK (can_search_again),
@@ -3702,28 +3702,25 @@ on_tabs_reordered (GeditMultiNotebook *multi,
 	g_signal_emit (G_OBJECT (window), signals[TABS_REORDERED], 0);
 }
 
-static void
-on_tab_detached (GeditMultiNotebook *multi,
-		 GeditNotebook      *notebook,
-		 GeditTab           *tab,
-		 GeditWindow        *window)
+static GtkNotebook *
+on_notebook_create_window (GeditMultiNotebook *mnb,
+                           GtkNotebook        *notebook,
+                           GtkWidget          *page,
+                           gint                x,
+                           gint                y,
+                           GeditWindow        *window)
 {
 	GeditWindow *new_window;
-	GeditNotebook *new_notebook;
-	
-	gedit_debug (DEBUG_WINDOW);
-	
+	GtkWidget *new_notebook;
+
 	new_window = clone_window (window);
-	new_notebook = gedit_multi_notebook_get_active_notebook (new_window->priv->multi_notebook);
 
-	gedit_notebook_move_tab (notebook,
-				 new_notebook,
-				 tab, 0);
+	gtk_window_move (GTK_WINDOW (new_window), x, y);
+	gtk_widget_show (GTK_WIDGET (new_window));
 
-	gtk_window_set_position (GTK_WINDOW (new_window), 
-				 GTK_WIN_POS_MOUSE);
+	new_notebook = _gedit_window_get_notebook (GEDIT_WINDOW (new_window));
 
-	gtk_widget_show (GTK_WIDGET (new_window));
+	return GTK_NOTEBOOK (new_notebook);
 }
 
 static void 
@@ -4220,16 +4217,16 @@ gedit_window_init (GeditWindow *window)
 			  window);
 
 	g_signal_connect (window->priv->multi_notebook,
-			  "tab-detached",
-			  G_CALLBACK (on_tab_detached),
-			  window);
-
-	g_signal_connect (window->priv->multi_notebook,
 			  "tabs-reordered",
 			  G_CALLBACK (on_tabs_reordered),
 			  window);
 
 	g_signal_connect (window->priv->multi_notebook,
+	                  "create-window",
+	                  G_CALLBACK (on_notebook_create_window),
+	                  window);
+
+	g_signal_connect (window->priv->multi_notebook,
 			  "show-popup-menu",
 			  G_CALLBACK (on_show_popup_menu),
 			  window);



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