Bug 1437305 - Implement "Initially show attachment pane" pref and UI for composition. r=aceman, ui-r=Paenglab a=jorgk
authorThomas Duellmann <bugzilla2007@duellmann24.net>
Sun, 18 Mar 2018 08:50:18 +0200
changeset 31358 5ace949bc4a44fc83629d557dc51301a7d337303
parent 31357 919d80f33c8fc63b98b08035cca6ef36b1dc11d3
child 31359 d265c609707c59469473b13bf50b24cf7616e1e6
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersaceman, Paenglab, jorgk
bugs1437305
Bug 1437305 - Implement "Initially show attachment pane" pref and UI for composition. r=aceman, ui-r=Paenglab a=jorgk
mail/app/profile/all-thunderbird.js
mail/components/compose/content/MsgComposeCommands.js
mail/components/compose/content/messengercompose.xul
--- a/mail/app/profile/all-thunderbird.js
+++ b/mail/app/profile/all-thunderbird.js
@@ -533,16 +533,18 @@ pref("mail.spotlight.logging.dump", fals
 pref("toolbar.customization.usesheet", true);
 #else
 pref("toolbar.customization.usesheet", false);
 #endif
 
 // Number of recipient rows shown by default
 pref("mail.compose.addresswidget.numRowsShownDefault", 3);
 
+// Start compositions with (empty) attachment pane showing
+pref("mail.compose.show_attachment_pane", false);
 // Check for missing attachments?
 pref("mail.compose.attachment_reminder", true);
 // Words that should trigger a missing attachments warning.
 pref("mail.compose.attachment_reminder_keywords", "chrome://messenger/locale/messengercompose/composeMsgs.properties");
 // When no action is taken on the inline missing attachment notification,
 // show an alert on send?
 pref("mail.compose.attachment_reminder_aggressive", true);
 
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -2970,16 +2970,21 @@ function ComposeStartup(aParams)
       gMsgCompose.compFields.body = "\n<" + body + ">\n";
     }
   }
 
   GetMsgSubjectElement().value = gMsgCompose.compFields.subject;
 
   AddAttachments(gMsgCompose.compFields.attachments);
 
+  if (Services.prefs.getBoolPref(
+      "mail.compose.show_attachment_pane")) {
+    toggleAttachmentPane("show");
+  }
+
   document.getElementById("msgcomposeWindow").dispatchEvent(
     new Event("compose-window-init", { bubbles: false , cancelable: true }));
 
   gMsgCompose.RegisterStateListener(stateListener);
 
   // Add an observer to be called when document is done loading,
   // which creates the editor.
   try {
@@ -5335,16 +5340,29 @@ function reorderAttachmentsPanelOnPopupS
   // required for updating the reorder commands.
   document.getElementById("attachmentBucket").focus();
   // We're updating commands before showing the panel so that button states
   // don't change after the panel is shown, and also because focus is still
   // in attachment bucket right now, which is required for updating them.
   updateReorderAttachmentsItems();
 }
 
+function attachmentHeaderContextOnPopupShowing() {
+  let initiallyShowItem =
+    document.getElementById("attachmentHeaderContext_initiallyShowItem");
+
+  initiallyShowItem.setAttribute("checked", Services.prefs.getBoolPref(
+    "mail.compose.show_attachment_pane"));
+}
+
+function toggleInitiallyShowAttachmentPane(aMenuItem) {
+  Services.prefs.setBoolPref("mail.compose.show_attachment_pane",
+                             aMenuItem.getAttribute("checked"));
+}
+
 function attachmentBucketOnBlur() {
   // Ensure that reorderAttachmentsPanel remains open while we're focused
   // on attachmentBucket or the panel, otherwise hide it.
   let attachmentBucket = document.getElementById("attachmentBucket");
   if (attachmentBucket.getAttribute("data-ignorenextblur") == "true") {
     // Hack to prevent the panel from hiding after RenameSelectedAttachment()
     attachmentBucket.setAttribute("data-ignorenextblur", "false");
     return;
--- a/mail/components/compose/content/messengercompose.xul
+++ b/mail/components/compose/content/messengercompose.xul
@@ -553,16 +553,25 @@
             command="cmd_reorderAttachments"/>
   <menuseparator id="attachmentListContext_removeAllSeparator"/>
   <menuitem id="attachmentListContext_removeAllItem"
             label="&removeAllAttachments.label;"
             accesskey="&removeAllAttachments.accesskey;"
             command="cmd_removeAllAttachments"/>
 </menupopup>
 
+<menupopup id="attachmentHeaderContext"
+           onpopupshowing="attachmentHeaderContextOnPopupShowing();">
+  <menuitem id="attachmentHeaderContext_initiallyShowItem"
+            type="checkbox"
+            label="&initiallyShowAttachmentPane.label;"
+            accesskey="&initiallyShowAttachmentPane.accesskey;"
+            oncommand="toggleInitiallyShowAttachmentPane(this);"/>
+</menupopup>
+
 <menupopup id="toolbar-context-menu"
            onpopupshowing="onViewToolbarsPopupShowing(event, 'compose-toolbox');">
   <menuseparator/>
   <menuitem id="CustomizeComposeToolbar"
             command="cmd_CustomizeComposeToolbar"
             label="&customizeToolbar.label;"
             accesskey="&customizeToolbar.accesskey;"/>
 </menupopup>
@@ -1211,26 +1220,30 @@
         <splitter id="attachmentbucket-sizer"
                   collapsed="true"
                   collapse="after"
                   onmouseup="attachmentBucketSizerOnMouseUp();"/>
         <vbox id="attachments-box" collapsed="true" persist="width">
           <hbox id="attachments-header-box"
                 align="center"
                 tooltiptext="&attachmentBucketHeader.tooltip;"
-                onclick="attachmentBucketHeaderOnClick();">
+                onclick="attachmentBucketHeaderOnClick();"
+                context="attachmentHeaderContext">
             <label id="attachmentBucketCount"
                    accesskey="&attachments.accesskey;"
                    flex="1" crop="end"
+                   context=""
                    control="attachmentBucket"/>
             <toolbarspring/>
-            <label id="attachmentBucketSize"/>
+            <label id="attachmentBucketSize"
+                   context=""/>
             <toolbarbutton id="attachmentBucketCloseButton"
                            class="ab-closebutton close-icon"
                            tooltiptext="&attachmentBucketCloseButton.tooltip;"
+                           context=""
                            oncommand="toggleAttachmentPane('hide');"/>
           </hbox>
           <attachmentlist id="attachmentBucket"
                           tooltiptext=""
                           disableonsend="true"
                           seltype="multiple"
                           orient="vertical"
                           flex="1"