[PATCH] Fix list view drag setup



The DND setup should take place in the "drag-begin" handler not after
the drag is already taking place. This inter alia takes care that the
drag icon is displayed instantly when the drag starts and not just some
time later.

Proposed patch attached.

-- 
Christian Neumair <chris gnome-de org>
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.256
diff -u -p -r1.256 fm-list-view.c
--- src/file-manager/fm-list-view.c	12 Aug 2005 18:11:30 -0000	1.256
+++ src/file-manager/fm-list-view.c	24 Aug 2005 12:26:54 -0000
@@ -406,6 +419,34 @@ get_drag_pixbuf (FMListView *view)
 	return ret;
 }
 
+static void
+drag_begin_callback (GtkWidget *widget,
+		     GdkDragContext *context,
+		     FMListView *view)
+{
+	GList *ref_list;
+	GdkPixbuf *pixbuf;
+
+	pixbuf = get_drag_pixbuf (view);
+	if (pixbuf) {
+		gtk_drag_set_icon_pixbuf (context,
+					  pixbuf,
+					  0, 0);
+		g_object_unref (pixbuf);
+	} else {
+		gtk_drag_set_icon_default (context);
+	}
+
+	stop_drag_check (view);
+	view->details->drag_started = TRUE;
+	
+	ref_list = get_filtered_selection_refs (GTK_TREE_VIEW (widget));
+	g_object_set_data_full (G_OBJECT (context),
+				"drag-info",
+				ref_list,
+				(GDestroyNotify)ref_list_free);
+}
+
 static gboolean
 motion_notify_callback (GtkWidget *widget,
 			GdkEventMotion *event,
@@ -414,8 +455,6 @@ motion_notify_callback (GtkWidget *widge
 	FMListView *view;
 	GdkDragContext *context;
 	GdkCursor *cursor;
-	GList *ref_list;
-	GdkPixbuf *pixbuf;	
 	GtkTreePath *last_hover_path;
 	GtkTreeIter iter;
 	
@@ -476,25 +515,6 @@ motion_notify_callback (GtkWidget *widge
 				 GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK,
 				 view->details->drag_button,
 				 (GdkEvent*)event);
-
-			stop_drag_check (view);
-			view->details->drag_started = TRUE;
-			
-			ref_list = get_filtered_selection_refs (GTK_TREE_VIEW (widget));
-			g_object_set_data_full (G_OBJECT (context),
-						"drag-info",
-						ref_list,
-						(GDestroyNotify)ref_list_free);
-
-			pixbuf = get_drag_pixbuf (view);
-			if (pixbuf) {
-				gtk_drag_set_icon_pixbuf (context,
-							  pixbuf,
-							  0, 0);
-				g_object_unref (pixbuf);
-			} else {
-				gtk_drag_set_icon_default (context);
-			}
 		}		      
 		return TRUE;
 	}
@@ -1346,6 +1366,8 @@ create_and_set_up_tree_view (FMListView 
 				 "changed",
 				 G_CALLBACK (list_selection_changed_callback), view, 0);
 
+	g_signal_connect_object (view->details->tree_view, "drag_begin",
+				 G_CALLBACK (drag_begin_callback), view, 0);
 	g_signal_connect_object (view->details->tree_view, "drag_data_get",
 				 G_CALLBACK (drag_data_get_callback), view, 0);
 	g_signal_connect_object (view->details->tree_view, "motion_notify_event",

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]