=?WINDOWS-1252?Q?[PATCH]_=96_Same_filesystem_drag-and-drop_of_a_rea?= =?WINDOWS-1252?Q?donly_file_should_gracefully_degrade_to_a_"copy"?=



Hi!,
the subject says it all, an example usecase is dragging a file from /etc and dropping it in your home dir, currently this performs a move operation that ends in an error dialog because /etc is readonly , with the patch applied the file gets *copied* instead, which is the expected behaviour.

See  http://bugzilla.gnome.org/show_bug.cgi?id=314139 for more info.

Thanks
Index: libnautilus-private/nautilus-dnd.c
===================================================================
--- libnautilus-private/nautilus-dnd.c	(revisión: 14183)
+++ libnautilus-private/nautilus-dnd.c	(copia de trabajo)
@@ -358,6 +358,36 @@ check_same_fs (GFile *file1, GFile *file
 	return res;
 }
 
+static gboolean
+source_parent_is_writable_ (GFile *file)
+{
+	GFile *parent;
+	GFileInfo *parent_info;
+	parent = g_file_get_parent (file);
+	if (parent == NULL) {
+		return FALSE;	
+	}
+
+	parent_info = g_file_query_info (parent, "standard::type,access::can-write", 
+					G_FILE_QUERY_INFO_NONE, NULL, NULL);
+	if (parent_info == NULL) {
+		g_object_unref (parent);
+		return FALSE;
+	}
+
+	if (g_file_info_get_file_type (parent_info) != G_FILE_TYPE_DIRECTORY ||
+	    g_file_info_get_attribute_boolean (parent_info, "access::can-write") == FALSE) {
+		g_object_unref (parent);		
+		g_object_unref (parent_info);
+		return FALSE;
+	}
+
+	g_object_unref (parent);
+	g_object_unref (parent_info);
+
+	return TRUE;
+}
+
 void
 nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
 					     const char *target_uri_string, const GList *items,
@@ -365,6 +395,7 @@ nautilus_drag_default_drop_action_for_ic
 {
 	gboolean same_fs;
 	gboolean target_is_source_parent;
+	gboolean source_parent_is_writable;
 	const char *dropped_uri;
 	GFile *target, *dropped;
 	GdkDragAction actions;
@@ -432,8 +463,9 @@ nautilus_drag_default_drop_action_for_ic
 	dropped = g_file_new_for_uri (dropped_uri);
 	same_fs = check_same_fs (target, dropped);
 	target_is_source_parent = g_file_has_prefix (dropped, target);
-	
-	if (same_fs || target_is_source_parent ||
+	source_parent_is_writable = source_parent_is_writable_ (dropped);
+
+	if ((same_fs && source_parent_is_writable) || target_is_source_parent ||
 	    g_file_has_uri_scheme (dropped, "trash")) {
 		if (actions & GDK_ACTION_MOVE) {
 			*action = GDK_ACTION_MOVE;


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