Bug 822572 - Add a Clear Downloads button to the Library view.

r=Mano
This commit is contained in:
Marco Bonardo 2013-01-05 15:46:16 +01:00
parent 5fd1a2f12b
commit a80f168d3e
4 changed files with 41 additions and 3 deletions

View File

@ -4,6 +4,11 @@
<?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">
@ -15,7 +20,8 @@
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">
@ -26,4 +32,13 @@
<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>

View File

@ -1252,6 +1252,7 @@ let ContentArea = {
init: function CA_init() {
this._deck = document.getElementById("placesViewsDeck");
this._toolbar = document.getElementById("placesToolbar");
ContentTree.init();
},
@ -1315,9 +1316,25 @@ let ContentArea = {
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.
*
@ -1347,7 +1364,10 @@ let ContentTree = {
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;

View File

@ -326,7 +326,7 @@
</menubar>
#endif
<spacer flex="1"/>
<spacer id="libraryToolbarSpacer" flex="1"/>
<textbox id="searchFilter"
clickSelectsAll="true"

View File

@ -74,3 +74,6 @@
-->
<!ENTITY downloadsHistory.label "Show All Downloads">
<!ENTITY downloadsHistory.accesskey "S">
<!ENTITY clearDownloadsButton.label "Clear Downloads">
<!ENTITY clearDownloadsButton.tooltip "Clears completed, canceled and failed downloads">