Bug 721330 Make Customizing Lightning Toolbars work in SeaMonkey f=paenglab r=Philipp.
authorPhilip Chee <philip.chee@gmail.com>
Mon, 30 Jan 2012 20:53:06 +0800
changeset 10552 ed69c6a773d6361c3e0f83a16a2729b23163bbc6
parent 10551 db773e5019e5e1e14a402b20d4a55ec0207d561c
child 10553 421466ffede8a93fbc059527b21146ebb1852871
push idunknown
push userunknown
push dateunknown
reviewersPhilipp
bugs721330
Bug 721330 Make Customizing Lightning Toolbars work in SeaMonkey f=paenglab r=Philipp.
calendar/lightning/content/lightning-toolbar.xul
calendar/lightning/content/messenger-overlay-sidebar.js
calendar/lightning/content/suite-overlay-sidebar.js
calendar/lightning/content/suite-overlay-sidebar.xul
calendar/lightning/jar.mn
--- a/calendar/lightning/content/lightning-toolbar.xul
+++ b/calendar/lightning/content/lightning-toolbar.xul
@@ -38,37 +38,37 @@
    - and other provisions required by the GPL or the LGPL. If you do not delete
    - the provisions above, a recipient may use your version of this file under
    - the terms of any one of the MPL, the GPL or the LGPL.
    -
    - ***** END LICENSE BLOCK ***** -->
 
 <!DOCTYPE overlay [
   <!ENTITY % mailOverlayDTD SYSTEM "chrome://messenger/locale/mailOverlay.dtd"> %mailOverlayDTD;
-  <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd"> %messengerDTD;
+  <!ENTITY % menuOverlayDTD SYSTEM "chrome://calendar/locale/menuOverlay.dtd" > %menuOverlayDTD;
   <!ENTITY % lightningDTD SYSTEM "chrome://lightning/locale/lightning.dtd"> %lightningDTD;
   <!ENTITY % calendarDTD SYSTEM "chrome://calendar/locale/calendar.dtd" > %calendarDTD;
   <!ENTITY % toolbarDTD SYSTEM "chrome://lightning/locale/lightning-toolbar.dtd" > %toolbarDTD;
 ]>
 
 <?xml-stylesheet href="chrome://lightning/skin/lightning.css" type="text/css"?>
 <?xml-stylesheet href="chrome://lightning/skin/lightning-toolbar.css" type="text/css"?>
 
 <overlay id="ltnToolbarOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <popupset id="calendar-popupset">
     <menupopup id="calendar-toolbar-context">
       <menuitem id="CustomizeCalendarToolbar"
-                label="&customizeToolbar.label;"
-                accesskey="&customizeToolbar.accesskey;"
+                label="&calendar.menu.customize.label;"
+                accesskey="&calendar.menu.customize.accesskey;"
                 oncommand="CustomizeMailToolbar('calendar-toolbox', 'CustomizeCalendarToolbar')"/>
     </menupopup>
     <menupopup id="task-toolbar-context">
       <menuitem id="CustomizeTaskToolbar"
-                label="&customizeToolbar.label;"
-                accesskey="&customizeToolbar.accesskey;"
+                label="&calendar.menu.customize.label;"
+                accesskey="&calendar.menu.customize.accesskey;"
                 oncommand="CustomizeMailToolbar('task-toolbox', 'CustomizeTaskToolbar')"/>
     </menupopup>
   </popupset>
 
   <!-- The popup id here must match the popup id in the SeaMonkey
        New Message button. See Bug 506461 -->
   <toolbarbutton id="button-newmsg"
                  type="menu-button">
--- a/calendar/lightning/content/messenger-overlay-sidebar.js
+++ b/calendar/lightning/content/messenger-overlay-sidebar.js
@@ -215,21 +215,25 @@ function ltnOnLoad(event) {
                                         gCalSetupMailContext.popup, false);
     }
 
     // Setup customizeDone handlers for our toolbars
     let toolbox = document.getElementById("calendar-toolbox");
     toolbox.customizeDone = function(aEvent) {
         MailToolboxCustomizeDone(aEvent, "CustomizeCalendarToolbar");
     };
-    let toolbox = document.getElementById("task-toolbox");
+    toolbox = document.getElementById("task-toolbox");
     toolbox.customizeDone = function(aEvent) {
         MailToolboxCustomizeDone(aEvent, "CustomizeTaskToolbar");
     };
 
+    Components.classes["@mozilla.org/observer-service;1"]
+              .getService(Components.interfaces.nsIObserverService)
+              .notifyObservers(window, "lightning-startup-done", false);
+
 }
 
 /* Called at midnight to tell us to redraw date-specific widgets.  Do NOT call
  * this for normal refresh, since it also calls scheduleMidnightRefresh.
  */
 function refreshUIBits() {
     try {
         getMinimonth().refreshDisplay();
new file mode 100644
--- /dev/null
+++ b/calendar/lightning/content/suite-overlay-sidebar.js
@@ -0,0 +1,46 @@
+var ltnSuiteUtils = {
+
+  customizeToolbar: function lSU_customizeToolbar(aItem) {
+    let toolbar = aItem.parentNode.triggerNode;
+    while (toolbar.localName != "toolbar")
+      toolbar = toolbar.parentNode;
+    goCustomizeToolbar(toolbar.toolbox);
+  },
+
+  addStartupObserver: function lSU_addStartupObserver() {
+    Components.classes["@mozilla.org/observer-service;1"]
+              .getService(Components.interfaces.nsIObserverService)
+              .addObserver(this.startupObserver, "lightning-startup-done",
+                           false);
+
+  },
+
+  startupObserver: {
+    observe: function lSU_observe(subject, topic, state) {
+      if (topic != "lightning-startup-done") {
+        return;
+      }
+
+      [["CustomizeCalendarToolbar", "calendar-toolbox"],
+       ["CustomizeTaskToolbar", "task-toolbox"]].forEach(function(eIDs) {
+        let [itemID, toolboxID] = eIDs;
+        let item = document.getElementById(itemID);
+        let toolbox = document.getElementById(toolboxID);
+        toolbox.customizeInit = function() {
+          item.setAttribute("disabled", "true");
+          toolboxCustomizeInit("mail-menubar");
+        };
+        toolbox.customizeDone = function(aToolboxChanged) {
+          item.removeAttribute("disabled");
+          toolboxCustomizeDone("mail-menubar", toolbox, aToolboxChanged);
+        };
+        toolbox.customizeChange = function(aEvent) {
+          toolboxCustomizeChange(toolbox, aEvent);
+        };
+      });
+    }
+  }
+
+}
+
+ltnSuiteUtils.addStartupObserver();
--- a/calendar/lightning/content/suite-overlay-sidebar.xul
+++ b/calendar/lightning/content/suite-overlay-sidebar.xul
@@ -35,14 +35,21 @@
    - the provisions above, a recipient may use your version of this file under
    - the terms of any one of the MPL, the GPL or the LGPL.
    -
    - ***** END LICENSE BLOCK ***** -->
 
 <overlay id="suiteSidebarOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
+  <script type="application/javascript" src="chrome://lightning/content/suite-overlay-sidebar.js"/>
+
   <key id="openLightningKey" removeelement="true"/>
   <key id="openTasksKey" removeelement="true"/>
   <key id="calendar-new-event-key" removeelement="true"/>
   <key id="calendar-new-todo-key" removeelement="true"/>
 
+  <menuitem id="CustomizeCalendarToolbar"
+            oncommand="ltnSuiteUtils.customizeToolbar(this)"/>
+  <menuitem id="CustomizeTaskToolbar"
+            oncommand="ltnSuiteUtils.customizeToolbar(this)"/>
+
 </overlay>
--- a/calendar/lightning/jar.mn
+++ b/calendar/lightning/jar.mn
@@ -39,16 +39,17 @@ lightning.jar:
     content/lightning/lightning-widgets.xml                (content/lightning-widgets.xml)
     content/lightning/messenger-overlay-accountCentral.xul (content/messenger-overlay-accountCentral.xul)
     content/lightning/messenger-overlay-messageWindow.xul  (content/messenger-overlay-messageWindow.xul)
 *   content/lightning/messenger-overlay-sidebar.js         (content/messenger-overlay-sidebar.js)
 *   content/lightning/messenger-overlay-sidebar.xul        (content/messenger-overlay-sidebar.xul)
     content/lightning/messenger-overlay-preferences.js     (content/messenger-overlay-preferences.js)
     content/lightning/messenger-overlay-preferences.xul    (content/messenger-overlay-preferences.xul)
     content/lightning/suite-overlay-preferences.xul        (content/suite-overlay-preferences.xul)
+    content/lightning/suite-overlay-sidebar.js             (content/suite-overlay-sidebar.js)
     content/lightning/suite-overlay-sidebar.xul            (content/suite-overlay-sidebar.xul)
 % skin lightning classic/1.0 %skin/lightning/
 % style chrome://global/content/customizeToolbar.xul chrome://lightning/skin/lightning-toolbar.css
     skin/lightning/accountCentral.css                      (themes/@THEME@/accountCentral.css)
     skin/lightning/imip.css                                (themes/@THEME@/imip.css)
     skin/lightning/lightning.css                           (themes/@THEME@/lightning.css)
     skin/lightning/lightning-toolbar.css                   (themes/@THEME@/lightning-toolbar.css)
     skin/lightning/lightning-widgets.css                   (themes/@THEME@/lightning-widgets.css)