bug 483241 - Fully implement download progress dialogs, r+sr=Neil
This commit is contained in:
Родитель
a2a13ae22f
Коммит
85ea9e51c5
|
@ -169,14 +169,15 @@ function resumeDownload(aDownloadID)
|
|||
function retryDownload(aDownloadID)
|
||||
{
|
||||
gDownloadManager.retryDownload(aDownloadID);
|
||||
gDownloadTreeView.removeDownload(aDownloadID);
|
||||
if (gDownloadTreeView)
|
||||
gDownloadTreeView.removeDownload(aDownloadID);
|
||||
}
|
||||
|
||||
function cancelDownload(aDownloadData)
|
||||
function cancelDownload(aDownload)
|
||||
{
|
||||
gDownloadManager.cancelDownload(aDownloadData.dlid);
|
||||
gDownloadManager.cancelDownload(aDownload.id);
|
||||
// delete the file if it exists
|
||||
var file = getLocalFileFromNativePathOrUrl(aDownloadData.file);
|
||||
var file = aDownload.targetFile;
|
||||
if (file.exists())
|
||||
file.remove(false);
|
||||
}
|
||||
|
@ -186,9 +187,11 @@ function removeDownload(aDownloadID)
|
|||
gDownloadManager.removeDownload(aDownloadID);
|
||||
}
|
||||
|
||||
function openDownload(aDownloadData)
|
||||
function openDownload(aDownload)
|
||||
{
|
||||
var file = getLocalFileFromNativePathOrUrl(aDownloadData.file);
|
||||
var name = aDownload.displayName;
|
||||
var file = aDownload.targetFile;
|
||||
|
||||
if (file.isExecutable()) {
|
||||
var alertOnEXEOpen = true;
|
||||
try {
|
||||
|
@ -207,7 +210,6 @@ function openDownload(aDownloadData)
|
|||
|
||||
if (alertOnEXEOpen) {
|
||||
var dlbundle = document.getElementById("dmBundle");
|
||||
var name = aDownloadData.target;
|
||||
var message = dlbundle.getFormattedString("fileExecutableSecurityWarning", [name, name]);
|
||||
|
||||
var title = dlbundle.getString("fileExecutableSecurityWarningTitle");
|
||||
|
@ -237,9 +239,9 @@ function openDownload(aDownloadData)
|
|||
}
|
||||
}
|
||||
|
||||
function showDownload(aDownloadData)
|
||||
function showDownload(aDownload)
|
||||
{
|
||||
var file = getLocalFileFromNativePathOrUrl(aDownloadData.file);
|
||||
var file = aDownload.targetFile;
|
||||
|
||||
try {
|
||||
// Show the directory containing the file and select the file
|
||||
|
@ -528,16 +530,21 @@ var dlTreeController = {
|
|||
retryDownload(selItemData.dlid);
|
||||
break;
|
||||
case "cmd_cancel":
|
||||
cancelDownload(selItemData);
|
||||
// fake an nsIDownload with the properties needed by that function
|
||||
cancelDownload({id: selItemData.dlid,
|
||||
targetFile: getLocalFileFromNativePathOrUrl(selItemData.file)});
|
||||
break;
|
||||
case "cmd_remove":
|
||||
removeDownload(selItemData.dlid);
|
||||
break;
|
||||
case "cmd_open":
|
||||
openDownload(selItemData);
|
||||
// fake an nsIDownload with the properties needed by that function
|
||||
openDownload({displayName: selItemData.target,
|
||||
targetFile: getLocalFileFromNativePathOrUrl(selItemData.file)});
|
||||
break;
|
||||
case "cmd_show":
|
||||
showDownload(selItemData);
|
||||
// fake an nsIDownload with the properties needed by that function
|
||||
showDownload({targetFile: getLocalFileFromNativePathOrUrl(selItemData.file)});
|
||||
break;
|
||||
case "cmd_openReferrer":
|
||||
openUILink(selItemData.referrer);
|
||||
|
|
|
@ -0,0 +1,397 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the SeaMonkey internet suite code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the SeaMonkey project at mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert Kaiser <kairo@kairo.at>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
|
||||
|
||||
// nsIDownloadManager, gDownloadManager, gDownloadListener
|
||||
// are defined in downloadmanager.js
|
||||
|
||||
var gDownload;
|
||||
var gDownloadBundle;
|
||||
var gTkDlBundle;
|
||||
|
||||
var gDlStatus;
|
||||
var gDlSize;
|
||||
var gTimeElapsed;
|
||||
var gProgressMeter;
|
||||
var gProgressText;
|
||||
var gCloseWhenDone;
|
||||
|
||||
var gLastSec = Infinity;
|
||||
var gStartTime = 0;
|
||||
var gEndTime = Date.now(); // not ideal if already finished, but usable for now
|
||||
var gDlActive = false;
|
||||
var gRetrying = false;
|
||||
|
||||
function progressStartup() {
|
||||
gDownload = window.arguments[0].QueryInterface(Components.interfaces.nsIDownload);
|
||||
|
||||
// cache elements to save .getElementById() calls
|
||||
gDownloadBundle = document.getElementById("dmBundle");
|
||||
gTkDlBundle = document.getElementById("tkdlBundle");
|
||||
gDlStatus = document.getElementById("dlStatus");
|
||||
gDlSize = document.getElementById("dlSize");
|
||||
gTimeElapsed = document.getElementById("timeElapsed");
|
||||
gProgressMeter = document.getElementById("progressMeter");
|
||||
gProgressText = document.getElementById("progressText");
|
||||
gCloseWhenDone = document.getElementById("closeWhenDone");
|
||||
|
||||
// Insert as first controller on the whole window
|
||||
window.controllers.insertControllerAt(0, ProgressDlgController);
|
||||
|
||||
gCloseWhenDone.checked = gPrefService.getBoolPref("browser.download.manager.closeWhenDone");
|
||||
|
||||
switch (gDownload.state) {
|
||||
case nsIDownloadManager.DOWNLOAD_NOTSTARTED:
|
||||
case nsIDownloadManager.DOWNLOAD_DOWNLOADING:
|
||||
case nsIDownloadManager.DOWNLOAD_PAUSED:
|
||||
case nsIDownloadManager.DOWNLOAD_QUEUED:
|
||||
case nsIDownloadManager.DOWNLOAD_SCANNING:
|
||||
gDlActive = true;
|
||||
break;
|
||||
case nsIDownloadManager.DOWNLOAD_FINISHED:
|
||||
if (gCloseWhenDone.checked)
|
||||
window.close();
|
||||
default:
|
||||
gDlActive = false;
|
||||
break;
|
||||
}
|
||||
|
||||
var fName = document.getElementById("fileName");
|
||||
var fSource = document.getElementById("fileSource");
|
||||
fName.value = gDownload.displayName;
|
||||
fName.tooltipText = gDownload.target.spec;
|
||||
var fromString;
|
||||
try {
|
||||
fromString = gDownload.source.host;
|
||||
}
|
||||
catch (e) { }
|
||||
if (!fromString)
|
||||
fromString = gDownload.source.prePath;
|
||||
fSource.value = gDownloadBundle.getFormattedString("fromSource", [fromString]);
|
||||
fSource.tooltipText = gDownload.source.spec;
|
||||
|
||||
// The DlProgressListener handles progress notifications.
|
||||
gDownloadListener = new DlProgressListener();
|
||||
gDownloadManager.addListener(gDownloadListener);
|
||||
|
||||
updateDownload();
|
||||
updateButtons();
|
||||
window.updateCommands("dlstate-change");
|
||||
}
|
||||
|
||||
function progressShutdown() {
|
||||
gDownloadManager.removeListener(gDownloadListener);
|
||||
window.controllers.removeController(ProgressDlgController);
|
||||
gPrefService.setBoolPref("browser.download.manager.closeWhenDone",
|
||||
gCloseWhenDone.checked);
|
||||
}
|
||||
|
||||
function updateDownload() {
|
||||
switch (gDownload.state) {
|
||||
case nsIDownloadManager.DOWNLOAD_NOTSTARTED:
|
||||
case nsIDownloadManager.DOWNLOAD_DOWNLOADING:
|
||||
case nsIDownloadManager.DOWNLOAD_PAUSED:
|
||||
case nsIDownloadManager.DOWNLOAD_QUEUED:
|
||||
case nsIDownloadManager.DOWNLOAD_SCANNING:
|
||||
gDlActive = true;
|
||||
gProgressMeter.style.opacity = 1;
|
||||
break;
|
||||
default:
|
||||
gDlActive = false;
|
||||
gProgressMeter.style.opacity = 0.5;
|
||||
break;
|
||||
}
|
||||
if (gDownload.size >= 0) {
|
||||
// if it was undetermined before, unhide text and switch mode
|
||||
if (gProgressText.hidden) {
|
||||
gProgressText.hidden = false;
|
||||
gProgressMeter.mode = "determined";
|
||||
}
|
||||
gProgressMeter.value = gDownload.percentComplete;
|
||||
gProgressText.value = gDownloadBundle.getFormattedString("percentFormat",
|
||||
[gDownload.percentComplete]);
|
||||
}
|
||||
else if (!gProgressText.hidden) {
|
||||
gProgressText.hidden = true;
|
||||
gProgressMeter.mode = "undetermined";
|
||||
}
|
||||
// Update window title
|
||||
var statusString;
|
||||
switch (gDownload.state) {
|
||||
case nsIDownloadManager.DOWNLOAD_PAUSED:
|
||||
statusString = gDownloadBundle.getString("paused");
|
||||
break;
|
||||
case nsIDownloadManager.DOWNLOAD_DOWNLOADING:
|
||||
statusString = gDownloadBundle.getString("downloading");
|
||||
break;
|
||||
case nsIDownloadManager.DOWNLOAD_FINISHED:
|
||||
statusString = gDownloadBundle.getString("finished");
|
||||
break;
|
||||
case nsIDownloadManager.DOWNLOAD_FAILED:
|
||||
statusString = gDownloadBundle.getString("failed");
|
||||
break;
|
||||
case nsIDownloadManager.DOWNLOAD_CANCELED:
|
||||
statusString = gDownloadBundle.getString("canceled");
|
||||
break;
|
||||
case nsIDownloadManager.DOWNLOAD_BLOCKED_PARENTAL: // Parental Controls
|
||||
case nsIDownloadManager.DOWNLOAD_BLOCKED_POLICY: // Security Zone Policy
|
||||
case nsIDownloadManager.DOWNLOAD_DIRTY: // possible virus/spyware
|
||||
statusString = gDownloadBundle.getString("blocked");
|
||||
break;
|
||||
default:
|
||||
statusString = gDownloadBundle.getString("notStarted");
|
||||
break;
|
||||
}
|
||||
var file = getLocalFileFromNativePathOrUrl(gDownload.target.spec);
|
||||
if (gDownload.size > 0) {
|
||||
document.title = gDownloadBundle.getFormattedString("progressTitlePercent",
|
||||
[gDownload.percentComplete,
|
||||
file.leafName, statusString]);
|
||||
}
|
||||
else {
|
||||
document.title = gDownloadBundle.getFormattedString("progressTitle",
|
||||
[file.leafName, statusString]);
|
||||
}
|
||||
|
||||
// download size
|
||||
var transfer = DownloadUtils.getTransferTotal(gDownload.amountTransferred,
|
||||
gDownload.size);
|
||||
if (gDownload.state == nsIDownloadManager.DOWNLOAD_DOWNLOADING) {
|
||||
var [rate, unit] = DownloadUtils.convertByteUnits(gDownload.speed);
|
||||
var dlSpeed = gDownloadBundle.getFormattedString("speedFormat", [rate, unit]);
|
||||
gDlSize.value = gDownloadBundle.getFormattedString("sizeSpeed",
|
||||
[transfer, dlSpeed]);
|
||||
}
|
||||
else
|
||||
gDlSize.value = transfer;
|
||||
|
||||
// download status
|
||||
if (gDlActive) {
|
||||
// Calculate the time remaining if we have valid values
|
||||
var seconds = (gDownload.speed > 0) && (gDownload.size > 0)
|
||||
? (gDownload.size - gDownload.amountTransferred) / gDownload.speed
|
||||
: -1;
|
||||
var [timeLeft, newLast] = DownloadUtils.getTimeLeft(seconds, gLastSec);
|
||||
gLastSec = newLast;
|
||||
}
|
||||
switch (gDownload.state) {
|
||||
case nsIDownloadManager.DOWNLOAD_BLOCKED_PARENTAL: // Parental Controls
|
||||
gDlStatus.value = gTkDlBundle.getString("stateBlocked");
|
||||
break;
|
||||
case nsIDownloadManager.DOWNLOAD_BLOCKED_POLICY: // Security Zone Policy
|
||||
gDlStatus.value = gTkDlBundle.getString("stateBlockedPolicy");
|
||||
break;
|
||||
case nsIDownloadManager.DOWNLOAD_DIRTY: // possible virus/spyware
|
||||
gDlStatus.value = gTkDlBundle.getString("stateDirty");
|
||||
break;
|
||||
default:
|
||||
if (gDlActive)
|
||||
gDlStatus.value = gDownloadBundle.getFormattedString("statusActive",
|
||||
[statusString, timeLeft]);
|
||||
else
|
||||
gDlStatus.value = statusString;
|
||||
break;
|
||||
}
|
||||
|
||||
// time elapsed
|
||||
if (!gStartTime && gDownload.startTime)
|
||||
gStartTime = Math.round(gDownload.startTime / 1000)
|
||||
if (gDlActive)
|
||||
gEndTime = Date.now();
|
||||
if (gStartTime && gEndTime && (gEndTime > gStartTime)) {
|
||||
var seconds = (gEndTime - gStartTime) / 1000;
|
||||
var [time1, unit1, time2, unit2] =
|
||||
DownloadUtils.convertTimeUnits(seconds);
|
||||
if (seconds < 3600 || time2 == 0)
|
||||
gTimeElapsed.value = gDownloadBundle.getFormattedString("timeElapsedSingle", [time1, unit1]);
|
||||
else
|
||||
gTimeElapsed.value = gDownloadBundle.getFormattedString("timeElapsedDouble", [time1, unit1, time2, unit2]);
|
||||
}
|
||||
else {
|
||||
gTimeElapsed.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
function updateButtons() {
|
||||
document.getElementById("pauseButton").hidden = !ProgressDlgController.isCommandEnabled("cmd_pause");
|
||||
document.getElementById("resumeButton").hidden = !ProgressDlgController.isCommandEnabled("cmd_resume");
|
||||
document.getElementById("retryButton").hidden = !ProgressDlgController.isCommandEnabled("cmd_retry");
|
||||
document.getElementById("cancelButton").hidden = !ProgressDlgController.isCommandEnabled("cmd_cancel");
|
||||
}
|
||||
|
||||
/**
|
||||
* DlProgressListener "class" is used to help update download items shown
|
||||
* in the progress dialog such as displaying amount transferred, transfer
|
||||
* rate, and time left for the download.
|
||||
*
|
||||
* This class implements the nsIDownloadProgressListener interface.
|
||||
*/
|
||||
function DlProgressListener() {}
|
||||
|
||||
DlProgressListener.prototype = {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// nsISupports
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIDownloadProgressListener]),
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// nsIDownloadProgressListener
|
||||
|
||||
onDownloadStateChange: function(aState, aDownload) {
|
||||
// first, check if we are retrying and this is the new download starting
|
||||
if (gRetrying &&
|
||||
(aDownload.state == nsIDownloadManager.DOWNLOAD_QUEUED ||
|
||||
aDownload.state == nsIDownloadManager.DOWNLOAD_BLOCKED_POLICY) &&
|
||||
aDownload.source.spec == gDownload.source.spec &&
|
||||
aDownload.target.spec == gDownload.target.spec) {
|
||||
gRetrying = false;
|
||||
gDownload = aDownload;
|
||||
}
|
||||
if (aDownload == gDownload) {
|
||||
if (gCloseWhenDone.checked &&
|
||||
(aDownload.state == nsIDownloadManager.DOWNLOAD_FINISHED)) {
|
||||
window.close();
|
||||
}
|
||||
updateDownload();
|
||||
updateButtons();
|
||||
window.updateCommands("dlstate-change");
|
||||
}
|
||||
},
|
||||
|
||||
onProgressChange: function(aWebProgress, aRequest,
|
||||
aCurSelfProgress, aMaxSelfProgress,
|
||||
aCurTotalProgress, aMaxTotalProgress, aDownload) {
|
||||
if (aDownload == gDownload)
|
||||
updateDownload();
|
||||
},
|
||||
|
||||
onStateChange: function(aWebProgress, aRequest, aState, aStatus, aDownload) {
|
||||
},
|
||||
|
||||
onSecurityChange: function(aWebProgress, aRequest, aState, aDownload) {
|
||||
}
|
||||
};
|
||||
|
||||
var ProgressDlgController = {
|
||||
supportsCommand: function(aCommand) {
|
||||
switch (aCommand) {
|
||||
case "cmd_pause":
|
||||
case "cmd_resume":
|
||||
case "cmd_retry":
|
||||
case "cmd_cancel":
|
||||
case "cmd_open":
|
||||
case "cmd_show":
|
||||
case "cmd_openReferrer":
|
||||
case "cmd_copyLocation":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
isCommandEnabled: function(aCommand) {
|
||||
switch (aCommand) {
|
||||
case "cmd_pause":
|
||||
return gDlActive &&
|
||||
gDownload.state != nsIDownloadManager.DOWNLOAD_PAUSED &&
|
||||
gDownload.resumable;
|
||||
case "cmd_resume":
|
||||
return gDownload.state == nsIDownloadManager.DOWNLOAD_PAUSED &&
|
||||
gDownload.resumable;
|
||||
case "cmd_open":
|
||||
case "cmd_show":
|
||||
// we can't reveal until the download is complete, because we have not given
|
||||
// the file its final name until them.
|
||||
return gDownload.state == nsIDownloadManager.DOWNLOAD_FINISHED &&
|
||||
gDownload.targetFile.exists();
|
||||
case "cmd_cancel":
|
||||
return gDlActive;
|
||||
case "cmd_retry":
|
||||
return gDownload.state == nsIDownloadManager.DOWNLOAD_CANCELED ||
|
||||
gDownload.state == nsIDownloadManager.DOWNLOAD_FAILED;
|
||||
case "cmd_openReferrer":
|
||||
return !!gDownload.referrer;
|
||||
case "cmd_copyLocation":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function(aCommand) {
|
||||
switch (aCommand) {
|
||||
case "cmd_pause":
|
||||
pauseDownload(gDownload.id);
|
||||
break;
|
||||
case "cmd_resume":
|
||||
resumeDownload(gDownload.id);
|
||||
break;
|
||||
case "cmd_retry":
|
||||
gRetrying = true;
|
||||
retryDownload(gDownload.id);
|
||||
break;
|
||||
case "cmd_cancel":
|
||||
cancelDownload(gDownload);
|
||||
break;
|
||||
case "cmd_open":
|
||||
openDownload(gDownload);
|
||||
break;
|
||||
case "cmd_show":
|
||||
showDownload(gDownload);
|
||||
break;
|
||||
case "cmd_openReferrer":
|
||||
openUILink(gDownload.referrer.spec);
|
||||
break;
|
||||
case "cmd_copyLocation":
|
||||
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
||||
.getService(Components.interfaces.nsIClipboardHelper);
|
||||
clipboard.copyString(gDownload.source.spec);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function(aEvent) {
|
||||
},
|
||||
|
||||
onCommandUpdate: function() {
|
||||
var cmds = ["cmd_pause", "cmd_resume", "cmd_retry", "cmd_cancel",
|
||||
"cmd_open", "cmd_show", "cmd_openReferrer", "cmd_copyLocation"];
|
||||
for (let command in cmds)
|
||||
goUpdateCommand(cmds[command]);
|
||||
}
|
||||
};
|
|
@ -21,6 +21,7 @@
|
|||
-
|
||||
- Contributor(s):
|
||||
- Justin Wood <Callek@gmail.com>
|
||||
- Robert Kaiser <kairo@kairo.at>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -36,17 +37,118 @@
|
|||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://communicator/skin/downloads/downloadmanager.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://communicator/locale/downloads/progressDialog.dtd">
|
||||
|
||||
<dialog xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
<window xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
buttons="accept,cancel"
|
||||
buttonlabelcancel="&cancelLabel;"
|
||||
buttonlabelaccept="&acceptLabel;"
|
||||
ondialogaccept='Components.classes["@mozilla.org/download-manager-ui;1"].getService(Components.interfaces.nsISuiteDownloadManagerUI).showManager();'
|
||||
title="&progressTitle;"
|
||||
width="40em;">
|
||||
<description>&tempDescription;</description>
|
||||
</dialog>
|
||||
onload="progressStartup();" onunload="progressShutdown();"
|
||||
title="&progress.title;"
|
||||
style="width:40em;">
|
||||
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://communicator/content/downloads/downloadmanager.js"/>
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://communicator/content/downloads/progressDialog.js"/>
|
||||
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="dmBundle"
|
||||
src="chrome://communicator/locale/downloads/downloadmanager.properties"/>
|
||||
<stringbundle id="tkdlBundle"
|
||||
src="chrome://global/locale/mozapps/downloads/downloads.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
<commandset id="dlProgressCommands">
|
||||
<commandset id="commandUpdate_DlProgress"
|
||||
commandupdater="true"
|
||||
events="focus,dlstate-change"
|
||||
oncommandupdate="ProgressDlgController.onCommandUpdate();"/>
|
||||
|
||||
<commandset id="downloadCommands">
|
||||
<command id="cmd_pause"
|
||||
oncommand="goDoCommand('cmd_pause');"/>
|
||||
<command id="cmd_resume"
|
||||
oncommand="goDoCommand('cmd_resume');"/>
|
||||
<command id="cmd_retry"
|
||||
oncommand="goDoCommand('cmd_retry');"/>
|
||||
<command id="cmd_cancel"
|
||||
oncommand="goDoCommand('cmd_cancel');"/>
|
||||
<command id="cmd_open"
|
||||
oncommand="goDoCommand('cmd_open');"/>
|
||||
<command id="cmd_show"
|
||||
oncommand="goDoCommand('cmd_show');"/>
|
||||
<command id="cmd_openReferrer"
|
||||
oncommand="goDoCommand('cmd_openReferrer');"/>
|
||||
<command id="cmd_copyLocation"
|
||||
oncommand="goDoCommand('cmd_copyLocation');"/>
|
||||
<command id="cmd_close" oncommand="window.close();"/>
|
||||
</commandset>
|
||||
</commandset>
|
||||
|
||||
<keyset>
|
||||
<key key="&closeWindow.key;" modifiers="accel" command="cmd_close"/>
|
||||
<key keycode="VK_ESCAPE" command="cmd_close"/>
|
||||
<key key="." modifiers="meta" command="cmd_close"/>
|
||||
</keyset>
|
||||
|
||||
<popupset id="progressPopupset">
|
||||
<popup id="fileContext">
|
||||
<menuitem id="dlContext-open"
|
||||
label="&cmd.open.label;"
|
||||
accesskey="&cmd.open.accesskey;"
|
||||
command="cmd_open"/>
|
||||
<menuitem id="dlContext-show"
|
||||
label="&cmd.show.label;"
|
||||
accesskey="&cmd.show.accesskey;"
|
||||
command="cmd_show"/>
|
||||
</popup>
|
||||
<popup id="sourceContext">
|
||||
<menuitem id="dlContext-openReferrer"
|
||||
label="&cmd.goToDownloadPage.label;"
|
||||
accesskey="&cmd.goToDownloadPage.accesskey;"
|
||||
command="cmd_openReferrer"/>
|
||||
<menuitem id="dlContext-copyLocation"
|
||||
label="&cmd.copyDownloadLink.label;"
|
||||
accesskey="&cmd.copyDownloadLink.accesskey;"
|
||||
command="cmd_copyLocation"/>
|
||||
</popup>
|
||||
</popupset>
|
||||
|
||||
<hbox>
|
||||
<label id="fileName" crop="center" value=""
|
||||
context="fileContext" popup="fileContext"
|
||||
style="-moz-user-focus: normal;"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label id="fileSource" crop="center" value=""
|
||||
context="sourceContext" popup="sourceContext"
|
||||
style="-moz-user-focus: normal;"/>
|
||||
</hbox>
|
||||
<hbox align="end">
|
||||
<vbox flex="1">
|
||||
<label id="dlSize" value=""/>
|
||||
<label id="timeElapsed" value=""/>
|
||||
<label id="dlStatus" flex="1" value=""/>
|
||||
</vbox>
|
||||
<button id="pauseButton" class="mini-button"
|
||||
command="cmd_pause" tooltiptext="&cmd.pause.tooltip;"/>
|
||||
<button id="resumeButton" class="mini-button"
|
||||
command="cmd_resume" tooltiptext="&cmd.resume.tooltip;"/>
|
||||
<button id="retryButton" class="mini-button"
|
||||
command="cmd_retry" tooltiptext="&cmd.retry.tooltip;"/>
|
||||
<button id="cancelButton" class="mini-button"
|
||||
command="cmd_cancel" tooltiptext="&cmd.cancel.tooltip;"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<progressmeter id="progressMeter" mode="determined" flex="1"/>
|
||||
<label id="progressText" value=""/>
|
||||
</hbox>
|
||||
<checkbox id="closeWhenDone"
|
||||
label="&closeWhenDone.label;"
|
||||
accesskey="&closeWhenDone.accesskey;"/>
|
||||
</window>
|
||||
|
|
|
@ -173,12 +173,10 @@ DownloadTreeView.prototype = {
|
|||
case "TimeRemaining":
|
||||
if (dl.isActive) {
|
||||
var dld = this._dm.getDownload(dl.dlid);
|
||||
var maxBytes = (dl.maxBytes == null) ? -1 : dl.maxBytes;
|
||||
var speed = (dld.speed == null) ? -1 : dld.speed;
|
||||
var lastSec = (dl.lastSec == null) ? Infinity : dl.lastSec;
|
||||
// Calculate the time remaining if we have valid values
|
||||
var seconds = (speed > 0) && (maxBytes > 0)
|
||||
? (maxBytes - dl.currBytes) / speed
|
||||
var seconds = (dld.speed > 0) && (dl.maxBytes > 0)
|
||||
? (dl.maxBytes - dl.currBytes) / dld.speed
|
||||
: -1;
|
||||
var [timeLeft, newLast] = DownloadUtils.getTimeLeft(seconds, lastSec);
|
||||
this._dlList[aRow].lastSec = newLast;
|
||||
|
@ -246,7 +244,9 @@ DownloadTreeView.prototype = {
|
|||
break;
|
||||
case "ActionStop":
|
||||
if (dl.isActive)
|
||||
cancelDownload(dl);
|
||||
// fake an nsIDownload with the properties needed by that function
|
||||
cancelDownload({id: dl.dlid,
|
||||
targetFile: getLocalFileFromNativePathOrUrl(dl.file)});
|
||||
else
|
||||
removeDownload(dl.dlid);
|
||||
break;
|
||||
|
|
|
@ -128,6 +128,7 @@ comm.jar:
|
|||
content/communicator/downloads/downloadmanager.xul (downloads/downloadmanager.xul)
|
||||
content/communicator/downloads/DownloadProgressListener.js (downloads/DownloadProgressListener.js)
|
||||
content/communicator/downloads/progressDialog.xul (downloads/progressDialog.xul)
|
||||
content/communicator/downloads/progressDialog.js (downloads/progressDialog.js)
|
||||
content/communicator/downloads/treeView.js (downloads/treeView.js)
|
||||
content/communicator/feeds/subscribe.xhtml (feeds/subscribe.xhtml)
|
||||
content/communicator/feeds/subscribe.js (feeds/subscribe.js)
|
||||
|
|
|
@ -14,6 +14,20 @@ blocked=Blocked
|
|||
downloadsTitleFiles=%1$S file - Download Manager;%1$S files - Download Manager
|
||||
downloadsTitlePercent=%2$S%% of %1$S file - Download Manager;%2$S%% of %1$S files - Download Manager
|
||||
|
||||
# LOCALIZATION NOTE (progressTitle):
|
||||
# %1$S is the file name, %2$S is the download state
|
||||
# examples: coolvideo.ogg - Finished; seamonkey-nightly.zip - Paused
|
||||
progressTitle=%1$S - %2$S
|
||||
# LOCALIZATION NOTE (progressTitlePercent):
|
||||
# %1$S is download percent, %2$S is the file name, %3$S is the download state
|
||||
# %% will appear as a single % sign, so %1$S%% is the percent number plus the % sign
|
||||
# examples: 42% of coolvideo.ogg - Paused; 98% of seamonkey-nightly.zip - Downloading
|
||||
progressTitlePercent=%1$S%% of %2$S - %3$S
|
||||
|
||||
# LOCALIZATION NOTE (percentFormat): %1$S is download percent
|
||||
# %% will appear as a single % sign, so %1$S%% is the percent number plus the % sign
|
||||
percentFormat=%1$S%%
|
||||
|
||||
# LOCALIZATION NOTE (speedFormat):
|
||||
# %1$S rate number; %2$S rate unit
|
||||
# units are taken from toolkit's downloads.properties
|
||||
|
@ -28,6 +42,26 @@ timeSingle=%1$S %2$S
|
|||
# example: 11 hours, 2 minutes; 1 day, 22 hours
|
||||
timeDouble=%1$S %2$S, %3$S %4$S
|
||||
|
||||
# LOCALIZATION NOTE (timeElapsedSingle): %1$S time number; %2$S time unit
|
||||
# example: 1 minute elapsed; 11 hours elapsed
|
||||
timeElapsedSingle=%1$S %2$S elapsed
|
||||
# LOCALIZATION NOTE (timeElapsedDouble):
|
||||
# %1$S time number; %2$S time unit; %3$S time sub number; %4$S time sub unit
|
||||
# example: 11 hours, 2 minutes elapsed; 1 day, 22 hours elapsed
|
||||
timeElapsedDouble=%1$S %2$S, %3$S %4$S elapsed
|
||||
|
||||
# LOCALIZATION NOTE (sizeSpeed):
|
||||
# %1$S is transfer progress; %2$S download speed
|
||||
# example: 1.1 of 11.1 GB (2.2 MB/sec)
|
||||
sizeSpeed=%1$S (%2$S)
|
||||
|
||||
# LOCALIZATION NOTE (statusActive): — is the "em dash" (long dash)
|
||||
# %1$S download status; %2$S time remaining
|
||||
# example: Paused — 11 hours, 2 minutes remaining
|
||||
statusActive=%1$S — %2$S
|
||||
|
||||
fromSource=From %S
|
||||
|
||||
fileExecutableSecurityWarning="%S" is an executable file. Executable files may contain viruses or other malicious code that could harm your computer. Use caution when opening this file. Are you sure you want to launch "%S"?
|
||||
fileExecutableSecurityWarningTitle=Open Executable File?
|
||||
fileExecutableSecurityWarningDontAsk=Don't ask me this again
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
-
|
||||
- Contributor(s):
|
||||
- Justin Wood <Callek@gmail.com>
|
||||
- Robert Kaiser <kairo@kairo.at>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -35,7 +36,19 @@
|
|||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!ENTITY cancelLabel "Close">
|
||||
<!ENTITY acceptLabel "Open Download Manager">
|
||||
<!ENTITY progressTitle "Download in Progress…">
|
||||
<!ENTITY tempDescription "We're sorry, but progress dialogs in downloads are currently not implemented. Your download has started.">
|
||||
<!ENTITY progress.title "Download in Progress…">
|
||||
<!ENTITY closeWindow.key "w">
|
||||
<!ENTITY cmd.pause.tooltip "Pause">
|
||||
<!ENTITY cmd.resume.tooltip "Resume">
|
||||
<!ENTITY cmd.retry.tooltip "Retry">
|
||||
<!ENTITY cmd.cancel.tooltip "Cancel">
|
||||
<!ENTITY cmd.open.label "Open">
|
||||
<!ENTITY cmd.open.accesskey "O">
|
||||
<!ENTITY cmd.show.label "Open Containing Folder">
|
||||
<!ENTITY cmd.show.accesskey "F">
|
||||
<!ENTITY cmd.goToDownloadPage.label "Go to Download Page">
|
||||
<!ENTITY cmd.goToDownloadPage.accesskey "G">
|
||||
<!ENTITY cmd.copyDownloadLink.label "Copy Download Link">
|
||||
<!ENTITY cmd.copyDownloadLink.accesskey "L">
|
||||
<!ENTITY closeWhenDone.label "Close this window when the download is complete.">
|
||||
<!ENTITY closeWhenDone.accesskey "w">
|
||||
|
|
|
@ -47,20 +47,23 @@
|
|||
-moz-image-region: rect(0px, 16px, 16px, 0px);
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-image(ActionPlay, downloading, resumable) {
|
||||
treechildren::-moz-tree-image(ActionPlay, downloading, resumable),
|
||||
#pauseButton {
|
||||
/* pause */
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadButtons.png");
|
||||
-moz-image-region: rect(0px, 48px, 16px, 32px);
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-image(ActionPlay, paused, resumable) {
|
||||
treechildren::-moz-tree-image(ActionPlay, paused, resumable),
|
||||
#resumeButton {
|
||||
/* resume */
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadButtons.png");
|
||||
-moz-image-region: rect(0px, 16px, 16px, 0px);
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-image(ActionPlay, failed),
|
||||
treechildren::-moz-tree-image(ActionPlay, canceled) {
|
||||
treechildren::-moz-tree-image(ActionPlay, canceled),
|
||||
#retryButton {
|
||||
/* retry */
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadButtons.png");
|
||||
-moz-image-region: rect(0px, 64px, 16px, 48px);
|
||||
|
@ -71,7 +74,8 @@ treechildren::-moz-tree-image(ActionPlay, canceled) {
|
|||
-moz-image-region: rect(0px, 32px, 16px, 16px);
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-image(ActionStop, active) {
|
||||
treechildren::-moz-tree-image(ActionStop, active),
|
||||
#cancelButton {
|
||||
/* cancel */
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadButtons.png");
|
||||
-moz-image-region: rect(0px, 32px, 16px, 16px);
|
||||
|
@ -82,3 +86,38 @@ treechildren::-moz-tree-image(ActionStop, inactive) {
|
|||
list-style-image: url("chrome://communicator/skin/downloads/dl-remove.png");
|
||||
-moz-image-region: auto;
|
||||
}
|
||||
|
||||
/* progress dialogs */
|
||||
|
||||
/* focusable label, focus ring like .link-text but not a link */
|
||||
#fileName, #fileSource {
|
||||
border: 1px solid transparent;
|
||||
/* 1px is used for border, make margins smaller by that */
|
||||
margin-top: 0px;
|
||||
margin-bottom: 1px;
|
||||
-moz-margin-start: 5px;
|
||||
-moz-margin-end: 4px;
|
||||
}
|
||||
#fileName:focus,
|
||||
#fileSource:focus {
|
||||
border: 1px dotted -moz-DialogText;
|
||||
}
|
||||
|
||||
#fileName {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.mini-button {
|
||||
-moz-appearance: none;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.mini-button > .button-box {
|
||||
-moz-appearance: none;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
|
|
@ -47,20 +47,23 @@
|
|||
-moz-image-region: rect(0px, 16px, 16px, 0px);
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-image(ActionPlay, downloading, resumable) {
|
||||
treechildren::-moz-tree-image(ActionPlay, downloading, resumable),
|
||||
#pauseButton {
|
||||
/* pause */
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadButtons.png");
|
||||
-moz-image-region: rect(0px, 48px, 16px, 32px);
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-image(ActionPlay, paused, resumable) {
|
||||
treechildren::-moz-tree-image(ActionPlay, paused, resumable),
|
||||
#resumeButton {
|
||||
/* resume */
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadButtons.png");
|
||||
-moz-image-region: rect(0px, 16px, 16px, 0px);
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-image(ActionPlay, failed),
|
||||
treechildren::-moz-tree-image(ActionPlay, canceled) {
|
||||
treechildren::-moz-tree-image(ActionPlay, canceled),
|
||||
#retryButton {
|
||||
/* retry */
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadButtons.png");
|
||||
-moz-image-region: rect(0px, 64px, 16px, 48px);
|
||||
|
@ -71,7 +74,8 @@ treechildren::-moz-tree-image(ActionPlay, canceled) {
|
|||
-moz-image-region: rect(0px, 32px, 16px, 16px);
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-image(ActionStop, active) {
|
||||
treechildren::-moz-tree-image(ActionStop, active),
|
||||
#cancelButton {
|
||||
/* cancel */
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadButtons.png");
|
||||
-moz-image-region: rect(0px, 32px, 16px, 16px);
|
||||
|
@ -82,3 +86,75 @@ treechildren::-moz-tree-image(ActionStop, inactive) {
|
|||
list-style-image: url("chrome://communicator/skin/downloads/dl-remove.png");
|
||||
-moz-image-region: auto;
|
||||
}
|
||||
|
||||
/* progress dialogs */
|
||||
|
||||
#fileName, #fileSource {
|
||||
border: 1px solid transparent;
|
||||
/* 1px is used for border, make margins smaller by that */
|
||||
margin-top: 0px;
|
||||
margin-bottom: 1px;
|
||||
-moz-margin-start: 5px;
|
||||
-moz-margin-end: 4px;
|
||||
}
|
||||
#fileName:focus,
|
||||
#fileSource:focus {
|
||||
border: 1px dotted;
|
||||
}
|
||||
|
||||
#fileName {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.mini-button {
|
||||
-moz-appearance: none;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.mini-button > .button-box {
|
||||
-moz-appearance: none;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.mini-button > .button-box > .button-text {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
/* progress dialogs */
|
||||
|
||||
/* focusable label, focus ring like .link-text but not a link */
|
||||
#fileName, #fileSource {
|
||||
border: 1px solid transparent;
|
||||
/* 1px is used for border, make margins smaller by that */
|
||||
margin-top: 0px;
|
||||
margin-bottom: 1px;
|
||||
-moz-margin-start: 5px;
|
||||
-moz-margin-end: 4px;
|
||||
}
|
||||
#fileName:focus,
|
||||
#fileSource:focus {
|
||||
border: 1px dotted;
|
||||
}
|
||||
|
||||
#fileName {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.mini-button {
|
||||
-moz-appearance: none;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.mini-button > .button-box {
|
||||
-moz-appearance: none;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче