--- gedit-notebook-no-backward.c	2007-07-15 13:17:15.000000000 +0200
+++ gedit-notebook.c	2007-07-15 18:16:42.000000000 +0200
@@ -77,6 +77,10 @@
 /* Signals */
 enum
 {
+	TAB_ADDED,
+	TAB_REMOVED,
+	TABS_REORDERED,
+	TAB_DETACHED,
 	TAB_CLOSE_REQUEST,
 	LAST_SIGNAL
 };
@@ -90,6 +94,45 @@
 
 	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),
@@ -131,6 +174,27 @@
 	return GTK_WIDGET (g_object_new (GEDIT_TYPE_NOTEBOOK, NULL));
 }
 
+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);
+}
+
 /* CHECK : called twice for each switch
  */
 static void
@@ -161,6 +225,32 @@
 	gtk_widget_grab_focus (GTK_WIDGET (view));
 }
 
+/* For backward comp., we emit old signals when new one are catched
+ */
+static void gedit_notebook_page_added_cb (GtkNotebook     *notebook,
+        								  GtkNotebookPage *page,
+        								  guint            page_num,
+        								  gpointer         data)
+{
+	g_signal_emit (notebook, signals[TAB_ADDED], 0, page);
+}
+
+static void gedit_notebook_page_removed_cb (GtkNotebook     *notebook,
+        								  GtkNotebookPage *page,
+        								  guint            page_num,
+        								  gpointer         data)
+{
+	g_signal_emit (notebook, signals[TAB_REMOVED], 0, page);
+}
+
+static void gedit_notebook_page_reordered_cb (GtkNotebook     *notebook,
+        								  GtkNotebookPage *page,
+        								  guint            page_num,
+        								  gpointer         data)
+{
+	g_signal_emit (notebook, signals[TABS_REORDERED], 0);
+}
+
 /*
  * update_tabs_visibility: Hide tabs if there is only one tab
  * and the pref is not set.
@@ -198,6 +288,23 @@
 				"switch-page",
 				G_CALLBACK (gedit_notebook_switch_page_cb),
 				NULL);
+	/* Added for backward compatibility, emit the old signals
+	 * when catching the GtkNotebook ones.
+	 * CHECK : GtkNotebook does not provide a signal for tab detachement
+	 * Are there a lot of plugins listenng for this signal ? 
+	 * */
+	g_signal_connect_after (G_OBJECT (notebook), 
+					"page-added",
+					G_CALLBACK (gedit_notebook_page_added_cb),
+					NULL);
+	g_signal_connect_after (G_OBJECT (notebook), 
+					"page-removed",
+					G_CALLBACK (gedit_notebook_page_removed_cb),
+					NULL);
+	g_signal_connect_after (G_OBJECT (notebook), 
+					"page-reordered",
+					G_CALLBACK (gedit_notebook_page_reordered_cb),
+					NULL);
 }
 
 static void
@@ -399,6 +506,17 @@
 }
 
 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,
@@ -598,3 +716,18 @@
 	
 	return nb->priv->close_buttons_sensitive;
 }
+
+void
+gedit_notebook_set_tab_drag_and_drop_enabled (GeditNotebook *nb,
+					      gboolean       enable)
+{
+	/* Stub */	
+}
+
+gboolean	
+gedit_notebook_get_tab_drag_and_drop_enabled (GeditNotebook *nb)
+{
+	/* Stub */ 
+	return TRUE;
+}
+
