nautilus r13659 - in trunk: . src/file-manager



Author: alexl
Date: Mon Jan 28 11:25:21 2008
New Revision: 13659
URL: http://svn.gnome.org/viewvc/nautilus?rev=13659&view=rev

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

        * src/file-manager/fm-directory-view.c:
	Enable paste into folder for volume links (#386800)
	Based on patch from John Millikin




Modified:
   trunk/ChangeLog
   trunk/src/file-manager/fm-directory-view.c

Modified: trunk/src/file-manager/fm-directory-view.c
==============================================================================
--- trunk/src/file-manager/fm-directory-view.c	(original)
+++ trunk/src/file-manager/fm-directory-view.c	Mon Jan 28 11:25:21 2008
@@ -5671,7 +5671,7 @@
 
 	selection = fm_directory_view_get_selection (view);
 
-	directory_uri = nautilus_file_get_uri (NAUTILUS_FILE (selection->data));
+	directory_uri = nautilus_file_get_activation_uri (NAUTILUS_FILE (selection->data));
 
 	paste_clipboard_data (view, selection_data, directory_uri);
 
@@ -6509,6 +6509,37 @@
 	view->details->templates_invalid = TRUE;
 }
 
+static gboolean
+can_paste_into_file (NautilusFile *file)
+{
+	if (nautilus_file_is_directory (file) &&
+	    nautilus_file_can_write (file)) {
+		return TRUE;
+	}
+	if (nautilus_file_has_activation_uri (file)) {
+		GFile *location;
+		NautilusFile *activation_file;
+		gboolean res;
+		
+		location = nautilus_file_get_activation_location (file);
+		activation_file = nautilus_file_get (location);
+		g_object_unref (location);
+	
+		/* The target location might not have data for it read yet,
+		   and we can't want to do sync I/O, so treat the unknown
+		   case as can-write */
+		res = (nautilus_file_get_file_type (activation_file) == G_FILE_TYPE_UNKNOWN) ||
+			(nautilus_file_get_file_type (activation_file) == G_FILE_TYPE_DIRECTORY &&
+			 nautilus_file_can_write (activation_file));
+
+		nautilus_file_unref (activation_file);
+		
+		return res;
+	}
+	
+	return FALSE;
+}
+
 static void
 clipboard_targets_received (GtkClipboard     *clipboard,
 			    GtkSelectionData *selection_data,
@@ -6554,9 +6585,8 @@
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      FM_ACTION_PASTE_FILES_INTO);
 	gtk_action_set_sensitive (action,
-				  can_paste && count == 1 &&
-				  nautilus_file_is_directory (NAUTILUS_FILE (selection->data)) &&
-				  nautilus_file_can_write (NAUTILUS_FILE (selection->data)));
+	                          can_paste && count == 1 &&
+	                          can_paste_into_file (NAUTILUS_FILE (selection->data)));
 	
 	nautilus_file_list_free (selection);
 	
@@ -6820,13 +6850,14 @@
 	gboolean is_read_only;
 	GtkAction *action;
 
-	selection_is_read_only = selection_count == 1
-		&& !nautilus_file_can_write (NAUTILUS_FILE (selection->data));
-	
+	selection_is_read_only = selection_count == 1 &&
+		(!nautilus_file_can_write (NAUTILUS_FILE (selection->data)) &&
+		 !nautilus_file_has_activation_uri (NAUTILUS_FILE (selection->data)));
+		 
 	is_read_only = fm_directory_view_is_read_only (view);
 	
-	can_paste_files_into = selection_count == 1 && 
-		nautilus_file_is_directory (NAUTILUS_FILE (selection->data));
+	can_paste_files_into = (selection_count == 1 && 
+	                        can_paste_into_file (NAUTILUS_FILE (selection->data)));
 
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      FM_ACTION_PASTE);



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