gecko/browser/metro/base/content/bindings/downloads.xml
2013-02-12 14:51:25 -06:00

209 lines
9.0 KiB
XML

<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE bindings [
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
%browserDTD;
]>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="download-base" extends="chrome://browser/content/bindings/grid.xml#richgrid-item">
<content>
<xul:vbox anonid="anon-richgrid-item" class="richgrid-item-content">
<xul:hbox class="richgrid-icon-container">
<xul:box class="richgrid-icon-box"><xul:image xbl:inherits="src=iconURI"/></xul:box>
<xul:box flex="1" />
</xul:hbox>
<xul:description xbl:inherits="value=label" crop="end"/>
</xul:vbox>
<children/>
</content>
<implementation>
<field name="nsIDLMgr">Components.interfaces.nsIDownloadManager</field>
<property name="paused">
<getter>
<![CDATA[
return parseInt(this.getAttribute("state")) == this.nsIDLMgr.DOWNLOAD_PAUSED;
]]>
</getter>
</property>
<property name="openable">
<getter>
<![CDATA[
return parseInt(this.getAttribute("state")) == this.nsIDLMgr.DOWNLOAD_FINISHED;
]]>
</getter>
</property>
<property name="inProgress">
<getter>
<![CDATA[
var state = parseInt(this.getAttribute("state"));
return state == this.nsIDLMgr.DOWNLOAD_NOTSTARTED ||
state == this.nsIDLMgr.DOWNLOAD_QUEUED ||
state == this.nsIDLMgr.DOWNLOAD_DOWNLOADING ||
state == this.nsIDLMgr.DOWNLOAD_PAUSED ||
state == this.nsIDLMgr.DOWNLOAD_SCANNING;
]]>
</getter>
</property>
<property name="removable">
<getter>
<![CDATA[
var state = parseInt(this.getAttribute("state"));
return state == this.nsIDLMgr.DOWNLOAD_FINISHED ||
state == this.nsIDLMgr.DOWNLOAD_CANCELED ||
state == this.nsIDLMgr.DOWNLOAD_BLOCKED_PARENTAL ||
state == this.nsIDLMgr.DOWNLOAD_BLOCKED_POLICY ||
state == this.nsIDLMgr.DOWNLOAD_DIRTY ||
state == this.nsIDLMgr.DOWNLOAD_FAILED;
]]>
</getter>
</property>
</implementation>
</binding>
<binding id="download-not-started" extends="#download-base">
<content orient="horizontal" align="start">
<xul:image validate="always" xbl:inherits="src=iconURL"/>
<xul:vbox flex="1" anonid="anon-richgrid-item" class="richgrid-item-content">
<xul:hbox align="center">
<xul:label class="title" xbl:inherits="value=name" crop="center" flex="1"/>
<xul:label class="normal" xbl:inherits="value=datetime"/>
</xul:hbox>
<xul:hbox>
<xul:label class="normal" xbl:inherits="value=status"/>
</xul:hbox>
<xul:hbox class="show-on-select" align="center">
<xul:button anonid="showpage-button" label="&downloadShowPage.label;"
oncommand="Downloads.showPage(document.getBindingParent(this));"/>
<xul:spacer flex="1"/>
</xul:hbox>
</xul:vbox>
</content>
<implementation>
<constructor>
<![CDATA[
let referrer = this.hasAttribute("referrer");
if (!referrer)
document.getAnonymousElementByAttribute(this, "anonid", "showpage-button").setAttribute("disabled", "true");
]]>
</constructor>
</implementation>
</binding>
<binding id="download-downloading" extends="#download-base">
<content orient="horizontal" align="start">
<xul:image validate="always" xbl:inherits="src=iconURL"/>
<xul:vbox flex="1" anonid="anon-richgrid-item" class="richgrid-item-content">
<xul:hbox align="center">
<xul:label class="title" xbl:inherits="value=name" crop="center" flex="1"/>
<xul:label class="normal" xbl:inherits="value=datetime"/>
</xul:hbox>
<xul:hbox align="center">
<xul:progressmeter anonid="progressmeter" mode="normal" value="0" flex="1" xbl:inherits="value=progress,mode=progressmode"/>
<xul:button class="download-pause" label="&downloadPause.label;"
oncommand="Downloads.pauseDownload(document.getBindingParent(this));"/>
<xul:button class="download-cancel" label="&downloadCancel.label;"
oncommand="Downloads.cancelDownload(document.getBindingParent(this));"/>
</xul:hbox>
<xul:label class="normal" xbl:inherits="value=status" crop="end"/>
</xul:vbox>
</content>
</binding>
<binding id="download-paused" extends="#download-base">
<content orient="horizontal" align="start">
<xul:image validate="always" xbl:inherits="src=iconURL"/>
<xul:vbox flex="1" anonid="anon-richgrid-item" class="richgrid-item-content">
<xul:hbox align="center">
<xul:label class="title" xbl:inherits="value=name" crop="center" flex="1"/>
<xul:label class="normal" xbl:inherits="value=datetime"/>
</xul:hbox>
<xul:hbox align="center">
<xul:progressmeter anonid="progressmeter" mode="normal" value="0" flex="1" xbl:inherits="value=progress,mode=progressmode"/>
<xul:button class="download-resume" label="&downloadResume.label;"
oncommand="Downloads.resumeDownload(document.getBindingParent(this));"/>
<xul:button class="download-cancel" label="&downloadCancel.label;"
oncommand="Downloads.cancelDownload(document.getBindingParent(this));"/>
</xul:hbox>
<xul:label class="normal" xbl:inherits="value=status" crop="end"/>
</xul:vbox>
</content>
</binding>
<binding id="download-retry" extends="#download-base">
<content orient="horizontal" align="start">
<xul:image validate="always" xbl:inherits="src=iconURL"/>
<xul:vbox flex="1" anonid="anon-richgrid-item" class="richgrid-item-content">
<xul:hbox align="center">
<xul:label class="title" xbl:inherits="value=name" crop="center" flex="1"/>
<xul:label class="normal" xbl:inherits="value=datetime"/>
</xul:hbox>
<xul:hbox>
<xul:label class="normal" xbl:inherits="value=status" crop="end" flex="1"/>
<xul:label class="hide-on-select download-retry-failed normal" value="&downloadFailed.label;" xbl:inherits="state" />
<xul:button class="show-on-select download-retry" label="&downloadRetry.label;"
oncommand="Downloads.retryDownload(document.getBindingParent(this));"/>
<xul:button class="show-on-select download-remove" label="&downloadRemove.label;"
oncommand="Downloads.removeDownload(document.getBindingParent(this));"/>
</xul:hbox>
</xul:vbox>
</content>
</binding>
<binding id="download-done" extends="#download-base">
<content orient="horizontal" align="start">
<xul:image validate="always" xbl:inherits="src=iconURL"/>
<xul:vbox flex="1" anonid="anon-richgrid-item" class="richgrid-item-content">
<xul:hbox align="center">
<xul:label class="title" xbl:inherits="value=name" crop="center" flex="1"/>
<xul:label class="normal" xbl:inherits="value=datetime"/>
</xul:hbox>
<xul:hbox>
<xul:label class="normal" xbl:inherits="value=status"/>
</xul:hbox>
<xul:hbox class="show-on-select" align="center">
<xul:button anonid="showpage-button" label="&downloadShowPage.label;"
oncommand="Downloads.showPage(document.getBindingParent(this));"/>
<xul:spacer flex="1"/>
<xul:button anonid="open-button" label="&downloadOpen2.label;"
oncommand="Downloads.openDownload(document.getBindingParent(this));"/>
<xul:button anonid="remove-button" label="&downloadRemove.label;"
oncommand="Downloads.removeDownload(document.getBindingParent(this));"/>
</xul:hbox>
</xul:vbox>
</content>
<implementation>
<constructor>
<![CDATA[
let referrer = this.hasAttribute("referrer");
if (!referrer)
document.getAnonymousElementByAttribute(this, "anonid", "showpage-button").setAttribute("disabled", "true");
let file = Downloads._getLocalFile(this.getAttribute("target"));
let mimeService = Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
let mimeType;
try {
mimeType = mimeService.getTypeFromFile(file);
}
catch(e) {}
if (!file.exists() || !mimeType)
document.getAnonymousElementByAttribute(this, "anonid", "open-button").setAttribute("disabled", "true");
]]>
</constructor>
</implementation>
</binding>
</bindings>