mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 781762 - Add the ability to delete all downloaded files at one time, r=margaret
This commit is contained in:
parent
04bd3392ee
commit
7515eb58a9
@ -7,6 +7,7 @@ let Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/DownloadUtils.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
let gStrings = Services.strings.createBundle("chrome://browser/locale/aboutDownloads.properties");
|
||||
|
||||
@ -111,6 +112,14 @@ let Downloads = {
|
||||
Downloads.cancelDownload(aTarget);
|
||||
}
|
||||
);
|
||||
|
||||
// Delete All shown when item is finished, canceled, or failed
|
||||
Downloads.deleteAllMenuItem = contextmenus.add(gStrings.GetStringFromName("downloadAction.deleteAll"),
|
||||
contextmenus.SelectorContext("li[state='" + this._dlmgr.DOWNLOAD_FINISHED + "']," +
|
||||
"li[state='" + this._dlmgr.DOWNLOAD_CANCELED + "']," +
|
||||
"li[state='" + this._dlmgr.DOWNLOAD_FAILED + "']"),
|
||||
this.deleteAll.bind(this)
|
||||
);
|
||||
},
|
||||
|
||||
uninit: function dl_uninit() {
|
||||
@ -121,6 +130,7 @@ let Downloads = {
|
||||
contextmenus.remove(this.resumeMenuItem);
|
||||
contextmenus.remove(this.retryMenuItem);
|
||||
contextmenus.remove(this.cancelMenuItem);
|
||||
contextmenus.remove(this.deleteAllMenuItem);
|
||||
|
||||
Services.obs.removeObserver(this, "dl-start");
|
||||
Services.obs.removeObserver(this, "dl-failed");
|
||||
@ -410,6 +420,25 @@ let Downloads = {
|
||||
} catch(ex) { }
|
||||
},
|
||||
|
||||
deleteAll: function dl_deleteAll() {
|
||||
let title = gStrings.GetStringFromName("downloadAction.deleteAll");
|
||||
let messageForm = gStrings.GetStringFromName("downloadMessage.deleteAll");
|
||||
let elements = this._list.querySelectorAll("li[state='" + this._dlmgr.DOWNLOAD_FINISHED + "']," +
|
||||
"li[state='" + this._dlmgr.DOWNLOAD_CANCELED + "']," +
|
||||
"li[state='" + this._dlmgr.DOWNLOAD_FAILED + "']");
|
||||
let message = PluralForm.get(elements.length, messageForm)
|
||||
.replace("#1", elements.length);
|
||||
let flags = Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_OK +
|
||||
Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL;
|
||||
let choice = Services.prompt.confirmEx(null, title, message, flags,
|
||||
null, null, null, null, {});
|
||||
if (choice == 0) {
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
this.removeDownload(elements[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
pauseDownload: function dl_pauseDownload(aItem) {
|
||||
try {
|
||||
let download = this._getDownloadForElement(aItem);
|
||||
|
@ -4,6 +4,13 @@
|
||||
|
||||
downloadAction.open=Open
|
||||
downloadAction.remove=Delete
|
||||
downloadAction.deleteAll=Delete All
|
||||
|
||||
# LOCALIZATION NOTE (downloadMessage.deleteAll):
|
||||
# Semi-colon list of plural forms. See:
|
||||
# http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
downloadMessage.deleteAll=Delete this download?;Delete #1 downloads?
|
||||
|
||||
downloadAction.pause=Pause
|
||||
downloadAction.resume=Resume
|
||||
downloadAction.cancel=Cancel
|
||||
|
Loading…
Reference in New Issue
Block a user