Bug 227749 - "Add "Copy Source Location" to download manager context menu" [p=jhenry@ccs.neu.edu (Jon Henry) r=sdwilsh ui-r=beltzner]

This commit is contained in:
reed%reedloden.com 2007-09-05 21:19:12 +00:00
Родитель 20fb3d286c
Коммит 3283743bc2
3 изменённых файлов: 38 добавлений и 7 удалений

Просмотреть файл

@ -28,6 +28,8 @@
<!ENTITY cmd.openWith.accesskey "h"> <!ENTITY cmd.openWith.accesskey "h">
<!ENTITY cmd.retry.label "Retry"> <!ENTITY cmd.retry.label "Retry">
<!ENTITY cmd.retry.accesskey "R"> <!ENTITY cmd.retry.accesskey "R">
<!ENTITY cmd.copyLocation.label "Copy Source Location">
<!ENTITY cmd.copyLocation.accesskey "L">
<!ENTITY cmd.remove.label "Remove"> <!ENTITY cmd.remove.label "Remove">
<!ENTITY cmd.remove.accesskey "e"> <!ENTITY cmd.remove.accesskey "e">
<!ENTITY cmd.info.label "Information"> <!ENTITY cmd.info.label "Information">

Просмотреть файл

@ -364,6 +364,15 @@ function retryDownload(aDownload)
gDownloadManager.retryDownload(aDownload.getAttribute("dlid")); gDownloadManager.retryDownload(aDownload.getAttribute("dlid"));
} }
function copySourceLocation(aDownload)
{
var uri = aDownload.getAttribute("uri");
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper);
clipboard.copyString(uri);
}
// This is called by the progress listener. We don't actually use the event // This is called by the progress listener. We don't actually use the event
// system here to minimize time wastage. // system here to minimize time wastage.
var gLastComputedMean = -1; var gLastComputedMean = -1;
@ -449,19 +458,26 @@ function Shutdown()
// View Context Menus // View Context Menus
var gContextMenus = [ var gContextMenus = [
// DOWNLOAD_DOWNLOADING // DOWNLOAD_DOWNLOADING
["menuitem_pause", "menuitem_cancel"], ["menuitem_pause", "menuitem_cancel", "menuseparator_copy_location",
"menuitem_copyLocation"],
// DOWNLOAD_FINISHED // DOWNLOAD_FINISHED
["menuitem_open", "menuitem_show", "menuitem_remove"], ["menuitem_open", "menuitem_show", "menuitem_remove",
"menuseparator_copy_location", "menuitem_copyLocation"],
// DOWNLOAD_FAILED // DOWNLOAD_FAILED
["menuitem_retry", "menuitem_remove"], ["menuitem_retry", "menuitem_remove", "menuseparator_copy_location",
"menuitem_copyLocation"],
// DOWNLOAD_CANCELED // DOWNLOAD_CANCELED
["menuitem_retry", "menuitem_remove"], ["menuitem_retry", "menuitem_remove", "menuseparator_copy_location",
"menuitem_copyLocation"],
// DOWNLOAD_PAUSED // DOWNLOAD_PAUSED
["menuitem_resume", "menuitem_cancel"], ["menuitem_resume", "menuitem_cancel", "menuseparator_copy_location",
"menuitem_copyLocation"],
// DOWNLOAD_QUEUED // DOWNLOAD_QUEUED
["menuitem_cancel"], ["menuitem_cancel", "menuseparator_copy_location",
"menuitem_copyLocation"],
// DOWNLOAD_BLOCKED // DOWNLOAD_BLOCKED
["menuitem_retry", "menuitem_remove"] ["menuitem_retry", "menuitem_remove", "menuseparator_copy_location",
"menuitem_copyLocation"]
]; ];
function buildContextMenu(aEvent) function buildContextMenu(aEvent)
@ -557,6 +573,7 @@ var gDownloadViewController = {
case "cmd_retry": case "cmd_retry":
return dl.removable; return dl.removable;
case "cmd_showInfo": case "cmd_showInfo":
case "cmd_copyLocation":
return true; return true;
} }
return false; return false;
@ -616,6 +633,9 @@ var gDownloadViewController = {
}, },
cmd_showInfo: function(aSelectedItem) { cmd_showInfo: function(aSelectedItem) {
showDownloadInfo(aSelectedItem); showDownloadInfo(aSelectedItem);
},
cmd_copyLocation: function(aSelectedItem) {
copySourceLocation(aSelectedItem);
} }
} }
}; };

Просмотреть файл

@ -98,6 +98,8 @@
oncommand="gDownloadViewController.doCommand('cmd_show');"/> oncommand="gDownloadViewController.doCommand('cmd_show');"/>
<command id="cmd_showInfo" <command id="cmd_showInfo"
oncommand="gDownloadViewController.doCommand('cmd_showInfo');"/> oncommand="gDownloadViewController.doCommand('cmd_showInfo');"/>
<command id="cmd_copyLocation"
oncommand="gDownloadViewController.doCommand('cmd_copyLocation');"/>
</commandset> </commandset>
<keyset id="downloadKeys"> <keyset id="downloadKeys">
@ -147,6 +149,13 @@
<menuitem id="menuitem_remove" <menuitem id="menuitem_remove"
label="&cmd.remove.label;" accesskey="&cmd.remove.accesskey;" label="&cmd.remove.label;" accesskey="&cmd.remove.accesskey;"
command="cmd_remove"/> command="cmd_remove"/>
<menuseparator id="menuseparator_copy_location"/>
<menuitem id="menuitem_copyLocation"
label="&cmd.copyLocation.label;"
accesskey="&cmd.copyLocation.accesskey;"
command="cmd_copyLocation"/>
</vbox> </vbox>
<menupopup id="downloadContextMenu" onpopupshowing="return buildContextMenu(event);"/> <menupopup id="downloadContextMenu" onpopupshowing="return buildContextMenu(event);"/>