Closed Bug 142798 Opened 23 years ago Closed 21 years ago

Should be able to copy url from download manager

Categories

(SeaMonkey :: Download & File Handling, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: hrosik, Assigned: csthomas)

References

Details

Attachments

(2 files, 8 obsolete files)

9.25 KB, patch
neil
: review+
jag+mozilla
: superreview+
Details | Diff | Splinter Review
9.49 KB, patch
Details | Diff | Splinter Review
1) download manager should be able to copy URL of a selected file into the clipboard. 2) DM doesn't show destination path of downloaded files. 3) properties window should open for downloaded (finished) files also not only for the ones being downloaded. 4) sorting doesn't work, files are always sorted by progress (Win95; rv:1.0rc2; Gecko/20020506)
Please do not file more than one issue per bug and try to do a thorough search for duplicates before filing the bugs. 2) is covered by bug 135805 3) is covered by bug 139606 4) is covered by bug 134824 If you want to do 1), it is possible to copy the downloaded file name from the properties box during a download. Highlight the name, right click with the mouse and choose Copy from the menu.
Summary: missing features in download manager → missing features in download manager
Focusing on issue #1.
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 95 → All
Hardware: PC → All
Summary: missing features in download manager → Should be able to copy filename from download manager
clarifying summary a bit.
Summary: Should be able to copy filename from download manager → Should be able to copy url from download manager
QA Contact: sairuh → petersen
*** Bug 209159 has been marked as a duplicate of this bug. ***
Function copyToClibboard is based on copyBookmark from bookmarks.js. A text/unicode and a text/html version is copied. The key_copy (^C on Win) mapping is there, but does not WFM. This is possibly related to Bug 198247 or Bug 202005 (Haven't tried the patches attachment 128325 [details] [diff] [review] or attachment 128326 [details] [diff] [review])
Attachment #129276 - Flags: review?
Attachment #129276 - Flags: review? → review?(neil.parkwaycc.co.uk)
I don't see how the html version is useful...
*** Bug 241308 has been marked as a duplicate of this bug. ***
If the html-copy is omitted, would the patch be ready for approval? Not necessary for Firefox branch but I think it would be useful for the trunk. The alternative solution is a bit cubersome (needs some keyboard & mouse clicking in order to mark and copy the entire url).
(In reply to comment #8) > ... (needs some keyboard & mouse clicking in > order to mark and copy the entire url). This is (at least on windows) only possible in progress dialog but not in download manager.
Attachment #149831 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #149832 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 149832 [details] [diff] [review] Patch: Same for Trunk (not tested yet) >+ var url = selectedItems[i].firstChild.lastChild.getAttribute("label"); This doesn't sound like the right way to do this... try gDownloadManager.getDownload(selectedItems[i].id).source.spec >+ const kXferableContractID = "@mozilla.org/widget/transferable;1"; >+ const kXferableIID = Components.interfaces.nsITransferable; >+ var xferable = Components.classes[kXferableContractID].createInstance(kXferableIID); >+ >+ xferable.addDataFlavor("text/unicode"); >+ unicodestring.data = sTextUnicode; >+ xferable.setTransferData("text/unicode", unicodestring, sTextUnicode.length*2); >+ >+ const kClipboardContractID = "@mozilla.org/widget/clipboard;1"; >+ const kClipboardIID = Components.interfaces.nsIClipboard; >+ var clipboard = Components.classes[kClipboardContractID].getService(kClipboardIID); >+ clipboard.setData(xferable, null, kClipboardIID.kGlobalClipboard); As this is now text you can use the clipboard helper component instead, which simplifies things trememdously.
Seeing as this bug hasn't been touched in 2 months, I'll see about updating the patch with Neil's recommendations.
Assignee: firefox → cst
(In reply to comment #12) >(From update of attachment 149832 [details] [diff] [review]) >>+ var url = selectedItems[i].firstChild.lastChild.getAttribute("label"); >This doesn't sound like the right way to do this... Sorry, my previous suggestion only worked for current downloads :-[
Attachment #129276 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #149831 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #149832 - Flags: review?(neil.parkwaycc.co.uk)
Attached patch Patch (for trunk) (obsolete) — Splinter Review
<Jan> CTho|away: I'd say use DOM since download manager uses tree content view that is DOM based anyway <Jan> CTho|away: tell Neil I'm ok with that
Attachment #149831 - Attachment is obsolete: true
Attachment #149832 - Attachment is obsolete: true
Attachment #157335 - Flags: review?(neil.parkwaycc.co.uk)
Status: NEW → ASSIGNED
Comment on attachment 157335 [details] [diff] [review] Patch (for trunk) >+ try { >+ gStatusBar.label = copyToClipboard(selectedItems); >+ } >+ catch (ex) { >+ } Which exception are you expecting? You shouldn't try to catch unexpected exceptions, they may be fallout from other people's bustage. >+ const kSuppWStringContractID = "@mozilla.org/supports-string;1"; >+ const kSuppWStringIID = Components.interfaces.nsISupportsString; >+ var unicodestring = Components.classes[kSuppWStringContractID].createInstance(kSuppWStringIID); You don't use these variables. >+ var sTextUnicode = ""; var sStatusText = ""; One statement per line, or use "," instead of "; var", or see below >+ for (var i = 0; i < selectedItems.length; ++i) { >+ var url = selectedItems[i].firstChild.lastChild.getAttribute("label"); // XXX assumes "Source" is last cell While there is a way to get the text from the view which works in the case where the cells are reordered the way the rest of the download manager works makes it tricky to access, so DOM is fine here. >+ No trailing spaces please. >+ else >+ sTextUnicode += "\n"; >+ sTextUnicode += url; Rather than concatenating the text by hand, put the text in an array and join it together. >+ if (selectedItems.length > 1) >+ sStatusText += " ..."; The status bar knows all about ellipsing strings, you could just return a space-separated list. >+ const kClipboardHelperCID = "@mozilla.org/widget/clipboardhelper;1"; >+ clipboardHelper = Components.classes[kClipboardHelperCID] Inline this if it will fit in 80 characters. >+ .getService(Components.interfaces["nsIClipboardHelper"]); Should be .nsIClipboardHelper >+ >+ Erroneous blank line. >+ <menuitem id="downloadPaneContext-copyurl" >+ label="&cmd.copyurl.label;" >+ accesskey="&cmd.copyurl.accesskey;" >+ command="cmd_copyurl"/> > </popup> I'm not sure this is the best place to put it. Try before the last separator. >+ <toolbarbutton id="btn_copyurl" label="&cmd.copyurl.label;" accesskey="&cmd.copyurl.accesskey;" >+ command="cmd_copyurl"/> > </toolbar> Also here, and any other similar lists.
Attachment #157335 - Flags: review?(neil.parkwaycc.co.uk) → review-
Attached patch Revised patch (obsolete) — Splinter Review
Attachment #157335 - Attachment is obsolete: true
Attachment #157977 - Flags: superreview?(jag)
Attachment #157977 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 157977 [details] [diff] [review] Revised patch Oops.
Attachment #157977 - Attachment is obsolete: true
Attachment #157977 - Flags: superreview?(jag)
Attachment #157977 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #157978 - Flags: superreview?(jag)
Attachment #157978 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 157978 [details] [diff] [review] Revised patch that actually works >Index: xpfe/components/download-manager/resources/downloadmanager.js >=================================================================== >RCS file: /cvsroot/mozilla/xpfe/components/download-manager/resources/downloadmanager.js,v >retrieving revision 1.37 >diff -u -p -9 -r1.37 downloadmanager.js >--- xpfe/components/download-manager/resources/downloadmanager.js 19 Aug 2004 00:46:31 -0000 1.37 >+++ xpfe/components/download-manager/resources/downloadmanager.js 6 Sep 2004 02:51:41 -0000 >@@ -305,34 +308,40 @@ var downloadViewController = { >+ case "cmd_copyurl": >+ selectedItems = getSelectedItems(); >+ if (selectedItems.length > 0) { >+ gStatusBar.label = copyToClipboard(selectedItems); Use two space indent like the surrounding code. >@@ -420,9 +429,26 @@ function doSort(node) >+function copyToClipboard(selectedItems) // Based on bookmarks.js:copyBookmark >+{ >+ var unicodeText, statusText; Just put |var| on the lines below where you initialize the variables. >+ var urlArray = new Array(selectedItems.length); >+ for (var i = 0; i < selectedItems.length; ++i) { >+ urlArray[i] = selectedItems[i].firstChild.lastChild.getAttribute("label"); >+ } Same indentation nit here. >+ unicodeText = urlArray.join("\n"); >+ statusText = urlArray.join(" "); >+ >+ clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] >+ .getService(Components.interfaces.nsIClipboardHelper); Missing |var| from clipboardHelper. Personally I prefer to line it up like this: >+ var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] >+ .getService(Components.interfaces.nsIClipboardHelper); Or at least indent the second/wrapped line to beyond the equals sign. >+ clipboardHelper.copyString(unicodeText); >+ >+ return statusText; >+} Actually, looks like you could just change this to clipboardHelper.copyString(urlArray.join("\n")); return urlArray.join(" "); // for status text and be rid of the temporary variables altogether.
Attached patch Re-revisd patch (obsolete) — Splinter Review
>and be rid of the temporary variables altogether. I wasn't sure if that would be clear enough to get an r+
Attachment #157978 - Attachment is obsolete: true
Attachment #157985 - Flags: superreview?(jag)
Attachment #157985 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #157978 - Flags: superreview?(jag)
Attachment #157978 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 157985 [details] [diff] [review] Re-revisd patch + return urlArray.join(" "); The comment I added to that line in my review would've helped clarify why you're doing that. sr=jag if you add that comment.
Attachment #157985 - Flags: superreview?(jag) → superreview+
Attached patch Patch with jag's comment (obsolete) — Splinter Review
Attachment #157985 - Attachment is obsolete: true
Attachment #157988 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #157985 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #157988 - Flags: superreview+
Comment on attachment 157988 [details] [diff] [review] Patch with jag's comment Review cancelled due to incomplete patch - no .dtd changes! > case "cmd_properties": > case "cmd_pause": > case "cmd_cancel": > case "cmd_remove": > case "cmd_openfile": > case "cmd_showinshell": > case "cmd_selectAll": >+ case "cmd_copyurl": You put the command in the right order in the xul... would be nice to do it here as well. > var cmds = ["cmd_properties", "cmd_pause", "cmd_cancel", "cmd_remove", >- "cmd_openfile", "cmd_showinshell"]; >+ "cmd_openfile", "cmd_showinshell", "cmd_copyurl"]; And here too. And in the .dtd of course ;-) >+function copyToClipboard(selectedItems) // Based on bookmarks.js:copyBookmark How much of copyBookmark is left? The comment might be misleading.
Attachment #157988 - Attachment is obsolete: true
Attachment #157988 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 158077 [details] [diff] [review] Patch I'm assuming I need a new sr. If not, please unset the request.
Attachment #158077 - Flags: superreview?(jag)
Attachment #158077 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 158077 [details] [diff] [review] Patch Heh, yeah, having the DTD changes is a good thing :-) Sorry I missed their absence. sr=jag
Attachment #158077 - Flags: superreview?(jag) → superreview+
Sorry, I forgot to move the addition to the DTD :(. If the other patch is otherwise ok, this is the one to check in.
Attachment #158077 - Flags: review?(neil.parkwaycc.co.uk) → review+
Whiteboard: r? → waiting for checkin
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Whiteboard: waiting for checkin
+<!ENTITY cmd.copyurl.label "Copy URL"> do users know what a URL is? maybe "Copy Source Address" or something would be better? Or do I just underestimate users? :-)
We already use "Location", so why not use it here? "Copy Location" is already a wellknown term among the users that would otherwise use this feature, and the string is already there.
(In reply to comment #32) > We already use "Location", so why not use it here? > "Copy Location" is already a wellknown term among the users that would otherwise > use this feature, and the string is already there. "Show file location" shows where you saved it. "Copy Location" would imply to me that it would copy the location you saved to, rather than the source location.
Good point. I'd vote for "Copy Source Location", then.
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: