exports: ["Download", "Downloads", "downloads"]
}, this);
+this.lazyRequire("overlay", ["overlay"]);
+
Cu.import("resource://gre/modules/DownloadUtils.jsm", this);
let prefix = "DOWNLOAD_";
this.nodes = {
commandTarget: self
};
+ XML.ignoreWhitespace = true;
+ XML.prettyPrinting = false;
util.xmlToDom(
<tr highlight="Download" key="row" xmlns:dactyl={NS} xmlns={XHTML}>
<td highlight="DownloadTitle">
message: Class.Memoize(function () {
+ XML.ignoreWhitespace = true;
+ XML.prettyPrinting = false;
util.xmlToDom(<table highlight="Downloads" key="list" xmlns={XHTML}>
- <tr highlight="DownloadHead">
+ <tr highlight="DownloadHead" key="head">
<span>{_("title.Title")}</span>
<span>{_("title.Status")}</span>
<span/>
</tr>
</table>, this.document, this.nodes);
+ this.index = Array.indexOf(this.nodes.list.childNodes,
+ this.nodes.head);
+
for (let row in iter(services.downloadManager.DBConnection
.createStatement("SELECT id FROM moz_downloads")))
this.addDownload(row.id);
.indexOf(download);
this.nodes.list.insertBefore(download.nodes.row,
- this.nodes.list.childNodes[index + 1]);
+ this.nodes.list.childNodes[index + this.index + 1]);
}
},
removeDownload: function removeDownload(id) {
}
});
-var Downloads = Module("downloads", {
+var Downloads = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
+ init: function () {
+ services.downloadManager.addListener(this);
+ },
+
+ destroy: function destroy() {
+ services.downloadManager.removeListener(this);
+ },
+
+ onDownloadStateChange: function (state, download) {
+ if (download.state == services.downloadManager.DOWNLOAD_FINISHED) {
+ let url = download.source.spec;
+ let title = download.displayName;
+ let file = download.targetFile.path;
+ let size = download.size;
+
+
+ overlay.modules.forEach(function (modules) {
+ modules.dactyl.echomsg({ domains: [util.getHost(url)], message: _("io.downloadFinished", title, file) },
+ 1, modules.commandline.ACTIVE_WINDOW);
+ modules.autocommands.trigger("DownloadPost", { url: url, title: title, file: file, size: size });
+ });
+ }
+ }
}, {
}, {
commands: function initCommands(dactyl, modules, window) {