changeset 407:3a9074e73f53

Rename vd_drop_update() to vd_dnd_drop_update(). Add two function pointers to ViewDir struct to keep vdtree_dnd_drop_expand_cancel() and vdtree_dnd_drop_expand() static to view_dir_tree.c.
author zas_
date Fri, 18 Apr 2008 16:53:41 +0000
parents 8e6f5bbe7843
children fcba18ac1551
files src/typedefs.h src/view_dir.c src/view_dir_tree.c src/view_dir_tree.h
diffstat 4 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/typedefs.h	Fri Apr 18 16:29:47 2008 +0000
+++ b/src/typedefs.h	Fri Apr 18 16:53:41 2008 +0000
@@ -548,6 +548,9 @@
 	void (*select_func)(ViewDir *vd, const gchar *path, gpointer data);
 	gpointer select_data;
 
+	void (*dnd_drop_update_func)(ViewDir *vd);
+	void (*dnd_drop_leave_func)(ViewDir *vd);
+	
 	LayoutWindow *layout;
 
 	GtkWidget *popup;
--- a/src/view_dir.c	Fri Apr 18 16:29:47 2008 +0000
+++ b/src/view_dir.c	Fri Apr 18 16:53:41 2008 +0000
@@ -70,6 +70,9 @@
 
 	vd->popup = NULL;
 
+	vd->dnd_drop_leave_func = NULL;
+	vd->dnd_drop_update_func = NULL;
+
 	vd->widget = gtk_scrolled_window_new(NULL, NULL);
 	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vd->widget), GTK_SHADOW_IN);
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vd->widget),
@@ -727,7 +730,7 @@
 		}
 }
 
-static void vd_drop_update(ViewDir *vd, gint x, gint y)
+static void vd_dnd_drop_update(ViewDir *vd, gint x, gint y)
 {
 	GtkTreePath *tpath;
 	FileData *fd = NULL;
@@ -743,7 +746,7 @@
 		{
 		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);
+		if (fd && vd->dnd_drop_update_func) vd->dnd_drop_update_func(vd);
 		}
 
 	vd->drop_fd = fd;
@@ -770,7 +773,7 @@
 		gdk_drawable_get_size(window, &w, &h);
 		if (x >= 0 && x < w && y >= 0 && y < h)
 			{
-			vd_drop_update(vd, x, y);
+			vd_dnd_drop_update(vd, x, y);
 			}
 		}
 
@@ -807,7 +810,7 @@
 		gdk_drag_status(context, context->suggested_action, time);
 		}
 
-	vd_drop_update(vd, x, y);
+	vd_dnd_drop_update(vd, x, y);
 
 	if (vd->drop_fd)
 		{
@@ -826,7 +829,7 @@
 
 	vd->drop_fd = NULL;
 
-	if (vd->type == DIRVIEW_TREE) vdtree_dnd_drop_expand_cancel(vd);
+	if (vd->dnd_drop_leave_func) vd->dnd_drop_leave_func(vd);
 }
 
 void vd_dnd_init(ViewDir *vd)
--- a/src/view_dir_tree.c	Fri Apr 18 16:29:47 2008 +0000
+++ b/src/view_dir_tree.c	Fri Apr 18 16:53:41 2008 +0000
@@ -179,13 +179,13 @@
 	return FALSE;
 }
 
-void vdtree_dnd_drop_expand_cancel(ViewDir *vd)
+static 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;
 }
 
-void vdtree_dnd_drop_expand(ViewDir *vd)
+static 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);
@@ -939,8 +939,10 @@
 	vd->type = DIRVIEW_TREE;
 
 	VDTREE_INFO(vd, drop_expand_id) = -1;
-
 	VDTREE_INFO(vd, busy_ref) = 0;
+	
+	vd->dnd_drop_leave_func = vdtree_dnd_drop_expand_cancel;
+	vd->dnd_drop_update_func = vdtree_dnd_drop_expand;
 
 	store = gtk_tree_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
 	vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
--- a/src/view_dir_tree.h	Fri Apr 18 16:29:47 2008 +0000
+++ b/src/view_dir_tree.h	Fri Apr 18 16:53:41 2008 +0000
@@ -33,9 +33,6 @@
 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);
-
 gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data);
 gint vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);