Bug 1599501 - Add Favourite folders to SeaMonkey. r=frg
authorIan Neal <iann_cvs@blueyonder.co.uk>
Sat, 11 Jan 2020 00:40:15 +0100
changeset 37053 4acbeec199dce57b440be070cf441deff35ab258
parent 37052 20be22b77f869cd88648410880855dd2fe3f98b5
child 37054 7ce4f25ecab93d1195dd8a95ff6daa5878f086ad
push id2552
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:24:16 +0000
treeherdercomm-beta@f95a6f4408a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrg
bugs1599501
Bug 1599501 - Add Favourite folders to SeaMonkey. r=frg
suite/locales/en-US/chrome/mailnews/messenger.dtd
suite/mailnews/content/mailContextMenus.js
suite/mailnews/content/mailWindowOverlay.js
suite/mailnews/content/mailWindowOverlay.xul
--- a/suite/locales/en-US/chrome/mailnews/messenger.dtd
+++ b/suite/locales/en-US/chrome/mailnews/messenger.dtd
@@ -89,16 +89,18 @@
 <!ENTITY unsubscribeNewsgroupCmd.accesskey "n">
 <!ENTITY selectMenu.label "Select">
 <!ENTITY selectMenu.accesskey "S">
 <!ENTITY selectThreadCmd.label "Thread">
 <!ENTITY selectThreadCmd.accesskey "T">
 <!ENTITY selectThreadCmd.key "a">
 <!ENTITY selectFlaggedCmd.label "Flagged Messages">
 <!ENTITY selectFlaggedCmd.accesskey "F">
+<!ENTITY menuFavoriteFolder.label "Favorite Folder">
+<!ENTITY menuFavoriteFolder.accesskey "v">
 <!ENTITY folderPropsCmd.label "Properties…">
 <!ENTITY folderPropsFolderCmd.label "Folder Properties…">
 <!ENTITY folderPropsNewsgroupCmd.label "Newsgroup Properties…">
 <!ENTITY folderPropsCmd.accesskey "o">
 <!ENTITY accountManagerCmd.label "Mail &amp; Newsgroups Account Settings…">
 <!ENTITY accountManagerCmd.accesskey "M">
 <!ENTITY undoDeleteMsgCmd.label "Undo Delete Message">
 <!ENTITY redoDeleteMsgCmd.label "Redo Delete Message">
@@ -522,16 +524,18 @@
 <!ENTITY folderContextNew.label "New Subfolder…">
 <!ENTITY folderContextNew.accesskey "N">
 <!ENTITY folderContextSubscribe.label "Subscribe…">
 <!ENTITY folderContextSubscribe.accesskey "b">
 <!ENTITY folderContextSearchMessages.label "Search Messages…">
 <!ENTITY folderContextSearchMessages.accesskey "S">
 <!ENTITY folderContextProperties.label "Properties…">
 <!ENTITY folderContextProperties.accesskey "P">
+<!ENTITY folderContextFavoriteFolder.label "Favorite Folder">
+<!ENTITY folderContextFavoriteFolder.accesskey "a">
 <!ENTITY folderContextSettings.label "Settings…">
 <!ENTITY folderContextSettings.accesskey "e">
 
 <!-- focusSearchInput.key also used by addressbook -->
 <!ENTITY focusSearchInput.key "k">
 <!ENTITY advancedButton.label "Advanced…">
 <!ENTITY advancedButton.accesskey "A">
 <!ENTITY searchButton.label "Search Messages…">
--- a/suite/mailnews/content/mailContextMenus.js
+++ b/suite/mailnews/content/mailContextMenus.js
@@ -259,16 +259,17 @@ function FillFolderPaneContextMenu()
   EnableMenuItem("folderPaneContext-openNewWindow", true);
 
   ShowMenuItem("folderPaneContext-openNewTab", (numSelected <= 1));
   EnableMenuItem("folderPaneContext-openNewTab", true);
 
   SetupRenameMenuItem(folder, numSelected, isServer, serverType, specialFolder);
   SetupRemoveMenuItem(folder, numSelected, isServer, serverType, specialFolder);
   SetupCompactMenuItem(folder, numSelected);
+  SetupFavoritesMenuItem(folder, numSelected, isServer, "folderPaneContext-favoriteFolder");
 
   ShowMenuItem("folderPaneContext-emptyTrash", (numSelected <= 1) && (specialFolder == 'Trash'));
   EnableMenuItem("folderPaneContext-emptyTrash", true);
   ShowMenuItem("folderPaneContext-emptyJunk", (numSelected <= 1) && (specialFolder == 'Junk'));
   EnableMenuItem("folderPaneContext-emptyJunk", true);
 
   var showSendUnsentMessages = (numSelected <= 1) && (specialFolder == 'Outbox');
   ShowMenuItem("folderPaneContext-sendUnsentMessages", showSendUnsentMessages);
@@ -332,16 +333,30 @@ function SetupCompactMenuItem(folder, nu
   let canCompact = folder.canCompact;
   ShowMenuItem("folderPaneContext-compact", numSelected <= 1 && canCompact);
   EnableMenuItem("folderPaneContext-compact", folder.isCommandEnabled("cmd_compactFolder"));
 
   if (canCompact)
     SetMenuItemLabel("folderPaneContext-compact", gMessengerBundle.getString("compactFolder"));
 }
 
+function SetupFavoritesMenuItem(folder, numSelected, isServer, menuItemId)
+{
+  var showItem = !isServer && (numSelected <=1);
+  ShowMenuItem(menuItemId, showItem);
+
+  // adjust the checked state on the menu
+  if (showItem)
+  {
+    document.getElementById(menuItemId)
+            .setAttribute("checked",
+                          folder.getFlag(Ci.nsMsgFolderFlags.Favorite));
+  }
+}
+
 function SetupNewMenuItem(folder, numSelected, isServer, serverType, specialFolder)
 {
   var isInbox = specialFolder == "Inbox";
 
   let showNew = (numSelected <= 1 && serverType != "nntp" &&
                  folder.canCreateSubfolders) || isInbox;
   ShowMenuItem("folderPaneContext-new", showNew);
   EnableMenuItem("folderPaneContext-new",
--- a/suite/mailnews/content/mailWindowOverlay.js
+++ b/suite/mailnews/content/mailWindowOverlay.js
@@ -88,16 +88,30 @@ function file_init()
   document.commandDispatcher.updateCommands('create-menu-file');
 }
 
 function InitEditMessagesMenu()
 {
   goSetMenuValue('cmd_delete', 'valueDefault');
   goSetAccessKey('cmd_delete', 'valueDefaultAccessKey');
   document.commandDispatcher.updateCommands('create-menu-edit');
+
+  // initialize the favorite Folder checkbox in the edit menu
+  let favoriteFolderMenu = document.getElementById("menu_favoriteFolder");
+  if (!favoriteFolderMenu.hasAttribute("disabled")) {
+    let folders = GetSelectedMsgFolders();
+    if (folders.length == 1 && !folders[0].isServer) {
+      let checked = folders[0].getFlag(Ci.nsMsgFolderFlags.Favorite);
+      // Adjust the checked state on the menu item.
+      favoriteFolderMenu.setAttribute("checked", checked);
+      favoriteFolderMenu.hidden = false;
+    } else {
+      favoriteFolderMenu.hidden = true;
+    }
+  }
 }
 
 function InitGoMessagesMenu()
 {
   // deactivate the folders in the go menu if we don't have a folderpane
   document.getElementById("goFolderMenu")
           .setAttribute("disabled", IsFolderPaneCollapsed());
   document.commandDispatcher.updateCommands('create-menu-go');
@@ -1447,16 +1461,22 @@ function ConfirmUnsubscribe(folder)
 function MsgUnsubscribe()
 {
     var folder = GetFirstSelectedMsgFolder();
     if (ConfirmUnsubscribe(folder)) {
         UnSubscribe(folder);
     }
 }
 
+function ToggleFavoriteFolderFlag()
+{
+  var folder = GetFirstSelectedMsgFolder();
+  folder.toggleFlag(Ci.nsMsgFolderFlags.Favorite);
+}
+
 function MsgSaveAsFile()
 {
   SaveAsFile(gFolderDisplay.selectedMessageUris);
 }
 
 function MsgSaveAsTemplate()
 {
   SaveAsTemplate(gFolderDisplay.selectedMessageUris);
--- a/suite/mailnews/content/mailWindowOverlay.xul
+++ b/suite/mailnews/content/mailWindowOverlay.xul
@@ -457,16 +457,22 @@
         oncommand="gFolderTreeController.emptyJunk();"/>
     <menuitem id="folderPaneContext-sendUnsentMessages"
         label="&folderContextSendUnsentMessages.label;"
         accesskey="&folderContextSendUnsentMessages.accesskey;"
         oncommand="goDoCommand('cmd_sendUnsentMsgs')"/>
 
     <menuseparator id="folderPaneContext-sep-edit"/>
 
+    <menuitem id="folderPaneContext-favoriteFolder"
+              type="checkbox"
+              label="&folderContextFavoriteFolder.label;"
+              accesskey="&folderContextFavoriteFolder.accesskey;"
+              checked="false"
+              oncommand="ToggleFavoriteFolderFlag();"/>
     <menuitem id="folderPaneContext-properties"
         label="&folderContextProperties.label;"
         accesskey="&folderContextProperties.accesskey;"
         oncommand="gFolderTreeController.editFolder();"/>
     <menuitem id="folderPaneContext-settings"
               label="&folderContextSettings.label;"
               accesskey="&folderContextSettings.accesskey;"
               oncommand="gFolderTreeController.editFolder();"/>
@@ -621,29 +627,35 @@
           accesskey="&contextMoveMsgMenu.accesskey;"
           oncommand="MsgMoveMessage(event.target._folder);">
       <menupopup id="mailContext-fileHereMenu"
                  type="folder"
                  mode="filing"
                  showFileHereLabel="true"
                  showRecent="true"
                  recentLabel="&contextMoveCopyMsgRecentMenu.label;"
-                 recentAccessKey="&contextMoveCopyMsgRecentMenu.accesskey;"/>
+                 recentAccessKey="&contextMoveCopyMsgRecentMenu.accesskey;"
+                 showFavorites="true"
+                 favoritesLabel="&contextMoveCopyMsgFavoritesMenu.label;"
+                 favoritesAccessKey="&contextMoveCopyMsgFavoritesMenu.accesskey;"/>
     </menu>
     <menu id="mailContext-copyMenu"
           label="&contextCopyMsgMenu.label;"
           accesskey="&contextCopyMsgMenu.accesskey;"
           oncommand="MsgCopyMessage(event.target._folder);">
       <menupopup id="mailContext-copyHereMenu"
                  type="folder"
                  mode="filing"
                  showFileHereLabel="true"
                  showRecent="true"
                  recentLabel="&contextMoveCopyMsgRecentMenu.label;"
-                 recentAccessKey="&contextMoveCopyMsgRecentMenu.accesskey;"/>
+                 recentAccessKey="&contextMoveCopyMsgRecentMenu.accesskey;"
+                 showFavorites="true"
+                 favoritesLabel="&contextMoveCopyMsgFavoritesMenu.label;"
+                 favoritesAccessKey="&contextMoveCopyMsgFavoritesMenu.accesskey;"/>
     </menu>
     <menuitem id="mailContext-saveAs"
               label="&contextSaveAs.label;"
               accesskey="&contextSaveAs.accesskey;"
               oncommand="MsgSaveAsFile();"/>
     <menuitem id="mailContext-delete"
               command="cmd_delete"/>
     <menuseparator id="mailContext-sep-print"/>
@@ -909,16 +921,23 @@
       <menuseparator id="editMenuAfterSelectSeparator"/>
       <menuitem id="menu_find" label="&findCmd.label;"/>
       <menuitem id="menu_findNext"/>
       <menuitem id="menu_findPrev"/>
       <menuseparator id="editMenuAfterFindSeparator"/>
       <menuitem id="menu_findTypeLinks"/>
       <menuitem id="menu_findTypeText"/>
       <menuseparator id="editPropertiesSeparator"/>
+      <menuitem id="menu_favoriteFolder"
+                type="checkbox"
+                label="&menuFavoriteFolder.label;"
+                accesskey="&menuFavoriteFolder.accesskey;"
+                checked="false"
+                oncommand="ToggleFavoriteFolderFlag();"
+                observes="mailHideMenus"/>
       <menuitem id="menu_properties" label="&folderPropsCmd.label;"
                 accesskey="&folderPropsCmd.accesskey;"
                 command="cmd_properties"
                 observes="mailHideMenus"/>
       <menuitem id="menu_accountmgr"
                 label="&accountManagerCmd.label;"
                 accesskey="&accountManagerCmd.accesskey;"
                 oncommand="MsgAccountManager(null);"/>
@@ -1226,17 +1245,20 @@
             accesskey="&folderMenu.accesskey;"
             oncommand="SelectMsgFolder(event.target._folder);"
             observes="mailHideMenus">
         <menupopup id="menu_GoFolderPopup"
                    type="folder"
                    showFileHereLabel="true"
                    showRecent="true"
                    recentLabel="&contextMoveCopyMsgRecentMenu.label;"
-                   recentAccessKey="&contextMoveCopyMsgRecentMenu.accesskey;"/>
+                   recentAccessKey="&contextMoveCopyMsgRecentMenu.accesskey;"
+                   showFavorites="true"
+                   favoritesLabel="&contextMoveCopyMsgFavoritesMenu.label;"
+                   favoritesAccessKey="&contextMoveCopyMsgFavoritesMenu.accesskey;"/>
       </menu>
       <menuseparator id="goFolderSeparator"/>
       <menuitem id="goStartPage" label="&startPageCmd.label;"
                 accesskey="&startPageCmd.accesskey;" command="cmd_goStartPage"
                 observes="mailHideMenus"/>
       <menuseparator id="goNextAfterStartPageSeparator" observes="mailHideMenus"/>
     </menupopup>
   </menu>
@@ -1346,29 +1368,35 @@
            accesskey="&moveMsgToMenu.accesskey;"
            oncommand="MsgMoveMessage(event.target._folder);">
         <menupopup id="menu_MovePopup"
                    type="folder"
                    mode="filing"
                    showFileHereLabel="true"
                    showRecent="true"
                    recentLabel="&moveCopyMsgRecentMenu.label;"
-                   recentAccessKey="&moveCopyMsgRecentMenu.accesskey;"/>
+                   recentAccessKey="&moveCopyMsgRecentMenu.accesskey;"
+                   showFavorites="true"
+                   favoritesLabel="&contextMoveCopyMsgFavoritesMenu.label;"
+                   favoritesAccessKey="&contextMoveCopyMsgFavoritesMenu.accesskey;"/>
     </menu>
     <menu id="copyMenu"
           label="&copyMsgToMenu.label;"
           accesskey="&copyMsgToMenu.accesskey;"
           oncommand="MsgCopyMessage(event.target._folder);">
         <menupopup id="menu_copyPopup"
                    type="folder"
                    mode="filing"
                    showFileHereLabel="true"
                    showRecent="true"
                    recentLabel="&moveCopyMsgRecentMenu.label;"
-                   recentAccessKey="&moveCopyMsgRecentMenu.accesskey;"/>
+                   recentAccessKey="&moveCopyMsgRecentMenu.accesskey;"
+                   showFavorites="true"
+                   favoritesLabel="&contextMoveCopyMsgFavoritesMenu.label;"
+                   favoritesAccessKey="&contextMoveCopyMsgFavoritesMenu.accesskey;"/>
     </menu>
     <menu id="tagMenu" label="&tagMenu.label;" accesskey="&tagMenu.accesskey;">
       <menupopup id="tagMenu-tagpopup" onpopupshowing="InitMessageTags(this)">
         <menuitem id="tagMenu-tagRemoveAll" oncommand="RemoveAllMessageTags();"/>
         <menuseparator id="tagMenuAfterRemoveSeparator"/>
         <menuseparator id="tagMenuBeforeCustomizeSeparator"/>
         <menuitem id="tagMenu-tagCustomize"
                   label="&tagCustomize.label;"
@@ -1637,17 +1665,20 @@
                    tooltiptext="&fileButton.tooltip;"
                    oncommand="MsgMoveMessage(event.target._folder);">
       <menupopup id="button-filePopup"
                  type="folder"
                  mode="filing"
                  showRecent="true"
                  showFileHereLabel="true"
                  recentLabel="&moveCopyMsgRecentMenu.label;"
-                 recentAccessKey="&moveCopyMsgRecentMenu.accesskey;"/>
+                 recentAccessKey="&moveCopyMsgRecentMenu.accesskey;"
+                 showFavorites="true"
+                 favoritesLabel="&contextMoveCopyMsgFavoritesMenu.label;"
+                 favoritesAccessKey="&contextMoveCopyMsgFavoritesMenu.accesskey;"/>
     </toolbarbutton>
 
     <toolbarbutton id="button-goback"
                    class="toolbarbutton-1"
                    type="menu-button"
                    label="&goBackButton.label;"
                    tooltiptext="&goBackButton.tooltip;"
                    observes="button_goBack"