Updates to new progress dialog code; NOT PART OF THE BUILD

This commit is contained in:
law%netscape.com 2002-02-07 03:22:27 +00:00
Родитель ae0480a313
Коммит a0b5190c5b
4 изменённых файлов: 34 добавлений и 22 удалений

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

@ -2,6 +2,9 @@
See: http://lxr.mozilla.org/seamonkey/source/embedding/components/ui/progressDlg/nsProgressDialog.xul
-->
<!-- This is used prior to initializing with a proper title -->
<!ENTITY defaultTitle "Saving">
<!-- These are used when saving -->
<!ENTITY savingTitle "Saving #1 (#2&#037;)">
<!ENTITY savingAlertTitle "Saving #1">
@ -31,12 +34,6 @@
<!ENTITY reveal "Reveal Location">
<!ENTITY launch "Launch File">
<!-- LOCALIZATION NOTE (filesFolder):
This is the name of the folder that is created parallel to a HTML file
when it is saved "With Images". The ^BASE^ section is replaced with the
leaf name of the file being saved (minus extension). -->
<!ENTITY filesFolder "^BASE^_files">
<!-- Status/progress messages -->
<!-- LOCALIZATION NOTE (pausedMsg):
@ -96,11 +93,3 @@
#1 will be replaced by the percentage of the file that has been saved -->
<!ENTITY percentMsg "#1&#037;">
<!-- LOCALIZATION NOTE (filesFolder):
This is the name of the folder that is created parallel to a HTML file
when it is saved "With Images". The ^BASE^ section is replaced with the
leaf name of the file being saved (minus extension). -->
<!ENTITY filesFolder "^BASE^_files">

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

@ -26,6 +26,7 @@
interface nsIWebBrowserPersist;
interface nsIDOMWindow;
interface nsILocalFile;
interface nsIObserver;
/* nsIProgressDialog
*
@ -44,6 +45,8 @@ interface nsILocalFile;
* closes it manually.
* 6. Release the instance. The instance will be referenced by
* the dialog itself, so it won't get freed until the dialog closes.
* The dialog will keep the instance alive, so typically one does
* not need to hold a reference to it.
*
* Important Note: Implementors of this interface must also implement
* nsISupportsWeakReference.
@ -98,6 +101,16 @@ interface nsIProgressDialog : nsIWebProgressListener {
*/
attribute wstring openingWith;
/**
* Set this attribute to the observer object that will be
* notified when the user presses the Cancel button. The
* observer's "observe" method will be called with:
* aSubject = the nsIProgressDialog
* aTopic = "oncancel"
* aData = ""
*/
attribute nsIObserver observer;
/**
* The web browser persist object doing the associated I/O.
* May be null.

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

@ -46,6 +46,7 @@ function nsProgressDialog() {
this.mParent = null;
this.mOperation = null;
this.mStartTime = ( new Date() ).getTime();
this.observer = null;
this.mLastUpdate = Number.MIN_VALUE; // To ensure first onProgress causes update.
this.mInterval = 750; // Default to .75 seconds.
this.mElapsed = 0;
@ -68,9 +69,9 @@ const nsIProgressDialog = Components.interfaces.nsIProgressDialog;
nsProgressDialog.prototype = {
// Turn this on to get debugging messages.
debug: true,
debug: false,
// Currently, use old helperAppDldProgress.xul.
// Chrome-related constants.
dialogChrome: "chrome://global/content/nsProgressDialog.xul",
dialogFeatures: "chrome,titlebar,minimizable=yes",
@ -80,6 +81,8 @@ nsProgressDialog.prototype = {
set parent(newval) { return this.mParent = newval; },
get operation() { return this.mOperation; },
set operation(newval) { return this.mOperation = newval; },
get observer() { return this.mObserver; },
set observer(newval) { return this.mObserver = newval; },
get startTime() { return this.mStartTime; },
set startTime(newval) { return this.mStartTime = newval/1000; }, // PR_Now() is in microseconds, so we convert.
get lastUpdate() { return this.mLastUpdate; },
@ -227,6 +230,7 @@ nsProgressDialog.prototype = {
onStatusChange: function( aWebProgress, aRequest, aStatus, aMessage ) {
// Check for error condition (only if dialog is still open).
if ( this.dialog && aStatus != Components.results.NS_OK ) {
this.dump( "nsProgressDialog::onStatusChange, status=" + this.hex( aStatus ) + "\n" );
// Get prompt service.
var prompter = Components.classes[ "@mozilla.org/embedcomp/prompt-service;1" ]
.getService( Components.interfaces.nsIPromptService );
@ -380,16 +384,23 @@ nsProgressDialog.prototype = {
// Cancel button stops the download (if not completed),
// and closes the dialog.
onCancel: function() {
// Cancel the download, if not completed.
if ( !this.completed ) {
if ( this.operation ) {
this.operation.cancelSave();
// XXX We're supposed to clean up files/directories.
}
if ( this.observer ) {
this.observer.observe( this, "oncancel", "" );
}
this.paused = false;
}
// Test whether the dialog is already closed.
// This will be the case if we've come through onUnload.
if ( this.dialog ) {
// Close the dialog.
this.dialog.close();
}
// Cancel the download, if not completed.
if ( !this.completed && this.operation ) {
this.operation.cancelDownload();
}
},
// onunload event means the dialog has closed.

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

@ -47,7 +47,7 @@ Contributor(s):
<window xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="dialog"
title="&savingTitle;"
title="&defaultTitle;"
onload="notifyObserver('onload')"
onunload="notifyObserver('onunload')">
@ -76,7 +76,6 @@ Contributor(s):
<data id="string.longTimeFormat">&longTimeFormat;</data>
<data id="string.unknownTime">&unknownTime;</data>
<data id="string.pausedMsg">&pausedMsg;</data>
<data id="string.filesFolder">&filesFolder;</data>
<data id="string.savingTitle">&savingTitle;</data>
<data id="string.savingAlertTitle">&savingAlertTitle;</data>
<data id="string.openingTitle">&openingTitle;</data>