nautilus r13610 - in trunk: . libnautilus-private



Author: alexl
Date: Tue Jan 15 15:50:17 2008
New Revision: 13610
URL: http://svn.gnome.org/viewvc/nautilus?rev=13610&view=rev

Log:
2008-01-15  Alexander Larsson  <alexl redhat com>

        * libnautilus-private/nautilus-dnd.[ch]:
	Add nautilus_drag_uris_local
	
        * libnautilus-private/nautilus-tree-view-drag-dest.c:
	Don't copy/move files if you dnd within the same
	location (#508216)




Modified:
   trunk/ChangeLog
   trunk/libnautilus-private/nautilus-dnd.c
   trunk/libnautilus-private/nautilus-dnd.h
   trunk/libnautilus-private/nautilus-tree-view-drag-dest.c

Modified: trunk/libnautilus-private/nautilus-dnd.c
==============================================================================
--- trunk/libnautilus-private/nautilus-dnd.c	(original)
+++ trunk/libnautilus-private/nautilus-dnd.c	Tue Jan 15 15:50:17 2008
@@ -202,9 +202,9 @@
 	return result;
 }
 
-
-gboolean
-nautilus_drag_items_local (const char *target_uri_string, const GList *selection_list)
+static gboolean
+nautilus_drag_file_local_internal (const char *target_uri_string,
+				   const char *first_source_uri)
 {
 	/* check if the first item on the list has target_uri_string as a parent
 	 * FIXME:
@@ -214,15 +214,12 @@
 	GFile *target, *item, *parent;
 	gboolean result;
 
-	/* must have at least one item */
-	g_assert (selection_list);
-
 	result = FALSE;
 
 	target = g_file_new_for_uri (target_uri_string);
 
 	/* get the parent URI of the first item in the selection */
-	item = g_file_new_for_uri (((NautilusDragSelectionItem *)selection_list->data)->uri);
+	item = g_file_new_for_uri (first_source_uri);
 	parent = g_file_get_parent (item);
 	g_object_unref (item);
 	
@@ -232,6 +229,27 @@
 	}
 	
 	return result;
+}	
+
+gboolean
+nautilus_drag_uris_local (const char *target_uri,
+			  const GList *source_uri_list)
+{
+	/* must have at least one item */
+	g_assert (source_uri_list);
+	
+	return nautilus_drag_file_local_internal (target_uri, source_uri_list->data);
+}
+
+gboolean
+nautilus_drag_items_local (const char *target_uri_string,
+			   const GList *selection_list)
+{
+	/* must have at least one item */
+	g_assert (selection_list);
+
+	return nautilus_drag_file_local_internal (target_uri_string,
+						  ((NautilusDragSelectionItem *)selection_list->data)->uri);
 }
 
 gboolean

Modified: trunk/libnautilus-private/nautilus-dnd.h
==============================================================================
--- trunk/libnautilus-private/nautilus-dnd.h	(original)
+++ trunk/libnautilus-private/nautilus-dnd.h	Tue Jan 15 15:50:17 2008
@@ -117,6 +117,8 @@
 GList 		           *nautilus_drag_build_selection_list          (GtkSelectionData                     *data);
 gboolean                    nautilus_drag_items_local                   (const char                           *target_uri,
 									 const GList                          *selection_list);
+gboolean                    nautilus_drag_uris_local                    (const char                           *target_uri,
+									 const GList                          *source_uri_list);
 gboolean                    nautilus_drag_items_in_trash                (const GList                          *selection_list);
 gboolean                    nautilus_drag_items_on_desktop              (const GList                          *selection_list);
 void                        nautilus_drag_default_drop_action_for_icons (GdkDragContext                       *context,

Modified: trunk/libnautilus-private/nautilus-tree-view-drag-dest.c
==============================================================================
--- trunk/libnautilus-private/nautilus-tree-view-drag-dest.c	(original)
+++ trunk/libnautilus-private/nautilus-tree-view-drag-dest.c	Tue Jan 15 15:50:17 2008
@@ -581,11 +581,13 @@
 	}
 
 	if (context->action > 0) {
-		g_signal_emit (dest, signals[MOVE_COPY_ITEMS], 0,
-			       source_uris, 
-			       drop_target,
-			       context->action,
-			       x, y);
+		if (!nautilus_drag_uris_local (drop_target, source_uris)) {
+			g_signal_emit (dest, signals[MOVE_COPY_ITEMS], 0,
+				       source_uris, 
+				       drop_target,
+				       context->action,
+				       x, y);
+		}
 	}
 
 	g_free (drop_target);



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