>From c46ce190fbb27f2d20e908e87ccbc11aa09fca52 Mon Sep 17 00:00:00 2001
From: Matthew Brush <matthewbrush@gmail.com>
Date: Sun, 20 Mar 2011 14:15:45 -0700
Subject: [PATCH 3/3] Enable DnD between sidebar and msgwin notebooks.

---
 src/msgwindow.c |   28 ++++++++++++++++++++++++++++
 src/sidebar.c   |   29 ++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/src/msgwindow.c b/src/msgwindow.c
index d367c73..5288572 100644
--- a/src/msgwindow.c
+++ b/src/msgwindow.c
@@ -80,6 +80,7 @@ static void on_msgwin_notebook_page_added(GtkNotebook *notebook,
 											guint page_num,
 											gpointer user_data);
 static void msgwin_set_all_tabs_reorderable(GtkNotebook *notebook);
+static void msgwin_set_all_tabs_detachable(GtkNotebook *notebook);
 
 void msgwin_show_hide_tabs(void)
 {
@@ -125,8 +126,21 @@ void msgwin_init(void)
 						 "page-added",
 						 G_CALLBACK(on_msgwin_notebook_page_added),
 						 NULL);
+						 
 		msgwin_set_all_tabs_reorderable(GTK_NOTEBOOK(main_widgets.message_window_notebook));
+		msgwin_set_all_tabs_detachable(GTK_NOTEBOOK(main_widgets.message_window_notebook));
 	}
+
+#if GTK_CHECK_VERSION(2, 24, 0) == TRUE
+	gtk_notebook_set_group_name(GTK_NOTEBOOK(main_widgets.message_window_notebook),
+								"msgwin_sidebar_nb");
+#elif GTK_CHECK_VERSION(2, 12, 0) == TRUE
+	gtk_notebook_set_group(GTK_NOTEBOOK(main_widgets.message_window_notebook), 
+						   GINT_TO_POINTER(1));
+#elif GTK_CHECK_VERSION(2, 10, 0) == TRUE
+	gtk_notebook_set_group_id(GTK_NOTEBOOK(main_widgets.message_window_notebook), 1);
+#endif
+
 }
 
 
@@ -1217,11 +1231,25 @@ static void msgwin_set_all_tabs_reorderable(GtkNotebook *notebook)
 }
 
 
+static void msgwin_set_all_tabs_detachable(GtkNotebook *notebook)
+{
+	gint i;
+	GtkWidget *child;
+	
+	for (i=0; i < gtk_notebook_get_n_pages(notebook); i++)
+	{
+		child = gtk_notebook_get_nth_page(notebook, i);
+		gtk_notebook_set_tab_detachable(notebook, child, TRUE);
+	}
+}
+
+
 static void on_msgwin_notebook_page_added(GtkNotebook *notebook,
 											GtkWidget *child,
 											guint page_num,
 											gpointer user_data)
 {
 	gtk_notebook_set_tab_reorderable(notebook, child, TRUE);
+	gtk_notebook_set_tab_detachable(notebook, child, TRUE);
 }
 
diff --git a/src/sidebar.c b/src/sidebar.c
index 99c2d25..e11c309 100644
--- a/src/sidebar.c
+++ b/src/sidebar.c
@@ -110,6 +110,7 @@ static void documents_menu_update(GtkTreeSelection *selection);
 static void sidebar_tabs_show_hide(GtkNotebook *notebook, GtkWidget *child,
 								   guint page_num, gpointer data);
 static void sidebar_set_all_tabs_reorderable(GtkNotebook *notebook);
+static void sidebar_set_all_tabs_detachable(GtkNotebook *notebook);
 
 
 /* the prepare_* functions are document-related, but I think they fit better here than in document.c */
@@ -1064,8 +1065,21 @@ void sidebar_init(void)
 			G_CALLBACK(sidebar_tabs_show_hide), NULL);
 			
 		sidebar_set_all_tabs_reorderable(GTK_NOTEBOOK(main_widgets.sidebar_notebook));
+		sidebar_set_all_tabs_detachable(GTK_NOTEBOOK(main_widgets.sidebar_notebook));
 	}
+	
 	sidebar_tabs_show_hide(GTK_NOTEBOOK(main_widgets.sidebar_notebook), NULL, 0, NULL);
+
+#if GTK_CHECK_VERSION(2, 24, 0) == TRUE
+	gtk_notebook_set_group_name(GTK_NOTEBOOK(main_widgets.sidebar_notebook),
+								"msgwin_sidebar_nb");
+#elif GTK_CHECK_VERSION(2, 12, 0) == TRUE
+	gtk_notebook_set_group(GTK_NOTEBOOK(main_widgets.sidebar_notebook), 
+						   GINT_TO_POINTER(1));
+#elif GTK_CHECK_VERSION(2, 10, 0) == TRUE
+	gtk_notebook_set_group_id(GTK_NOTEBOOK(main_widgets.sidebar_notebook), 1);
+#endif
+	
 }
 
 #define WIDGET(w) w && GTK_IS_WIDGET(w)
@@ -1127,6 +1141,7 @@ static void sidebar_tabs_show_hide(GtkNotebook *notebook, GtkWidget *child,
 		gtk_notebook_set_show_tabs(notebook, (tabs > 1));
 		
 		sidebar_set_all_tabs_reorderable(notebook);
+		sidebar_set_all_tabs_detachable(notebook);
 	}
 }
 
@@ -1136,10 +1151,22 @@ static void sidebar_set_all_tabs_reorderable(GtkNotebook *notebook)
 	gint i;
 	GtkWidget *child;
 	
-	
 	for (i=0; i < gtk_notebook_get_n_pages(notebook); i++)
 	{
 		child = gtk_notebook_get_nth_page(notebook, i);
 		gtk_notebook_set_tab_reorderable(notebook, child, TRUE);
 	}
 }
+
+
+static void sidebar_set_all_tabs_detachable(GtkNotebook *notebook)
+{
+	gint i;
+	GtkWidget *child;
+	
+	for (i=0; i < gtk_notebook_get_n_pages(notebook); i++)
+	{
+		child = gtk_notebook_get_nth_page(notebook, i);
+		gtk_notebook_set_tab_detachable(notebook, child, TRUE);
+	}
+}
-- 
1.7.1

