From c64fba4654b4fa9359f76cd6bdb338b5aa50c7ab Mon Sep 17 00:00:00 2001 From: "mozilla.mano@sent.com" Date: Mon, 26 Nov 2007 11:04:23 -0800 Subject: [PATCH] Bug 404884 (along with bug 399800) - Add "Show All History" command to the history menu. r=dietrich. --- browser/base/content/browser-menubar.inc | 8 ++--- browser/base/content/browser-places.js | 17 +++++----- browser/base/content/browser-sets.inc | 8 +++-- browser/components/places/content/places.js | 17 ++++++++-- browser/components/places/content/utils.js | 31 +++++++++++++++---- .../locales/en-US/chrome/browser/browser.dtd | 4 +-- 6 files changed, 57 insertions(+), 28 deletions(-) diff --git a/browser/base/content/browser-menubar.inc b/browser/base/content/browser-menubar.inc index 7384d3c8f48..55e7a0f0ba0 100644 --- a/browser/base/content/browser-menubar.inc +++ b/browser/base/content/browser-menubar.inc @@ -362,8 +362,8 @@ - + @@ -398,8 +398,8 @@ - + diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index d388e536437..2af302994f6 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -313,25 +313,22 @@ var PlacesCommandHook = { /** * Opens the Places Organizer. - * @param aPlace - * The place to select in the organizer window (a place: URI) - * @param aForcePlace - * If true, aPlace will be set even if the organizer window is - * already open + * @param aLeftPaneRoot + * The query to select in the organizer window - options + * are: History, AllBookmarks, BookmarksMenu, BookmarksToolbar, + * UnfiledBookmarks and Tags. */ - showPlacesOrganizer: function PCH_showPlacesOrganizer(aPlace, aForcePlace) { + showPlacesOrganizer: function PCH_showPlacesOrganizer(aLeftPaneRoot) { var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var organizer = wm.getMostRecentWindow("Places:Organizer"); if (!organizer) { // No currently open places window, so open one with the specified mode. openDialog("chrome://browser/content/places/places.xul", - "", "chrome,toolbar=yes,dialog=no,resizable", aPlace); + "", "chrome,toolbar=yes,dialog=no,resizable", aLeftPaneRoot); } else { - if (aForcePlace) - organizer.selectPlaceURI(aPlace); - + organizer.PlacesOrganizer.selectLeftPaneQuery(aLeftPaneRoot); organizer.focus(); } }, diff --git a/browser/base/content/browser-sets.inc b/browser/base/content/browser-sets.inc index adaa7bac387..9904f0579f5 100644 --- a/browser/base/content/browser-sets.inc +++ b/browser/base/content/browser-sets.inc @@ -117,8 +117,10 @@ - + + @@ -260,7 +262,7 @@ # Accel+Shift+A-F are reserved on GTK2 #ifndef MOZ_WIDGET_GTK2 - + #endif #ifdef XP_WIN diff --git a/browser/components/places/content/places.js b/browser/components/places/content/places.js index 3543c82e11a..404e8cb1758 100755 --- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -43,10 +43,15 @@ var PlacesOrganizer = { _initFolderTree: function() { var leftPaneRoot = PlacesUtils.leftPaneFolderId; - var allBookmarksId = PlacesUtils.allBookmarksFolderId; this._places.place = "place:excludeItems=1&expandQueries=0&folder=" + leftPaneRoot; - this._places.selectItems([allBookmarksId]); - asContainer(this._places.selectedNode).containerOpen = true; + }, + + selectLeftPaneQuery: function PO_selectLeftPaneQuery(aQueryName) { + var itemId = PlacesUtils.leftPaneQueries[aQueryName]; + this._places.selectItems([itemId]); + // Forcefully expand all-bookmarks + if (aQueryName == "AllBookmarks") + asContainer(this._places.selectedNode).containerOpen = true; }, init: function PO_init() { @@ -54,6 +59,12 @@ var PlacesOrganizer = { this._content = document.getElementById("placeContent"); this._initFolderTree(); + var leftPaneSelection = "AllBookmarks"; // default to all-bookmarks + if ("arguments" in window && window.arguments.length > 0) + leftPaneSelection = window.arguments[0]; + + this.selectLeftPaneQuery(leftPaneSelection); + var view = this._content.treeBoxObject.view; if (view.rowCount > 0) view.selection.select(0); diff --git a/browser/components/places/content/utils.js b/browser/components/places/content/utils.js index 738659ebd1f..59a57d0bcfe 100644 --- a/browser/components/places/content/utils.js +++ b/browser/components/places/content/utils.js @@ -1693,6 +1693,12 @@ var PlacesUtils = { return element; }, + get leftPaneQueries() { + // build the map + this.leftPaneFolderId; + return this.leftPaneQueries; + }, + // get the folder id for the organizer left-pane folder get leftPaneFolderId() { var prefs = Cc["@mozilla.org/preferences-service;1"]. @@ -1701,7 +1707,15 @@ var PlacesUtils = { var allBookmarksId; try { leftPaneRoot = prefs.getIntPref("browser.places.leftPaneFolderId"); - // oh, easy! + // Build the leftPaneQueries Map + delete this.leftPaneQueries; + this.leftPaneQueries = {}; + var items = this.annotations.getItemsWithAnnotation(ORGANIZER_QUERY_ANNO, { }); + for (var i=0; i < items.length; i++) { + var queryName = this.annotations + .getItemAnnotation(items[i], ORGANIZER_QUERY_ANNO); + this.leftPaneQueries[queryName] = items[i]; + } delete this.leftPaneFolderId; return this.leftPaneFolderId = leftPaneRoot; } @@ -1711,6 +1725,9 @@ var PlacesUtils = { const EXPIRE_NEVER = this.annotations.EXPIRE_NEVER; var callback = { runBatched: function(aUserData) { + delete self.leftPaneQueries; + self.leftPaneQueries = { }; + // Left Pane Root Folder leftPaneRoot = self.bookmarks.createFolder(self.placesRootId, "", -1); @@ -1720,6 +1737,7 @@ var PlacesUtils = { let itemId = self.bookmarks.insertBookmark(leftPaneRoot, uri, -1, title); self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO, "History", 0, EXPIRE_NEVER); + self.leftPaneQueries["History"] = itemId; // XXX: Downloads @@ -1728,6 +1746,7 @@ var PlacesUtils = { itemId = self.bookmarks.insertBookmark(leftPaneRoot, uri, -1, null); self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO, "Tags", 0, EXPIRE_NEVER); + self.leftPaneQueries["Tags"] = itemId; // All Bookmarks Folder title = self.getString("OrganizerQueryAllBookmarks"); @@ -1735,18 +1754,21 @@ var PlacesUtils = { allBookmarksId = itemId; self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO, "AllBookmarks", 0, EXPIRE_NEVER); + self.leftPaneQueries["AllBookmarks"] = itemId; // All Bookmarks->Bookmarks Toolbar Query uri = IO.newURI("place:folder=" + self.toolbarFolderId); itemId = self.bookmarks.insertBookmark(allBookmarksId, uri, -1, null); self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO, "BookmarksToolbar", 0, EXPIRE_NEVER); + self.leftPaneQueries["BookmarksToolbar"] = itemId; // All Bookmarks->Bookmarks Menu Query uri = IO.newURI("place:folder=" + self.bookmarksMenuFolderId); itemId = self.bookmarks.insertBookmark(allBookmarksId, uri, -1, null); self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO, "BookmarksMenu", 0, EXPIRE_NEVER); + self.leftPaneQueries["BookmarksMenu"] = itemId; // All Bookmarks->Unfiled bookmarks uri = IO.newURI("place:folder=" + self.unfiledBookmarksFolderId); @@ -1754,6 +1776,7 @@ var PlacesUtils = { self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO, "UnfiledBookmarks", 0, EXPIRE_NEVER); + self.leftPaneQueries["UnfiledBookmarks"] = itemId; // disallow manipulating this folder within the organizer UI self.bookmarks.setFolderReadonly(leftPaneRoot, true); @@ -1761,7 +1784,6 @@ var PlacesUtils = { }; this.bookmarks.runInBatchMode(callback, null); prefs.setIntPref("browser.places.leftPaneFolderId", leftPaneRoot); - prefs.setIntPref("browser.places.allBookmarksFolderId", allBookmarksId); delete this.leftPaneFolderId; return this.leftPaneFolderId = leftPaneRoot; }, @@ -1770,10 +1792,7 @@ var PlacesUtils = { // ensure the left-pane root is initialized; this.leftPaneFolderId; delete this.allBookmarksFolderId; - return this.allBookmarksFolderId = - Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch2). - getIntPref("browser.places.allBookmarksFolderId"); + return this.allBookmarksFolderId = this.leftPaneQueries["AllBookmarks"]; } }; diff --git a/browser/locales/en-US/chrome/browser/browser.dtd b/browser/locales/en-US/chrome/browser/browser.dtd index a4f87b0508b..5302e76d183 100644 --- a/browser/locales/en-US/chrome/browser/browser.dtd +++ b/browser/locales/en-US/chrome/browser/browser.dtd @@ -60,7 +60,7 @@ - + @@ -171,7 +171,7 @@ - +