Index: configure.ac
===================================================================
--- configure.ac	(revision 5722)
+++ configure.ac	(working copy)
@@ -147,7 +147,7 @@
 
 PKG_CHECK_MODULES(GEDIT, [
 	glib-2.0 >= 2.12.0
-	gtk+-2.0 >= 2.10.0
+	gtk+-2.0 >= 2.11.0
 	gtksourceview-2.0 >= 1.90.2
 	libgnomeui-2.0 >= 2.16.0
 	libglade-2.0 >= 2.5.1
Index: gedit/gedit-documents-panel.c
===================================================================
--- gedit/gedit-documents-panel.c	(revision 5722)
+++ gedit/gedit-documents-panel.c	(working copy)
@@ -649,8 +649,8 @@
 	if (new_position > old_position)
 		new_position = MAX (0, new_position - 1);
 		
-	gedit_notebook_reorder_tab (GEDIT_NOTEBOOK (nb),
-				    tab,
+	gtk_notebook_reorder_child (GTK_NOTEBOOK (nb),
+				    GTK_WIDGET(tab),
 				    new_position);
 
 	panel->priv->is_reodering = FALSE;				    
Index: gedit/gedit-notebook.c
===================================================================
--- gedit/gedit-notebook.c	(revision 5722)
+++ gedit/gedit-notebook.c	(working copy)
@@ -66,14 +66,7 @@
 struct _GeditNotebookPrivate
 {
 	GList         *focused_pages;
-	GeditTooltips *title_tips;
-	gulong         motion_notify_handler_id;
-	gint           x_start;
-	gint           y_start;
-	gint           drag_in_progress : 1;
-	gint	       always_show_tabs : 1;
 	gint           close_buttons_sensitive : 1;
-	gint           tab_drag_and_drop_enabled : 1;
 };
 
 G_DEFINE_TYPE(GeditNotebook, gedit_notebook, GTK_TYPE_NOTEBOOK)
@@ -80,21 +73,9 @@
 
 static void gedit_notebook_finalize (GObject *object);
 
-static void move_current_tab_to_another_notebook  (GeditNotebook  *src,
-						   GeditNotebook  *dest,
-						   GdkEventMotion *event,
-						   gint            dest_position);
-
-/* Local variables */
-static GdkCursor *cursor = NULL;
-
 /* Signals */
 enum
 {
-	TAB_ADDED,
-	TAB_REMOVED,
-	TABS_REORDERED,
-	TAB_DETACHED,
 	TAB_CLOSE_REQUEST,
 	LAST_SIGNAL
 };
@@ -108,45 +89,6 @@
 
 	object_class->finalize = gedit_notebook_finalize;
 
-	signals[TAB_ADDED] =
-		g_signal_new ("tab_added",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (GeditNotebookClass, tab_added),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__OBJECT,
-			      G_TYPE_NONE,
-			      1,
-			      GEDIT_TYPE_TAB);
-	signals[TAB_REMOVED] =
-		g_signal_new ("tab_removed",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (GeditNotebookClass, tab_removed),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__OBJECT,
-			      G_TYPE_NONE,
-			      1,
-			      GEDIT_TYPE_TAB);
-	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),
@@ -161,141 +103,6 @@
 	g_type_class_add_private (object_class, sizeof(GeditNotebookPrivate));
 }
 
-static GeditNotebook *
-find_notebook_at_pointer (gint abs_x, gint abs_y)
-{
-	GdkWindow *win_at_pointer;
-	GdkWindow *toplevel_win;
-	gpointer toplevel = NULL;
-	gint x, y;
-
-	/* FIXME multi-head */
-	win_at_pointer = gdk_window_at_pointer (&x, &y);
-	if (win_at_pointer == NULL)
-	{
-		/* We are outside all windows of the same application */
-		return NULL;
-	}
-
-	toplevel_win = gdk_window_get_toplevel (win_at_pointer);
-
-	/* get the GtkWidget which owns the toplevel GdkWindow */
-	gdk_window_get_user_data (toplevel_win, &toplevel);
-
-	/* toplevel should be an GeditWindow */
-	if ((toplevel != NULL) && 
-	    GEDIT_IS_WINDOW (toplevel))
-	{
-		return GEDIT_NOTEBOOK (_gedit_window_get_notebook
-						(GEDIT_WINDOW (toplevel)));
-	}
-
-	/* We are outside all windows containing a notebook */
-	return NULL;
-}
-
-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);
-}
-
-static gint
-find_tab_num_at_pos (GeditNotebook *notebook, 
-		     gint           abs_x, 
-		     gint           abs_y)
-{
-	GtkPositionType tab_pos;
-	int page_num = 0;
-	GtkNotebook *nb = GTK_NOTEBOOK (notebook);
-	GtkWidget *page;
-
-	tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));
-
-	if (GTK_NOTEBOOK (notebook)->first_tab == NULL)
-	{
-		return AFTER_ALL_TABS;
-	}
-
-	/* 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))
-	{
-		return NOT_IN_APP_WINDOWS;
-	}
-
-	while ((page = gtk_notebook_get_nth_page (nb, page_num)) != NULL)
-	{
-		GtkWidget *tab;
-		gint max_x, max_y;
-		gint x_root, y_root;
-
-		tab = gtk_notebook_get_tab_label (nb, page);
-		g_return_val_if_fail (tab != NULL, AFTER_ALL_TABS);
-
-		if (!GTK_WIDGET_MAPPED (GTK_WIDGET (tab)))
-		{
-			++page_num;
-			continue;
-		}
-
-		gdk_window_get_origin (GDK_WINDOW (tab->window),
-				       &x_root, &y_root);
-
-		max_x = x_root + tab->allocation.x + tab->allocation.width;
-		max_y = y_root + tab->allocation.y + tab->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;
-		}
-
-		++page_num;
-	}
-	
-	return AFTER_ALL_TABS;
-}
-
-static gint 
-find_notebook_and_tab_at_pos (gint            abs_x, 
-			      gint            abs_y,
-			      GeditNotebook **notebook,
-			      gint           *page_num)
-{
-	*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;
-	}
-}
-
 /* 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. */
@@ -305,7 +112,7 @@
 			 GeditTab      *tab,
 			 gint           dest_position)
 {
-	g_return_if_fail (GEDIT_IS_NOTEBOOK (src));	
+	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));
@@ -317,288 +124,6 @@
 	g_object_unref (tab);
 }
 
-/* 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_reorder_tab (GeditNotebook *src,
-			    GeditTab      *tab,
-			    gint           dest_position)
-{
-	gint old_position;
-	
-	g_return_if_fail (GEDIT_IS_NOTEBOOK (src));	
-	g_return_if_fail (GEDIT_IS_TAB (tab));
-
-	old_position = gtk_notebook_page_num (GTK_NOTEBOOK (src), 
-				    	      GTK_WIDGET (tab));
-				    	      
-	if (old_position == dest_position)
-		return;
-
-	gtk_notebook_reorder_child (GTK_NOTEBOOK (src), 
-				    GTK_WIDGET (tab),
-				    dest_position);
-		
-	if (!src->priv->drag_in_progress)
-	{
-		g_signal_emit (G_OBJECT (src), 
-			       signals[TABS_REORDERED], 
-			       0);
-	}
-}
-
-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 ())
-	{
-		gdk_pointer_grab (GTK_WIDGET (notebook)->window,
-				  FALSE,
-				  GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
-				  NULL, 
-				  cursor, 
-				  time);
-	}
-}
-
-static void
-drag_stop (GeditNotebook *notebook)
-{
-	if (notebook->priv->drag_in_progress)
-	{
-		g_signal_emit (G_OBJECT (notebook), 
-			       signals[TABS_REORDERED], 
-			       0);
-	}
-
-	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;
-	}
-}
-
-/* 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)
-{
-	gint cur_page_num;
-
-	cur_page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
-	if (dest_position != cur_page_num)
-	{
-		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);
-	}
-}
-
-static gboolean
-motion_notify_cb (GeditNotebook  *notebook,
-		  GdkEventMotion *event,
-		  gpointer        data)
-{
-	GeditNotebook *dest;
-	gint page_num;
-	gint result;
-
-	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;
-		}
-
-		return FALSE;
-	}
-
-	result = find_notebook_and_tab_at_pos ((gint)event->x_root,
-					       (gint)event->y_root,
-					       &dest, 
-					       &page_num);
-
-	if (result != NOT_IN_APP_WINDOWS)
-	{
-		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);
-		}
-	}
-
-	return FALSE;
-}
-
-static void
-move_current_tab_to_another_notebook (GeditNotebook  *src,
-				      GeditNotebook  *dest,
-				      GdkEventMotion *event,
-				      gint            dest_position)
-{
-	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));
-
-	gedit_notebook_move_tab (src, dest, tab, dest_position);
-
-	/* 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);
-
-	drag_start (dest, event->time);
-}
-
-static gboolean
-button_release_cb (GeditNotebook  *notebook,
-		   GdkEventButton *event,
-		   gpointer        data)
-{
-	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);
-
-		/* 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);
-		}
-
-		/* ungrab the pointer if it's grabbed */
-		if (gdk_pointer_is_grabbed ())
-		{
-			gdk_pointer_ungrab (event->time);
-		}
-		gtk_grab_remove (GTK_WIDGET (notebook));
-	}
-
-	/* This must be called even if a drag isn't happening */
-	drag_stop (notebook);
-
-	return FALSE;
-}
-
-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);
-		}
-	}
-
-	return FALSE;
-}
-
 GtkWidget *
 gedit_notebook_new (void)
 {
@@ -605,6 +130,8 @@
 	return GTK_WIDGET (g_object_new (GEDIT_TYPE_NOTEBOOK, NULL));
 }
 
+/* CHECK : called twice for each switch
+ */
 static void
 gedit_notebook_switch_page_cb (GtkNotebook     *notebook,
                                GtkNotebookPage *page,
@@ -633,26 +160,6 @@
 	gtk_widget_grab_focus (GTK_WIDGET (view));
 }
 
-/*
- * update_tabs_visibility: Hide tabs if there is only one tab
- * and the pref is not set.
- */
-static void
-update_tabs_visibility (GeditNotebook *nb, 
-			gboolean       before_inserting)
-{
-	gboolean show_tabs;
-	guint num;
-
-	num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
-
-	if (before_inserting) num++;
-
-	show_tabs = (nb->priv->always_show_tabs || num > 1);
-
-	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs);
-}
-
 static void
 gedit_notebook_init (GeditNotebook *notebook)
 {
@@ -659,27 +166,10 @@
 	notebook->priv = GEDIT_NOTEBOOK_GET_PRIVATE (notebook);
 
 	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), FALSE);
-
-	notebook->priv->title_tips = gedit_tooltips_new ();
-	g_object_ref_sink (notebook->priv->title_tips);
-
-	notebook->priv->always_show_tabs = TRUE;
-
-	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);
+	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE);
 
 	g_signal_connect_after (G_OBJECT (notebook), 
 				"switch_page",
@@ -694,8 +184,6 @@
 
 	if (notebook->priv->focused_pages)
 		g_list_free (notebook->priv->focused_pages);
-		
-	g_object_unref (notebook->priv->title_tips);
 
 	G_OBJECT_CLASS (gedit_notebook_parent_class)->finalize (object);
 }
@@ -708,7 +196,6 @@
 	GtkWidget *ebox;
 	GtkWidget *button;
 	GtkWidget *spinner;
-	GeditTooltips *tips;	
 	gchar *str;
 	GtkImage *icon;
 	GeditTabState  state;
@@ -713,7 +200,6 @@
 	GtkImage *icon;
 	GeditTabState  state;
 	
-	tips = GEDIT_TOOLTIPS (g_object_get_data (G_OBJECT (hbox), "tooltips"));
 	label = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label"));
 	ebox = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label-ebox"));
 	icon = GTK_IMAGE (g_object_get_data (G_OBJECT (hbox), "icon"));
@@ -722,8 +208,7 @@
 
 	nb = GEDIT_NOTEBOOK (gtk_widget_get_parent (GTK_WIDGET (tab)));
 
-	g_return_if_fail ((tips    != NULL) && 
-			  (label   != NULL) && 
+	g_return_if_fail ((label   != NULL) && 
 			  (ebox    != NULL) && 
 			  (button  != NULL) &&
 			  (icon    != NULL) &&
@@ -739,7 +224,7 @@
 	str = _gedit_tab_get_tooltips (tab);
 	g_return_if_fail (str != NULL);
 	
-	gedit_tooltips_set_tip (tips, ebox, str, NULL);
+	gtk_widget_set_tooltip_markup (ebox, str);
 	g_free (str);
 		
 	state = gedit_tab_get_state (tab);
@@ -841,8 +326,8 @@
 	gtk_container_add (GTK_CONTAINER (close_button), image);
 	gtk_box_pack_start (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
 
-	gedit_tooltips_set_tip (nb->priv->title_tips, close_button,
-			      _("Close document"), NULL);
+	gtk_widget_set_tooltip_text (close_button,
+			       _("Close document"));
 
 	g_signal_connect (close_button,
 			  "clicked",
@@ -886,7 +371,6 @@
 	g_object_set_data (G_OBJECT (hbox), "icon", icon);
 	g_object_set_data (G_OBJECT (hbox), "close-button", close_button);
 	g_object_set_data (G_OBJECT (tab), "close-button", close_button);
-	g_object_set_data (G_OBJECT (hbox), "tooltips", nb->priv->title_tips);
 
 	return hbox;
 }
@@ -892,21 +376,10 @@
 }
 
 void
-gedit_notebook_set_always_show_tabs (GeditNotebook *nb, 
-				     gboolean       show_tabs)
-{
-	g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
-
-	nb->priv->always_show_tabs = (show_tabs != FALSE);
-
-	update_tabs_visibility (nb, FALSE);
-}
-
-void
 gedit_notebook_add_tab (GeditNotebook *nb,
-		        GeditTab      *tab,
-		        gint           position,
-		        gboolean       jump_to)
+			GeditTab      *tab,
+			gint           position,
+			gboolean       jump_to)
 {
 	GtkWidget *label;
 
@@ -915,8 +388,6 @@
 
 	label = build_tab_label (nb, tab);
 
-	update_tabs_visibility (nb, TRUE);
-
 	gtk_notebook_insert_page (GTK_NOTEBOOK (nb), 
 				  GTK_WIDGET (tab),
 				  label, 
@@ -922,20 +393,26 @@
 				  label, 
 				  position);
 
+	/* Set the tab detachable and reorderable */
+	gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (nb),
+				      GTK_WIDGET (tab),
+				      TRUE);
+	gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (nb),
+					 GTK_WIDGET (tab),
+					 TRUE);
+
 	sync_name (tab, NULL, label);
-		         
+
 	g_signal_connect_object (tab, 
 				 "notify::name",
-			         G_CALLBACK (sync_name), 
-			         label, 
-			         0);
-	g_signal_connect_object (tab, 
+				 G_CALLBACK (sync_name), 
+				 label,
+				 0);
+				 g_signal_connect_object (tab,
 				 "notify::state",
-			         G_CALLBACK (sync_name), 
-			         label, 
-			         0);			         
-
-	g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
+				 G_CALLBACK (sync_name), 
+				 label, 
+				 0);
 
 	/* The signal handler may have reordered the tabs */
 	position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), 
@@ -995,10 +472,7 @@
 
 	label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
 	ebox = GTK_WIDGET (g_object_get_data (G_OBJECT (label), "label-ebox"));
-	gedit_tooltips_set_tip (GEDIT_TOOLTIPS (nb->priv->title_tips), 
-			        ebox, 
-			        NULL, 
-			        NULL);
+	gtk_widget_set_tooltip_text (ebox, NULL);
 
 	g_signal_handlers_disconnect_by_func (tab,
 					      G_CALLBACK (sync_name), 
@@ -1011,11 +485,7 @@
 
 	gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
 
-	update_tabs_visibility (nb, FALSE);
-
-	g_signal_emit (G_OBJECT (nb), signals[TAB_REMOVED], 0, tab);
-
-	g_object_unref (tab);	
+	g_object_unref (tab);
 }
 
 void
@@ -1101,26 +571,3 @@
 	
 	return nb->priv->close_buttons_sensitive;
 }
-
-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;		
-}
-
-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;
-}
-
Index: gedit/gedit-notebook.h
===================================================================
--- gedit/gedit-notebook.h	(revision 5722)
+++ gedit/gedit-notebook.h	(working copy)
@@ -81,16 +81,8 @@
         GtkNotebookClass parent_class;
 
 	/* Signals */
-	void	 (* tab_added)      (GeditNotebook *notebook,
-				     GeditTab      *tab);
-	void	 (* tab_removed)    (GeditNotebook *notebook,
-				     GeditTab      *tab);
-	void	 (* tab_detached)   (GeditNotebook *notebook,
-				     GeditTab      *tab);
-	void	 (* tabs_reordered) (GeditNotebook *notebook);
-	void	 (* tab_close_request)
-				    (GeditNotebook *notebook,
-				     GeditTab      *tab);
+	void	 (* tab_close_request)(GeditNotebook *notebook,
+				       GeditTab      *tab);
 };
 
 /*
@@ -110,11 +102,7 @@
 
 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,
+void		gedit_notebook_move_tab		(GeditNotebook *src,
 						 GeditNotebook *dest,
 						 GeditTab      *tab,
 						 gint           dest_position);
@@ -119,11 +107,6 @@
 						 GeditTab      *tab,
 						 gint           dest_position);
 
-/* FIXME: do we really need this function ? */
-void		gedit_notebook_set_always_show_tabs	
-						(GeditNotebook *nb,
-						 gboolean       show_tabs);
-
 void		gedit_notebook_set_close_buttons_sensitive
 						(GeditNotebook *nb,
 						 gboolean       sensitive);
@@ -131,13 +114,6 @@
 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);
-
 G_END_DECLS
 
 #endif /* GEDIT_NOTEBOOK_H */
Index: gedit/gedit-window.c
===================================================================
--- gedit/gedit-window.c	(revision 5722)
+++ gedit/gedit-window.c	(working copy)
@@ -80,7 +80,8 @@
 
 enum
 {
-	TARGET_URI_LIST = 100
+	TARGET_URI_LIST = 100,
+	DND_DRAG_TYPE_TAB = 101
 };
 
 static const GtkTargetEntry drag_types[] =
@@ -86,6 +87,7 @@
 static const GtkTargetEntry drag_types[] =
 {
 	{ "text/uri-list", 0, TARGET_URI_LIST },
+	{ "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, DND_DRAG_TYPE_TAB},
 };
 
 G_DEFINE_TYPE(GeditWindow, gedit_window, GTK_TYPE_WINDOW)
@@ -317,7 +319,7 @@
 gedit_window_tab_removed (GeditWindow *window,
 			  GeditTab    *tab) 
 {
-	gedit_plugins_engine_garbage_collect();
+	gedit_plugins_engine_garbage_collect ();
 }
 
 static void
@@ -2073,9 +2075,6 @@
 	gedit_notebook_set_close_buttons_sensitive (GEDIT_NOTEBOOK (window->priv->notebook),
 						    !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
 						    
-	gedit_notebook_set_tab_drag_and_drop_enabled (GEDIT_NOTEBOOK (window->priv->notebook),
-						      !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
-
 	if ((window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION) != 0)
 	{
 		/* TODO: If we really care, Find could be active
@@ -2279,6 +2278,10 @@
 	gedit_plugins_engine_update_plugins_ui (window, FALSE);
 }
 
+/* CHECK Shall we break this callback in two parts, one handling uris the other tabs ?
+ * Only the GeditView is a drop target, even if the whole window should accept tabs as
+ * drag data (see line 3265), can someone explain me ?
+ */ 
 static void
 drag_data_received_cb (GtkWidget        *widget,
 		       GdkDragContext   *context,
@@ -2290,48 +2293,72 @@
 		       gpointer          data)
 {
 	GtkWidget *target_window;
-	gchar **uris;
-	GSList *uri_list = NULL;
-	gint i;
-
-	if (info != TARGET_URI_LIST)
+	
+	if (info != TARGET_URI_LIST && info != DND_DRAG_TYPE_TAB)
 		return;
-
 	g_return_if_fail (widget != NULL);
-
 	target_window = gtk_widget_get_toplevel (widget);
 	g_return_if_fail (GEDIT_IS_WINDOW (target_window));
-	
-	if ((GEDIT_WINDOW(target_window)->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION) != 0)
-		return;
-
-	uris = g_uri_list_extract_uris ((gchar *) selection_data->data);
 
-	for (i = 0; uris[i] != NULL; i++)
+	if (info == TARGET_URI_LIST)
 	{
-		gchar *uri;
-		
-		uri = gedit_utils_make_canonical_uri_from_shell_arg (uris[i]);
-		
-		/* Silently ignore malformed URI/filename */
-		if (uri != NULL)
-			uri_list = g_slist_prepend (uri_list, uri);	
+		gchar **uris;
+		GSList *uri_list = NULL;
+		gint i;
+			
+		if ((GEDIT_WINDOW(target_window)->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION) != 0)
+			return;
+	
+		uris = g_uri_list_extract_uris ((gchar *) selection_data->data);
+	
+		for (i = 0; uris[i] != NULL; i++)
+		{
+			gchar *uri;
+			
+			uri = gedit_utils_make_canonical_uri_from_shell_arg (uris[i]);
+			
+			/* Silently ignore malformed URI/filename */
+			if (uri != NULL)
+				uri_list = g_slist_prepend (uri_list, uri);	
+		}
+	
+		g_strfreev (uris);
+	
+		if (uri_list == NULL)
+			return;
+	
+		uri_list = g_slist_reverse (uri_list);
+	
+		gedit_commands_load_uris (GEDIT_WINDOW (target_window),
+					  uri_list,
+					  NULL,
+					  0);
+	
+		g_slist_foreach (uri_list, (GFunc) g_free, NULL);	
+		g_slist_free (uri_list);
 	}
-
-	g_strfreev (uris);
-
-	if (uri_list == NULL)
-		return;
-
-	uri_list = g_slist_reverse (uri_list);
+	else if (info == DND_DRAG_TYPE_TAB)
+	{
+		GtkWidget *target_notebook;
+		GtkWidget *source_notebook;
+		GtkWidget **child;
 
-	gedit_commands_load_uris (GEDIT_WINDOW (target_window),
-				  uri_list,
-				  NULL,
-				  0);
+		source_notebook = gtk_drag_get_source_widget (context);
+		target_notebook = GEDIT_WINDOW (target_window)->priv->notebook;
+		child = (void*) selection_data->data;
+		
+		g_return_if_fail (GEDIT_IS_NOTEBOOK (source_notebook));
+		g_return_if_fail (GEDIT_IS_NOTEBOOK (target_notebook));
+		g_return_if_fail (GEDIT_IS_TAB (*child));
+		
+		if (source_notebook == target_notebook)
+			return;
 
-	g_slist_foreach (uri_list, (GFunc) g_free, NULL);	
-	g_slist_free (uri_list);
+		gedit_notebook_move_tab (GEDIT_NOTEBOOK (source_notebook),
+					 GEDIT_NOTEBOOK (target_notebook),
+					 GEDIT_TAB (*child),
+					 -1);
+	}
 }
 
 /*
@@ -2530,9 +2557,10 @@
 }
 
 static void
-notebook_tab_added (GeditNotebook *notebook,
-		    GeditTab      *tab,
-		    GeditWindow   *window)
+notebook_tab_added (GtkNotebook *notebook,
+		    GtkWidget   *tab,
+		    guint        page_num,
+		    GeditWindow	*window)
 {
 	GeditView *view;
 	GeditDocument *doc;
@@ -2555,8 +2583,8 @@
 	gtk_action_set_sensitive (action,
 				  window->priv->num_tabs > 1);
 
-	view = gedit_tab_get_view (tab);
-	doc = gedit_tab_get_document (tab);
+	view = gedit_tab_get_view (GEDIT_TAB (tab));
+	doc = gedit_tab_get_document (GEDIT_TAB (tab));
 
 	/* IMPORTANT: remember to disconnect the signal in notebook_tab_removed
 	 * if a new signal is connected here */
@@ -2636,9 +2664,10 @@
 }
 
 static void
-notebook_tab_removed (GeditNotebook *notebook,
-		      GeditTab      *tab,
-		      GeditWindow   *window)
+notebook_tab_removed (GtkNotebook *notebook,
+		      GtkWidget   *tab,
+		      guint        page_num,
+		      GeditWindow *window)
 {
 	GeditView     *view;
 	GeditDocument *doc;
@@ -2650,8 +2679,8 @@
 
 	--window->priv->num_tabs;
 
-	view = gedit_tab_get_view (tab);
-	doc = gedit_tab_get_document (tab);
+	view = gedit_tab_get_view (GEDIT_TAB (tab));
+	doc = gedit_tab_get_document (GEDIT_TAB (tab));
 
 	g_signal_handlers_disconnect_by_func (tab,
 					      G_CALLBACK (sync_name), 
@@ -2752,8 +2781,10 @@
 }
 
 static void
-notebook_tabs_reordered (GeditNotebook *notebook,
-			 GeditWindow   *window)
+notebook_tabs_reordered (GtkNotebook *notebook,
+			GtkWidget    *child,
+			guint         page_num,
+			GeditWindow  *window)
 {
 	update_documents_list_menu (window);
 	update_next_prev_doc_sensitivity_per_window (window);
@@ -2761,24 +2792,30 @@
 	g_signal_emit (G_OBJECT (window), signals[TABS_REORDERED], 0);
 }
 
-static void
-notebook_tab_detached (GeditNotebook *notebook,
-		       GeditTab      *tab,
-		       GeditWindow   *window)
+static GtkNotebook*
+notebook_tab_detached  (GtkNotebook *source,
+			GtkWidget   *page,
+			gint         x,
+			gint         y,
+			GeditWindow *window)
 {
 	GeditWindow *new_window;
 	
+	/* If the tab s the only one in the source notebook, then
+	 * we forbid the drag operation
+	 */
+	if (gtk_notebook_get_n_pages (source) < 2)
+		return NULL;
+
 	new_window = clone_window (window);
-		
-	gedit_notebook_move_tab (notebook,
-				 GEDIT_NOTEBOOK (_gedit_window_get_notebook (new_window)),
-				 tab, 0);
-				 
+
 	gtk_window_set_position (GTK_WINDOW (new_window), 
 				 GTK_WIN_POS_MOUSE);
-					 
+
 	gtk_widget_show (GTK_WIDGET (new_window));
-}		      
+
+	return GTK_NOTEBOOK (new_window->priv->notebook);
+}
 
 static void 
 notebook_tab_close_request (GeditNotebook *notebook,
@@ -3187,7 +3224,12 @@
   	
 	gedit_debug_message (DEBUG_WINDOW, "Create gedit notebook");
 	window->priv->notebook = gedit_notebook_new ();
-  	gtk_paned_pack1 (GTK_PANED (window->priv->vpaned), 
+	/* Set the current app pointer as the notebook group,
+	 * so we can move tabs between windows of the same app */
+	gtk_notebook_set_group (GTK_NOTEBOOK (window->priv->notebook),
+				gedit_app_get_default ());
+
+	gtk_paned_pack1 (GTK_PANED (window->priv->vpaned), 
   			 window->priv->notebook,
   			 TRUE, 
   			 TRUE);
@@ -3230,23 +3272,23 @@
 
 	/* Connect signals */
 	g_signal_connect (window->priv->notebook,
-			  "switch_page",
+			  "switch-page",
 			  G_CALLBACK (notebook_switch_page),
 			  window);
 	g_signal_connect (window->priv->notebook,
-			  "tab_added",
+			  "page-added",
 			  G_CALLBACK (notebook_tab_added),
 			  window);
 	g_signal_connect (window->priv->notebook,
-			  "tab_removed",
+			  "page-removed",
 			  G_CALLBACK (notebook_tab_removed),
 			  window);
 	g_signal_connect (window->priv->notebook,
-			  "tabs_reordered",
+			  "page-reordered",
 			  G_CALLBACK (notebook_tabs_reordered),
-			  window);			  
+			  window);
 	g_signal_connect (window->priv->notebook,
-			  "tab_detached",
+			  "create-window",
 			  G_CALLBACK (notebook_tab_detached),
 			  window);
 	g_signal_connect (window->priv->notebook,
@@ -3515,7 +3557,7 @@
 	gtk_widget_show (GTK_WIDGET (new_window));
 	
 	return new_window;
-}				      
+}
 
 void
 gedit_window_set_active_tab (GeditWindow *window,
