mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 824240 - Make the Downloads View Seamonkey-friendly. r=mak
This commit is contained in:
parent
960c2d8d65
commit
6f5f6bfb3c
36
browser/components/places/content/downloadsViewOverlay.xul
Normal file
36
browser/components/places/content/downloadsViewOverlay.xul
Normal file
@ -0,0 +1,36 @@
|
||||
<!-- 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"?>
|
||||
|
||||
<overlay id="downloadsViewOverlay"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript"><![CDATA[
|
||||
let useNewView = false;
|
||||
try {
|
||||
useNewView = Services.prefs.getBoolPref("browser.library.useNewDownloadsView");
|
||||
}
|
||||
catch(ex) { }
|
||||
|
||||
if (useNewView) {
|
||||
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")));
|
||||
}
|
||||
]]></script>
|
||||
|
||||
<window id="places">
|
||||
<commandset id="downloadCommands"/>
|
||||
<menupopup id="downloadsContextMenu"/>
|
||||
</window>
|
||||
|
||||
<deck id="placesViewsDeck">
|
||||
<richlistbox id="downloadsRichListBox"/>
|
||||
</deck>
|
||||
</overlay>
|
@ -5,11 +5,6 @@
|
||||
|
||||
Components.utils.import("resource:///modules/MigrationUtils.jsm");
|
||||
|
||||
const DOWNLOADS_QUERY = "place:transition=" +
|
||||
Components.interfaces.nsINavHistoryService.TRANSITION_DOWNLOAD +
|
||||
"&sort=" +
|
||||
Components.interfaces.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING;
|
||||
|
||||
var PlacesOrganizer = {
|
||||
_places: null,
|
||||
|
||||
@ -1246,34 +1241,55 @@ let gPrivateBrowsingListener = {
|
||||
#endif
|
||||
|
||||
let ContentArea = {
|
||||
_specialViews: new Map(),
|
||||
|
||||
init: function CA_init() {
|
||||
this._deck = document.getElementById("placesViewsDeck");
|
||||
this._specialViews = new Map();
|
||||
ContentTree.init();
|
||||
},
|
||||
|
||||
_shouldUseNewDownloadsView: function CA_shouldUseNewDownloadsView() {
|
||||
try {
|
||||
return Services.prefs.getBoolPref("browser.library.useNewDownloadsView");
|
||||
}
|
||||
catch(ex) { }
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @param aQueryString
|
||||
* a query string
|
||||
* @return the view to be used for loading aQueryString.
|
||||
*/
|
||||
getContentViewForQueryString:
|
||||
function CA_getContentViewForQueryString(aQueryString) {
|
||||
if (this._specialViews.has(aQueryString))
|
||||
return this._specialViews.get(aQueryString);
|
||||
if (aQueryString == DOWNLOADS_QUERY && this._shouldUseNewDownloadsView()) {
|
||||
let view = new DownloadsPlacesView(document.getElementById("downloadsRichListBox"));
|
||||
this.setContentViewForQueryString(aQueryString, view);
|
||||
return view;
|
||||
try {
|
||||
if (this._specialViews.has(aQueryString)) {
|
||||
let view = this._specialViews.get(aQueryString);
|
||||
if (typeof view == "function") {
|
||||
view = view();
|
||||
this._specialViews.set(aQueryString, view);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
}
|
||||
catch(ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
return ContentTree.view;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets a custom view to be used rather than the default places tree
|
||||
* whenever the given query is selected in the left pane.
|
||||
* @param aQueryString
|
||||
* a query string
|
||||
* @param aView
|
||||
* Either the custom view or a function that will return the view
|
||||
* the first (and only) time it's called.
|
||||
*/
|
||||
setContentViewForQueryString:
|
||||
function CA_setContentViewForQueryString(aQueryString, aView) {
|
||||
if (!aQueryString ||
|
||||
typeof aView != "object" && typeof aView != "function")
|
||||
throw new Error("Invalid arguments");
|
||||
|
||||
this._specialViews.set(aQueryString, aView);
|
||||
},
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
<?xml-stylesheet href="chrome://browser/skin/places/organizer.css"?>
|
||||
|
||||
<?xul-overlay href="chrome://browser/content/places/editBookmarkOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://browser/content/downloads/allDownloadsViewOverlay.xul"?>
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
<?xul-overlay href="chrome://browser/content/macBrowserOverlay.xul"?>
|
||||
@ -405,7 +404,6 @@
|
||||
</treecols>
|
||||
<treechildren flex="1"/>
|
||||
</tree>
|
||||
<richlistbox id="downloadsRichListBox"/>
|
||||
</deck>
|
||||
<deck id="detailsDeck" style="height: 11em;">
|
||||
<vbox id="itemsCountBox" align="center">
|
||||
@ -440,7 +438,4 @@
|
||||
</deck>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
||||
<commandset id="downloadCommands"/>
|
||||
<menupopup id="downloadsContextMenu"/>
|
||||
</window>
|
||||
|
@ -3,6 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
browser.jar:
|
||||
% overlay chrome://browser/content/places/places.xul chrome://browser/content/places/downloadsViewOverlay.xul
|
||||
# Provide another URI for the bookmarkProperties dialog so we can persist the
|
||||
# attributes separately
|
||||
content/browser/places/bookmarkProperties2.xul (content/bookmarkProperties.xul)
|
||||
@ -30,3 +31,4 @@ browser.jar:
|
||||
content/browser/places/moveBookmarks.js (content/moveBookmarks.js)
|
||||
content/browser/places/editBookmarkOverlay.xul (content/editBookmarkOverlay.xul)
|
||||
content/browser/places/editBookmarkOverlay.js (content/editBookmarkOverlay.js)
|
||||
content/browser/places/downloadsViewOverlay.xul (content/downloadsViewOverlay.xul)
|
||||
|
Loading…
Reference in New Issue
Block a user