Bug 822572 - Add a Clear Downloads button to the Library view.
authorMarco Bonardo <mbonardo@mozilla.com>
Sat, 05 Jan 2013 15:46:16 +0100
changeset 117738 1be4b28a143d1272f5ab6c62dbf80c7f0c8deb88
parent 117737 a55044631d140b83ad2f5cd07037972b850d59db
child 117739 8f9693d9279133eca661a0facc8f5178d532afec
push id24110
push userphilringnalda@gmail.com
push dateSat, 05 Jan 2013 23:57:49 +0000
treeherdermozilla-central@20d1a5916ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs822572
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 822572 - Add a Clear Downloads button to the Library view. r=Mano
browser/components/places/content/downloadsViewOverlay.xul
browser/components/places/content/places.js
browser/components/places/content/places.xul
browser/locales/en-US/chrome/browser/downloads/downloads.dtd
--- a/browser/components/places/content/downloadsViewOverlay.xul
+++ b/browser/components/places/content/downloadsViewOverlay.xul
@@ -1,29 +1,44 @@
 <!-- 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/. -->
 
 <?xul-overlay href="chrome://browser/content/downloads/allDownloadsViewOverlay.xul"?>
 
+<!DOCTYPE overlay [
+<!ENTITY % downloadsDTD SYSTEM "chrome://browser/locale/downloads/downloads.dtd">
+%downloadsDTD;
+]>
+
 <overlay id="downloadsViewOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script type="application/javascript"><![CDATA[
     const DOWNLOADS_QUERY = "place:transition=" +
       Components.interfaces.nsINavHistoryService.TRANSITION_DOWNLOAD +
       "&sort=" +
       Components.interfaces.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING;
 
     ContentArea.setContentViewForQueryString(DOWNLOADS_QUERY,
       function() new DownloadsPlacesView(document.getElementById("downloadsRichListBox")),
-      { showDetailsPane: false });
+      { showDetailsPane: false,
+        toolbarSet: "back-button, forward-button, organizeButton, clearDownloadsButton, libraryToolbarSpacer, searchFilter" });
   ]]></script>
 
   <window id="places">
     <commandset id="downloadCommands"/>
     <menupopup id="downloadsContextMenu"/>
   </window>
 
   <deck id="placesViewsDeck">
     <richlistbox id="downloadsRichListBox"/>
   </deck>
+
+  <toolbar id="placesToolbar">
+    <toolbarbutton id="clearDownloadsButton"
+                   insertbefore="libraryToolbarSpacer"
+                   label="&clearDownloadsButton.label;"
+                   command="downloadsCmd_clearDownloads"
+                   tooltiptext="&clearDownloadsButton.tooltip;"/>
+  </toolbar>
+
 </overlay>
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -1247,16 +1247,17 @@ let gPrivateBrowsingListener = {
 };
 #endif
 
 let ContentArea = {
   _specialViews: new Map(),
 
   init: function CA_init() {
     this._deck = document.getElementById("placesViewsDeck");
+    this._toolbar = document.getElementById("placesToolbar");
     ContentTree.init();
   },
 
   /**
    * Gets the content view to be used for loading the given query.
    * If a custom view was set by setContentViewForQueryString, that
    * view would be returned, else the default tree view is returned
    *
@@ -1310,19 +1311,35 @@ let ContentArea = {
       this._deck.selectedPanel = aView.associatedElement;
     return aView;
   },
 
   get currentPlace() this.currentView.place,
   set currentPlace(aQueryString) {
     this.currentView = this.getContentViewForQueryString(aQueryString);
     this.currentView.place = aQueryString;
+    this._updateToolbarSet();
     return aQueryString;
   },
 
+  _updateToolbarSet: function CA__updateToolbarSet() {
+    let toolbarSet = this.currentViewOptions.toolbarSet;
+    for (let elt of this._toolbar.childNodes) {
+      // On Windows and Linux the menu buttons are menus wrapped in a menubar.
+      if (elt.id == "placesMenu") {
+        for (let menuElt of elt.childNodes) {
+          menuElt.hidden = toolbarSet.indexOf(menuElt.id) == -1;
+        }
+      }
+      else {
+        elt.hidden = toolbarSet.indexOf(elt.id) == -1;
+      }
+    }
+  },
+
   /**
    * Options for the current view.
    *
    * @see ContentTree.viewOptions for supported options and default values.
    */
   get currentViewOptions() {
     // Use ContentTree options as default.
     let viewOptions = ContentTree.viewOptions;
@@ -1342,17 +1359,20 @@ let ContentArea = {
 
 let ContentTree = {
   init: function CT_init() {
     this._view = document.getElementById("placeContent");
   },
 
   get view() this._view,
 
-  get viewOptions() Object.seal({ showDetailsPane: true }),
+  get viewOptions() Object.seal({
+    showDetailsPane: true,
+    toolbarSet: "back-button, forward-button, organizeButton, viewMenu, maintenanceButton, libraryToolbarSpacer, searchFilter"
+  }),
 
   openSelectedNode: function CT_openSelectedNode(aEvent) {
     let view = this.view;
     PlacesUIUtils.openNodeWithEvent(view.selectedNode, aEvent, view);
   },
 
   onClick: function CT_onClick(aEvent) {
     // Only handle clicks on tree children.
--- a/browser/components/places/content/places.xul
+++ b/browser/components/places/content/places.xul
@@ -321,17 +321,17 @@
           </menupopup>
 #ifdef XP_MACOSX
         </toolbarbutton>
 #else
         </menu>
       </menubar>
 #endif
 
-      <spacer flex="1"/>
+      <spacer id="libraryToolbarSpacer" flex="1"/>
 
       <textbox id="searchFilter"
                clickSelectsAll="true"
                type="search"
                aria-controls="placeContent"
                oncommand="PlacesSearchBox.search(this.value);"
                collection="bookmarks">
       </textbox>
--- a/browser/locales/en-US/chrome/browser/downloads/downloads.dtd
+++ b/browser/locales/en-US/chrome/browser/downloads/downloads.dtd
@@ -69,8 +69,11 @@
 
 <!-- LOCALIZATION NOTE (downloadsHistory.label, downloadsHistory.accesskey):
      This string is shown at the bottom of the Downloads Panel when all the
      downloads fit in the available space, or when there are no downloads in
      the panel at all.
      -->
 <!ENTITY downloadsHistory.label           "Show All Downloads">
 <!ENTITY downloadsHistory.accesskey       "S">
+
+<!ENTITY clearDownloadsButton.label       "Clear Downloads">
+<!ENTITY clearDownloadsButton.tooltip     "Clears completed, canceled and failed downloads">