Bug 1124400 - [ReadingList] Add section to bookmarks popup for reading list items and actions, r=Unfocussed.

This commit is contained in:
Florian Quèze 2015-02-23 13:58:36 +01:00
parent bbbb0cf83b
commit 1d788f3de7
13 changed files with 150 additions and 1 deletions

View File

@ -444,6 +444,28 @@
onpopupshowing="if (!this.parentNode._placesView)
new PlacesMenu(event, 'place:folder=TOOLBAR');"/>
</menu>
#ifndef XP_MACOSX
# Disabled on Mac because we can't fill native menupopups asynchronously
<menuseparator/>
<menu id="menu_readingList"
class="menu-iconic bookmark-item"
label="&readingList.label;"
container="true">
<observes element="readingListSidebar" attribute="hidden"/>
<menupopup id="readingListPopup"
#ifndef XP_MACOSX
placespopup="true"
#endif
onpopupshowing="ReadingListUI.onReadingListPopupShowing(this);">
<menuseparator id="viewReadingListSidebarSeparator"/>
<menuitem id="viewReadingListSidebar" class="subviewbutton"
oncommand="SidebarUI.toggle('readingListSidebar');"
label="&readingList.showSidebar.label;">
<observes element="readingListSidebar" attribute="checked"/>
</menuitem>
</menupopup>
</menu>
#endif
<menuseparator id="bookmarksMenuItemsSeparator"/>
<!-- Bookmarks menu items -->
<menuseparator builder="end"

View File

@ -4,6 +4,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
XPCOMUtils.defineLazyModuleGetter(this, "ReadingList",
"resource:///modules/readinglist/ReadingList.jsm");
let ReadingListUI = {
/**
* Initialize the ReadingList UI.
@ -65,4 +68,70 @@ let ReadingListUI = {
SidebarUI.hide();
}
},
onReadingListPopupShowing(target) {
if (target.id == "BMB_readingListPopup") {
// Setting this class in the .xul file messes with the way
// browser-places.js inserts bookmarks in the menu.
document.getElementById("BMB_viewReadingListSidebar")
.classList.add("panel-subview-footer");
}
while (!target.firstChild.id)
target.firstChild.remove();
let classList = "menuitem-iconic bookmark-item menuitem-with-favicon";
let insertPoint = target.firstChild;
if (insertPoint.classList.contains("subviewbutton"))
classList += " subviewbutton";
ReadingList.getItems().then(items => {
for (let item of items) {
let menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", item.title || item.url.spec);
menuitem.setAttribute("class", classList);
let node = menuitem._placesNode = {
// Passing the PlacesUtils.nodeIsURI check is required for the
// onCommand handler to load our URI.
type: Ci.nsINavHistoryResultNode.RESULT_TYPE_URI,
// makes PlacesUIUtils.canUserRemove return false.
// The context menu is broken without this.
parent: {type: Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER},
// A -1 id makes this item a non-bookmark, which avoids calling
// PlacesUtils.annotations.itemHasAnnotation to check if the
// bookmark should be opened in the sidebar (this call fails for
// readinglist item, and breaks loading our URI).
itemId: -1,
// Used by the tooltip and onCommand handlers.
uri: item.url.spec,
// Used by the tooltip.
title: item.title
};
Favicons.getFaviconURLForPage(item.url, uri => {
if (uri) {
menuitem.setAttribute("image",
Favicons.getFaviconLinkForIcon(uri).spec);
}
});
target.insertBefore(menuitem, insertPoint);
}
if (!items.length) {
let menuitem = document.createElement("menuitem");
let bundle =
Services.strings.createBundle("chrome://browser/locale/places/places.properties");
menuitem.setAttribute("label", bundle.GetStringFromName("bookmarksMenuEmptyFolder"));
menuitem.setAttribute("class", "bookmark-item");
menuitem.setAttribute("disabled", true);
target.insertBefore(menuitem, insertPoint);
}
});
}
};

View File

@ -37,6 +37,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "ContentSearch",
"resource:///modules/ContentSearch.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AboutHome",
"resource:///modules/AboutHome.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "Favicons",
"@mozilla.org/browser/favicon-service;1",
"mozIAsyncFavicons");
XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
"@mozilla.org/network/dns-service;1",
"nsIDNSService");

View File

@ -950,6 +950,22 @@
new PlacesMenu(event, 'place:folder=UNFILED_BOOKMARKS',
PlacesUIUtils.getViewForNode(this.parentNode.parentNode).options);"/>
</menu>
<menuseparator>
<observes element="readingListSidebar" attribute="hidden"/>
</menuseparator>
<menu id="BMB_readingList"
class="menu-iconic bookmark-item subviewbutton"
label="&readingList.label;"
container="true">
<observes element="readingListSidebar" attribute="hidden"/>
<menupopup id="BMB_readingListPopup"
placespopup="true"
onpopupshowing="ReadingListUI.onReadingListPopupShowing(this);">
<menuitem id="BMB_viewReadingListSidebar" class="subviewbutton"
oncommand="SidebarUI.show('readingListSidebar');"
label="&readingList.showSidebar.label;"/>
</menupopup>
</menu>
<menuseparator/>
<!-- Bookmarks menu items will go here -->
<menuitem id="BMB_bookmarksShowAll"

View File

@ -126,6 +126,17 @@
label="&unsortedBookmarksCmd.label;"
class="subviewbutton cui-withicon"
oncommand="PlacesCommandHook.showPlacesOrganizer('UnfiledBookmarks'); PanelUI.hide();"/>
<toolbarseparator>
<observes element="readingListSidebar" attribute="hidden"/>
</toolbarseparator>
<toolbarbutton id="panelMenu_viewReadingListSidebar"
label="&readingList.showSidebar.label;"
class="subviewbutton"
key="key_readingListSidebar"
oncommand="SidebarUI.toggle('readingListSidebar'); PanelUI.hide();">
<observes element="readingListSidebar" attribute="checked"/>
<observes element="readingListSidebar" attribute="hidden"/>
</toolbarbutton>
<toolbarseparator class="small-separator"/>
<toolbaritem id="panelMenu_bookmarksMenu"
orient="vertical"

View File

@ -847,7 +847,6 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!ENTITY readingList.label "Reading List">
<!ENTITY readingList.sidebar.commandKey "R">
<!-- Pre-landed string for bug 1124400 -->
<!ENTITY readingList.showSidebar.label "Show Reading List Sidebar">
<!-- Pre-landed string for bug 1124153 -->
<!ENTITY readingList.sidebar.showMore.label "Show more…">

View File

@ -518,6 +518,11 @@ menuitem:not([type]):not(.menuitem-tooltip):not(.menuitem-iconic-tooltip) {
list-style-image: url("chrome://browser/skin/places/unsortedBookmarks.png");
}
#menu_readingList,
#BMB_readingList {
list-style-image: url("chrome://browser/skin/readinglist/readinglist-icon.svg");
}
#menu_openDownloads {
list-style-image: url("chrome://browser/skin/Toolbar-small.png");
-moz-image-region: rect(0px 16px 16px 0px);

View File

@ -91,6 +91,7 @@ browser.jar:
skin/classic/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
skin/classic/browser/reader-mode-16.png (../shared/reader/reader-mode-16.png)
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
skin/classic/browser/readinglist/sidebar.css (../shared/readinglist/sidebar.css)
skin/classic/browser/webRTC-shareDevice-16.png
skin/classic/browser/webRTC-shareDevice-64.png

View File

@ -563,6 +563,11 @@ toolbarpaletteitem[place="palette"] > #personal-bookmarks > #bookmarks-toolbar-p
}
}
/* #menu_readingList, svg icons don't work in the mac native menubar */
#BMB_readingList {
list-style-image: url("chrome://browser/skin/readinglist/readinglist-icon.svg");
}
/* ----- PRIMARY TOOLBAR BUTTONS ----- */
toolbar .toolbarbutton-1:not([type="menu-button"]),

View File

@ -142,6 +142,7 @@ browser.jar:
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
skin/classic/browser/reader-mode-16.png (../shared/reader/reader-mode-16.png)
skin/classic/browser/reader-mode-16@2x.png (../shared/reader/reader-mode-16@2x.png)
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
skin/classic/browser/readinglist/sidebar.css (../shared/readinglist/sidebar.css)
skin/classic/browser/webRTC-shareDevice-16.png
skin/classic/browser/webRTC-shareDevice-16@2x.png

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16">
<rect x="4.8" y="6.4" fill="#808080" width="11.2" height="3.2"/>
<rect x="4.8" y="11.2" fill="#808080" width="11.2" height="3.2"/>
<rect x="4.8" y="1.6" fill="#808080" width="11.2" height="3.2"/>
<circle fill="#808080" cx="1.6" cy="3.2" r="1.6"/>
<circle fill="#808080" cx="1.6" cy="8" r="1.6"/>
<circle fill="#808080" cx="1.6" cy="12.8" r="1.6"/>
</svg>

After

Width:  |  Height:  |  Size: 510 B

View File

@ -2526,6 +2526,12 @@ notification[value="translation"] {
-moz-image-region: auto;
}
#menu_readingList,
#BMB_readingList {
list-style-image: url("chrome://browser/skin/readinglist/readinglist-icon.svg");
-moz-image-region: auto;
}
/* ::::: Keyboard UI Panel ::::: */
.KUI-panel {

View File

@ -110,6 +110,7 @@ browser.jar:
skin/classic/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
skin/classic/browser/reader-mode-16.png (../shared/reader/reader-mode-16.png)
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
skin/classic/browser/readinglist/sidebar.css (../shared/readinglist/sidebar.css)
skin/classic/browser/notification-pluginNormal.png (../shared/plugins/notification-pluginNormal.png)
skin/classic/browser/notification-pluginAlert.png (../shared/plugins/notification-pluginAlert.png)
@ -576,6 +577,7 @@ browser.jar:
skin/classic/aero/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
skin/classic/aero/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
skin/classic/aero/browser/reader-mode-16.png (../shared/reader/reader-mode-16.png)
skin/classic/aero/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
skin/classic/aero/browser/readinglist/sidebar.css (../shared/readinglist/sidebar.css)
skin/classic/aero/browser/notification-pluginNormal.png (../shared/plugins/notification-pluginNormal.png)
skin/classic/aero/browser/notification-pluginAlert.png (../shared/plugins/notification-pluginAlert.png)