Closed Bug 192728 Opened 22 years ago Closed 14 years ago

Add possibility to drag downloaded files from download window and drop/move them to desktop (as example)

Categories

(SeaMonkey :: Download & File Handling, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
seamonkey2.1a2

People

(Reporter: hauser, Assigned: InvisibleSmiley)

References

Details

Attachments

(3 files, 5 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030114
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030114

The above URL is a complementary RFE.

It would be great to be able to move/copy a downloaded file from the download
window to any location (i.e. directory in MS file explorer, {emtpy} MS-Word
windows, etc.) where one normally can drop files...

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Product: Browser → Seamonkey
The corresponding bug for Firefox is Bug 242204.
Assignee: bross2 → download-manager
QA Contact: chrispetersen
bug 132024 and bug 242204 are not real blockers but closely related, so let's add them as dependencies to have anyone on the CC list here notified of status changes on the others.
Depends on: 132024, 242204
OS: Windows 2000 → All
Hardware: x86 → All
Assignee: download → nobody
QA Contact: download
bug 242204 has been duped to Bug 462172
Depends on: 462172
No longer depends on: 242204
I'll add this to my todo list of bugs already fixed in TB
Assignee: nobody → philbaseless-firefox
Attached patch basic functionality (obsolete) — Splinter Review
This implements/ports the basic functionality from FF Bug 462172. No tests, thus not requesting review and not changing assignee or bug status. I hope this helps who ever is brave enough to add tests (e.g. Phil who did the FF bug).
Looking more closely at the checkin for bug 462172 I found that in fact only one test file was actually specifically for download drag testing [1]. The test uses utils.js which we don't have but we have replacements for the few functions called from there (getDMUI(), getDMWindow()). I was almost done adapting the test for our setup when I realized that synthesizeDragStart() [2] requires passing in an element. For Toolkit's DM that's easy because there each download relates to a richlistitem which has an "id" attribute with a value of "dl" + dlid [3] so that document.getElementById() can be used. For us it's hard (impossible?) because we have a tree and the nsITreeView interface provides no way to get a row element.

To cut a long story short: Unless there's a way to somehow get a XUL treerow we'll have to write our own synthesizeDragStart() that issues synthesizeMouse() calls with configurable x/y coordinates, similar to mouseDblClickOnCell() [4], or extend the existing Toolkit version with optional x/y coordinate start parameters (in which case we could pass in aTree.body as the element).

[1] toolkit/mozapps/downloads/tests/chrome/test_bug_462172.xul
[2] testing/mochitest/tests/SimpleTest/EventUtils.js
[3] toolit/mozapps/downloads/content/downloads.js: createDownloadItem()
[4] suite/common/downloads/test/chrome/test_enter_dblclick_opens.xul

Now I've invested several times as much time into porting the test for this in comparison to how long it took to port the basic functionality and the test is not even working yet. Sigh... :-(
Depends on: 554418
Attached patch test (obsolete) — Splinter Review
Test, pending bug 554418. Not requesting review until that one is fixed.
Assignee: philbaseless-firefox → jh
Status: NEW → ASSIGNED
Comment on attachment 430687 [details] [diff] [review]
basic functionality

Note:
1. If you select multiple downloads, only one is actually handled. Same in FF.
2. I couldn't find a program on Linux that serves as a valid drop target. I tried Nautilus (Gnome), Thunar (XFce), Dolphin (KDE 4), Konqueror (KDE 4), ROX Filer. Works fine on WinXP. Same in FF. Possible hint: ROX Filer says "Sorry - I need a target of type text/uri-list or XdndDirectSave0".
Attachment #430687 - Flags: review?(neil)
Attachment #434312 - Flags: review?(neil)
Comment on attachment 430687 [details] [diff] [review]
basic functionality

>+    var selectionCount = 0;
>+    if (gDownloadTreeView && gDownloadTreeView.selection)
>+      selectionCount = gDownloadTreeView.selection.count;
>+    if (!selectionCount)
>+      return;
Nit: Since you don't actually use the selection here, you can test this inline without actually saving the count. (Or are you planning multiple files?)

>+      saveURL(url, name ? name : url, null, true, true);
You don't actually need to pass anything for the second parameter, do you?
Note that download manager doesn't load the script that defines saveURL...

>+        ondragover="gDownloadDNDObserver.onDragOver(event);event.stopPropagation();"
Why here and not in onDragOver?
Attached patch patch v2 (obsolete) — Splinter Review
(In reply to comment #9)
> (From update of attachment 430687 [details] [diff] [review])
> >+    var selectionCount = 0;
> >+    if (gDownloadTreeView && gDownloadTreeView.selection)
> >+      selectionCount = gDownloadTreeView.selection.count;
> >+    if (!selectionCount)
> >+      return;
> Nit: Since you don't actually use the selection here, you can test this inline
> without actually saving the count. (Or are you planning multiple files?)

Not really planning. It'd surely be nice to have in the future, though. Anyway, whoever does that then should be able to figure out how to get the selection count I guess so I inlined it for now.

> >+      saveURL(url, name ? name : url, null, true, true);
> You don't actually need to pass anything for the second parameter, do you?
> Note that download manager doesn't load the script that defines saveURL...

Looking at other examples it seems you're right but I feel that it's cleaner to actually use the information we have. onDrop could be called independent from the corresponding onDragStart, i.e. when the drag is not coming from the download manager (in theory), right? In that case name could be different from what can be extracted from the url.

> >+        ondragover="gDownloadDNDObserver.onDragOver(event);event.stopPropagation();"
> Why here and not in onDragOver?

The usual answer: FF had it like that. Changed (AFAICS they use onDragOver only once, too).


I also found why d&d didn't work on Linux (the ROX error message was really helpful!). Implementing text/uri-list and text/plain in addition is the key. That makes it work in all applications listed in comment 8. I even tried SciTE and KWrite (both text editors) successfully.

<http://mdn.beonex.com/En/DragDrop/Recommended_Drag_Types>
(Note the following under Dragging Files: "If possible, you may also include the file URL of the file using both the text/uri-list and/or text/plain types. These types should be added last so that the more specific application/x-moz-file type has higher priority.")

<http://www.rfc-editor.org/rfc/rfc2483.txt>
(Notes that CRLF is required. Something that ROX will happily tell you, too.)

With that we're better than FF! :-)

I guess I'll file a bug for the red panda later. ;-)
Attachment #430687 - Attachment is obsolete: true
Attachment #445611 - Flags: review?(neil)
Attachment #430687 - Flags: review?(neil)
(In reply to comment #10)
> (In reply to comment #9)
> > >+      saveURL(url, name ? name : url, null, true, true);
> > You don't actually need to pass anything for the second parameter, do you?
> > Note that download manager doesn't load the script that defines saveURL...
> Looking at other examples it seems you're right but I feel that it's cleaner to
> actually use the information we have. onDrop could be called independent from
> the corresponding onDragStart, i.e. when the drag is not coming from the
> download manager (in theory), right? In that case name could be different from
> what can be extracted from the url.
Sorry, I misled you here - I was thinking of the case when we have no name.
(In reply to comment #11)
> Sorry, I misled you here - I was thinking of the case when we have no name.

Changed to saveURL(url, name, null, true, true); locally.
After all that, saveURL isn't defined, so dropping on DM fails anyway...
(In reply to comment #13)
> After all that, saveURL isn't defined, so dropping on DM fails anyway...

Fixed by including contentAreaUtils.js (cf. FF's downloads.xul). Also added ondrop attribute to the tree element.
Attachment #445611 - Attachment is obsolete: true
Attachment #446587 - Flags: review?(neil)
Attachment #445611 - Flags: review?(neil)
Comment on attachment 446587 [details] [diff] [review]
patch v3 [Checkin: comment 21]

[I wonder why the special save link as filename guessing code doesn't live in contentAreaUtils.js]
Attachment #446587 - Flags: review?(neil) → review+
(In reply to comment #10)
> I guess I'll file a bug for the red panda later. ;-)

Filed bug 567377.

Neil, since your review queue is pretty long, should I move the test review request to IanN?
Comment on attachment 434312 [details] [diff] [review]
test

Test doesn't pass anymore:

failed | Checking for Real file match - got [object DataTransfer], expected null
passed | Drag start did not return item for missing file

Back to the drawing board, canceling review request until I have something better. :-(
Attachment #434312 - Flags: review?(neil)
Attached patch test v2 (obsolete) — Splinter Review
Now that was easy. And tests the Linux requirements. :-)
Attachment #434312 - Attachment is obsolete: true
Attachment #447226 - Flags: review?(neil)
Comment on attachment 447226 [details] [diff] [review]
test v2

rs=me (I just skimmed the patch, I didn't actually try it or anything...)

>+      var win = aSubject.QueryInterface(Components.interfaces.nsIDOMWindow);
Shouldn't have to do this, as windows have class info.
Attachment #447226 - Flags: review?(neil) → review+
(In reply to comment #19)
> (From update of attachment 447226 [details] [diff] [review])
> rs=me (I just skimmed the patch, I didn't actually try it or anything...)

Fortunately I did. ;-)

> >+      var win = aSubject.QueryInterface(Components.interfaces.nsIDOMWindow);
> Shouldn't have to do this, as windows have class info.

It works without the QI, as in the other tests, so I removed it. Also added the two new MIME types to the first comment ("Assure download manager...").
Attachment #447226 - Attachment is obsolete: true
Attachment #447515 - Flags: review+
Comment on attachment 446587 [details] [diff] [review]
patch v3 [Checkin: comment 21]

http://hg.mozilla.org/comm-central/rev/6ca437a04a93
Attachment #446587 - Attachment description: patch v3 → patch v3 [Checkin: comment 21]
Attachment #447515 - Attachment description: test v2a, rs=neil → test v2a, rs=neil [Checkin: comment 21]
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → seamonkey2.1a2
Flags: in-testsuite+
Note: While testing this locally with my self-compiled build (VS2005/SP1, -O2, among others) I ran into a repeatable crash:
<http://crash-stats.mozilla.com/report/index/808bc513-f9e2-4201-a4fc-c384d2100526>
This might be the same as described in this forum thread:
<http://forums.mozillazine.org/viewtopic.php?f=42&t=1708215>
which points to Bug 526038 which is still open.

I checked in anyway since official nightly builds are not affected by that somewhat unrelated issue (verified by replacing the downloadmanager.* files in the current nightly build's comm.jar and d&d'ing to and from the DM successfully).
Comment on attachment 446587 [details] [diff] [review]
patch v3 [Checkin: comment 21]

>   <tree id="downloadTree"
>         flex="1" type="downloads"
>         class="plain"
>         context="downloadContext"
>         enableColumnDrag="true"
>         ondblclick="goDoCommand('cmd_open');"
>+        ondragstart="gDownloadDNDObserver.onDragStart(event);"
>+        ondragover="gDownloadDNDObserver.onDragOver(event);"
>+        ondrop="gDownloadDNDObserver.onDrop(event);"
We need to move these handlers to the <treechildren> element, since currently I can't drag the scrollbar :-(
Attached patch move handlers (obsolete) — Splinter Review
(In reply to comment #23)
> We need to move these handlers to the <treechildren> element, since currently I
> can't drag the scrollbar :-(

Strangely I could only reproduce this once per profile. Anyway, with this patch it's fixed for me for new profiles.
Attachment #449089 - Flags: review?(neil)
Comment on attachment 449089 [details] [diff] [review]
move handlers

I specifically excluded the onselect handler ;-)
Attachment #449089 - Flags: review?(neil) → review-
Attachment #449089 - Attachment is obsolete: true
Attachment #449101 - Flags: review?(neil)
Attachment #449101 - Flags: review?(neil) → review+
Comment on attachment 449101 [details] [diff] [review]
move handlers v2 [Checkin: comment 27]

http://hg.mozilla.org/comm-central/rev/49017fdba4ba
Attachment #449101 - Attachment description: move handlers v2 → move handlers v2 [Checkin: comment 27]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: