зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1674539 - Add option to hide Other Bookmarks button from bookmarks toolbar. r=jaws,fluent-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D97211
This commit is contained in:
Родитель
573c881bae
Коммит
6a8271fa76
|
@ -2064,6 +2064,11 @@ pref("browser.toolbars.keyboard_navigation", true);
|
|||
// "always": Always show
|
||||
// "never": Never show
|
||||
pref("browser.toolbars.bookmarks.visibility", "newtab");
|
||||
|
||||
// Visibility of the "Show Other Bookmarks" menuitem in the
|
||||
// bookmarks toolbar contextmenu.
|
||||
pref("browser.toolbars.bookmarks.showOtherBookmarks", true);
|
||||
|
||||
// When true, this pref will always show the bookmarks bar on
|
||||
// the New Tab Page, allowing showing/hiding via keyboard shortcut,
|
||||
// and other functionality to improve the usage of the Bookmarks Toolbar.
|
||||
|
|
|
@ -2362,9 +2362,14 @@ var BookmarkingUI = {
|
|||
let unfiledGuid = PlacesUtils.bookmarks.unfiledGuid;
|
||||
let numberOfBookmarks = PlacesUtils.getChildCountForFolder(unfiledGuid);
|
||||
let placement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
|
||||
let showOtherBookmarksEnabled = Services.prefs.getBoolPref(
|
||||
"browser.toolbars.bookmarks.showOtherBookmarks",
|
||||
true
|
||||
);
|
||||
|
||||
if (
|
||||
numberOfBookmarks > 0 &&
|
||||
showOtherBookmarksEnabled &&
|
||||
placement?.area == CustomizableUI.AREA_BOOKMARKS
|
||||
) {
|
||||
let otherBookmarksPopup = document.getElementById("OtherBookmarksPopup");
|
||||
|
@ -2379,5 +2384,43 @@ var BookmarkingUI = {
|
|||
}
|
||||
},
|
||||
|
||||
buildShowOtherBookmarksMenuItem() {
|
||||
let unfiledGuid = PlacesUtils.bookmarks.unfiledGuid;
|
||||
let numberOfBookmarks = PlacesUtils.getChildCountForFolder(unfiledGuid);
|
||||
|
||||
if (!gBookmarksToolbar2h2020 || numberOfBookmarks < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let showOtherBookmarksMenuItem = Services.prefs.getBoolPref(
|
||||
"browser.toolbars.bookmarks.showOtherBookmarks",
|
||||
true
|
||||
);
|
||||
|
||||
let menuItem = document.createXULElement("menuitem");
|
||||
|
||||
menuItem.setAttribute("id", "show-other-bookmarks_PersonalToolbar");
|
||||
menuItem.setAttribute("toolbarId", "PersonalToolbar");
|
||||
menuItem.setAttribute("type", "checkbox");
|
||||
menuItem.setAttribute("checked", showOtherBookmarksMenuItem);
|
||||
menuItem.setAttribute("selectiontype", "none|single");
|
||||
|
||||
MozXULElement.insertFTLIfNeeded("browser/toolbarContextMenu.ftl");
|
||||
document.l10n.setAttributes(
|
||||
menuItem,
|
||||
"toolbar-context-menu-bookmarks-show-other-bookmarks"
|
||||
);
|
||||
menuItem.addEventListener("command", () => {
|
||||
Services.prefs.setBoolPref(
|
||||
"browser.toolbars.bookmarks.showOtherBookmarks",
|
||||
!showOtherBookmarksMenuItem
|
||||
);
|
||||
|
||||
BookmarkingUI.maybeShowOtherBookmarksFolder();
|
||||
});
|
||||
|
||||
return menuItem;
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
|
||||
};
|
||||
|
|
|
@ -6303,6 +6303,15 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) {
|
|||
if (toolbar.id == "PersonalToolbar" && gBookmarksToolbar2h2020) {
|
||||
let menu = BookmarkingUI.buildBookmarksToolbarSubmenu(toolbar);
|
||||
popup.insertBefore(menu, firstMenuItem);
|
||||
|
||||
// Insert Show Otherbookmarks menu item.
|
||||
let otherBookmarksMenuItem = BookmarkingUI.buildShowOtherBookmarksMenuItem();
|
||||
|
||||
if (!otherBookmarksMenuItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
popup.insertBefore(otherBookmarksMenuItem, menu.nextElementSibling);
|
||||
} else {
|
||||
let menuItem = document.createXULElement("menuitem");
|
||||
menuItem.setAttribute("id", "toggle_" + toolbar.id);
|
||||
|
|
|
@ -250,8 +250,18 @@ PlacesViewBase.prototype = {
|
|||
this._contextMenuShown = aPopup;
|
||||
window.updateCommands("places");
|
||||
|
||||
// Add the View menu for the Bookmarks Toolbar if the click originated
|
||||
// from the Bookmarks Toolbar.
|
||||
// Ensure that an existing "Show Other Bookmarks" item is removed before adding it
|
||||
// again. This item should only be added when gBookmarksToolbar2h2020 is true, but
|
||||
// its possible the pref could be toggled off in the same window. This results in
|
||||
// the "Show Other Bookmarks" menu item still being visible even when the pref is
|
||||
// set to false.
|
||||
let existingOtherBookmarksItem = aPopup.querySelector(
|
||||
"#show-other-bookmarks_PersonalToolbar"
|
||||
);
|
||||
existingOtherBookmarksItem?.remove();
|
||||
|
||||
// Add the View menu for the Bookmarks Toolbar and "Show Other Bookmarks" menu item
|
||||
// if the click originated from the Bookmarks Toolbar.
|
||||
if (gBookmarksToolbar2h2020) {
|
||||
let existingSubmenu = aPopup.querySelector("#toggle_PersonalToolbar");
|
||||
existingSubmenu?.remove();
|
||||
|
@ -259,6 +269,20 @@ PlacesViewBase.prototype = {
|
|||
if (bookmarksToolbar?.contains(aPopup.triggerNode)) {
|
||||
let menu = BookmarkingUI.buildBookmarksToolbarSubmenu(bookmarksToolbar);
|
||||
aPopup.appendChild(menu);
|
||||
|
||||
if (
|
||||
aPopup.triggerNode.id === "OtherBookmarks" ||
|
||||
aPopup.triggerNode.id === "PlacesToolbarItems"
|
||||
) {
|
||||
let otherBookmarksMenuItem = BookmarkingUI.buildShowOtherBookmarksMenuItem();
|
||||
|
||||
if (otherBookmarksMenuItem) {
|
||||
aPopup.insertBefore(
|
||||
otherBookmarksMenuItem,
|
||||
menu.nextElementSibling
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,3 +64,7 @@ toolbar-context-menu-bookmarks-toolbar-never-show =
|
|||
toolbar-context-menu-bookmarks-toolbar-on-new-tab =
|
||||
.label = Only on New Tab
|
||||
.accesskey = O
|
||||
|
||||
toolbar-context-menu-bookmarks-show-other-bookmarks =
|
||||
.label = Show Other Bookmarks
|
||||
.accesskey = h
|
||||
|
|
Загрузка…
Ссылка в новой задаче