Ticket #45 (closed defect: fixed)

Opened 23 months ago

Last modified 22 months ago

Drag and drop from muCommander to GNOME doesn't work

Reported by: xmirog@… Owned by: maxence@…
Priority: high Milestone:
Component: UI > Other Version: Nightly build
Severity: normal Keywords:
Cc: Operating System: unspecified
Java version: unspecified

Description

If you drag a file from GNOME (e.g. from Nautilus) to muCommander, it works perfectly: muCommander copies/moves the file to the directory where the file was dropped. But the reverse doesn't work.

Steps:
1) Open a directory in Nautilus (the "explorer" in GNOME)
2) Drag a file (e.g. "foo.txt" in directory "/path/to/foo") from muCommander and drop it in Nautilus with the CTRL key pressed

Expected:
In Nautilus, a file "foo.txt" is created, with the same size, name and content as the original one.

Real:
In Nautilus, a file called "new file" is created. Its content is "/path/to/foo/foo.txt".

Attachments

TransferableFileSet.java (13.9 kB) - added by xmirog@… 23 months ago.
TransferableFileSet? class modified

Change History

Changed 23 months ago by xmirog@…

It seems the problem is that in GNOME and KDE, the drag and drop system doesn't use the 'Flavor.javaFileList' flavour for the transfer of files, but another one based on a list of file URIs. The problem is described here (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4899516) and here (http://forums.java.net/jive/thread.jspa?forumID=74&threadID=8509).

I think changing a little the class TransferableFileSet? to support this flavor would make the DnD work completely in Linux (at least with GNOME and KDE). I have made a little change only to test it and it seems to work. This is my change (you may use this snippet as you want, reformat it, modify it and include it in your source code):
<<
=== modified file 'mucommander/source/com/mucommander/ui/dnd/TransferableFileSet.java'
--- mucommander/source/com/mucommander/ui/dnd/TransferableFileSet.java 2008-04-26 08:02:17 +0000
+++ mucommander/source/com/mucommander/ui/dnd/TransferableFileSet.java 2008-04-27 21:19:22 +0000
@@ -68,6 +68,8 @@

/** Does DataFlavor?.stringFlavor transfer the files' full paths or filenames only ? */
private boolean stringFlavourTransfersFilename = false;


+ /** DataFlavor? used for GNOME/KDE transfers */
+ private static DataFlavor? TEXT_URI_FLAVOR;

/** Custom FileSet? DataFlavor? used for local transfers */
private static DataFlavor? FILE_SET_DATA_FLAVOR;

@@ -76,6 +78,7 @@

// Create a single custom DataFlavor? instance that designates the FileSet? class to transfer data
try {

FILE_SET_DATA_FLAVOR = new DataFlavor?(DataFlavor?.javaJVMLocalObjectMimeType+";class="+FileSet?.class.getName());

+ TEXT_URI_FLAVOR = new DataFlavor?("text/uri-list;class="+String.class.getName());

}
catch(ClassNotFoundException? e) {

// That should never happen

@@ -250,6 +253,8 @@

if(stringFlavorSupported)

supportedDataFlavorsV.add(DataFlavor?.stringFlavor);


+ supportedDataFlavorsV.add(TEXT_URI_FLAVOR);
+

DataFlavor? supportedDataFlavors[] = new DataFlavor?[supportedDataFlavorsV.size()];
supportedDataFlavorsV.toArray(supportedDataFlavors);


@@ -264,6 +269,8 @@

return javaFileListFlavorSupported;

else if(dataFlavor.equals(DataFlavor?.stringFlavor))

return stringFlavorSupported;

+ else if(dataFlavor.equals(TEXT_URI_FLAVOR))
+ return true;

return false;

}

@@ -315,9 +322,26 @@

return sb.toString();

}

+ // GNOME & KDE
+ else if(dataFlavor.equals(TEXT_URI_FLAVOR)) {
+ StringBuffer? sb = new StringBuffer?();
+ AbstractFile? file;
+ File javaFile;
+ for(int i=0; i<nbFiles; i++) {
+ file = fileSet.fileAt(i);
+ javaFile = new File(stringFlavourTransfersFilename?file.getName():file.getAbsolutePath());
+ sb.append(javaFile.toURI());
+ if(i!=nbFiles-1){
+ sb.append("\r\n");
+ }
+ }
+
+ return sb.toString();
+ }

// Any other requested DataFlavor? will thrown an UnsupportedFlavorException?
else {

throw new UnsupportedFlavorException?(dataFlavor);

}

}

}

+


I hope this helps to solve this issue.

Changed 23 months ago by maxence@…

  • status changed from new to assigned

Thanks a lot for the bug report and the fix, much appreciated! I'm trying to apply your patch but without any success, 'patch' keeps complaining about 'malformed patch at line xx'. Could you please attach the whole java file to this bug ? I don't have any local changes so it's easier that way.

Thanks again,
Maxence

Changed 23 months ago by xmirog@…

TransferableFileSet? class modified

Changed 23 months ago by maxence@…

  • status changed from assigned to closed
  • resolution set to fixed

I reviewed your patch and integrated it, with a small modification to play nice with file protocols other than 'file' (local filesystem). Note that I was able to reproduce the problem on Ubuntu and validate the fix.

Can you please download the latest nightly build (will be ready in 10 minutes) and check that everything is cool?

Thanks again!

Changed 23 months ago by xmirog@…

The latest build now works perfect with drag & drop in GNOME! Thank you!

Changed 23 months ago by maxence@…

Thank *you*, makes me wish all bugs came with an attached fix ;)

Changed 22 months ago by xmirog@…

:-)

Note: See TracTickets for help on using tickets.