Bug 404884 (along with bug 399800) - Add "Show All History" command to the history menu. r=dietrich.

This commit is contained in:
mozilla.mano@sent.com 2007-11-26 11:04:23 -08:00
Родитель 1fc18fbbc1
Коммит c64fba4654
6 изменённых файлов: 57 добавлений и 28 удалений

Просмотреть файл

@ -362,8 +362,8 @@
<menupopup id="historyUndoPopup" onpopupshowing="HistoryMenu.populateUndoSubmenu();"/>
</menu>
<menuseparator id="endUndoSeparator"/>
<menuitem observes="viewHistorySidebar" label="&historyShowSidebarCmd.label;"
key="key_gotoHistory"/>
<menuitem label="&showAllHistoryCmd.label;"
command="Browser:ShowAllHistory"/>
</menupopup>
</menu>
@ -398,8 +398,8 @@
</menu>
<menuitem label="&addCurPagesCmd.label;"
command="Browser:BookmarkAllTabs" key="bookmarkAllTabsKb"/>
<menuitem label="&showBookmarksCmd.label;"
command="Browser:ShowBookmarks" key="manBookmarkKb"/>
<menuitem label="&showAllBookmarksCmd.label;"
command="Browser:ShowAllBookmarks" key="manBookmarkKb"/>
<menuseparator builder="start"/>
</menupopup>
</menu>

Просмотреть файл

@ -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();
}
},

Просмотреть файл

@ -117,8 +117,10 @@
</commandset>
<commandset id="placesCommands">
<command id="Browser:ShowBookmarks"
oncommand="PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_BOOKMARKS);"/>
<command id="Browser:ShowAllBookmarks"
oncommand="PlacesCommandHook.showPlacesOrganizer('AllBookmarks');"/>
<command id="Browser:ShowAllHistory"
oncommand="PlacesCommandHook.showPlacesOrganizer('History');"/>
</commandset>
<broadcasterset id="mainBroadcasterSet">
@ -260,7 +262,7 @@
# Accel+Shift+A-F are reserved on GTK2
#ifndef MOZ_WIDGET_GTK2
<key id="bookmarkAllTabsKb" key="&addCurPageAsCmd.commandkey;" command="Browser:BookmarkAllTabs" modifiers="accel,shift"/>
<key id="manBookmarkKb" key="&bookmarksSidebarCmd.commandkey;" command="Browser:ShowBookmarks" modifiers="accel,shift"/>
<key id="manBookmarkKb" key="&bookmarksSidebarCmd.commandkey;" command="Browser:ShowAllBookmarks" modifiers="accel,shift"/>
#endif
<key id="viewBookmarksSidebarKb" key="&bookmarksSidebarCmd.commandkey;" command="viewBookmarksSidebar" modifiers="accel"/>
#ifdef XP_WIN

Просмотреть файл

@ -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);

Просмотреть файл

@ -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"];
}
};

Просмотреть файл

@ -60,7 +60,7 @@
<!ENTITY subscribeToPageMenupopup.label "Subscribe to This Page">
<!ENTITY subscribeToPageMenuitem.label "Subscribe to This Page...">
<!ENTITY addCurPagesCmd.label "Bookmark All Tabs...">
<!ENTITY showBookmarksCmd.label "Show All Bookmarks...">
<!ENTITY showAllBookmarksCmd.label "Show All Bookmarks...">
<!ENTITY bookmarkAllCmd.label "Bookmark All Tabs...">
<!ENTITY backCmd.label "Back">
@ -171,7 +171,7 @@
<!ENTITY historyUndoMenu.label "Recently Closed Tabs">
<!ENTITY historyHomeCmd.label "Home">
<!ENTITY historyShowSidebarCmd.label "Show in Sidebar">
<!ENTITY showAllHistoryCmd.label "Show All History...">
<!ENTITY openCmd.commandkey "l">
<!ENTITY urlbar.accesskey "d">