Bug 1427407 - add "Add-ons" menuitem in the Add-ons submenu of appmenu. ui-r=Paenglab, r=Paenglab
authoraceman <acelists@atlas.sk>
Sat, 30 Dec 2017 13:25:00 +0100
changeset 22945 2639c3ea8ba0f3642ea0dadb2504f934b964ef12
parent 22944 dd64bc33f829ef8c87475e4eb0c3ab15b081415c
child 22946 3744f4ef8956d4368a213b31d7b75c169eab406f
push id13891
push usermozilla@jorgk.com
push dateSat, 30 Dec 2017 22:20:19 +0000
treeherdercomm-central@2639c3ea8ba0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPaenglab, Paenglab
bugs1427407
Bug 1427407 - add "Add-ons" menuitem in the Add-ons submenu of appmenu. ui-r=Paenglab, r=Paenglab
mail/base/content/mailWindowOverlay.js
mail/base/content/mailWindowOverlay.xul
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -3710,18 +3710,21 @@ function initAppMenuPopup(aMenuPopup, aE
 }
 
 /**
  *  Generates menu items for opening preferences dialog/tab for each installed addon.
  *
  *  @option aMenupopup  The menupopup element to populate.
  */
 function initAddonPrefsMenu(aMenupopup) {
-  // Clear all but the first special menuitem.
-  while (aMenupopup.children.length > 1) {
+  // Starting at the bottom, clear all menu items until we hit
+  // "no add-on prefs", which is the only disabled element. Above this element
+  // there may be further items that we want to preserve.
+  let noPrefsElem = aMenupopup.querySelector('[disabled="true"]');
+  while (aMenupopup.lastChild != noPrefsElem) {
     aMenupopup.lastChild.remove();
   }
 
   // Enumerate all enabled addons with URL to XUL document with prefs.
   AddonManager.getAddonsByTypes(["extension"], (addons) => {
     let addonsFound = [];
     for (let addon of addons) {
       if (!addon.userDisabled && !addon.appDisabled && !addon.softDisabled &&
@@ -3741,15 +3744,15 @@ function initAddonPrefsMenu(aMenupopup) 
           newItem.setAttribute("optionsType", addon.optionsType);
         let iconURL = addon.iconURL || addon.icon64URL;
         if (iconURL) {
           newItem.setAttribute("class", "menuitem-iconic");
           newItem.setAttribute("image", iconURL);
         }
         aMenupopup.appendChild(newItem);
       }
-      aMenupopup.firstChild.setAttribute("collapsed", "true");
+      noPrefsElem.setAttribute("collapsed", "true");
     } else {
       // Only show message that there are no addons with prefs.
-      aMenupopup.firstChild.setAttribute("collapsed", "false");
+      noPrefsElem.setAttribute("collapsed", "false");
     }
   });
 }
--- a/mail/base/content/mailWindowOverlay.xul
+++ b/mail/base/content/mailWindowOverlay.xul
@@ -1345,16 +1345,18 @@
         <spacer class="appmenuPane-spacer"/>
         <splitmenu id="appmenu_addons"
                    class="menuitem-iconic"
                    label="&addons.label;"
                    oncommand="openAddonsMgr();">
           <menupopup id="appmenu_addonPrefs"
                      onpopupshowing="initAddonPrefsMenu(this);"
                      oncommand="openAddonPrefs(event.target.value, event.target.getAttribute('optionsType'));">
+            <menuitem label="&addons.label;" oncommand="openAddonsMgr();"/>
+            <menuseparator class="appmenu-menuseparator"/>
             <menuitem label="&addonNoPrefs.label;" disabled="true"/>
           </menupopup>
         </splitmenu>
         <splitmenu id="appmenu_customize"
 #ifdef XP_WIN
                    label="&preferencesCmd2.label;"
 #else
                    label="&preferencesCmdUnix.label;"