Bug 1635458 - Add print context menu items and print button to address book toolbar. r=frg r=mkmelin
authorIan Neal <iann_cvs@blueyonder.co.uk>
Mon, 04 May 2020 00:04:21 +0100
changeset 39232 a172c7754d7d9721ab93c80fd4d0def59f395563
parent 39231 45df638cd2b2bdb6caaf8d911bb51da84c8a165d
child 39233 1317619f493e6c9718d92299ece67ec97e287254
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewersfrg, mkmelin
bugs1635458, 364133, 485371
Bug 1635458 - Add print context menu items and print button to address book toolbar. r=frg r=mkmelin Add print button to toolbar and port the relevant parts of the following bugs to SeaMonkey: * Bug 364133 - Print command added to address book's context menu * Bug 485371 - New gnomestripe icons for address book
mailnews/addrbook/content/abResultsPane.js
suite/locales/en-US/chrome/mailnews/addressbook/abMainWindow.dtd
suite/mailnews/components/addrbook/content/abCommon.js
suite/mailnews/components/addrbook/content/addressbook.js
suite/mailnews/components/addrbook/content/addressbook.xul
--- a/mailnews/addrbook/content/abResultsPane.js
+++ b/mailnews/addrbook/content/abResultsPane.js
@@ -378,16 +378,18 @@ function InvalidateResultsPane() {
 
 // Controller object for Results Pane
 var ResultsPaneController = {
   supportsCommand(command) {
     switch (command) {
       case "cmd_selectAll":
       case "cmd_delete":
       case "button_delete":
+      case "cmd_printpreview":
+      case "cmd_print":
       case "cmd_printcardpreview":
       case "cmd_printcard":
       case "cmd_properties":
       case "cmd_newlist":
       case "cmd_newCard":
         return true;
       default:
         return false;
@@ -434,16 +436,24 @@ var ResultsPaneController = {
         document.querySelectorAll(`[command=${command}]`).forEach(e => {
           e.disabled = !enabled;
           if (labelAttr && e.hasAttribute(labelAttr)) {
             e.setAttribute("label", e.getAttribute(labelAttr));
           }
         });
         return enabled;
       }
+      case "cmd_printpreview":
+      case "cmd_print":
+        // cmd_printpreview and cmd_print are currently only used in SeaMonkey.
+        let enabled = (GetNumSelectedCards() > 0);
+        document.querySelectorAll("[command=cmd_print]").forEach(e => {
+          e.disabled = !enabled;
+        });
+        return enabled;
       case "cmd_printcardpreview":
       case "cmd_printcard":
         return GetNumSelectedCards() > 0;
       case "cmd_properties": {
         let attrs = {
           label: "valueGeneric",
           accesskey: "valueGenericAccessKey",
           tooltiptext: "valueGenericTooltipText",
@@ -494,16 +504,24 @@ var ResultsPaneController = {
         if (gAbView) {
           gAbView.selection.selectAll();
         }
         break;
       case "cmd_delete":
       case "button_delete":
         AbDelete();
         break;
+      case "cmd_printpreview":
+        // cmd_printpreview is currently only used in SeaMonkey.
+        AbPrintPreviewCard();
+        break;
+      case "cmd_print":
+        // cmd_print is currently only used in SeaMonkey.
+        AbPrintCard();
+        break;
       case "cmd_properties":
         AbEditSelectedCard();
         break;
       case "cmd_newlist":
         AbNewList();
         break;
       case "cmd_newCard":
         AbNewCard();
--- a/suite/locales/en-US/chrome/mailnews/addressbook/abMainWindow.dtd
+++ b/suite/locales/en-US/chrome/mailnews/addressbook/abMainWindow.dtd
@@ -75,26 +75,29 @@
 <!ENTITY editItemButton.label                           "Properties">
 <!ENTITY editItemButton.accesskey                       "P">
 <!ENTITY newmsgButton.label                             "Compose">
 <!ENTITY newmsgButton.accesskey                         "C">
 <!ENTITY deleteItemButton.label                         "Delete">
 <!ENTITY deleteItemButton.accesskey                     "D">
 <!ENTITY newimButton.label                              "Instant Message">
 <!ENTITY newimButton.accesskey                          "I">
+<!ENTITY printButton.label                              "Print">
+<!ENTITY printButton.accesskey                          "r">
 <!ENTITY searchNameAndEmail.placeholder                 "Search Name and Email">
 <!ENTITY searchBox.title                                "Search">
 
 <!-- Tooltips -->
 <!ENTITY addressbookToolbar.tooltip                     "Address Book Toolbar">
 <!ENTITY newContactButton.tooltip                       "Create a new address book contact">
 <!ENTITY newlistButton.tooltip                          "Create a new list">
 <!ENTITY editItemButton.tooltip                         "Edit the selected item">
 <!ENTITY newmsgButton.tooltip                           "Send a mail message">
 <!ENTITY newIM.tooltip                                  "Send an instant message or chat">
+<!ENTITY printButton.tooltip                            "Print selected item">
 <!ENTITY deleteItemButton.tooltip                       "Delete selected item">
 <!ENTITY advancedButton.tooltip                         "Advanced address search">
 
 <!-- Dir Tree header -->
 <!ENTITY dirTreeHeader.label                            "Address Books">
 
 <!-- Card Summary Pane -->
 <!-- Box Headings -->
--- a/suite/mailnews/components/addrbook/content/abCommon.js
+++ b/suite/mailnews/components/addrbook/content/abCommon.js
@@ -37,16 +37,18 @@ var DirPaneController =
   {
     switch (command) {
       case "cmd_selectAll":
       case "cmd_delete":
       case "button_delete":
       case "cmd_properties":
       case "cmd_printcard":
       case "cmd_printcardpreview":
+      case "cmd_print":
+      case "cmd_printpreview":
       case "cmd_newlist":
       case "cmd_newCard":
         return true;
       default:
         return false;
     }
   },
 
@@ -99,16 +101,22 @@ var DirPaneController =
         }
 
         // Else return true to enable deletion (default).
         return true;
       }
       case "cmd_printcard":
       case "cmd_printcardpreview":
         return (GetSelectedCardIndex() != -1);
+      case "cmd_print":
+      case "cmd_printpreview":
+        document.querySelectorAll("[command=cmd_print]").forEach(e => {
+          e.disabled = false;
+        });
+        return true;
       case "cmd_properties":
         return (getSelectedDirectoryURI() != null);
       case "cmd_newlist":
       case "cmd_newCard":
         return true;
       default:
         return false;
     }
@@ -117,16 +125,22 @@ var DirPaneController =
   doCommand: function(command)
   {
     switch (command) {
       case "cmd_printcard":
       case "cmd_printcardpreview":
       case "cmd_selectAll":
         SendCommandToResultsPane(command);
         break;
+      case "cmd_print":
+        AbPrintAddressBook();
+        break;
+      case "cmd_printpreview":
+        AbPrintPreviewAddressBook();
+        break;
       case "cmd_delete":
       case "button_delete":
         if (gDirTree)
           AbDeleteSelectedDirectory();
         break;
       case "cmd_properties":
         AbEditSelectedDirectory();
         break;
--- a/suite/mailnews/components/addrbook/content/addressbook.js
+++ b/suite/mailnews/components/addrbook/content/addressbook.js
@@ -147,16 +147,17 @@ function SetNameColumn(cmd)
 }
 
 function CommandUpdate_AddressBook()
 {
   goUpdateCommand('cmd_delete');
   goUpdateCommand('button_delete');
   goUpdateCommand('cmd_printcardpreview');
   goUpdateCommand('cmd_printcard');
+  goUpdateCommand('cmd_print');
   goUpdateCommand('cmd_properties');
   goUpdateCommand('cmd_newlist');
 }
 
 function ResultsPaneSelectionChanged()
 {
   UpdateCardView();
 }
--- a/suite/mailnews/components/addrbook/content/addressbook.xul
+++ b/suite/mailnews/components/addrbook/content/addressbook.xul
@@ -70,16 +70,18 @@
     <command id="cmd_newNavigator"/>
     <command id="cmd_newPrivateWindow"/>
     <command id="cmd_newEditor"/>
     <command id="cmd_newlist" oncommand="AbNewList();"/>
     <command id="cmd_newCard" oncommand="goDoCommand('cmd_newCard');"/>
     <command id="cmd_newMessage" oncommand="AbNewMessage();"/>
     <command id="cmd_newim" oncommand="AbIMSelected()"/>
     <command id="cmd_printSetup" oncommand="PrintUtils.showPageSetup()"/>
+    <command id="cmd_print" oncommand="goDoCommand('cmd_print');"/>
+    <command id="cmd_printpreview" oncommand="goDoCommand('cmd_printpreview');"/>
     <command id="cmd_printcard" oncommand="AbPrintCard()"/>
     <command id="cmd_printcardpreview" oncommand="AbPrintPreviewCard()"/>
     <command id="cmd_printAddressBook" oncommand="AbPrintAddressBook()"/>
     <command id="cmd_printPreviewAddressBook" oncommand="AbPrintPreviewAddressBook()"/>
     <command id="cmd_close" oncommand="AbClose()"/>
     <command id="cmd_properties" oncommand="goDoCommand('cmd_properties');"/>
     <command id="cmd_undo"/>
     <command id="cmd_redo"/>
@@ -171,16 +173,20 @@
             label="&newContactButton.label;"
             accesskey="&newContactButton.accesskey;"
             command="cmd_newCard"/>
   <menuitem id="dirTreeContext-newlist"
             label="&newlistButton.label;"
             accesskey="&newlistButton.accesskey;"
             command="cmd_newlist"/>
   <menuseparator/>
+  <menuitem id="dirTreeContext-print"
+            label="&printButton.label;"
+            accesskey="&printButton.accesskey;"
+            command="cmd_printAddressBook"/>
   <menuitem id="dirTreeContext-delete"
             label="&deleteItemButton.label;"
             accesskey="&deleteItemButton.accesskey;"
             command="button_delete"/>
 </menupopup>
 
 <menupopup id="abResultsTreeContext">
   <menuitem id="abResultsTreeContext-properties"
@@ -192,16 +198,20 @@
             label="&newmsgButton.label;"
             accesskey="&newmsgButton.accesskey;"
             command="cmd_newMessage"/>
   <menuitem id="abResultsTreeContext-newim"
             label="&newimButton.label;"
             accesskey="&newimButton.accesskey;"
             command="cmd_newim"/>
   <menuseparator/>
+  <menuitem id="abResultsTreeContext-print"
+            label="&printButton.label;"
+            accesskey="&printButton.accesskey;"
+            command="cmd_printcard"/>
   <menuitem id="abResultsTreeContext-delete"
             label="&deleteItemButton.label;"
             accesskey="&deleteItemButton.accesskey;"
             command="button_delete"/>
 </menupopup>
 
 <menupopup id="toolbar-context-menu"/>
 
@@ -256,31 +266,35 @@
                           accesskey="&newMessageCmd.accesskey;"
                           key="key_newMessage"
                           command="cmd_newMessage"/>
                 <menuitem id="menu_newEditor"/>
               </menupopup>
             </menu>
             <menuitem id="menu_close"/>
             <menuseparator/>
-            <menuitem id="menu_printSetup"/>
 #ifndef XP_MACOSX
             <menuitem id="printPreviewMenuItem"
                       label="&printPreviewContactViewCmd.label;"
                       accesskey="&printPreviewContactViewCmd.accesskey;"
                       command="cmd_printcardpreview"/>
+#endif
+            <menuitem id="printMenuItem" label="&printContactViewCmd.label;"
+                      accesskey="&printContactViewCmd.accesskey;"
+                      key="key_printCard"
+                      command="cmd_printcard"/>
+            <menuseparator id="menu_PageSetupSeparator"/>
+            <menuitem id="menu_printSetup"/>
+            <menuseparator id="menu_PrintAddrbookSeparator"/>
+#ifndef XP_MACOSX
             <menuitem id="printPreviewAddressBook"
                       label="&printPreviewAddressBook.label;"
                       accesskey="&printPreviewAddressBook.accesskey;"
                       command="cmd_printPreviewAddressBook"/>
 #endif
-            <menuitem id="printMenuItem" label="&printContactViewCmd.label;"
-                      accesskey="&printContactViewCmd.accesskey;"
-                      key="key_printCard"
-                      command="cmd_printcard"/>
             <menuitem id="printAddressBook"
                       label="&printAddressBook.label;"
                       accesskey="&printAddressBook.accesskey;"
                       command="cmd_printAddressBook"/>
           </menupopup>
         </menu>
 
         <menu id="menu_Edit">
@@ -497,16 +511,20 @@
                    removable="true"
                    oncommand="AbIMSelected();"/>
     <toolbarbutton id="button-abdelete"
                    class="toolbarbutton-1"
                    label="&deleteItemButton.label;"
                    tooltiptext="&deleteItemButton.tooltip;"
                    removable="true"
                    oncommand="goDoCommand('button_delete');"/>
+    <toolbarbutton id="print-button"
+                   label="&printButton.label;"
+                   tooltiptext="&printButton.tooltip;"
+                   removable="true"/>
     <toolbaritem id="searchBox"
                  flex="1"
                  title="&searchBox.title;"
                  removable="true"
                  align="center"
                  class="toolbaritem-noline chromeclass-toolbar-additional">
       <textbox id="searchInput"
                flex="1"