changeset 394:4a5e1377f3d7

Merge dirlist/dirview dnd code.
author zas_
date Thu, 17 Apr 2008 14:51:32 +0000
parents 8d422d424d51
children c359fc2c5a1f
files src/view_dir.c src/view_dir.h src/view_dir_list.c src/view_dir_tree.c src/view_dir_tree.h
diffstat 5 files changed, 286 insertions(+), 521 deletions(-) [+]
line wrap: on
line diff
--- a/src/view_dir.c	Wed Apr 16 22:51:32 2008 +0000
+++ b/src/view_dir.c	Thu Apr 17 14:51:32 2008 +0000
@@ -12,10 +12,12 @@
 #include "main.h"
 #include "view_dir.h"
 
+#include "dnd.h"
 #include "dupe.h"
 #include "filelist.h"
 #include "layout_image.h"
 #include "layout_util.h"
+#include "ui_bookmark.h"
 #include "ui_fileops.h"
 #include "ui_tree_edit.h"
 #include "ui_menu.h"
@@ -576,3 +578,274 @@
 	return menu;
 }
 
+/*
+ *-----------------------------------------------------------------------------
+ * dnd
+ *-----------------------------------------------------------------------------
+ */
+
+static GtkTargetEntry vd_dnd_drop_types[] = {
+	{ "text/uri-list", 0, TARGET_URI_LIST }
+};
+static gint vd_dnd_drop_types_count = 1;
+
+static void vd_dest_set(ViewDir *vd, gint enable)
+{
+	if (enable)
+		{
+		gtk_drag_dest_set(vd->view,
+				  GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+				  vd_dnd_drop_types, vd_dnd_drop_types_count,
+				  GDK_ACTION_MOVE | GDK_ACTION_COPY);
+		}
+	else
+		{
+		gtk_drag_dest_unset(vd->view);
+		}
+}
+
+static void vd_dnd_get(GtkWidget *widget, GdkDragContext *context,
+			   GtkSelectionData *selection_data, guint info,
+			   guint time, gpointer data)
+{
+	ViewDir *vd = data;
+	GList *list;
+	gchar *uritext = NULL;
+	gint length = 0;
+
+	if (!vd->click_fd) return;
+
+	switch (info)
+		{
+		case TARGET_URI_LIST:
+		case TARGET_TEXT_PLAIN:
+			list = g_list_prepend(NULL, vd->click_fd);
+			uritext = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN));
+			g_list_free(list);
+			break;
+		}
+	if (uritext)
+		{
+		gtk_selection_data_set (selection_data, selection_data->target,
+				8, (guchar *)uritext, length);
+		g_free(uritext);
+		}
+}
+
+static void vd_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
+{
+	ViewDir *vd = data;
+
+	vd_color_set(vd, vd->click_fd, TRUE);
+	vd_dest_set(vd, FALSE);
+}
+
+static void vd_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
+{
+	ViewDir *vd = data;
+
+	vd_color_set(vd, vd->click_fd, FALSE);
+
+	if (vd->type == DIRVIEW_LIST && context->action == GDK_ACTION_MOVE)
+		{
+		vd_refresh(vd);
+		}
+	vd_dest_set(vd, TRUE);
+}
+
+static void vd_dnd_drop_receive(GtkWidget *widget,
+				    GdkDragContext *context, gint x, gint y,
+				    GtkSelectionData *selection_data, guint info,
+				    guint time, gpointer data)
+{
+	ViewDir *vd = data;
+	GtkTreePath *tpath;
+	GtkTreeIter iter;
+	FileData *fd = NULL;
+
+	vd->click_fd = NULL;
+
+	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y,
+					  &tpath, NULL, NULL, NULL))
+		{
+		GtkTreeModel *store;
+
+		store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
+		gtk_tree_model_get_iter(store, &iter, tpath);
+		switch (vd->type)
+			{
+			case DIRVIEW_LIST:
+				gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
+				break;
+			case DIRVIEW_TREE:
+				{
+				NodeData *nd;
+				gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
+				fd = (nd) ? nd->fd : NULL;
+				};
+				break;
+			}
+		gtk_tree_path_free(tpath);
+		}
+
+	if (!fd) return;
+
+	if (info == TARGET_URI_LIST)
+		{
+		GList *list;
+		gint active;
+
+		list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
+		if (!list) return;
+
+		active = access_file(fd->path, W_OK | X_OK);
+
+		vd_color_set(vd, fd, TRUE);
+		vd->popup = vd_drop_menu(vd, active);
+		gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, 0, time);
+
+		vd->drop_fd = fd;
+		vd->drop_list = list;
+		}
+}
+
+static void vd_drop_update(ViewDir *vd, gint x, gint y)
+{
+	GtkTreePath *tpath;
+	GtkTreeIter iter;
+	FileData *fd = NULL;
+
+	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vd->view), x, y,
+					  &tpath, NULL, NULL, NULL))
+		{
+		GtkTreeModel *store;
+	
+		store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
+		gtk_tree_model_get_iter(store, &iter, tpath);
+		switch (vd->type)
+			{
+			case DIRVIEW_LIST:
+				gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
+				break;
+			case DIRVIEW_TREE:
+				{
+				NodeData *nd;
+				gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
+				fd = (nd) ? nd->fd : NULL;
+				};
+				break;
+			}
+		gtk_tree_path_free(tpath);
+		}
+
+	if (fd != vd->drop_fd)
+		{
+		vd_color_set(vd, vd->drop_fd, FALSE);
+		vd_color_set(vd, fd, TRUE);
+		if (vd->type == DIRVIEW_TREE && fd) vdtree_dnd_drop_expand(vd);
+		}
+
+	vd->drop_fd = fd;
+}
+
+void vd_dnd_drop_scroll_cancel(ViewDir *vd)
+{
+	if (vd->drop_scroll_id != -1) g_source_remove(vd->drop_scroll_id);
+	vd->drop_scroll_id = -1;
+}
+
+static gint vd_auto_scroll_idle_cb(gpointer data)
+{
+	ViewDir *vd = data;
+
+	if (vd->drop_fd)
+		{
+		GdkWindow *window;
+		gint x, y;
+		gint w, h;
+
+		window = vd->view->window;
+		gdk_window_get_pointer(window, &x, &y, NULL);
+		gdk_drawable_get_size(window, &w, &h);
+		if (x >= 0 && x < w && y >= 0 && y < h)
+			{
+			vd_drop_update(vd, x, y);
+			}
+		}
+
+	vd->drop_scroll_id = -1;
+	return FALSE;
+}
+
+static gint vd_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
+{
+	ViewDir *vd = data;
+
+	if (!vd->drop_fd || vd->drop_list) return FALSE;
+
+	if (vd->drop_scroll_id == -1) vd->drop_scroll_id = g_idle_add(vd_auto_scroll_idle_cb, vd);
+
+	return TRUE;
+}
+
+static gint vd_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context,
+				   gint x, gint y, guint time, gpointer data)
+{
+        ViewDir *vd = data;
+
+	vd->click_fd = NULL;
+
+	if (gtk_drag_get_source_widget(context) == vd->view)
+		{
+		/* from same window */
+		gdk_drag_status(context, 0, time);
+		return TRUE;
+		}
+	else
+		{
+		gdk_drag_status(context, context->suggested_action, time);
+		}
+
+	vd_drop_update(vd, x, y);
+
+	if (vd->drop_fd)
+		{
+		GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vd->view));
+		widget_auto_scroll_start(vd->view, adj, -1, -1, vd_auto_scroll_notify_cb, vd);
+		}
+
+	return FALSE;
+}
+
+static void vd_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
+{
+	ViewDir *vd = data;
+
+	if (vd->drop_fd != vd->click_fd) vd_color_set(vd, vd->drop_fd, FALSE);
+
+	vd->drop_fd = NULL;
+
+	if (vd->type == DIRVIEW_TREE) vdtree_dnd_drop_expand_cancel(vd);
+}
+
+void vd_dnd_init(ViewDir *vd)
+{
+	gtk_drag_source_set(vd->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
+			    dnd_file_drag_types, dnd_file_drag_types_count,
+			    GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
+	g_signal_connect(G_OBJECT(vd->view), "drag_data_get",
+			 G_CALLBACK(vd_dnd_get), vd);
+	g_signal_connect(G_OBJECT(vd->view), "drag_begin",
+			 G_CALLBACK(vd_dnd_begin), vd);
+	g_signal_connect(G_OBJECT(vd->view), "drag_end",
+			 G_CALLBACK(vd_dnd_end), vd);
+
+	vd_dest_set(vd, TRUE);
+	g_signal_connect(G_OBJECT(vd->view), "drag_data_received",
+			 G_CALLBACK(vd_dnd_drop_receive), vd);
+	g_signal_connect(G_OBJECT(vd->view), "drag_motion",
+			 G_CALLBACK(vd_dnd_drop_motion), vd);
+	g_signal_connect(G_OBJECT(vd->view), "drag_leave",
+			 G_CALLBACK(vd_dnd_drop_leave), vd);
+}
+
--- a/src/view_dir.h	Wed Apr 16 22:51:32 2008 +0000
+++ b/src/view_dir.h	Thu Apr 17 14:51:32 2008 +0000
@@ -42,6 +42,8 @@
 GtkWidget *vd_drop_menu(ViewDir *vd, gint active);
 GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd);
 
+void vd_dnd_drop_scroll_cancel(ViewDir *vd);
+void vd_dnd_init(ViewDir *vd);
 
 #endif
 
--- a/src/view_dir_list.c	Wed Apr 16 22:51:32 2008 +0000
+++ b/src/view_dir_list.c	Thu Apr 17 14:51:32 2008 +0000
@@ -33,8 +33,6 @@
 #define VDLIST_INFO(_vd_, _part_) (((ViewDirInfoList *)(_vd_->info))->_part_)
 
 
-static gint vdlist_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data);
-
 /*
  *-----------------------------------------------------------------------------
  * misc
@@ -98,153 +96,11 @@
  *-----------------------------------------------------------------------------
  */
 
-static GtkTargetEntry vdlist_dnd_drop_types[] = {
-	{ "text/uri-list", 0, TARGET_URI_LIST }
-};
-static gint vdlist_dnd_drop_types_count = 1;
-
-static void vdlist_dest_set(ViewDir *vd, gint enable)
-{
-	if (enable)
-		{
-		gtk_drag_dest_set(vd->view,
-				  GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
-				  vdlist_dnd_drop_types, vdlist_dnd_drop_types_count,
-				  GDK_ACTION_MOVE | GDK_ACTION_COPY);
-		}
-	else
-		{
-		gtk_drag_dest_unset(vd->view);
-		}
-}
-
-static void vdlist_dnd_get(GtkWidget *widget, GdkDragContext *context,
-			   GtkSelectionData *selection_data, guint info,
-			   guint time, gpointer data)
-{
-	ViewDir *vd = data;
-	GList *list;
-	gchar *text = NULL;
-	gint length = 0;
-
-	if (!vd->click_fd) return;
-
-	switch (info)
-		{
-		case TARGET_URI_LIST:
-		case TARGET_TEXT_PLAIN:
-			list = g_list_prepend(NULL, vd->click_fd);
-			text = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN));
-			g_list_free(list);
-			break;
-		}
-	if (text)
-		{
-		gtk_selection_data_set (selection_data, selection_data->target,
-				8, (guchar *)text, length);
-		g_free(text);
-		}
-}
-
-static void vdlist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
-{
-	ViewDir *vd = data;
-
-	vd_color_set(vd, vd->click_fd, TRUE);
-	vdlist_dest_set(vd, FALSE);
-}
-
-static void vdlist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
-{
-	ViewDir *vd = data;
-
-	vd_color_set(vd, vd->click_fd, FALSE);
-
-	if (context->action == GDK_ACTION_MOVE)
-		{
-		vdlist_refresh(vd);
-		}
-	vdlist_dest_set(vd, TRUE);
-}
-
-static void vdlist_dnd_drop_receive(GtkWidget *widget,
-				    GdkDragContext *context, gint x, gint y,
-				    GtkSelectionData *selection_data, guint info,
-				    guint time, gpointer data)
-{
-	ViewDir *vd = data;
-	GtkTreePath *tpath;
-	GtkTreeIter iter;
-	FileData *fd = NULL;
-
-	vd->click_fd = NULL;
-
-	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y,
-					  &tpath, NULL, NULL, NULL))
-		{
-		GtkTreeModel *store;
-
-		store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
-		gtk_tree_model_get_iter(store, &iter, tpath);
-		gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
-		gtk_tree_path_free(tpath);
-		}
-
-	if (!fd) return;
-
-	if (info == TARGET_URI_LIST)
-		{
-		GList *list;
-		gint active;
-
-		list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
-		if (!list) return;
-
-		active = access_file(fd->path, W_OK | X_OK);
-
-		vd_color_set(vd, fd, TRUE);
-		vd->popup = vd_drop_menu(vd, active);
-		gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, 0, time);
-
-		vd->drop_fd = fd;
-		vd->drop_list = list;
-		}
-}
-
-#if 0
-static gint vdlist_get_row_visibility(ViewDir *vd, FileData *fd)
-{
-	GtkTreeModel *store;
-	GtkTreeViewColumn *column;
-	GtkTreePath *tpath;
-	GtkTreeIter iter;
-
-	GdkRectangle vrect;
-	GdkRectangle crect;
-
-	if (!fd || vd_find_row(vd, fd, &iter) < 0) return 0;
-
-	column = gtk_tree_view_get_column(GTK_TREE_VIEW(vd->view), 0);
-	store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
-	tpath = gtk_tree_model_get_path(store, &iter);
-
-	gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(vd->view), &vrect);
-	gtk_tree_view_get_cell_area(GTK_TREE_VIEW(vd->view), tpath, column, &crect);
-printf("window: %d + %d; cell: %d + %d\n", vrect.y, vrect.height, crect.y, crect.height);
-	gtk_tree_path_free(tpath);
-
-	if (crect.y + crect.height < vrect.y) return -1;
-	if (crect.y > vrect.y + vrect.height) return 1;
-	return 0;
-}
-#endif
-
 static void vdlist_scroll_to_row(ViewDir *vd, FileData *fd, gfloat y_align)
 {
 	GtkTreeIter iter;
 
-	if (GTK_WIDGET_REALIZED(vd->view) &&
-	    vd_find_row(vd, fd, &iter) >= 0)
+	if (GTK_WIDGET_REALIZED(vd->view) && vd_find_row(vd, fd, &iter) >= 0)
 		{
 		GtkTreeModel *store;
 		GtkTreePath *tpath;
@@ -259,131 +115,6 @@
 		}
 }
 
-static void vdlist_drop_update(ViewDir *vd, gint x, gint y)
-{
-	GtkTreePath *tpath;
-	GtkTreeIter iter;
-	FileData *fd = NULL;
-
-	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vd->view), x, y,
-					  &tpath, NULL, NULL, NULL))
-		{
-		GtkTreeModel *store;
-
-		store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
-		gtk_tree_model_get_iter(store, &iter, tpath);
-		gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
-		gtk_tree_path_free(tpath);
-		}
-
-	if (fd != vd->drop_fd)
-		{
-		vd_color_set(vd, vd->drop_fd, FALSE);
-		vd_color_set(vd, fd, TRUE);
-		}
-
-	vd->drop_fd = fd;
-}
-
-static void vdlist_dnd_drop_scroll_cancel(ViewDir *vd)
-{
-	if (vd->drop_scroll_id != -1) g_source_remove(vd->drop_scroll_id);
-	vd->drop_scroll_id = -1;
-}
-
-static gint vdlist_auto_scroll_idle_cb(gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (vd->drop_fd)
-		{
-		GdkWindow *window;
-		gint x, y;
-		gint w, h;
-
-		window = vd->view->window;
-		gdk_window_get_pointer(window, &x, &y, NULL);
-		gdk_drawable_get_size(window, &w, &h);
-		if (x >= 0 && x < w && y >= 0 && y < h)
-			{
-			vdlist_drop_update(vd, x, y);
-			}
-		}
-
-	vd->drop_scroll_id = -1;
-	return FALSE;
-}
-
-static gint vdlist_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (!vd->drop_fd || vd->drop_list) return FALSE;
-
-	if (vd->drop_scroll_id == -1) vd->drop_scroll_id = g_idle_add(vdlist_auto_scroll_idle_cb, vd);
-
-	return TRUE;
-}
-
-static gint vdlist_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context,
-				   gint x, gint y, guint time, gpointer data)
-{
-	ViewDir *vd = data;
-
-	vd->click_fd = NULL;
-
-	if (gtk_drag_get_source_widget(context) == vd->view)
-		{
-		/* from same window */
-		gdk_drag_status(context, 0, time);
-		return TRUE;
-		}
-	else
-		{
-		gdk_drag_status(context, context->suggested_action, time);
-		}
-
-	vdlist_drop_update(vd, x, y);
-
-        if (vd->drop_fd)
-		{
-		GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vd->view));
-		widget_auto_scroll_start(vd->view, adj, -1, -1, vdlist_auto_scroll_notify_cb, vd);
-		}
-
-	return FALSE;
-}
-
-static void vdlist_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (vd->drop_fd != vd->click_fd) vd_color_set(vd, vd->drop_fd, FALSE);
-
-	vd->drop_fd = NULL;
-}
-
-static void vdlist_dnd_init(ViewDir *vd)
-{
-	gtk_drag_source_set(vd->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
-			    dnd_file_drag_types, dnd_file_drag_types_count,
-			    GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
-	g_signal_connect(G_OBJECT(vd->view), "drag_data_get",
-			 G_CALLBACK(vdlist_dnd_get), vd);
-	g_signal_connect(G_OBJECT(vd->view), "drag_begin",
-			 G_CALLBACK(vdlist_dnd_begin), vd);
-	g_signal_connect(G_OBJECT(vd->view), "drag_end",
-			 G_CALLBACK(vdlist_dnd_end), vd);
-
-	vdlist_dest_set(vd, TRUE);
-	g_signal_connect(G_OBJECT(vd->view), "drag_data_received",
-			 G_CALLBACK(vdlist_dnd_drop_receive), vd);
-	g_signal_connect(G_OBJECT(vd->view), "drag_motion",
-			 G_CALLBACK(vdlist_dnd_drop_motion), vd);
-	g_signal_connect(G_OBJECT(vd->view), "drag_leave",
-			 G_CALLBACK(vdlist_dnd_drop_leave), vd);
-}
-
 /*
  *-----------------------------------------------------------------------------
  * main
@@ -714,7 +445,7 @@
 {
 	ViewDir *vd = data;
 
-	vdlist_dnd_drop_scroll_cancel(vd);
+	vd_dnd_drop_scroll_cancel(vd);
 	widget_auto_scroll_stop(vd->view);
 
 	filelist_free(VDLIST_INFO(vd, list));
@@ -766,7 +497,7 @@
 	gtk_container_add(GTK_CONTAINER(vd->widget), vd->view);
 	gtk_widget_show(vd->view);
 
-	vdlist_dnd_init(vd);
+	vd_dnd_init(vd);
 
 	g_signal_connect(G_OBJECT(vd->view), "button_press_event",
 			 G_CALLBACK(vdlist_press_cb), vd);
--- a/src/view_dir_tree.c	Wed Apr 16 22:51:32 2008 +0000
+++ b/src/view_dir_tree.c	Thu Apr 17 14:51:32 2008 +0000
@@ -167,126 +167,12 @@
  *----------------------------------------------------------------------------
  */
 
-static GtkTargetEntry vdtree_dnd_drop_types[] = {
-	{ "text/uri-list", 0, TARGET_URI_LIST }
-};
-static gint vdtree_dnd_drop_types_count = 1;
-
-
-static void vdtree_dest_set(ViewDir *vd, gint enable)
-{
-	if (enable)
-		{
-		gtk_drag_dest_set(vd->view,
-				  GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
-				  vdtree_dnd_drop_types, vdtree_dnd_drop_types_count,
-				  GDK_ACTION_MOVE | GDK_ACTION_COPY);
-		}
-	else
-		{
-		gtk_drag_dest_unset(vd->view);
-		}
-}
-
-static void vdtree_dnd_get(GtkWidget *widget, GdkDragContext *context,
-			   GtkSelectionData *selection_data, guint info,
-			   guint time, gpointer data)
-{
-	ViewDir *vd = data;
-	GList *list;
-	gchar *uri_text = NULL;
-	gint length = 0;
-
-	if (!vd->click_fd) return;
-
-	switch (info)
-		{
-		case TARGET_URI_LIST:
-		case TARGET_TEXT_PLAIN:
-			list = g_list_prepend(NULL, vd->click_fd);
-			uri_text = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN));
-			g_list_free(list);
-			break;
-		}
-
-	if (uri_text)
-		{
-		gtk_selection_data_set(selection_data, selection_data->target,
-				       8, (guchar *)uri_text, length);
-		g_free(uri_text);
-		}
-}
-
-static void vdtree_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
-{
-	ViewDir *vd = data;
-
-	vd_color_set(vd, vd->click_fd, TRUE);
-	vdtree_dest_set(vd, FALSE);
-}
-
-static void vdtree_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
-{
-	ViewDir *vd = data;
-
-	vd_color_set(vd, vd->click_fd, FALSE);
-	vdtree_dest_set(vd, TRUE);
-}
-
-static void vdtree_dnd_drop_receive(GtkWidget *widget,
-				    GdkDragContext *context, gint x, gint y,
-				    GtkSelectionData *selection_data, guint info,
-				    guint time, gpointer data)
-{
-	ViewDir *vd = data;
-	GtkTreePath *tpath;
-	GtkTreeIter iter;
-	FileData *fd = NULL;
-
-	vd->click_fd = NULL;
-
-	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y,
-					  &tpath, NULL, NULL, NULL))
-		{
-		GtkTreeModel *store;
-		NodeData *nd;
-
-		store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
-		gtk_tree_model_get_iter(store, &iter, tpath);
-		gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
-		gtk_tree_path_free(tpath);
-
-		fd = (nd) ? nd->fd : NULL;
-		}
-
-	if (!fd) return;
-
-        if (info == TARGET_URI_LIST)
-                {
-		GList *list;
-		gint active;
-
-		list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
-		if (!list) return;
-
-		active = access_file(fd->path, W_OK | X_OK);
-
-		vd_color_set(vd, fd, TRUE);
-		vd->popup = vd_drop_menu(vd, active);
-		gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, 0, time);
-
-		vd->drop_fd = fd;
-		vd->drop_list = list;
-		}
-}
-
 static gint vdtree_dnd_drop_expand_cb(gpointer data)
 {
 	ViewDir *vd = data;
 	GtkTreeIter iter;
 
-	if (vd->drop_fd &&
-	    vd_find_row(vd, vd->drop_fd, &iter))
+	if (vd->drop_fd && vd_find_row(vd, vd->drop_fd, &iter))
 		{
 		vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->path);
 		vdtree_expand_by_data(vd, vd->drop_fd, TRUE);
@@ -296,148 +182,18 @@
 	return FALSE;
 }
 
-static void vdtree_dnd_drop_expand_cancel(ViewDir *vd)
+void vdtree_dnd_drop_expand_cancel(ViewDir *vd)
 {
 	if (VDTREE_INFO(vd, drop_expand_id) != -1) g_source_remove(VDTREE_INFO(vd, drop_expand_id));
 	VDTREE_INFO(vd, drop_expand_id) = -1;
 }
 
-static void vdtree_dnd_drop_expand(ViewDir *vd)
+void vdtree_dnd_drop_expand(ViewDir *vd)
 {
 	vdtree_dnd_drop_expand_cancel(vd);
 	VDTREE_INFO(vd, drop_expand_id) = g_timeout_add(1000, vdtree_dnd_drop_expand_cb, vd);
 }
 
-static void vdtree_drop_update(ViewDir *vd, gint x, gint y)
-{
-	GtkTreePath *tpath;
-	GtkTreeIter iter;
-	FileData *fd = NULL;
-
-	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vd->view), x, y,
-					  &tpath, NULL, NULL, NULL))
-		{
-		GtkTreeModel *store;
-		NodeData *nd;
-
-		store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
-		gtk_tree_model_get_iter(store, &iter, tpath);
-		gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
-		gtk_tree_path_free(tpath);
-
-		fd = (nd) ? nd->fd : NULL;
-		}
-
-	if (fd != vd->drop_fd)
-		{
-		vd_color_set(vd, vd->drop_fd, FALSE);
-		vd_color_set(vd, fd, TRUE);
-		if (fd) vdtree_dnd_drop_expand(vd);
-		}
-
-	vd->drop_fd = fd;
-}
-
-static void vdtree_dnd_drop_scroll_cancel(ViewDir *vd)
-{
-	if (vd->drop_scroll_id != -1) g_source_remove(vd->drop_scroll_id);
-	vd->drop_scroll_id = -1;
-}
-
-static gint vdtree_auto_scroll_idle_cb(gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (vd->drop_fd)
-		{
-		GdkWindow *window;
-		gint x, y;
-		gint w, h;
-
-		window = vd->view->window;
-		gdk_window_get_pointer(window, &x, &y, NULL);
-		gdk_drawable_get_size(window, &w, &h);
-		if (x >= 0 && x < w && y >= 0 && y < h)
-			{
-			vdtree_drop_update(vd, x, y);
-			}
-		}
-
-	vd->drop_scroll_id = -1;
-	return FALSE;
-}
-
-static gint vdtree_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (!vd->drop_fd || vd->drop_list) return FALSE;
-
-	if (vd->drop_scroll_id == -1) vd->drop_scroll_id = g_idle_add(vdtree_auto_scroll_idle_cb, vd);
-
-	return TRUE;
-}
-
-static gint vdtree_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context,
-				   gint x, gint y, guint time, gpointer data)
-{
-        ViewDir *vd = data;
-
-	vd->click_fd = NULL;
-
-	if (gtk_drag_get_source_widget(context) == vd->view)
-		{
-		gdk_drag_status(context, 0, time);
-		return TRUE;
-		}
-	else
-		{
-		gdk_drag_status(context, context->suggested_action, time);
-		}
-
-	vdtree_drop_update(vd, x, y);
-
-	if (vd->drop_fd)
-		{
-		GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vd->view));
-		widget_auto_scroll_start(vd->view, adj, -1, -1, vdtree_auto_scroll_notify_cb, vd);
-		}
-
-	return FALSE;
-}
-
-static void vdtree_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (vd->drop_fd != vd->click_fd) vd_color_set(vd, vd->drop_fd, FALSE);
-
-	vd->drop_fd = NULL;
-
-	vdtree_dnd_drop_expand_cancel(vd);
-}
-
-static void vdtree_dnd_init(ViewDir *vd)
-{
-	gtk_drag_source_set(vd->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
-			    dnd_file_drag_types, dnd_file_drag_types_count,
-			    GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
-	g_signal_connect(G_OBJECT(vd->view), "drag_data_get",
-			 G_CALLBACK(vdtree_dnd_get), vd);
-	g_signal_connect(G_OBJECT(vd->view), "drag_begin",
-			 G_CALLBACK(vdtree_dnd_begin), vd);
-	g_signal_connect(G_OBJECT(vd->view), "drag_end",
-			 G_CALLBACK(vdtree_dnd_end), vd);
-
-	vdtree_dest_set(vd, TRUE);
-	g_signal_connect(G_OBJECT(vd->view), "drag_data_received",
-			 G_CALLBACK(vdtree_dnd_drop_receive), vd);
-	g_signal_connect(G_OBJECT(vd->view), "drag_motion",
-			 G_CALLBACK(vdtree_dnd_drop_motion), vd);
-	g_signal_connect(G_OBJECT(vd->view), "drag_leave",
-			 G_CALLBACK(vdtree_dnd_drop_leave), vd);
-}
-
 /*
  *----------------------------------------------------------------------------
  * parts lists
@@ -1261,7 +1017,7 @@
 	GtkTreeModel *store;
 
 	vdtree_dnd_drop_expand_cancel(vd);
-	vdtree_dnd_drop_scroll_cancel(vd);
+	vd_dnd_drop_scroll_cancel(vd);
 	widget_auto_scroll_stop(vd->view);
 
 	store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
@@ -1333,7 +1089,7 @@
 
 	vdtree_setup_root(vd);
 
-	vdtree_dnd_init(vd);
+	vd_dnd_init(vd);
 
 	g_signal_connect(G_OBJECT(vd->view), "button_press_event",
 			 G_CALLBACK(vdtree_press_cb), vd);
--- a/src/view_dir_tree.h	Wed Apr 16 22:51:32 2008 +0000
+++ b/src/view_dir_tree.h	Thu Apr 17 14:51:32 2008 +0000
@@ -31,5 +31,8 @@
 FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint force);
 void vdtree_rename_by_data(ViewDir *vd, FileData *fd);
 
+void vdtree_dnd_drop_expand_cancel(ViewDir *vd);
+void vdtree_dnd_drop_expand(ViewDir *vd);
+
 #endif