Bug 490282 - Trigger choice of customization sheet from a pref instead of a build-time widget ifdef, r=Standard8
authorPhil Ringnalda <philringnalda@gmail.com>
Mon, 27 Apr 2009 20:09:46 -0700
changeset 2504 bc4a5c45d3ac508fde8255e7093b0002439cf42a
parent 2503 c8cdbc3a283c736fd37e424dc430a6889ecffb49
child 2505 fcb4e943da8e9c94d5deb95f0799d750f937625f
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs490282
Bug 490282 - Trigger choice of customization sheet from a pref instead of a build-time widget ifdef, r=Standard8
mail/app/profile/all-thunderbird.js
mail/base/Makefile.in
mail/base/content/mailCore.js
mail/base/content/messageWindow.xul
mail/base/content/messenger.xul
mail/components/addrbook/Makefile.in
mail/components/addrbook/content/addressbook.xul
mail/components/compose/Makefile.in
mail/components/compose/content/messengercompose.xul
--- a/mail/app/profile/all-thunderbird.js
+++ b/mail/app/profile/all-thunderbird.js
@@ -441,8 +441,15 @@ pref("mail.winsearch.logging.dump", fals
 #else
 #ifdef XP_MACOSX
 // Should we output warnings and errors to the "error console"?
 pref("mail.spotlight.logging.console", false);
 // Should we output all output levels to stdout via dump?
 pref("mail.spotlight.logging.dump", false);
 #endif
 #endif
+
+// Whether to use a panel that looks like an OS X sheet for customization
+#ifdef XP_MACOSX
+pref("toolbar.customization.usesheet", true);
+#else
+pref("toolbar.customization.usesheet", false);
+#endif
--- a/mail/base/Makefile.in
+++ b/mail/base/Makefile.in
@@ -51,13 +51,9 @@ endif
 ifneq (,$(filter windows gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
 DEFINES += -DHAVE_SHELL_SERVICE=1
 endif
 
 ifdef MOZ_UPDATER
 DEFINES += -DMOZ_UPDATER=1
 endif
 
-ifeq (cocoa, $(MOZ_WIDGET_TOOLKIT))
-DEFINES += -DTOOLBAR_CUSTOMIZATION_SHEET
-endif
-
 include $(topsrcdir)/config/rules.mk
--- a/mail/base/content/mailCore.js
+++ b/mail/base/content/mailCore.js
@@ -37,62 +37,70 @@
 # ***** END LICENSE BLOCK *****
 
 /*
  * Core mail routines used by all of the major mail windows (address book, 3-pane, compose and stand alone message window).
  * Routines to support custom toolbars in mail windows, opening up a new window of a particular type all live here. 
  * Before adding to this file, ask yourself, is this a JS routine that is going to be used by all of the main mail windows?
  */
 
+var gCustomizeSheet = false;
+
 function CustomizeMailToolbar(toolboxId, customizePopupId)
 {
   // Disable the toolbar context menu items
   var menubar = document.getElementById("mail-menubar");
   for (var i = 0; i < menubar.childNodes.length; ++i)
     menubar.childNodes[i].setAttribute("disabled", true);
 
   var customizePopup = document.getElementById(customizePopupId);
   customizePopup.setAttribute("disabled", "true");
 
   var toolbox = document.getElementById(toolboxId);
 
   var customizeURL = "chrome://global/content/customizeToolbar.xul";
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
-  var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
-  sheetFrame.hidden = false;
-  sheetFrame.toolbox = toolbox;
+  let prefSvc = Components.classes["@mozilla.org/preferences-service;1"]
+                          .getService(Components.interfaces.nsIPrefService)
+                          .getBranch(null);
+  gCustomizeSheet = prefSvc.getBoolPref("toolbar.customization.usesheet");
 
-  // The document might not have been loaded yet, if this is the first time.
-  // If it is already loaded, reload it so that the onload intialization code
-  // re-runs.
-  if (sheetFrame.getAttribute("src") == customizeURL)
-    sheetFrame.contentWindow.location.reload()
-  else
-    sheetFrame.setAttribute("src", customizeURL);
+  if (gCustomizeSheet) {
+    var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
+    sheetFrame.hidden = false;
+    sheetFrame.toolbox = toolbox;
 
-  var sheetWidth = sheetFrame.style.width.match(/([0-9]+)px/)[1];
-  document.getElementById("customizeToolbarSheetPopup")
-          .openPopup(toolbox, "after_start",
-                     (window.innerWidth - sheetWidth) / 2, 0);
-#else
-  var wintype = document.documentElement.getAttribute("windowtype");
-  wintype = wintype.replace(/:/g, "");
+    // The document might not have been loaded yet, if this is the first time.
+    // If it is already loaded, reload it so that the onload intialization code
+    // re-runs.
+    if (sheetFrame.getAttribute("src") == customizeURL)
+      sheetFrame.contentWindow.location.reload()
+    else
+      sheetFrame.setAttribute("src", customizeURL);
 
-  window.openDialog(customizeURL,
-                    "CustomizeToolbar"+wintype,
-                    "chrome,all,dependent", toolbox);
-#endif
+    var sheetWidth = sheetFrame.style.width.match(/([0-9]+)px/)[1];
+    document.getElementById("customizeToolbarSheetPopup")
+            .openPopup(toolbox, "after_start",
+                       (window.innerWidth - sheetWidth) / 2, 0);
+  }
+  else {
+    var wintype = document.documentElement.getAttribute("windowtype");
+    wintype = wintype.replace(/:/g, "");
+
+    window.openDialog(customizeURL,
+                      "CustomizeToolbar"+wintype,
+                      "chrome,all,dependent", toolbox);
+  }
 }
 
 function MailToolboxCustomizeDone(aEvent, customizePopupId)
 {
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
-  document.getElementById("customizeToolbarSheetIFrame").hidden = true;
-  document.getElementById("customizeToolbarSheetPopup").hidePopup();
-#endif
+  if (gCustomizeSheet) {
+    document.getElementById("customizeToolbarSheetIFrame").hidden = true;
+    document.getElementById("customizeToolbarSheetPopup").hidePopup();
+  }
 
   // Update global UI elements that may have been added or removed
 
   // Re-enable parts of the UI we disabled during the dialog
   var menubar = document.getElementById("mail-menubar");
   for (var i = 0; i < menubar.childNodes.length; ++i)
     menubar.childNodes[i].setAttribute("disabled", false);
 
--- a/mail/base/content/messageWindow.xul
+++ b/mail/base/content/messageWindow.xul
@@ -45,20 +45,18 @@
 <?xul-overlay href="chrome://messenger/content/mailOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/editContactOverlay.xul"?>
 
 <!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
 %messengerDTD;
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
 <!ENTITY % customizeToolbarDTD SYSTEM "chrome://global/locale/customizeToolbar.dtd">
 %customizeToolbarDTD;
-#endif
 ]>
 
 <window id="messengerWindow"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="&titledefault.label;"
         titlemodifier="&titledefault.label;"
         titlemenuseparator="&titleSeparator.label;"
         onload="OnLoadMessageWindow()"
@@ -173,18 +171,16 @@
              style="height: 0px; min-height: 1px" flex="1" name="messagepane"
              disablesecurity="true" disablehistory="true" type="content-primary"
              onresize="return messagePaneOnResize(event);" autofind="false"
              src="about:blank" onclick="return contentAreaClick(event);" />
     <splitter id="attachment-splitter" collapse="after" resizebefore="closest" resizeafter="closest" collapsed="true"/>
     <hbox id="attachmentView"/>
     <findbar id="FindToolbar" browserid="messagepane"/>
   </vbox>
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
   <panel id="customizeToolbarSheetPopup" noautohide="true">
     <iframe id="customizeToolbarSheetIFrame"
             style="&dialog.style;"
             hidden="true"/>
   </panel>
-#endif
 
   <statusbar class="chromeclass-status" id="status-bar"/>
 </window>
--- a/mail/base/content/messenger.xul
+++ b/mail/base/content/messenger.xul
@@ -47,21 +47,20 @@
 <?xul-overlay href="chrome://messenger/content/mailOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/editContactOverlay.xul"?>
 
 <!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
 %messengerDTD;
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
 <!ENTITY % customizeToolbarDTD SYSTEM "chrome://global/locale/customizeToolbar.dtd">
 %customizeToolbarDTD;
-#endif
-<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd"> %globalDTD;
+<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
+%globalDTD;
 ]>
 
 <window id="messengerWindow"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="&titledefault.label;"
         titlemodifier="&titledefault.label;"
         titlemenuseparator="&titleSeparator.label;"
         onload="OnLoadMessenger()"
@@ -346,23 +345,21 @@
                 </vbox>
               </box>
             </vbox>
           </box>
         </box> <!-- end of mailContent -->
       </tabpanels>
     </tabmail>
   </hbox>
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
   <panel id="customizeToolbarSheetPopup" noautohide="true">
     <iframe id="customizeToolbarSheetIFrame"
             style="&dialog.style;"
             hidden="true"/>
   </panel>
-#endif
 
   <notificationbox id="mail-notification-box"/>
   <statusbar id="status-bar" class="chromeclass-status">
     <statusbarpanel id="unreadMessageCount"/>
     <statusbarpanel id="totalMessageCount"/>
   </statusbar>
 </window>
 
--- a/mail/components/addrbook/Makefile.in
+++ b/mail/components/addrbook/Makefile.in
@@ -38,12 +38,8 @@
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 include $(topsrcdir)/config/rules.mk
-
-ifeq (cocoa, $(MOZ_WIDGET_TOOLKIT))
-DEFINES += -DTOOLBAR_CUSTOMIZATION_SHEET
-endif
--- a/mail/components/addrbook/content/addressbook.xul
+++ b/mail/components/addrbook/content/addressbook.xul
@@ -47,20 +47,18 @@
 
 <!DOCTYPE window [
 <!ENTITY % abMainWindowDTD SYSTEM "chrome://messenger/locale/addressbook/abMainWindow.dtd" >
 %abMainWindowDTD;
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
 %globalDTD;
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
 <!ENTITY % customizeToolbarDTD SYSTEM "chrome://global/locale/customizeToolbar.dtd">
 %customizeToolbarDTD;
-#endif
 ]>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:html="http://www.w3.org/1999/xhtml"
     id="addressbookWindow"
     height="450"
     width="750"
@@ -835,20 +833,18 @@
                 </vbox>
               </vbox>
             </hbox>
           </vbox>
         </vbox>
       </hbox>
     </vbox>
   </hbox>
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
   <panel id="customizeToolbarSheetPopup" noautohide="true">
     <iframe id="customizeToolbarSheetIFrame"
             style="&dialog.style;"
             hidden="true"/>
   </panel>
-#endif
   
   <statusbar id="status-bar" class="chromeclass-status">
     <statusbarpanel id="statusText" flex="1" value="&statusText.label;"/>            
   </statusbar>  
 </window>
--- a/mail/components/compose/Makefile.in
+++ b/mail/components/compose/Makefile.in
@@ -38,12 +38,8 @@
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 include $(topsrcdir)/config/rules.mk
-
-ifeq (cocoa, $(MOZ_WIDGET_TOOLKIT))
-DEFINES += -DTOOLBAR_CUSTOMIZATION_SHEET
-endif
--- a/mail/components/compose/content/messengercompose.xul
+++ b/mail/components/compose/content/messengercompose.xul
@@ -50,20 +50,18 @@
 
 <!DOCTYPE window [
 <!ENTITY % messengercomposeDTD SYSTEM "chrome://messenger/locale/messengercompose/messengercompose.dtd" >
 %messengercomposeDTD;
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % charsetDTD SYSTEM "chrome://global/locale/charsetOverlay.dtd" >
 %charsetDTD;
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
 <!ENTITY % customizeToolbarDTD SYSTEM "chrome://global/locale/customizeToolbar.dtd">
 %customizeToolbarDTD;
-#endif
 ]>
 
 <window id="msgcomposeWindow"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:nc="http://home.netscape.com/NC-rdf#"
         onunload="ComposeUnload()"
         onload="ComposeLoad()"
         onclose="return DoCommandClose()"
@@ -777,23 +775,21 @@
   <!-- The mail message body frame -->
   <vbox id="appcontent" flex="1">
     <editor type="content-primary" id="content-frame" src="about:blank" name="browser.message.body" flex="1"
             context="msgComposeContext"/>
   </vbox>
 
   </vbox>
   </hbox>
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
   <panel id="customizeToolbarSheetPopup" noautohide="true">
     <iframe id="customizeToolbarSheetIFrame"
             style="&dialog.style;"
             hidden="true"/>
   </panel>
-#endif
 
   <statusbar id="status-bar" class="chromeclass-status">
     <statusbarpanel id="statusText" flex="1"/>
     <statusbarpanel class="statusbarpanel-progress" id="statusbar-progresspanel">
       <progressmeter id="compose-progressmeter" class="progressmeter-statusbar" mode="normal" value="0"/>
     </statusbarpanel>
   </statusbar>