GNOME Bugzilla – Bug 386800
No 'Paste into folder' option in the menu of a mounted device
Last modified: 2008-01-28 11:12:41 UTC
That bug has been opened on https://launchpad.net/distros/ubuntu/+source/nautilus/+bug/63614 "Binary package hint: nautilus After copying a file in Nautilus, it is possible to paste it into a folder via right-clicking on the folder and selecting 'Paste Into Folder'. However, this option does not exist when right-clicking on mounted devices (such as a USB drive or network share)."
Created attachment 102260 [details] [review] Add "Paste Into Folder" to the context menus of mounted volumes and disks
Forgot to mention, that patch applies to the 2.20 tree, not the new GIO stuff.
Created attachment 102292 [details] [review] Add "Paste Into Folder" to context menus (for GIO) GIO version
can_unmount is not the right check. There are mounts that you aren't allowed to unmount that you can write to. Should check for (writable && is_directory) || type == MOUNTABLE || type == SHORTCUT. Of course, the later two should only really be allowed if they point to a directory, and that directory is writable. But we can ignore that for now and just display an error dialog if that is not true.
Created attachment 102761 [details] [review] Add "Paste Into Folder" to context menus (for GIO, v2) New patch, this tests if the file has an activation URI. If so, it tests for the ability to paste into that URI. For some reason, when I construct a NautilusFile using nautilus_file_get_by_uri, is_directory always returns FALSE. I had to manually retrieve a GFileInfo and run tests against that.
The reason that is_directory() returns FALSE for you is that the data for the NautilusFile has not been read yet. One needs to request that info and await its async reading by either a call_when_ready() or a monitor() call. Sync I/O like that is not allowed in nautilus. I've commited a patch based on your code that handles this by looking at the activation location and returning true if is_directory and can_write, or if the target type is unknown. In practice i think most links like that will be to directories, so its probably ok. Its kinda a pain to handle the async I/O stuff correctly with DnD...