Bug 606683 - Allow customization of toolbars in Composer and formatting toolbar in MailNews Composition. Patch Tidy up some broadcasters and commandsets v2.2
authorIan Neal <iann_cvs@blueyonder.co.uk>
Wed, 02 Mar 2011 23:02:49 +0000
changeset 7243 369ad40b3fc1a996fce7df5942102c022a78ac10
parent 7242 81a7fdd8816b6a16e1cf58cb374c7bf42d9d84cd
child 7244 a4afd59a66b2d9d6ae44344c4f3d1c30cdd86ca3
push idunknown
push userunknown
push dateunknown
bugs606683
Bug 606683 - Allow customization of toolbars in Composer and formatting toolbar in MailNews Composition. Patch Tidy up some broadcasters and commandsets v2.2 r=neil
editor/ui/composer/content/editor.xul
editor/ui/composer/content/editorOverlay.xul
editor/ui/locales/en-US/chrome/composer/editor.dtd
editor/ui/locales/en-US/chrome/composer/editorOverlay.dtd
suite/debugQA/content/debugQATextEditorShell.xul
suite/mailnews/compose/MsgComposeCommands.js
suite/mailnews/compose/messengercompose.xul
--- a/editor/ui/composer/content/editor.xul
+++ b/editor/ui/composer/content/editor.xul
@@ -20,16 +20,17 @@
    - Netscape Communications Corporation.
    - Portions created by the Initial Developer are Copyright (C) 1999-2000
    - the Initial Developer. All Rights Reserved.
    -
    - Contributor(s):
    -   Ben Goodger
    -   Michael Lowe
    -   Sammy Ford
+   -   Ian Neal
    -
    - Alternatively, the contents of this file may be used under the terms of
    - either of the GNU General Public License Version 2 or later (the "GPL"),
    - or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    - in which case the provisions of the GPL or the LGPL are applicable instead
    - of those above. If you wish to allow use of your version of this file only
    - under the terms of either the GPL or the LGPL, and not to allow others to
    - use your version of this file under the terms of the MPL, indicate your
@@ -90,43 +91,41 @@
   <script type="application/javascript" src="chrome://communicator/content/contentAreaClick.js"/>
   <script type="application/javascript" src="chrome://global/content/printUtils.js"/>
   <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
 
   <popupset id="editorContentContextSet"/>
   <menupopup id="sidebarPopup"/>
   <menupopup id="popupNotificationMenu"/>
 
-  <commandset id="tasksCommands">
-    <commandset id="globalEditMenuItems"/>
-    <commandset id="selectEditMenuItems"/>
-    <commandset id="undoEditMenuItems"/>
-    <commandset id="clipboardEditMenuItems"/>
-    
+  <commandset id="editorCommands">
     <commandset id="commonEditorMenuItems"/>
     <commandset id="composerMenuItems"/>
     <commandset id="composerEditMenuItems"/>
     <commandset id="composerSaveMenuItems"/>    
     <commandset id="composerStyleMenuItems"/>
     <commandset id="composerTableMenuItems"/>
     <commandset id="composerListMenuItems"/>
-    <command id="toggleSidebar"/>
+    <commandset id="tasksCommands"/>
+    <!-- view menu -->
+    <command id="cmd_viewEditModeToolbar"
+             oncommand="goToggleToolbar('EditModeToolbar','cmd_viewEditModeToolbar');"
+             checked="true"/>
   </commandset>
 
   <tooltip id="aHTMLTooltip" onpopupshowing="return FillInHTMLTooltipEditor(this);"/>
 
-  <broadcaster id="args" value="about:blank"/>
-  
   <!-- Interim hack to transition from nsIXULWindowCallbacks/ShowWindowWithArgs
   <broadcaster id="dialog.start" ready="false"/>
   <observes element="dialog.start" attribute="ready" onbroadcast="EditorStartup('html')"/>
 -->
-  <broadcasterset id="broadcasterset">
+  <broadcasterset id="editorBroadcasters">
     <broadcaster id="Editor:Throbber" busy="false"/>
     <broadcaster id="Communicator:WorkMode"/>
+    <broadcaster id="args" value="about:blank"/>
   </broadcasterset>
 
   <!-- keys are appended from the overlay -->
   <keyset id="editorKeys">
     <keyset id="tasksKeys"/>
     <key id="showHideSidebar"/>
     <!-- eat these tab events here to stop focus from moving -->
     <key keycode="VK_TAB" oncommand="return true;"/>
--- a/editor/ui/composer/content/editorOverlay.xul
+++ b/editor/ui/composer/content/editorOverlay.xul
@@ -290,27 +290,31 @@
     <command id="cmd_NormalizeTable"      oncommand="goDoCommand('cmd_NormalizeTable')"/>
     <command id="cmd_JoinTableCells"      oncommand="goDoCommand('cmd_JoinTableCells')"/>
     <command id="cmd_SplitTableCell"      oncommand="goDoCommand('cmd_SplitTableCell')"/>
     <command id="cmd_ConvertToTable"      oncommand="goDoCommand('cmd_ConvertToTable')"/>
     <command id="cmd_TableOrCellColor"    oncommand="goDoCommand('cmd_TableOrCellColor')"/>
     <command id="cmd_editTable"           oncommand="goDoCommand('cmd_editTable')"/>
   </commandset>
 
-  <broadcasterset id="broadcasterset">
-    <!-- Broadcasters/commands with no other home -->
-    <!-- view menu -->
+  <commandset id="editorCommands">
+    <commandset id="globalEditMenuItems"/>
+    <commandset id="selectEditMenuItems"/>
+    <commandset id="undoEditMenuItems"/>
+    <commandset id="clipboardEditMenuItems"/>
+    <command id="toggleSidebar"/>
+    <!-- file menu -->
     <command id="cmd_newNavigator"/>
     <command id="cmd_newEditor"/>
     <command id="cmd_newEditorTemplate"/>
     <command id="cmd_newEditorDraft"/>
+    <!-- view menu -->
     <command id="cmd_viewCompToolbar"     oncommand="goToggleToolbar('EditToolbar','cmd_viewCompToolbar');"         checked="true"/>
     <command id="cmd_viewFormatToolbar"   oncommand="goToggleToolbar('FormatToolbar','cmd_viewFormatToolbar');"     checked="true"/>
-    <command id="cmd_viewEditModeToolbar" oncommand="goToggleToolbar('EditModeToolbar','cmd_viewEditModeToolbar');" checked="true"/>
-  </broadcasterset>
+  </commandset>
 
   <!-- File  menu items -->
   <!-- Note: globalOverlay.xul uses menu_newEditor, but we want different menu item text
              so we use our own id, label, and accesskey but connect to the same global key and broadcaster node
    -->
   <menu id="fileMenu" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;">
     <menupopup id="menu_FilePopup" onpopupshowing="EditorInitFileMenu();">
       <menu id="menu_New">
--- a/editor/ui/locales/en-US/chrome/composer/editor.dtd
+++ b/editor/ui/locales/en-US/chrome/composer/editor.dtd
@@ -37,16 +37,19 @@
 
 <!-- Window title -->
 <!-- LOCALIZATION NOTE  (editorWindow.titlemodifier): DONT_TRANSLATE -->
 <!ENTITY editorWindow.titlemodifier "Composer"> 
 <!ENTITY editorWindow.titlemodifiermenuseparator " - ">
 
 <!-- Menu items:  the . means that the menu item isn't implemented yet -->
 
+<!-- Toolbar-only items -->
+<!ENTITY compositionToolbar.tooltip "Composition Toolbar">
+
 <!-- View menu items -->
 <!ENTITY viewMenu.label "View">
 <!ENTITY viewMenu.accesskey "V">
 <!ENTITY compositionToolbarCmd.label "Composition Toolbar">
 <!ENTITY compositionToolbarCmd.accesskey "C">
 <!ENTITY formattingToolbarCmd.label "Format Toolbar">
 <!ENTITY formattingToolbarCmd.accesskey "F">
 <!ENTITY editmodeToolbarCmd.label "Edit Mode Toolbar">
--- a/editor/ui/locales/en-US/chrome/composer/editorOverlay.dtd
+++ b/editor/ui/locales/en-US/chrome/composer/editorOverlay.dtd
@@ -400,17 +400,16 @@
 <!ENTITY tableSplitCell.accesskey "C">
 <!ENTITY convertToTable.label "Create Table from Selection">
 <!ENTITY convertToTable.accesskey "r">
 <!ENTITY tableProperties.label "Table Properties…">
 <!ENTITY tableProperties.accesskey "o">
 
 <!-- Toolbar-only items -->
 <!ENTITY menuBar.tooltip "Menu Bar">
-<!ENTITY compositionToolbar.tooltip "Composition Toolbar">
 <!ENTITY formatToolbar.tooltip "Formatting Toolbar">
 <!ENTITY newToolbarCmd.tooltip "Create a new Composer page">
 <!ENTITY openToolbarCmd.label "Open">
 <!ENTITY openToolbarCmd.tooltip "Open a local file">
 <!ENTITY saveToolbarCmd.tooltip "Save file to a local location">
 <!ENTITY publishToolbarCmd.tooltip "Upload file to a remote location">
 <!ENTITY previewToolbarCmd.label "Browse">
 <!ENTITY previewToolbarCmd.tooltip "Load this page in the browser">
--- a/suite/debugQA/content/debugQATextEditorShell.xul
+++ b/suite/debugQA/content/debugQATextEditorShell.xul
@@ -18,16 +18,17 @@
    -
    - The Initial Developer of the Original Code is
    - Netscape Communications Corporation.
    - Portions created by the Initial Developer are Copyright (C) 1998-1999
    - the Initial Developer. All Rights Reserved.
    -
    - Contributor(s):
    -   Ryan Cassin (rcassin@supernova.org)
+   -   Ian Neal (iann_bugzilla@blueyonder.co.uk)
    -
    - Alternatively, the contents of this file may be used under the terms of
    - either of the GNU General Public License Version 2 or later (the "GPL"),
    - or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    - in which case the provisions of the GPL or the LGPL are applicable instead
    - of those above. If you wish to allow use of your version of this file only
    - under the terms of either the GPL or the LGPL, and not to allow others to
    - use your version of this file under the terms of the MPL, indicate your
@@ -74,38 +75,34 @@
         width="640" height="480"
         screenX="10" screenY="10"
         persist="screenX screenY width height sizemode">
 
   <script type="application/javascript" src="chrome://editor/content/editor.js"/>
   <script type="application/javascript" src="chrome://editor/content/ComposerCommands.js"/>
   <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
 
-  <commands id="commands">
-    <commandset id="globalEditMenuItems"/>
-    <commandset id="selectEditMenuItems"/>
-    <commandset id="undoEditMenuItems"/>
-    <commandset id="clipboardEditMenuItems"/>
+  <commandset id="editorCommands">
     <commandset id="commonEditorMenuItems"/>
     <commandset id="composerEditMenuItems"/>
     <commandset id="composerSaveMenuItems"/>
     <commandset id="composerMenuItems"/>
     <commandset id="tasksCommands"/>
-  </commands>
-
-  <broadcaster id="args" value="chrome://debugqa/content/EditorInitPagePlain.html"/>
+  </commandset>
 
 <!-- Interim hack to transition from nsIXULWindowCallbacks/ShowWindowWithArgs
   <broadcaster id="dialog.start" ready="false"/>
   <observes element="dialog.start" attribute="ready" onbroadcast="EditorStartup('text')"/>
  -->
 
   <!-- broadcaster nodes are appended here from the overlays -->
-  <broadcasterset id="broadcasterset">
+  <broadcasterset id="editorBroadcasters">
     <broadcaster id="Editor:Throbber" busy="false"/>
+    <broadcaster id="args"
+                 value="chrome://debugqa/content/EditorInitPagePlain.html"/>
   </broadcasterset>
 
   <!-- keys are appended from the overlay -->
   <keyset id="editorKeys">
     <keyset id="tasksKeys"/>
     <key id="showHideSidebar"/>
   </keyset>
 
@@ -142,17 +139,20 @@
 
       <!-- help menu filled from globalOverlay -->
       <menu id="menu_Help"/>
 
       <spacer flex="1"/>
     </menubar>
 
      <!-- toolbar filled out from editorOverlay -->
-    <toolbar class="toolbar-primary" id="EditToolbar" persist="collapsed">
+    <toolbar id="EditToolbar"
+             class="chromeclass-toolbar toolbar-primary"
+             persist="collapsed"
+             grippytooltiptext="&compositionToolbar.tooltip;">
       <toolbarbutton id="newButton"/>
       <toolbarbutton id="openButton"/>
       <toolbarbutton id="saveButton"/>
       <toolbarbutton id="printButton"/>
       <toolbarseparator class="toolbarseparator-primary"/>
       <toolbarbutton id="spellingButton"/>
       <spacer flex="1"/>
     </toolbar>
--- a/suite/mailnews/compose/MsgComposeCommands.js
+++ b/suite/mailnews/compose/MsgComposeCommands.js
@@ -418,20 +418,16 @@ var defaultController =
       //Edit Menu
       case "cmd_delete":
       case "cmd_renameAttachment":
       case "cmd_selectAll":
       case "cmd_openAttachment":
       case "cmd_account":
       case "cmd_preferences":
 
-      //View Menu
-      case "cmd_showComposeToolbar":
-      case "cmd_showFormatToolbar":
-
       //Options Menu
       case "cmd_selectAddress":
       case "cmd_outputFormat":
       case "cmd_quoteMessage":
         return true;
 
       default:
 //        dump("##MsgCompose: command " + command + "no supported!\n");
@@ -471,22 +467,16 @@ var defaultController =
       case "cmd_selectAll":
         return MessageHasAttachments();
       case "cmd_openAttachment":
         return MessageGetNumSelectedAttachments() == 1;
       case "cmd_account":
       case "cmd_preferences":
         return true;
 
-      //View Menu
-      case "cmd_showComposeToolbar":
-        return true;
-      case "cmd_showFormatToolbar":
-        return composeHTML;
-
       //Options Menu
       case "cmd_selectAddress":
         return !gWindowLocked;
       case "cmd_outputFormat":
         return composeHTML;
       case "cmd_quoteMessage":
         var selectedURIs = GetSelectedMessages();
         if (selectedURIs && selectedURIs.length > 0)
@@ -529,20 +519,16 @@ var defaultController =
       //Edit Menu
       case "cmd_delete"             : if (MessageGetNumSelectedAttachments() > 0) RemoveSelectedAttachment();  break;
       case "cmd_renameAttachment"   : if (MessageGetNumSelectedAttachments() == 1) RenameSelectedAttachment(); break;
       case "cmd_selectAll"          : if (MessageHasAttachments()) SelectAllAttachments();                     break;
       case "cmd_openAttachment"     : if (MessageGetNumSelectedAttachments() == 1) OpenSelectedAttachment();   break;
       case "cmd_account"            : MsgAccountManager(null); break;
       case "cmd_preferences"        : DoCommandPreferences(); break;
 
-      //View Menu
-      case "cmd_showComposeToolbar" : goToggleToolbar('composeToolbar', 'menu_showComposeToolbar'); break;
-      case "cmd_showFormatToolbar"  : goToggleToolbar('FormatToolbar', 'menu_showFormatToolbar');   break;
-
       //Options Menu
       case "cmd_selectAddress"      : if (defaultController.isCommandEnabled(command)) SelectAddress();         break;
       case "cmd_quoteMessage"       : if (defaultController.isCommandEnabled(command)) QuoteSelectedMessage();  break;
       default:
 //        dump("##MsgCompose: don't know what to do with command " + command + "!\n");
         return;
     }
   },
--- a/suite/mailnews/compose/messengercompose.xul
+++ b/suite/mailnews/compose/messengercompose.xul
@@ -19,17 +19,17 @@
    - Netscape Communications Corporation.
    - Portions created by the Initial Developer are Copyright (C) 1999
    - the Initial Developer. All Rights Reserved.
    -
    - Contributor(s):
    -   Ben Goodger <ben@netscape.com> (ass'td polish fixes)
    -   Håkan Waara <hwaara@chello.se>
    -   Neil Rashbrook <neil@parkwaycc.co.uk> (ass'td polish fix)
-   -   Ian Neal <bugzilla@arlen.demon.co.uk>
+   -   Ian Neal <iann_bugzilla@blueyonder.co.uk>
    -
    - Alternatively, the contents of this file may be used under the terms of
    - either of the GNU General Public License Version 2 or later (the "GPL"),
    - or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    - in which case the provisions of the GPL or the LGPL are applicable instead
    - of those above. If you wish to allow use of your version of this file only
    - under the terms of either the GPL or the LGPL, and not to allow others to
    - use your version of this file under the terms of the MPL, indicate your
@@ -103,31 +103,25 @@
 <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
 
 <commandset id="composeCommands">
   <commandset id="msgComposeCommandUpdate"
     commandupdater="true"
     events="focus"
     oncommandupdate="CommandUpdate_MsgCompose()"/>
 
-  <commandset id="globalEditMenuItems"/>
-  <commandset id="selectEditMenuItems"/>
-  <commandset id="undoEditMenuItems"/>
-  <commandset id="clipboardEditMenuItems"/>
-
+  <commandset id="editorCommands"/>
   <commandset id="commonEditorMenuItems"/>
   <commandset id="composerMenuItems"/>
   <commandset id="composerEditMenuItems"/>
   <commandset id="composerStyleMenuItems"/>
   <commandset id="composerTableMenuItems"/>
   <commandset id="composerListMenuItems"/>
   <commandset id="tasksCommands"/>
   <!-- File Menu -->
-  <command id="cmd_newNavigator"/>
-  <command id="cmd_newEditor"/>
   <command id="cmd_new" oncommand="goDoCommand('cmd_newMessage')"/>
   <command id="cmd_attachFile" oncommand="goDoCommand('cmd_attachFile')"/>
   <command id="cmd_attachPage" oncommand="goDoCommand('cmd_attachPage')"/>
   <command id="cmd_attachVCard" checked="false" oncommand="ToggleAttachVCard(event.target)"/>
   <command id="cmd_saveDefault" oncommand="goDoCommand('cmd_saveDefault')"/>
   <command id="cmd_saveAsFile" oncommand="goDoCommand('cmd_saveAsFile')"/>
   <command id="cmd_saveAsDraft" oncommand="goDoCommand('cmd_saveAsDraft')"/>
   <command id="cmd_saveAsTemplate" oncommand="goDoCommand('cmd_saveAsTemplate')"/>
@@ -141,30 +135,29 @@
   <!--command id="cmd_find"/-->
   <!--command id="cmd_findNext"/-->
   <command id="cmd_rewrap"  oncommand="goDoCommand('cmd_rewrap')"/>
   <command id="cmd_renameAttachment" oncommand="goDoCommand('cmd_renameAttachment')" disabled="true"/>
   <command id="cmd_openAttachment" oncommand="goDoCommand('cmd_openAttachment')"/>
   <command id="cmd_account" oncommand="goDoCommand('cmd_account')"/>
 
   <!-- View Menu -->
-  <command id="cmd_showComposeToolbar" oncommand="goDoCommand('cmd_showComposeToolbar')"/>
-  <command id="cmd_showFormatToolbar" oncommand="goDoCommand('cmd_showFormatToolbar')"/>
-  <command id="toggleSidebar"/>
+  <command id="cmd_viewComposeToolbar"
+           oncommand="goToggleToolbar('composeToolbar', 'cmd_viewComposeToolbar');"
+           checked="true"/>
 
   <!-- Options Menu -->
   <command id="cmd_selectAddress" oncommand="goDoCommand('cmd_selectAddress')"/>
   <command id="cmd_outputFormat" oncommand="OutputFormatMenuSelect(event.target)"/>
   <command id="cmd_quoteMessage" oncommand="goDoCommand('cmd_quoteMessage')"/>
 
   <command id="cmd_CustomizeToolbars" oncommand="goCustomizeToolbar(getMailToolbox());"/>
 </commandset>
 
 <broadcasterset id="composeBroadcasters">
-  <broadcaster id="Editor:Throbber" busy="false"/>
   <broadcaster id="Communicator:WorkMode"/>
   <broadcaster id="args" value="editorType=default"/>
 </broadcasterset>
 
 <keyset id="tasksKeys">
   <!-- File Menu -->
   <key id="key_close"/>
   <key id="key_save"  key="&saveCmd.key;" command="cmd_saveDefault" modifiers="accel"/>
@@ -421,24 +414,22 @@
           <menu id="menu_View">
             <menupopup id="menu_View_Popup">
               <menu id="menu_Toolbars">
                 <menupopup id="view_toolbars_popup">
                   <menuitem id="menu_showComposeToolbar"
                             type="checkbox"
                             label="&showComposeToolbarCmd.label;"
                             accesskey="&showComposeToolbarCmd.accesskey;"
-                            command="cmd_showComposeToolbar"
-                            checked="true"/>
+                            command="cmd_viewComposeToolbar"/>
                   <menuitem id="menu_showFormatToolbar"
                             type="checkbox"
                             label="&showFormatToolbarCmd.label;"
                             accesskey="&showFormatToolbarCmd.accesskey;"
-                            command="cmd_showFormatToolbar"
-                            checked="true"/>
+                            command="cmd_viewFormatToolbar"/>
                   <menuitem id="menu_showTaskbar"/>
                 </menupopup>
               </menu>
             </menupopup>
           </menu>
 
           <menu id="insertMenu"
                 command="cmd_renderedHTMLEnabler"/>
@@ -582,17 +573,17 @@
     <toolbar id="composeToolbar"
              class="toolbar-primary chromeclass-toolbar"
              persist="collapsed"
              grippytooltiptext="&mailToolbar.tooltip;"
              toolbarname="&showComposeToolbarCmd.label;"
              accesskey="&showComposeToolbarCmd.accesskey;"
              customizable="true"
              defaultset="button-send,separator,button-address,button-attach,spellingButton,button-security,separator,button-save,spring,throbber-box"
-             togglemenuitem="menu_showComposeToolbar"
+             togglemenuitem="cmd_viewComposeToolbar"
              context="toolbar-context-menu">
     </toolbar>
 
     <toolbarset id="customToolbars" context="toolbar-context-menu"/>
 
     <toolbar id="MsgHeadersToolbar"
              persist="collapsed"
              flex="1"