mobile/chrome/content/bindings/downloads.xml
author Vivien Nicolas <21@vingtetun.org>
Mon, 26 Apr 2010 16:55:04 -0400
changeset 66171 b9eed31df8eb1d615d057431e9f9382013ef7989
parent 65698 3c64365edb1280f63e0629e5b2613e920b33b20a
child 66740 41d8616dd6da336fb3fbc9cbe6c487eb71182ad2
permissions -rw-r--r--
Bug 561765 - PDF create from the 'Save Page As PDF' menu should appear into the downloads panel [r=mfinkle]

<?xml version="1.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.xml#richlistitem">
    <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">
        <xul:hbox align="center">
          <xul:label class="title" xbl:inherits="value=target" 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="DownloadsView.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">
        <xul:hbox align="center">
          <xul:label class="title" xbl:inherits="value=target" 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="DownloadsView.pauseDownload(document.getBindingParent(this));"/>
          <xul:button class="download-cancel" label="&downloadCancel.label;"
                      oncommand="DownloadsView.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">
        <xul:hbox align="center">
          <xul:label class="title" xbl:inherits="value=target" 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="DownloadsView.resumeDownload(document.getBindingParent(this));"/>
          <xul:button class="download-cancel" label="&downloadCancel.label;"
                      oncommand="DownloadsView.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">
        <xul:hbox align="center">
          <xul:label class="title" xbl:inherits="value=target" 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;"/>
          <xul:button class="show-on-select download-retry" label="&downloadRetry.label;"
                      oncommand="DownloadsView.retryDownload(document.getBindingParent(this));"/>
          <xul:button class="show-on-select download-remove" label="&downloadRemove.label;"
                      oncommand="DownloadsView.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">
        <xul:hbox align="center">
          <xul:label class="title" xbl:inherits="value=target" 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="DownloadsView.showPage(document.getBindingParent(this));"/>
          <xul:spacer flex="1"/>
          <xul:button anonid="open-button" label="&downloadOpen2.label;"
                      oncommand="DownloadsView.openDownload(document.getBindingParent(this));"/>
          <xul:button anonid="remove-button" label="&downloadRemove.label;"
                      oncommand="DownloadsView.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 = DownloadsView._getLocalFile(this.getAttribute("file"));
          if (!file.exists())
            document.getAnonymousElementByAttribute(this, "anonid", "open-button").setAttribute("disabled", "true");
        ]]>
      </constructor>
    </implementation>
  </binding>

</bindings>