Fix bug 456385 - Thunderbird3: Integrate Calendar and Task mode menu items into new menu. r=mschroeder
authorPhilipp Kewisch <mozilla@kewis.ch>
Sat, 20 Jun 2009 18:26:22 +0200
changeset 2898 ffb301b5cd6b2e68a8cdf68cd05c0a493d8060dd
parent 2897 7a767870e14eb6db047fdb0e5dbcce81fdbab2db
child 2899 d285993e5dab24dc136a32d8429a226f510672a0
push id2348
push usermozilla@kewis.ch
push dateSat, 20 Jun 2009 16:26:43 +0000
treeherdercomm-central@ffb301b5cd6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmschroeder
bugs456385
Fix bug 456385 - Thunderbird3: Integrate Calendar and Task mode menu items into new menu. r=mschroeder
calendar/base/content/calendar-base-view.xml
calendar/base/content/calendar-common-sets.js
calendar/base/content/calendar-common-sets.xul
calendar/base/content/calendar-menus.xml
calendar/base/content/calendar-multiday-view.xml
calendar/base/content/calendar-task-tree.js
calendar/base/content/calendar-task-view.xul
calendar/base/content/calendar-views.js
calendar/base/content/calendar-views.xml
calendar/base/content/today-pane.js
calendar/base/content/today-pane.xul
calendar/base/content/widgets/calendar-widgets.xml
calendar/base/public/calICalendarView.idl
calendar/lightning/content/lightning-scripts.inc
calendar/lightning/content/messenger-overlay-sidebar.js
calendar/lightning/content/messenger-overlay-sidebar.xul
calendar/lightning/content/messenger-overlay-toolbar.js
calendar/lightning/jar.mn
calendar/locales/en-US/chrome/calendar/menuOverlay.dtd
calendar/locales/en-US/chrome/lightning/lightning.dtd
calendar/locales/en-US/chrome/sunbird/menuOverlay.dtd
calendar/resources/content/calendar.js
calendar/sunbird/base/content/calendar-menubar.inc
calendar/sunbird/base/content/calendar-sets.inc
--- a/calendar/base/content/calendar-base-view.xml
+++ b/calendar/base/content/calendar-base-view.xml
@@ -349,16 +349,18 @@
                 onget="return document.getElementById('calendarviewBroadcaster')"/>
 
       <property name="labeldaybox" readonly="true"
                 onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'labeldaybox')"/>
 
       <property name="rotated"
                 onget="return (this.orient == 'horizontal')"
                 onset="return (this.orient = (val ? 'horizontal' : 'vertical'))"/>
+      <property name="supportsRotation" readonly="true"
+                onget="return false"/>
       <property name="displayDaysOff"
                 onget="return this.mDisplayDaysOff;"
                 onset="return (this.mDisplayDaysOff = val);"/>
       <property name="controller"
                 onget="return this.mController;"
                 onset="return (this.mController = val);"/>
       <property name="daysOffArray"
                 onget="return this.mDaysOffArray;"
@@ -370,16 +372,18 @@
                 onget="return this.mShowCompleted;"
                 onset="return (this.mShowCompleted = val);"/>
       <property name="timezone"
                 onget="return this.mTimezone;"
                 onset="return (this.mTimezone = val);"/>
       <property name="workdaysOnly"
                 onget="return this.mWorkdaysOnly;"
                 onset="return (this.mWorkdaysOnly = val);"/>
+      <property name="supportsWorkdaysOnly" readonly="true"
+                onget="return true;"/>
       <property name="selectionObserver" readonly="true"
                 onget="return this.mSelectionObserver;"/>
       <property name="startDay" readonly="true"
                 onget="return this.startDate;"/>
       <property name="endDay" readonly="true"
                 onget="return this.endDate;"/>
       <property name="supportDisjointDates" readonly="true"
                 onget="return false;"/>
--- a/calendar/base/content/calendar-common-sets.js
+++ b/calendar/base/content/calendar-common-sets.js
@@ -61,44 +61,65 @@ var calendarController = {
         "calendar_import_command": true,
         "calendar_export_command": true,
         "calendar_export_selection_command": true,
 
         "calendar_publish_selected_calendar_command": true,
         "calendar_publish_calendar_command": true,
         "calendar_publish_selected_events_command": true,
 
+        "calendar_view_next_command": true,
+        "calendar_view_prev_command": true,
+
+        "calendar_toggle_orientation_command": true,
+        "calendar_toggle_workdays_only_command": true,
+
         "calendar_task_filter_command": true,
         "calendar_reload_remote_calendars": true,
+        "calendar_show_unifinder_command": true,
+        "calendar_toggle_completed_command": true,
         "calendar_percentComplete-0_command": true,
         "calendar_percentComplete-25_command": true,
         "calendar_percentComplete-50_command": true,
         "calendar_percentComplete-75_command": true,
         "calendar_percentComplete-100_command": true,
-        "calendar_percentComplete-100_command2": true,
         "calendar_priority-0_command": true,
         "calendar_priority-9_command": true,
         "calendar_priority-5_command": true,
         "calendar_priority-1_command": true,
         "calendar_general-priority_command": true,
+        "calendar_general-progress_command": true,
         "calendar_task_category_command": true,
         "cmd_cut": true,
         "cmd_copy": true,
         "cmd_paste": true,
         "cmd_undo": true,
         "cmd_redo": true,
         "cmd_print": true,
         "cmd_selectAll": true,
         "cmd_pageSetup": true,
 
         // Thunderbird commands
         "cmd_printpreview": true,
         "button_print": true,
         "button_delete": true,
-        "cmd_delete": true
+        "cmd_delete": true,
+        "cmd_properties": true,
+        "cmd_runJunkControls": true,
+        "cmd_deleteJunk": true,
+        "cmd_applyFilters": true,
+        "cmd_applyFiltersToSelection": true,
+        "cmd_goForward": true,
+        "cmd_goBack": true,
+
+        // Pseudo commands
+        "calendar_in_foreground": true,
+        "calendar_in_background": true,
+        "calendar_mode_calendar": true,
+        "calendar_mode_task": true
     },
 
     updateCommands: function cC_updateCommands() {
         for (var command in this.commands) {
             goUpdateCommand(command);
         }
     },
 
@@ -126,47 +147,81 @@ var calendarController = {
                 return this.selected_items_writable;
             case "calendar_new_todo_command":
                 return this.writable && this.calendars_support_tasks;
             case "calendar_modify_todo_command":
                  return this.todo_items_selected;
                  // This code is temporarily commented out due to
                  // bug 469684 Unifinder-todo: raising of the context menu fires blur-event
                  // this.todo_tasktree_focused;
+            case "calendar_edit_calendar_command":
+                return this.isCalendarInForeground();
             case "calendar_task_filter_command":
                 return true;
             case "calendar_delete_todo_command":
+            case "calendar_toggle_completed_command":
             case "calendar_percentComplete-0_command":
             case "calendar_percentComplete-25_command":
             case "calendar_percentComplete-50_command":
             case "calendar_percentComplete-75_command":
             case "calendar_percentComplete-100_command":
-            case "calendar_percentComplete-100_command2":
             case "calendar_priority-0_command":
             case "calendar_priority-9_command":
             case "calendar_priority-5_command":
             case "calendar_priority-1_command":
             case "calendar_task_category_command":
+            case "calendar_general-progress_command":
             case "calendar_general-priority_command":
-                return this.writable &&
+                return this.isCalendarInForeground() &&
+                       this.writable &&
                        this.todo_items_selected &&
                        this.todo_items_writable;
             case "calendar_delete_calendar_command":
-                return !this.last_calendar;
-
+                return this.isCalendarInForeground() && !this.last_calendar;
             case "calendar_import_command":
                 return this.writable;
             case "calendar_export_selection_command":
                 return this.item_selected;
-
+            case "calendar_toggle_orientation_command":
+                return this.isCalendarInForeground() &&
+                       gCurrentMode &&
+                       gCurrentMode == "calendar" &&
+                       currentView().supportsRotation;
+            case "calendar_toggle_workdays_only_command":
+                return this.isCalendarInForeground() &&
+                       gCurrentMode &&
+                       gCurrentMode == "calendar" &&
+                       currentView().supportsWorkdaysOnly;
             case "calendar_publish_selected_events_command":
                 return this.item_selected;
 
             case "calendar_reload_remote_calendar":
                 return !this.no_network_calendars && !this.offline;
+
+            // The following commands all just need the calendar in foreground,
+            // make sure you take care when changing things here.
+            case "calendar_view_next_command":
+            case "calendar_view_prev_command":
+            case "calendar_in_foreground":
+                return this.isCalendarInForeground();
+            case "calendar_in_background":
+                return !this.isCalendarInForeground();
+
+            // The following commands need calendar mode, be careful when
+            // changing things.
+            case "calendar_show_unifinder_command":
+            case "calendar_mode_calendar":
+                return this.isCalendarInForeground() &&
+                       gCurrentMode &&
+                       gCurrentMode == "calendar";
+
+            case "calendar_mode_task":
+                return this.isCalendarInForeground() &&
+                       gCurrentMode &&
+                       gCurrentMode == "task";
             default:
                 if (this.defaultController && !this.isCalendarInForeground()) {
                     // The delete-button demands a special handling in mail-mode
                     // as it is supposed to delete an element of the focused pane
                     if (aCommand == "cmd_delete" || aCommand == "button_delete") {
                         var focusedElement = document.commandDispatcher.focusedElement;
                         if (focusedElement) {
                             if (focusedElement.getAttribute("id") == "agenda-listbox") {
@@ -200,16 +255,22 @@ var calendarController = {
                     case "cmd_redo":
                         goSetMenuValue(aCommand, 'valueDefault');
                         return canRedo();
                     case "cmd_printpreview":
                         return false;
                     case "button_delete":
                     case "cmd_delete":
                         return this.item_selected;
+                    case "cmd_properties":
+                    case "cmd_runJunkControls":
+                    case "cmd_deleteJunk":
+                    case "cmd_applyFilters":
+                    case "cmd_applyFiltersToSelection":
+                        return false;
                 }
                 if (aCommand in this.commands) {
                     // All other commands we support should be enabled by default
                     return true;
                 }
         }
         return false;
     },
@@ -300,16 +361,31 @@ var calendarController = {
                 break;
             case "calendar_publish_selected_events_command":
                 publishCalendarData();
                 break;
 
             case "calendar_reload_remote_calendars":
                 getCompositeCalendar().refresh();
                 break;
+            case "calendar_show_unifinder_command":
+                toggleUnifinder();
+                break;
+            case "calendar_view_next_command":
+                currentView().moveView(1);
+                break;
+            case "calendar_view_prev_command":
+                currentView().moveView(-1);
+                break;
+            case "calendar_toggle_orientation_command":
+                toggleOrientation();
+                break;
+            case "calendar_toggle_workdays_only_command":
+                toggleWorkdaysOnly();
+                break;
             default:
                 if (this.defaultController && !this.isCalendarInForeground()) {
                     // If calendar is not in foreground, let the default controller take
                     // care. If we don't have a default controller (i.e sunbird), just
                     // continue.
                     this.defaultController.doCommand(aCommand);
                     return;
                 }
@@ -337,16 +413,23 @@ var calendarController = {
                         PrintUtils.showPageSetup();
                         break;
                     case "button_print":
                     case "cmd_print":
                         calPrint();
                         break;
 
                     // Thunderbird commands
+                    case "cmd_goForward":
+                        currentView().moveView(1);
+                        break;
+                    case "cmd_goBack":
+                        currentView().moveView(-1);
+                        break;
+
                     // For these commands, nothing should happen in calendar mode.
                     case "cmd_printpreview":
                     case "button_delete":
                     case "cmd_delete":
                     default:
                     return;
                 }
         }
@@ -549,17 +632,16 @@ function injectCalendarCommandController
         // we leave the current thread in order to re-enter the message loop.
 
         var tbController = top.controllers.getControllerForCommand("cmd_undo");
         if (!tbController) {
             setTimeout(injectCalendarCommandController, 0);
             return;
         } else {
             calendarController.defaultController = tbController;
-            ltnInitializeMenus();
         }
     }
     top.controllers.insertControllerAt(0, calendarController);
     document.commandDispatcher.updateCommands("calendar_commands");
 }
 
 /**
  * Remove the calendar command controller from the document.
--- a/calendar/base/content/calendar-common-sets.xul
+++ b/calendar/base/content/calendar-common-sets.xul
@@ -79,52 +79,61 @@
     <command id="calendar_export_selection_command" oncommand="goDoCommand('calendar_export_selection_command')"/>
 
     <command id="calendar_publish_selected_calendar_command" oncommand="goDoCommand('calendar_publish_selected_calendar_command')"/>
     <command id="calendar_publish_calendar_command" oncommand="goDoCommand('calendar_publish_calendar_command')"/>
     <command id="calendar_publish_selected_events_command" oncommand="goDoCommand('calendar_publish_selected_events_command')"/>
 
     <command id="calendar_reload_remote_calendars" oncommand="goDoCommand('calendar_reload_remote_calendars')"/>
 
-    <command id="calendar_show_unifinder_command" oncommand="toggleUnifinder()"/>
+    <command id="calendar_show_unifinder_command" oncommand="goDoCommand('calendar_show_unifinder_command')"/>
     <!-- The dash instead of the underscore is intended. the 'xxx-view' part should be the id of the view in the deck -->
     <command id="calendar_day-view_command" oncommand="showCalendarView('day')"/>
     <command id="calendar_week-view_command" oncommand="showCalendarView('week')"/>
     <command id="calendar_multiweek-view_command" oncommand="showCalendarView('multiweek')"/>
     <command id="calendar_month-view_command" oncommand="showCalendarView('month')"/>
     <command id="calendar_task_category_command" oncommand="contextChangeTaskCategory(event);"/>
+    <command id="calendar_toggle_completed_command" oncommand="toggleCompleted(event)"/>
     <command id="calendar_percentComplete-0_command" oncommand="contextChangeTaskProgress(event, 0)"/>
     <command id="calendar_percentComplete-25_command" oncommand="contextChangeTaskProgress(event, 25)"/>
     <command id="calendar_percentComplete-50_command" oncommand="contextChangeTaskProgress(event, 50)"/>
     <command id="calendar_percentComplete-75_command" oncommand="contextChangeTaskProgress(event, 75)"/>
     <command id="calendar_percentComplete-100_command" oncommand="contextChangeTaskProgress(event, 100)"/>
-    <command id="calendar_percentComplete-100_command2" oncommand="contextChangeTaskProgress2(event, 100)"/>
     <command id="calendar_priority-0_command" oncommand="contextChangeTaskPriority(event, 0)"/>
     <command id="calendar_priority-9_command" oncommand="contextChangeTaskPriority(event, 9)"/>
     <command id="calendar_priority-5_command" oncommand="contextChangeTaskPriority(event, 5)"/>
     <command id="calendar_priority-1_command" oncommand="contextChangeTaskPriority(event, 1)"/>
     <command id="calendar_general-priority_command" oncommand="goDoCommand('calendar_general-priority_command')"/>
-    <command id="calendar_toggle_orientation_command" persist="checked" oncommand="toggleOrientation()" disabled="true"/>
-    <command id="calendar_toggle_workdays_only_command" persist="checked" oncommand="toggleWorkdaysOnly()"/>
+    <command id="calendar_general-progress_command" oncommand="goDoCommand('calendar_general-priority_command')"/>
+    <command id="calendar_toggle_orientation_command" persist="checked" oncommand="goDoCommand('calendar_toggle_orientation_command')"/>
+    <command id="calendar_toggle_workdays_only_command" persist="checked" oncommand="goDoCommand('calendar_toggle_workdays_only_command')"/>
     <command id="calendar_toggle_tasks_in_view_command" persist="checked" oncommand="toggleTasksInView()"/>
     <command id="calendar_toggle_show_completed_in_view_command" persist="checked" oncommand="toggleShowCompletedInView()"/>
     <command id="calendar_toggle_minimonthpane_command" oncommand="document.getElementById('minimonth-pane').togglePane(event)"/>
     <command id="calendar_toggle_calendarlist_command" oncommand="document.getElementById('calendar-list-pane').togglePane(event)"/>
     <command id="calendar_task_filter_command" oncommand="taskViewUpdate(event.explicitOriginalTarget.getAttribute('value'))"/>
     <command id="calendar_toggle_filter_command" oncommand="document.getElementById('task-filter-pane').togglePane(event)"/>
-    <command id="calendar_view_next_command" oncommand="currentView().moveView(1)"/>
+    <command id="calendar_view_next_command" oncommand="goDoCommand('calendar_view_next_command')"/>
     <command id="calendar_view_today_command" oncommand="currentView().moveView()"/>
-    <command id="calendar_view_prev_command" oncommand="currentView().moveView(-1)"/>
-    <command id="calendar_go_to_today_command" oncommand="goToDate(now())"/>
+    <command id="calendar_view_prev_command" oncommand="goDoCommand('calendar_view_prev_command')"/>
+
+    <!-- this is a pseudo-command that is disabled when in calendar mode -->
+    <command id="calendar_in_foreground"/>
+    <!-- this is a pseudo-command that is disabled when not in calendar mode -->
+    <command id="calendar_in_background"/>
+
+    <!-- These commands are enabled when in calendar or task mode, respectively -->
+    <command id="calendar_mode_calendar"/>
+    <command id="calendar_mode_task"/>
   </commandset>
 
   <keyset id="calendar-keys">
 #ifdef XP_MACOSX
-    // The following Mac specific code-lines are necessary, because you can't 
-    // just use the OPTION key on Mac OSX. So we will use SHIFT+OPTION on the 
+    // The following Mac specific code-lines are necessary, because you can't
+    // just use the OPTION key on Mac OSX. So we will use SHIFT+OPTION on the
     // Mac, but just ALT on all other platforms. See bug 448946.
     <key id="calendar-day-view-key" key="&calendar.dayView.key;" observes="calendar_day-view_command" modifiers="shift alt"/>
     <key id="calendar-week-view-key" key="&calendar.weekView.key;" observes="calendar_week-view_command" modifiers="shift alt"/>
     <key id="calendar-multiweek-view-key" key="&calendar.multiweekView.key;" observes="calendar_multiweek-view_command" modifiers="shift alt"/>
     <key id="calendar-month-view-key" key="&calendar.monthView.key;" observes="calendar_month-view_command" modifiers="shift alt"/>
 #else
     <key id="calendar-day-view-key" key="&calendar.dayView.key;" observes="calendar_day-view_command" modifiers="alt"/>
     <key id="calendar-week-view-key" key="&calendar.weekView.key;" observes="calendar_week-view_command" modifiers="alt"/>
@@ -276,17 +285,18 @@
                 key="calendar-new-todo-key"
                 command="calendar_new_todo_command"
                 observes="calendar_new_todo_command"/>
       <menuseparator id="calendar-menuseparator-beforemarkcompleted"/>
       <menuitem id="calendar-context-markcompleted"
                 type="checkbox"
                 label="&calendar.context.markcompleted.label;"
                 accesskey="&calendar.context.markcompleted.accesskey;"
-                oncommand="toggleCompleted(event)"/>
+                observes="calendar_toggle_completed_command"
+                command="calendar_toggle_completed_command"/>
       <menu id="task-context-menu-progress"
             label="&calendar.context.progress.label;"
             accesskey="&calendar.context.progress.accesskey;">
         <menupopup id="progress-menupopup" type="task-progress"/>
       </menu>
       <menu id="task-context-menu-priority"
             label="&calendar.context.priority.label;"
             accesskey="&calendar.context.priority.accesskey;">
--- a/calendar/base/content/calendar-menus.xml
+++ b/calendar/base/content/calendar-menus.xml
@@ -163,9 +163,9 @@
       <children/>                    
      </content>
     <implementation>
       <constructor><![CDATA[
           this.mType = "priority";
       ]]></constructor>
     </implementation>
    </binding>
-</bindings>
\ No newline at end of file
+</bindings>
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -2187,16 +2187,19 @@
       ]]></constructor>
 
       <property name="daysInView" readonly="true">
         <getter><![CDATA[
           return this.labeldaybox.childNodes && this.labeldaybox.childNodes.length;
         ]]></getter>
       </property>
 
+      <property name="supportsRotation" readonly="true"
+                onget="return true"/>
+
       <method name="handlePreference">
         <parameter name="aSubject"/>
         <parameter name="aTopic"/>
         <parameter name="aPreference"/>
         <body><![CDATA[
             aSubject.QueryInterface(Components.interfaces.nsIPrefBranch2);
             switch (aPreference) {
 
--- a/calendar/base/content/calendar-task-tree.js
+++ b/calendar/base/content/calendar-task-tree.js
@@ -91,41 +91,38 @@ function addCategoryNames(aEvent) {
 }
 
 /**
  * Change the opening context menu for the selected tasks.
  *
  * @param aEvent    The popupshowing event of the opening menu.
  */
 function changeContextMenuForTask(aEvent) {
-    var tasks = getSelectedTasks(aEvent);
-    var task = null;
-    var tasksSelected = (tasks.length > 0);
+    let tasksSelected = (getSelectedTasks(aEvent).length > 0);
     applyAttributeToMenuChildren(aEvent.target, "disabled", (!tasksSelected));
     document.getElementById("calendar_new_todo_command").removeAttribute("disabled");
-    if (tasksSelected) {
-        if (isPropertyValueSame(tasks, "isCompleted")) {
-            setBooleanAttribute(document.getElementById("calendar-context-markcompleted"), "checked", tasks[0].isCompleted);
-        } else {
-            document.getElementById("calendar-context-markcompleted").setAttribute("checked", false);
-        }
-    }
+    changeMenuForTask(aEvent);
 }
 
 /**
- * Handler function to mark selected tasks as completed.
- *
- * XXXberend Please explain more and rename to something easier to understand.
+ * Change the opening menu for the selected tasks.
  *
- * @param aEvent      The DOM event that triggered this command.
- * @param aProgress   The progress percentage to set.
+ * @param aEvent    The popupshowing event of the opening menu.
  */
-function contextChangeTaskProgress2(aEvent, aProgress) {
-    contextChangeTaskProgress(aEvent, aProgress);
-    document.getElementById("calendar_percentComplete-100_command2").checked = false;
+function changeMenuForTask(aEvent) {
+    let tasks = getSelectedTasks(aEvent);
+    let tasksSelected = (tasks.length > 0);
+    if (tasksSelected) {
+        let cmd = document.getElementById("calendar_toggle_completed_command");
+        if (isPropertyValueSame(tasks, "isCompleted")) {
+            setBooleanAttribute(cmd, "checked", tasks[0].isCompleted);
+        } else {
+            setBooleanAttribute(cmd, "checked", false);
+        }
+    }
 }
 
 /**
  * Handler function to change the progress of all selected tasks.
  *
  * @param aEvent      The DOM event that triggered this command.
  * @param aProgress   The progress percentage to set.
  */
@@ -281,21 +278,19 @@ function tasksToMail(aEvent) {
  * Convert selected tasks to events.
  */
 function tasksToEvents(aEvent) {
     var tasks = getSelectedTasks(aEvent);
     calendarCalendarButtonDNDObserver.onDropItems(tasks);
 }
 
 /**
- * Toggle the completed state on tasks retrieved from the given event.
+ * Toggle the completed state on selected tasks.
  *
- * XXXberend Please clarify if this is correct and describe more clearly.
- *
- * @param aEvent    The command event that holds information about the tasks.
+ * @param aEvent    The originating event, can be null.
  */
 function toggleCompleted(aEvent) {
     if (aEvent.target.getAttribute("checked") == "true") {
-        contextChangeTaskProgress(aEvent, 100);
+        contextChangeTaskProgress(aEvent, 0);
     } else {
-        contextChangeTaskProgress(aEvent, 0);
+        contextChangeTaskProgress(aEvent, 100);
     }
 }
--- a/calendar/base/content/calendar-task-view.xul
+++ b/calendar/base/content/calendar-task-view.xul
@@ -158,18 +158,18 @@
                       class="msgHeaderView-button">
                 <menupopup id="task-actions-category-menupopup"
                            onpopupshowing="addCategoryNames(event)"/>
               </button>
               <button id="task-actions-markcompleted"
                       type="menu-button"
                       label="&calendar.context.markcompleted.label;"
                       tooltiptext="&calendar.task.complete.button.tooltip;"
-                      command="calendar_percentComplete-100_command2"
-                      observes="calendar_percentComplete-100_command2"
+                      command="calendar_toggle_completed_command"
+                      observes="calendar_toggle_completed_command"
                       class="msgHeaderView-button">
                 <menupopup id="task-actions-markcompleted-menupopup" type="task-progress"/>
               </button>
               <button id="task-actions-priority"
                       type="menu"
                       label="&calendar.context.priority.label;"
                       tooltiptext="&calendar.task.priority.button.tooltip;"
                       command="calendar_general-priority_command"
--- a/calendar/base/content/calendar-views.js
+++ b/calendar/base/content/calendar-views.js
@@ -341,33 +341,28 @@ function switchToView(aViewType) {
             node.setAttribute(attr, node.getAttribute(attr + "-" + aViewType));
         } else {
             node.setAttribute(attr, node.getAttribute(attr + "-all"));
         }
     }
 
     // Set up the labels for the context menu
     ["calendar-view-context-menu-next",
-     "calendar-view-context-menu-previous"].forEach(function(x) setupViewNode(x, "label"));
+     "calendar-view-context-menu-previous",
+     "calendar-go-menu-next",
+     "calendar-go-menu-previous"].forEach(function(x) setupViewNode(x, "label"));
+
+    ["calendar-go-menu-next",
+     "calendar-go-menu-previous"].forEach(function(x) setupViewNode(x, "accesskey"));
 
     // Set up the labels for the view navigation
     ["previous-view-button",
      "today-view-button",
      "next-view-button"].forEach(function(x) setupViewNode(x, "tooltiptext"));
     
-        
-
-    // Disable the menuitem when not in day or week view.
-    var rotated = document.getElementById("calendar_toggle_orientation_command");
-    if (aViewType == "day" || aViewType == "week") {
-        rotated.removeAttribute("disabled");
-    } else {
-        rotated.setAttribute("disabled", "true");
-    }
-
     try {
         selectedDay = viewDeck.selectedPanel.selectedDay;
         currentSelection = viewDeck.selectedPanel.getSelectedItems({});
     } catch (ex) {
         // This dies if no view has even been chosen this session, but that's
         // ok because we'll just use now() below.
     }
 
--- a/calendar/base/content/calendar-views.xml
+++ b/calendar/base/content/calendar-views.xml
@@ -51,16 +51,19 @@
     <binding id="calendar-day-view"
              extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-multiday-view">
         <implementation implements="calICalendarView">
             <property name="observerID">
                 <getter><![CDATA[
                     return "day-view-observer";
                 ]]></getter>
             </property>
+            <property name="supportsWorkdaysOnly"
+                      readonly="true"
+                      onget="return false;"/>
 
             <!--Public methods-->
             <method name="goToDay">
                 <parameter name="aDate"/>
                 <body><![CDATA[
                     aDate = aDate.getInTimezone(this.timezone);
                     this.setDateRange(aDate, aDate);
                     this.selectedDay = aDate;
--- a/calendar/base/content/today-pane.js
+++ b/calendar/base/content/today-pane.js
@@ -263,38 +263,35 @@ var TodayPane = {
   updatePeriod: function updatePeriod() {
       var date = this.start.clone();
       return agendaListbox.refreshPeriodDates(date);
   },
 
   /**
    * Display a certain section in the minday/minimonth part of the todaypane.
    *
-   * @param aIndex      A numeric value:
-   *                     - 1: Show the miniday
-   *                     - 2: show the minimonth
-   *                     - 3: show none of both
+   * @param aSection      The section to display
    */
-  displayMiniSection: function displayMiniSection(aIndex) {
-      document.getElementById("today-minimonth-box").setVisible(aIndex == 2);
-      document.getElementById("mini-day-box").setVisible(aIndex == 1);
-      document.getElementById("today-none-box").setVisible(aIndex == 3);
-      setBooleanAttribute(document.getElementById("today-Minimonth"), "freebusy", aIndex == 2);
+  displayMiniSection: function displayMiniSection(aSection) {
+      document.getElementById("today-minimonth-box").setVisible(aSection == 'minimonth');
+      document.getElementById("mini-day-box").setVisible(aSection == 'miniday');
+      document.getElementById("today-none-box").setVisible(aSection == 'none');
+      setBooleanAttribute(document.getElementById("today-Minimonth"), "freebusy", aSection == 'minimonth');
   },
 
   /**
    * Disable or enable the today pane menuitems that have an attribute
    * name="minidisplay"
    *
    * @param disable         If true, items will be disabled, otherwise enabled.
    */
   disableMenuItems: function disableMenuItems(disable) {
-       var menu = document.getElementById("today-pane-menu");
+       let menu = document.getElementById("ltnTodayPaneMenuPopup");
        if (menu) {
-           setAttributeToChildren(menu.firstChild, "disabled", disable, "name", "minidisplay");
+           setAttributeToChildren(menu, "disabled", disable, "name", "minidisplay");
        }
   },
 
   /**
    * Handler function for the DOMAttrModified event used to observe the
    * todaypane-splitter.
    *
    * @param aEvent      The DOM event occurring on attribute modification.
--- a/calendar/base/content/today-pane.xul
+++ b/calendar/base/content/today-pane.xul
@@ -91,32 +91,32 @@
                   mode="mail,calendar,task"
                   collapsedinmodes="calendar"
                   persist="collapsed height collapsedinmodes"
                   broadcaster="modeBroadcaster">
               <modebox id="today-none-box"
                        mode="mail,calendar,task"
                        collapsedinmodes="mail,calendar,task"
                        broadcaster="modeBroadcaster"
-                       refcontrol="today-pane-displaynone"
+                       refcontrol="ltnTodayPaneDisplayNone"
                        persist="collapsedinmodes"/>
               <modehbox id="today-minimonth-box"
                         pack="center"
                         class="today-subpane"
                         mode="mail,calendar,task"
                         broadcaster="modeBroadcaster"
                         collapsedinmodes="mail,calendar,task"
-                        refcontrol="today-pane-displayminimonth"
+                        refcontrol="ltnTodayPaneDisplayMinimonth"
                         persist="collapsedinmodes">
                 <minimonth id="today-Minimonth" freebusy="true" onchange="TodayPane.setDaywithjsDate(this.value);"/>
               </modehbox>
               <modebox id="mini-day-box"
                        mode="mail,calendar,task"
                        class="today-subpane"
-                       refcontrol="today-pane-displayminiday"
+                       refcontrol="ltnTodayPaneDisplayMiniday"
                        broadcaster="modeBroadcaster"
                        collapsedinmodes=""
                        persist="collapsedinmodes">
                 <stack flex="1">
                   <image id="mini-day-image" flex="1"/>
                   <hbox flex="1">
                     <deck id="dateContainer" selectedIndex="0">
                       <hbox pack="center">
--- a/calendar/base/content/widgets/calendar-widgets.xml
+++ b/calendar/base/content/widgets/calendar-widgets.xml
@@ -180,17 +180,18 @@
             if (this.hasAttribute("collapsedinmodes")) {
                 var collapsedModes = this.getAttribute("collapsedinmodes").split(",");
                 var modeIndex = collapsedModes.indexOf(this.currentMode);
                 collapsedInMode = (modeIndex > -1);
             }
             if ((aVisible === true) && (pushModeCollapsedAttribute == false)){
                 display = (aVisible === true) && (!collapsedInMode);
             }
-            setBooleanAttribute(this, "collapsed", (!display));
+
+            setBooleanAttribute(this, "collapsed", (!display || !this.isVisibleInMode()));
             if (pushModeCollapsedAttribute) {
                 if (!display) {
                     if (modeIndex == -1) {
                         collapsedModes.push(this.currentMode);
                         if (this.getAttribute("collapsedinmodes") == ",") {
                             collapsedModes.splice(0,2);
                         }
                     }
@@ -208,16 +209,17 @@
                     document.persist(id, "collapsedinmodes");
                 }
             }
             if (notifyRefControl === true) {
                 if (this.hasAttribute("refcontrol")) {
                     var command =  document.getElementById(this.getAttribute("refcontrol"))
                     if (command) {
                         command.setAttribute("checked", display);
+                        setBooleanAttribute(command, "disabled", !this.isVisibleInMode());
                     }
                 }
             }
         ]]></body>
       </method>
 
       <method name="isVisibleInMode">
         <parameter name="aMode"/>
--- a/calendar/base/public/calICalendarView.idl
+++ b/calendar/base/public/calICalendarView.idl
@@ -76,17 +76,22 @@ interface calICalendarView : nsISupports
    */
   attribute calICalendar displayCalendar;
 
   /**
    * the controller for this view
    */
   attribute calICalendarViewController controller;
 
-/**
+  /**
+   * If true, the view supports workdays only
+   */
+  readonly attribute boolean supportsWorkdaysOnly;
+
+  /**
    * If this is set to 'true', the view should not display days specified to be
    * non-workdays.  The implementor is responsible for obtaining what those
    * days are on its own.
    */
   attribute boolean workdaysOnly;
 
   /**
    * Whether or not tasks are to be displayed in the calICalendarView
@@ -94,16 +99,21 @@ interface calICalendarView : nsISupports
   attribute boolean tasksInView;
 
   /**
    * If set, the view will be rotated (i.e time on top, date at left)
    */
   attribute boolean rotated;
 
   /**
+   * If true, the view is rotatable
+   */
+  readonly attribute boolean supportsRotation;
+
+  /**
    * Whether or not completed tasks are shown in the calICalendarView
    */
   attribute boolean showCompleted;
 
   /**
    * Ensure that the given date is visible; the view is free
    * to show more dates than the given date (e.g. week view
    * would show the entire week).
--- a/calendar/lightning/content/lightning-scripts.inc
+++ b/calendar/lightning/content/lightning-scripts.inc
@@ -39,18 +39,9 @@
 # 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 ***** -->
 
 <script type="application/javascript" src="chrome://lightning/content/lightning-utils.js"/>
 <script type="application/javascript" src="chrome://lightning/content/messenger-overlay-sidebar.js"/>
-<script type="application/javascript" src="chrome://lightning/content/messenger-overlay-toolbar.js"/>
 <script type="application/javascript" src="chrome://calendar/content/calendar-invitations-manager.js"/>
-<script type="application/javascript">
-    var calendarmenulabel = "&lightning.calendar.label;";
-    var calendarmenuaccesskey = "&lightning.calendar.accesskey;";
-    var messagemenulabel = "&msgMenu.label;";
-    var messagemenuaccesskey = "&msgMenu.accesskey;";
-    var tasksmenulabel = "&lightning.tasks.label;";
-    var tasksmenuaccesskey = "&lightning.tasks.accesskey;";
-</script>
--- a/calendar/lightning/content/messenger-overlay-sidebar.js
+++ b/calendar/lightning/content/messenger-overlay-sidebar.js
@@ -125,19 +125,20 @@ function ltnOnLoad(event) {
 
     // Add an unload function to the window so we don't leak any listeners
     window.addEventListener("unload", ltnFinish, false);
 
     // Set up invitations manager
     scheduleInvitationsUpdate(FIRST_DELAY_STARTUP);
     getCalendarManager().addObserver(gInvitationsCalendarManagerObserver);
 
-    var filter = document.getElementById("task-tree-filtergroup");
+    let filter = document.getElementById("task-tree-filtergroup");
     filter.value = filter.value || "all";
     document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);
+    document.getElementById("modeBroadcaster").setAttribute("checked", "true");
 
     let mailContextPopup = document.getElementById("mailContext");
     if (mailContextPopup)
       mailContextPopup.addEventListener("popupshowing",
                                         gCalSetupMailContext.popup, false);
 
 }
 
@@ -259,290 +260,16 @@ function findMailSearchBox() {
         return tb2Box;
     }
 
     // In later versions, it's possible that a user removed the search box from
     // the toolbar.
     return null;
 }
 
-var calendarpopuplist = new Array();
-var taskpopuplist = new Array();
-var mailpopuplist = new Array();
-var menulist = new Array();
-#ifdef XP_MACOSX
-    var quitMenu = null;
-    var prefMenu = null;
-#endif
-
-function ltnInitializeMenus(){
-#ifdef XP_MACOSX
-    // The following Mac specific code-lines became necessary due to bug 409845
-    prefMenu = document.getElementById("menu_preferences");
-    prefMenu.setAttribute("mode", "system");
-    quitMenu = document.getElementById("menu_FileQuitItem");
-    quitMenu.setAttribute("mode", "system");
-#endif
-    copyPopupMenus();
-    ltnRemoveMailOnlyItems(calendarpopuplist, "calendar");
-    ltnRemoveMailOnlyItems(taskpopuplist, "task");
-    document.getElementById("modeBroadcaster").setAttribute("checked", true);
-}
-
-function getMenuElementById(aElementId, aMenuPopup) {
-        var element = null;
-        var elements = aMenuPopup.getElementsByAttribute("id", aElementId);
-        if (elements.length > 0) {
-            element = elements[0];
-        }
-        return element;
-    }
-
-/**  removes all succeedingmenu elements of a container up to the next
-*    menuseparator that thus denotes the end of the section. Elements with the
-*    attribute mode == 'calendar' are ignored
-*/
-function removeMenuElementsInSection(aElement, aExcludeMode) {
-    var element = aElement;
-    if (element) {
-        var bleaveloop = false;
-        while (!bleaveloop) {
-            var ignore = false;
-            bleaveloop = element.localName == "menuseparator";
-            if (bleaveloop) {
-                // we delete the menuseparator only if it's the last element
-                // within its container
-                bleaveloop = (element.nextSibling != null);
-            }
-            if (element.hasAttribute("mode")) {
-            ignore = element.getAttribute("mode") == aExcludeMode ||
-                     element.getAttribute("mode") == "calendar,task";
-            }
-            var nextMenuElement = element.nextSibling;
-            if (!ignore) {
-                try {
-                    element.parentNode.removeChild(element);
-                } catch (e) {
-                    dump("Element '" + element.getAttribute("id") + "' could not be removed\n");
-                }
-            }
-            if (!bleaveloop) {
-                element = nextMenuElement;
-                bleaveloop = (element == null);
-            }
-        }
-    }
-}
-
-function removeElements(aElementList) {
-    aElementList.forEach(function(element) {
-        try {
-            if (element) {
-                element.parentNode.removeChild(element);
-            }
-        } catch (e) {
-            dump("Element '" + element.getAttribute("id") + "' could not be removed\n");
-        }
-    });
-}
-
-function addToPopupList(aMenuElement, aNewPopupMenu, aPopupList, aExcludedModes, aClone, aRemovePopupShowing) {
-    var child = aMenuElement.firstChild;
-    if (child) {
-        if (child.localName == "menupopup") {
-            if (aNewPopupMenu) {
-                var newPopupMenu = aNewPopupMenu;
-            } else {
-                var newPopupMenu = child;
-            }
-            if (aClone) {
-                newPopupMenu = newPopupMenu.cloneNode(true);
-                if (aRemovePopupShowing) {
-                    newPopupMenu.removeAttribute("onpopupshowing");
-                }
-            }
-            removeMenuElements(newPopupMenu, aExcludedModes);
-            aPopupList.push(newPopupMenu);
-        }
-    }
-}
-
-function copyPopupMenus() {
-    // define menuList...
-    menulist.push(document.getElementById("menu_File"));
-    menulist.push(document.getElementById("menu_Edit"));
-    var menuView = document.getElementById("menu_View");
-    menulist.push(menuView);
-    menulist.push(menuView.nextSibling); // id-less menu_Go
-    menulist.push(document.getElementById("messageMenu"));
-    menulist.push(document.getElementById("tasksMenu"));
-
-    // define PopupMenus for calendar mode...
-    var excludeList = new Array("mail", "task", "system");
-    addToPopupList(menulist[0], null, calendarpopuplist, excludeList, true, true);
-    addToPopupList(menulist[1], null, calendarpopuplist, excludeList, true, false);
-    addToPopupList(menulist[2], null, calendarpopuplist, excludeList, true, true);
-    addToPopupList(menulist[3], document.getElementById("calendar-GoPopupMenu"), calendarpopuplist, excludeList, true, false);
-    addToPopupList(menulist[4], document.getElementById("calendarCalendarPopupMenu"), calendarpopuplist, excludeList, true, false);
-    addToPopupList(menulist[5], null, calendarpopuplist, excludeList, true, false);
-
-    // define PopupMenus for task mode...
-    var excludeList = new Array("mail", "calendar", "system");
-    addToPopupList(menulist[0], null, taskpopuplist, excludeList, true, true);
-    addToPopupList(menulist[1], null, taskpopuplist, excludeList, true, false);
-    addToPopupList(menulist[2], null, taskpopuplist, excludeList, true, true);
-    addToPopupList(menulist[3], document.getElementById("calendar-GoPopupMenu"), taskpopuplist, excludeList, true, false);
-    var tasksViewMenuPopup = clonePopupMenu("taskitem-context-menu", "taskitem-menu", "menu-");
-    tasksViewMenuPopup.removeChild(getMenuElementById("menu-" + "task-context-menu-modify", tasksViewMenuPopup));
-    tasksViewMenuPopup.removeChild(getMenuElementById("menu-" + "task-context-menu-delete", tasksViewMenuPopup));
-    addToPopupList(menulist[4], tasksViewMenuPopup, taskpopuplist, excludeList, false, false);
-    addToPopupList(menulist[5], null, taskpopuplist, excludeList, true, true);
-
-    // define PopupMenus for mail mode...
-    var excludeList = new Array("calendar", "task", "calendar,task");
-    addToPopupList(menulist[0], null, mailpopuplist, excludeList, false, false);
-    addToPopupList(menulist[1], null, mailpopuplist, excludeList, false, false);
-    addToPopupList(menulist[2], null, mailpopuplist, excludeList, false, false);
-    // copy calendar-GoPopupMenu into Thunderbird's GoPopupMenu to switch modes
-    var tbGoPopupMenu = menulist[3].lastChild;
-    var calGoPopupMenu = document.getElementById("calendar-GoPopupMenu").cloneNode(true);
-    var calGoItem;
-    while ((calGoItem = calGoPopupMenu.firstChild)) {
-        tbGoPopupMenu.appendChild(calGoPopupMenu.removeChild(calGoItem));
-    }
-    addToPopupList(menulist[3], null, mailpopuplist, excludeList, false, false);
-    addToPopupList(menulist[4], null, mailpopuplist, excludeList, false, false);
-    addToPopupList(menulist[5], null, mailpopuplist, excludeList, false, false);
-}
-
-function removeNeedlessSeparators(aMenuPopupList) {
-    aMenuPopupList.forEach(function(aMenuPopup) {
-        var child = aMenuPopup.firstChild;
-        if (child) {
-            if (child.localName == "menuseparator") {
-                try {
-                    aMenuPopup.removeChild(child)
-                } catch (e) {
-                    dump("Element '" + child.getAttribute("id") + "' could not be removed\n");
-                }
-            }
-        }
-        child = aMenuPopup.lastChild;
-        if (child) {
-            if (child.localName == "menuseparator") {
-                try {
-                    aMenuPopup.removeChild(child)
-                } catch (e) {
-                    dump("Element '" + child.getAttribute("id") + "' could not be removed\n");
-                }
-            }
-        }
-    });
-}
-
-function ltnRemoveMailOnlyItems(aMenuPopupList, aExcludeMode) {
-    removeElements(
-// "File" - menu
-    [getMenuElementById("openMessageFileMenuitem", aMenuPopupList[0]),
-     getMenuElementById("newAccountMenuItem", aMenuPopupList[0]),
-     getMenuElementById("fileAttachmentMenu", aMenuPopupList[0]),
-     getAdjacentSibling(getMenuElementById("menu_saveAs", aMenuPopupList[0]), 2),
-
-// "Edit" - menu
-     getMenuElementById("menu_find", aMenuPopupList[1]),
-     getMenuElementById("menu_favoriteFolder", aMenuPopupList[1]),
-     getMenuElementById("menu_properties", aMenuPopupList[1]),
-     getMenuElementById("menu_accountmgr", aMenuPopupList[1]),
-
-// "View"-menu
-     getMenuElementById("menu_showMessengerToolbar", aMenuPopupList[2]),
-
-// "Tools"-menu
-     getMenuElementById("tasksMenuMail", aMenuPopupList[5]),
-     getMenuElementById("menu_import", aMenuPopupList[5])]);
-
-     removeNeedlessSeparators(aMenuPopupList);
-
-// "File" - menu
-    [getMenuElementById("menu_newFolder", aMenuPopupList[0]),
-     getMenuElementById("menu_saveAs", aMenuPopupList[0]),
-     getMenuElementById("menu_getnextnmsg", aMenuPopupList[0]),
-     getMenuElementById("menu_renameFolder", aMenuPopupList[0]),
-//     getMenuElementById("offlineMenuItem", aMenuPopupList[0]),
-
-// "Edit" - menu
-     getMenuElementById("menu_delete", aMenuPopupList[1]),
-     getMenuElementById("menu_select", aMenuPopupList[1]),
-
-// "View"-menu
-     getMenuElementById("menu_MessagePaneLayout", aMenuPopupList[2]),
-     getMenuElementById("viewSortMenu", aMenuPopupList[2]),
-     getMenuElementById("viewheadersmenu", aMenuPopupList[2]),
-     getMenuElementById("viewTextSizeMenu", aMenuPopupList[2]),
-     getMenuElementById("pageSourceMenuItem", aMenuPopupList[2]),
-
-// "Tools"-menu
-     getMenuElementById("filtersCmd", aMenuPopupList[5]),
-     getMenuElementById("runJunkControls", aMenuPopupList[5])].forEach(function(element){
-        removeMenuElementsInSection(element, aExcludeMode);
-    });
-}
-
-function swapPopupMenus() {
-    var showStatusbar = document.getElementById("menu_showTaskbar").getAttribute("checked");
-    var newmenupopuplist = null;
-    if (gCurrentMode == "mail") {
-        newmenupopuplist = mailpopuplist;
-    } else if (gCurrentMode == "calendar") {
-        newmenupopuplist = calendarpopuplist;
-    } else if (gCurrentMode == "task") {
-        newmenupopuplist = taskpopuplist;
-    }
-    for (var i = 0; i < menulist.length; i++) {
-        var menu = menulist[i];
-        var oldmenupopup = menu.firstChild;
-        if (oldmenupopup) {
-            menu.replaceChild(newmenupopuplist[i], oldmenupopup);
-        }
-    }
-#ifdef XP_MACOSX
-    document.getElementById("menu_File").firstChild.appendChild(quitMenu);
-    document.getElementById("tasksMenu").firstChild.appendChild(prefMenu);
-#endif
-    document.getElementById("menu_showTaskbar").setAttribute("checked", showStatusbar);
-    var messageMenu = document.getElementById("messageMenu");
-    if (gCurrentMode == "mail") {
-        messageMenu.setAttribute("label", messagemenulabel);
-        messageMenu.setAttribute("accesskey", messagemenuaccesskey);
-    } else if (gCurrentMode == "calendar"){
-        messageMenu.setAttribute("label", calendarmenulabel);
-        messageMenu.setAttribute("accesskey", calendarmenuaccesskey);
-    } else if (gCurrentMode == "task"){
-        messageMenu.setAttribute("label", tasksmenulabel);
-        messageMenu.setAttribute("accesskey", tasksmenuaccesskey);
-    }
-}
-
-function removeMenuElements(aRoot, aModeValue) {
-    for (var n = 0; n < aModeValue.length; n++) {
-        var modeElements = aRoot.getElementsByAttribute("mode", aModeValue[n]);
-        if (modeElements.length > 0) {
-            for (var i = modeElements.length-1; i >=0; i--) {
-                var element = modeElements[i];
-                if (element) {
-                    var localName = element.localName;
-                    if (localName =="menuitem" || localName == "menuseparator" || localName == "menu"){
-                        element.parentNode.removeChild(element);
-                    }
-                }
-            }
-        }
-    }
-}
-
 // == invitations link
 const FIRST_DELAY_STARTUP = 100;
 const FIRST_DELAY_RESCHEDULE = 100;
 const FIRST_DELAY_REGISTER = 10000;
 const FIRST_DELAY_UNREGISTER = 0;
 
 var gInvitationsOperationListener = {
     mCount: 0,
@@ -606,9 +333,117 @@ function openInvitationsDialog() {
     gInvitationsCalendarManagerObserver.mCount = 0;
     getInvitationsManager().openInvitationsDialog(
         gInvitationsOperationListener,
         function oiD_callback() {
             scheduleInvitationsUpdate(FIRST_DELAY_RESCHEDULE);
         });
 }
 
+/**
+ * the current mode is set to a string defining the current
+ * mode we're in. allowed values are:
+ *  - 'mode'
+ *  - 'mail'
+ *  - 'calendar'
+ *  - 'task'
+ */
+var gCurrentMode = 'mail';
+
+/**
+ * ltnSwitch2Mail() switches to the mail mode
+ */
+
+function ltnSwitch2Mail() {
+  if (gCurrentMode != 'mail') {
+    var switch2mail = document.getElementById("switch2mail");
+    var switch2calendar = document.getElementById("switch2calendar");
+    var switch2task = document.getElementById("switch2task");
+    switch2mail.setAttribute("checked", "true");
+    switch2calendar.removeAttribute("checked");
+    switch2task.removeAttribute("checked");
+
+    gCurrentMode = 'mail';
+    document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);
+
+    document.commandDispatcher.updateCommands('calendar_commands');
+    window.setCursor("auto");
+  }
+}
+
+/**
+ * ltnSwitch2Calendar() switches to the calendar mode
+ */
+
+function ltnSwitch2Calendar() {
+  if (gCurrentMode != 'calendar') {
+    var switch2mail = document.getElementById("switch2mail");
+    var switch2calendar = document.getElementById("switch2calendar");
+    var switch2task = document.getElementById("switch2task");
+    switch2mail.removeAttribute("checked");
+    switch2calendar.setAttribute("checked", "true");
+    switch2task.removeAttribute("checked");
+
+    gCurrentMode = 'calendar';    
+    document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);    
+
+    // display the calendar panel on the display deck
+    var viewBox = document.getElementById("calendar-view-box");
+    uncollapseElement(viewBox);
+    var deck = document.getElementById("calendarDisplayDeck");
+    deck.selectedPanel = viewBox;
+
+    // show the last displayed type of calendar view
+    showCalendarView(gLastShownCalendarView);
+
+    document.commandDispatcher.updateCommands('calendar_commands');
+    window.setCursor("auto");
+  }
+}
+
+/**
+ * ltnSwitch2Task() switches to the task mode
+ */
+
+function ltnSwitch2Task() {
+  if (gCurrentMode != 'task') {
+    var switch2mail = document.getElementById("switch2mail");
+    var switch2calendar = document.getElementById("switch2calendar");
+    var switch2task = document.getElementById("switch2task");
+    switch2mail.removeAttribute("checked");
+    switch2calendar.removeAttribute("checked");
+    switch2task.setAttribute("checked", "true");
+
+    gCurrentMode = 'task';
+    document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);    
+
+    // display the task panel on the display deck
+    var taskBox = document.getElementById("calendar-task-box");
+    uncollapseElement(taskBox);
+    var deck = document.getElementById("calendarDisplayDeck");
+    deck.selectedPanel = taskBox;
+
+    document.commandDispatcher.updateCommands('calendar_commands');
+    window.setCursor("auto");
+  }
+}
+
+const gCalSetupMailContext = {
+    popup: function gCalSetupMailContext_popup() {
+        var hasSelection = (GetFirstSelectedMessage() != null);
+        // Disable the convert menu altogether.
+        setElementValue("mailContext-calendar-convert-menu",
+                        !hasSelection && "true", "hidden");
+    }
+};
+
+// Overwrite the InitMessageMenu function, since we never know in which order
+// the popupshowing event will be processed. This function takes care of
+// disabling the message menu when in calendar or task mode.
+function calInitMessageMenu() {
+    calInitMessageMenu.origFunc();
+
+    document.getElementById("markMenu").disabled = (gCurrentMode != 'mail');
+}
+calInitMessageMenu.origFunc = InitMessageMenu;
+InitMessageMenu = calInitMessageMenu;
+
 document.addEventListener("load", ltnOnLoad, true);
--- a/calendar/lightning/content/messenger-overlay-sidebar.xul
+++ b/calendar/lightning/content/messenger-overlay-sidebar.xul
@@ -71,384 +71,425 @@
 <overlay id="ltnSidebarOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 <!-- All JS files that messenger-overlay-sidebar.xul wishes to include *must* go into the
      calendar-scripts.inc file (all scripts shared with Sunbird) or lightning-scripts.inc
      file (scripts relevant for Lightning-only). -->
 #include ../../base/content/calendar-scripts.inc
 #include lightning-scripts.inc
 
-<menupopup id="menu_FilePopup">
-  <menu id="menu_Open"
-        mode="calendar"
-        label="&lightning.menupopup.open.label;"
-        accesskey="&lightning.menupopup.open.accesskey;"
-        insertafter="menu_New">
-    <menupopup id="menu_OpenPopup">
-      <menuitem id="ltnOpenMessageFileMenuitem"
-                mode="calendar"
-                label="&lightning.menupopup.open.message.label;"
-                accesskey="&lightning.menupopup.open.message.accesskey;"
-                oncommand="MsgOpenFromFile();"/>
-      <menuitem id="ltnOpenCalendarFileMenuitem"
-                mode="calendar"
-                label="&lightning.menupopup.open.calendar.label;"
-                accesskey="&lightning.menupopup.open.calendar.accesskey;"
-                oncommand="openLocalCalendar();"/>
-    </menupopup>
-  </menu>
-  <menuitem id="calendar-export-selection-menu"
-             mode="calendar"
-             label="&calendar.export.selection.label;"
-             accesskey="&calendar.export.selection.accesskey;"
-             command="calendar_export_selection_command"
-             observes="calendar_export_selection_command"
-             insertafter="menu_close"/>
-  <menuitem id="calendar-export-menu"
-             mode="calendar"
-             label="&calendar.export.calendar;"
-             accesskey="&calendar.export.calendar.accesskey;"
-             command="calendar_export_command"
-             observes="calendar_export_command"
-             insertafter="menu_close"/>
-  <menuitem id="calendar-import-menu"
-             label="&calendar.importcalendar.label;"
-             accesskey="&calendar.import.accesskey;"
-             command="calendar_import_command"
-             observes="calendar_import_command"
-             mode="calendar"
-             insertafter="menu_close"/>
-  <menuseparator id="afterMenu_close"
-             mode="calendar"
-             insertafter="menu_close"/>
-</menupopup>
+  <menupopup id="menu_FilePopup">
+    <menu id="menu_Open"
+          mode="calendar"
+          label="&lightning.menupopup.open.label;"
+          accesskey="&lightning.menupopup.open.accesskey;"
+          insertafter="menu_New">
+      <menupopup id="menu_OpenPopup">
+        <menuitem id="ltnOpenMessageFileMenuitem"
+                  label="&lightning.menupopup.open.message.label;"
+                  accesskey="&lightning.menupopup.open.message.accesskey;"
+                  oncommand="MsgOpenFromFile();"/>
+        <menuitem id="ltnOpenCalendarFileMenuitem"
+                  label="&lightning.menupopup.open.calendar.label;"
+                  accesskey="&lightning.menupopup.open.calendar.accesskey;"
+                  oncommand="openLocalCalendar();"/>
+      </menupopup>
+    </menu>
+  </menupopup>
+  <menuitem id="openMessageFileMenuitem" hidden="true"/>
 
   <menupopup id="menu_NewPopup">
-    <menuitem id="ltnNewEvent" label="&lightning.menupopup.new.event.label;"
-               accesskey="&event.new.event.accesskey;"
-               key="calendar-new-event-key"
-               command="calendar_new_event_command"
-               observes="calendar_new_event_command"
-               position="2"/>
-    <menuitem id="ltnNewTask" label="&lightning.menupopup.new.task.label;"
-               accesskey="&event.new.todo.accesskey;"
-               key="calendar-new-todo-key"
-               command="calendar_new_todo_command"
-               observes="calendar_new_todo_command"
-               position="3"/>
-    <menuseparator id="afterltnNewTask" position="4"/>
+    <menuitem id="ltnNewEvent"
+              label="&lightning.menupopup.new.event.label;"
+              insertbefore="menu_newFolder"
+              accesskey="&event.new.event.accesskey;"
+              key="calendar-new-event-key"
+              command="calendar_new_event_command"
+              observes="calendar_new_event_command"/>
+    <menuitem id="ltnNewTask"
+              label="&lightning.menupopup.new.task.label;"
+              insertbefore="menu_newFolder"
+              accesskey="&event.new.todo.accesskey;"
+              key="calendar-new-todo-key"
+              command="calendar_new_todo_command"
+              observes="calendar_new_todo_command"/>
+    <menuseparator id="afterltnNewTask"
+                   insertbefore="menu_newFolder"/>
+
     <menuseparator id="beforenewAccountMenuItem"
-                   mode="mail"
                    insertbefore="newAccountMenuItem"/>
     <menuitem id="ltnNewCalendar" label="&lightning.menupopup.new.calendar.label;"
                command="calendar_new_calendar_command"
                observes="calendar_new_calendar_command"
                accesskey="&calendar.new.server.accesskey;"
                insertafter="newAccountMenuItem"/>
   </menupopup>
+
+  <menupopup id="menu_EditPopup">
+    <menuitem id="ltnCalendarProperties"
+              insertafter="menu_properties"
+              label="&calendar.properties.label;"
+              accesskey="&calendar.properties.accesskey;"
+              command="calendar_edit_calendar_command"
+              observes="calendar_edit_calendar_command"/>
+  </menupopup>
+
   <menupopup id="menu_View_Popup">
-    <menu label="&showCurrentView.label;"
-          mode="calendar,task"
-          accesskey="&showCurrentView.accesskey;">
-      <menupopup>
-        <menuitem type="checkbox"
-                  id="ltn-workdays-only-menuitem"
-                  label="&calendar.onlyworkday.checkbox.label;"
-                  accesskey="&calendar.onlyworkday.checkbox.accesskey;"
-                  mode="calendar"
-                  observes="calendar_toggle_workdays_only_command"/>
-        <menuitem type="checkbox"
-                  id="ltn-tasks-in-view-menuitem"
-                  label="&calendar.displaytodos.checkbox.label;"
-                  accesskey="&calendar.displaytodos.checkbox.accesskey;"
-                  mode="calendar"
-                  observes="calendar_toggle_tasks_in_view_command"/>
-        <menuitem type="checkbox"
-                  id="ltn-show-completed-in-view"
-                  persist="checked"
-                  label="&calendar.completedtasks.checkbox.label;"
-                  accesskey="&calendar.completedtasks.checkbox.accesskey;"
-                  mode="calendar"
-                  observes="calendar_toggle_show_completed_in_view_command"/>
-        <menuitem type="checkbox"
-                  id="ltn-multiday-rotated"
-                  label="&calendar.orientation.label;"
-                  accesskey="&calendar.orientation.accesskey;"
-                  mode="calendar"
-                  command="calendar_toggle_orientation_command"
-                  observes="calendar_toggle_orientation_command"/>
-        <observes element="filterBroadcaster" attribute="value" onbroadcast="checkRadioControl(this.parentNode, document.getElementById(this.getAttribute('element')).getAttribute('value'));"/>
-        <menuitem id="tasks-view-filter-all"
-                  name="filtergroup"
-                  value="all"
-                  type="radio"
-                  command="calendar_task_filter_command"
-                  mode="task"
-                  label="&calendar.task.filter.all.label;"
-                  accesskey="&calendar.task.filter.all.accesskey;"/>
-        <menuitem id="tasks-view-filter-today"
-                  name="filtergroup"
-                  value="today"
-                  type="radio"
-                  command="calendar_task_filter_command"
-                  mode="task"
-                  label="&calendar.task.filter.today.label;"
-                  accesskey="&calendar.task.filter.today.accesskey;"/>
-        <menuitem id="tasks-view-filter-next7days"
-                  name="filtergroup"
-                  value="next7days"
-                  type="radio"
-                  command="calendar_task_filter_command"
-                  mode="task"
-                  label="&calendar.task.filter.next7days.label;"
-                  accesskey="&calendar.task.filter.next7days.accesskey;"/>
-        <menuitem id="tasks-view-filter-notstartedtasks"
-                  name="filtergroup"
-                  value="notstarted"
-                  type="radio"
-                  command="calendar_task_filter_command"
-                  mode="task"
-                  label="&calendar.task.filter.notstarted.label;"
-                  accesskey="&calendar.task.filter.notstarted.accesskey;"/>
-        <menuitem id="tasks-view-filter-overdue"
-                  name="filtergroup"
-                  value="overdue"
-                  type="radio"
-                  command="calendar_task_filter_command"
-                  mode="task"
-                  label="&calendar.task.filter.overdue.label;"
-                  accesskey="&calendar.task.filter.overdue.accesskey;"/>
-        <menuitem id="tasks-view-filter-completed"
-                  name="filtergroup"
-                  type="radio"
-                  value="completed"
-                  command="calendar_task_filter_command"
-                  mode="task"
-                  label="&calendar.task.filter.completed.label;"
-                  accesskey="&calendar.task.filter.completed.accesskey;"/>
-        <menuitem id="tasks-view-filter-open"
-                  name="filtergroup"
-                  type="radio"
-                  value="open"
-                  command="calendar_task_filter_command"
-                  mode="task"
-                  label="&calendar.task.filter.open.label;"
-                  accesskey="&calendar.task.filter.open.accesskey;"/>
-      </menupopup>
-    </menu>
-    <menuseparator id="before-Unifinder-Section" mode="calendar"/>
-    <menuitem id="calendar-show-unifinder-menu"
-              type="checkbox"
-              checked="true"
-              label="&showUnifinderCmd.label;"
-              accesskey="&showUnifinderCmd.accesskey;"
-              mode="calendar"
-              command="calendar_show_unifinder_command"/>
-    <menuseparator id="before-Calendar-View-Section" mode="calendar"/>
-    <menuitem id="ltnChangeViewDay"
-              label="&lightning.toolbar.day.label;"
-              accesskey="&lightning.toolbar.day.accesskey;"
-              type="radio"
-              name="calendarMenuViews"
-              mode="calendar"
-              key="calendar-day-view-key"
-              observes="calendar_day-view_command"/>
-    <menuitem id="ltnChangeViewWeek"
-              label="&lightning.toolbar.week.label;"
-              accesskey="&lightning.toolbar.week.accesskey;"
-              type="radio"
-              name="calendarMenuViews"
-              mode="calendar"
-              key="calendar-week-view-key"
-              observes="calendar_week-view_command"/>
-    <menuitem id="ltnChangeViewMultiweek"
-              label="&lightning.toolbar.multiweek.label;"
-              accesskey="&lightning.toolbar.multiweek.accesskey;"
-              type="radio"
-              name="calendarMenuViews"
-              mode="calendar"
-              key="calendar-multiweek-view-key"
-              observes="calendar_multiweek-view_command"/>
-    <menuitem id="ltnChangeViewMonth"
-              label="&lightning.toolbar.month.label;"
-              accesskey="&lightning.toolbar.month.accesskey;"
-              type="radio"
-              name="calendarMenuViews"
-              mode="calendar"
-              key="calendar-month-view-key"
-              observes="calendar_month-view_command"/>
-    <menuseparator id="before-task-View-Section" mode="mail,calendar,task"/>
-    <menuitem id="tasks-view-minimonth"
-              type="checkbox"
-              mode="calendar,task"
-              label="&calendar.tasks.view.minimonth.label;"
-              accesskey="&calendar.tasks.view.minimonth.accesskey;"
-              command="calendar_toggle_minimonthpane_command"/>
-    <menuitem id="tasks-view-filtertasks"
-              type="checkbox"
-              mode="task"
-              label="&calendar.tasks.view.filtertasks.label;"
-              accesskey="&calendar.tasks.view.filtertasks.accesskey;"
-              command="calendar_toggle_filter_command"/>
-    <menuitem id="tasks-view-calendarlist"
-              type="checkbox"
-              mode="calendar,task"
-              label="&calendar.tasks.view.calendarlist.label;"
-              accesskey="&calendar.tasks.view.calendarlist.accesskey;"
-              command="calendar_toggle_calendarlist_command"/>
-    <menuseparator id="before-today-pane"/>
-    <menu id="today-pane-menu"
+    <menuseparator id="ltnViewMenuSeparator"
+                   insertbefore="viewSortMenuSeparator"/>
+    <menu id="ltnTodayPaneMenu"
+          observes="calendar_in_foreground"
+          insertbefore="viewSortMenuSeparator"
           label="&calendar.context.button.label;"
           accesskey="&calendar.context.button.accesskey;">
-      <menupopup>
+      <menupopup id="ltnTodayPaneMenuPopup">
         <menuitem id="ltnShowTodayPane-2"
                   label="&todaypane.showTodayPane.label;"
                   accesskey="&todaypane.showTodayPane.accesskey;"
                   type="checkbox"
                   key="todaypanekey"
                   command="calendar_toggle_todaypane_command"/>
-        <menuseparator id="before-displayminiday"/>
-        <menuitem id="today-pane-displayminiday"
+        <menuseparator id="ltnSeparatorBeforeDisplayMiniday"/>
+        <menuitem id="ltnTodayPaneDisplayMiniday"
                   name="minidisplay"
                   value="miniday"
                   type="radio"
-                  oncommand="TodayPane.displayMiniSection(1)"
+                  oncommand="TodayPane.displayMiniSection('miniday')"
                   label="&todaypane.showMiniday.label;"
                   accesskey="&todaypane.showMiniday.accesskey;"/>
-        <menuitem id="today-pane-displayminimonth"
+        <menuitem id="ltnTodayPaneDisplayMinimonth"
                   name="minidisplay"
                   value="minimonth"
                   type="radio"
-                  oncommand="TodayPane.displayMiniSection(2)"
+                  oncommand="TodayPane.displayMiniSection('minimonth')"
                   label="&todaypane.showMinimonth.label;"
                   accesskey="&todaypane.showMinimonth.accesskey;"/>
-        <menuitem id="today-pane-displaynone"
+        <menuitem id="ltnTodayPaneDisplayNone"
                   name="minidisplay"
                   value="none"
                   type="radio"
-                  oncommand="TodayPane.displayMiniSection(3)"
+                  oncommand="TodayPane.displayMiniSection('none')"
                   label="&todaypane.showNone.label;"
                   accesskey="&todaypane.showNone.accesskey;"/>
       </menupopup>
     </menu>
+    <menu id="ltnCalendarMenu"
+          insertbefore="viewSortMenuSeparator"
+          label="&lightning.menu.view.calendar.label;"
+          accesskey="&lightning.menu.view.calendar.accesskey;">
+      <menupopup id="ltnTasksMenuPopup">
+        <menuitem id="ltnChangeViewDay"
+                  label="&lightning.toolbar.day.label;"
+                  accesskey="&lightning.toolbar.day.accesskey;"
+                  type="radio"
+                  name="calendarMenuViews"
+                  key="calendar-day-view-key"
+                  observes="calendar_day-view_command"/>
+        <menuitem id="ltnChangeViewWeek"
+                  label="&lightning.toolbar.week.label;"
+                  accesskey="&lightning.toolbar.week.accesskey;"
+                  type="radio"
+                  name="calendarMenuViews"
+                  key="calendar-week-view-key"
+                  observes="calendar_week-view_command"/>
+        <menuitem id="ltnChangeViewMultiweek"
+                  label="&lightning.toolbar.multiweek.label;"
+                  accesskey="&lightning.toolbar.multiweek.accesskey;"
+                  type="radio"
+                  name="calendarMenuViews"
+                  key="calendar-multiweek-view-key"
+                  observes="calendar_multiweek-view_command"/>
+        <menuitem id="ltnChangeViewMonth"
+                  label="&lightning.toolbar.month.label;"
+                  accesskey="&lightning.toolbar.month.accesskey;"
+                  type="radio"
+                  name="calendarMenuViews"
+                  key="calendar-month-view-key"
+                  observes="calendar_month-view_command"/>
+        <menuseparator id="ltnBeforeCalendarViewSection"/>
+        <menuitem id="ltnTasksViewMinimonth"
+                  type="checkbox"
+                  label="&calendar.tasks.view.minimonth.label;"
+                  accesskey="&calendar.tasks.view.minimonth.accesskey;"
+                  command="calendar_toggle_minimonthpane_command"/>
+        <menuitem id="ltnTasksViewCalendarlist"
+                  type="checkbox"
+                  label="&calendar.tasks.view.calendarlist.label;"
+                  accesskey="&calendar.tasks.view.calendarlist.accesskey;"
+                  command="calendar_toggle_calendarlist_command"/>
+        <menuseparator id="ltnBeforeCurrentViewMenu"/>
+        <menu id="ltnCalendarCurrentViewMenu"
+              observes="calendar_mode_calendar"
+              label="&showCurrentView.label;"
+              accesskey="&showCurrentView.accesskey;">
+          <menupopup id="ltnCalendarCurrentViewMenuPopup">
+            <menuitem type="checkbox"
+                      id="ltnWorkdaysOnlyMenuitem"
+                      label="&calendar.onlyworkday.checkbox.label;"
+                      accesskey="&calendar.onlyworkday.checkbox.accesskey;"
+                      observes="calendar_toggle_workdays_only_command"/>
+            <menuitem type="checkbox"
+                      id="ltnTasksInViewMenuitem"
+                      label="&calendar.displaytodos.checkbox.label;"
+                      accesskey="&calendar.displaytodos.checkbox.accesskey;"
+                      observes="calendar_toggle_tasks_in_view_command"/>
+            <menuitem type="checkbox"
+                      id="ltnShowCompletedInViewMenuItem"
+                      label="&calendar.completedtasks.checkbox.label;"
+                      accesskey="&calendar.completedtasks.checkbox.accesskey;"
+                      observes="calendar_toggle_show_completed_in_view_command"/>
+            <menuitem type="checkbox"
+                      id="ltnViewRotated"
+                      label="&calendar.orientation.label;"
+                      accesskey="&calendar.orientation.accesskey;"
+                      command="calendar_toggle_orientation_command"
+                      observes="calendar_toggle_orientation_command"/>
+          </menupopup>
+        </menu>
+      </menupopup>
+    </menu>
+    <menu id="ltnTasksMenu"
+          observes="calendar_mode_task"
+          insertbefore="viewSortMenuSeparator"
+          label="&lightning.menu.view.tasks.label;"
+          accesskey="&lightning.menu.view.tasks.accesskey;">
+      <menupopup id="ltnTasksMenuPopup">
+        <observes element="filterBroadcaster"
+                  attribute="value"
+                  onbroadcast="checkRadioControl(this.parentNode, document.getElementById(this.getAttribute('element')).getAttribute('value'));"/>
+        <menuitem id="ltnTasksViewFilterTasks"
+                  type="checkbox"
+                  label="&calendar.tasks.view.filtertasks.label;"
+                  accesskey="&calendar.tasks.view.filtertasks.accesskey;"
+                  command="calendar_toggle_filter_command"/>
+        <menuseparator id="ltnTasksViewSeparator"/>
+        <menuitem id="ltnTasksViewFilterAll"
+                  name="filtergroup"
+                  value="all"
+                  type="radio"
+                  command="calendar_task_filter_command"
+                  label="&calendar.task.filter.all.label;"
+                  accesskey="&calendar.task.filter.all.accesskey;"/>
+        <menuitem id="ltnTasksViewFilterToday"
+                  name="filtergroup"
+                  value="today"
+                  type="radio"
+                  command="calendar_task_filter_command"
+                  label="&calendar.task.filter.today.label;"
+                  accesskey="&calendar.task.filter.today.accesskey;"/>
+        <menuitem id="ltnTasksViewFilterNext7days"
+                  name="filtergroup"
+                  value="next7days"
+                  type="radio"
+                  command="calendar_task_filter_command"
+                  label="&calendar.task.filter.next7days.label;"
+                  accesskey="&calendar.task.filter.next7days.accesskey;"/>
+        <menuitem id="ltnTasksViewFilterNotstartedtasks"
+                  name="filtergroup"
+                  value="notstarted"
+                  type="radio"
+                  command="calendar_task_filter_command"
+                  label="&calendar.task.filter.notstarted.label;"
+                  accesskey="&calendar.task.filter.notstarted.accesskey;"/>
+        <menuitem id="ltnTasksViewFilterOverdue"
+                  name="filtergroup"
+                  value="overdue"
+                  type="radio"
+                  command="calendar_task_filter_command"
+                  label="&calendar.task.filter.overdue.label;"
+                  accesskey="&calendar.task.filter.overdue.accesskey;"/>
+        <menuitem id="ltnTasksViewFilterCompleted"
+                  name="filtergroup"
+                  type="radio"
+                  value="completed"
+                  command="calendar_task_filter_command"
+                  label="&calendar.task.filter.completed.label;"
+                  accesskey="&calendar.task.filter.completed.accesskey;"/>
+        <menuitem id="ltnTasksViewFilterOpen"
+                  name="filtergroup"
+                  type="radio"
+                  value="open"
+                  command="calendar_task_filter_command"
+                  label="&calendar.task.filter.open.label;"
+                  accesskey="&calendar.task.filter.open.accesskey;"/>
+      </menupopup>
+    </menu>
   </menupopup>
 
+  <menupopup id="menu_GoPopup">
+    <menuitem id="ltnGoToToday"
+              insertafter="goNextSeparator"
+              label="&goTodayCmd.label;"
+              accesskey="&goTodayCmd.accesskey;"
+              observes="calendar_go_to_today_command"
+              key="calendar-go-to-today-key"/>
+  </menupopup>
+
+  <menupopup id="menu_GoNextPopup">
+    <menuseparator id="ltnGoNextSeparator"/>
+    <!-- Label is set up automatically using the view id. When writing a
+         view extension, overlay this menuitem and add a label-<myviewtype>
+         attribute with the correct label -->
+    <menuitem id="calendar-go-menu-next"
+              label=""
+              label-day="&lightning.toolbar.day.label;"
+              label-week="&lightning.toolbar.week.label;"
+              label-multiweek="&lightning.toolbar.week.label;"
+              label-month="&lightning.toolbar.month.label;"
+              accesskey-day="&lightning.toolbar.day.accesskey;"
+              accesskey-week="&lightning.toolbar.week.accesskey;"
+              accesskey-multiweek="&lightning.toolbar.week.accesskey;"
+              accesskey-month="&lightning.toolbar.month.accesskey;"
+              observes="calendar_view_next_command"/>
+  </menupopup>
+  <menupopup id="menu_GoPreviousPopup">
+    <menuseparator id="ltnGoPreviousSeparator"/>
+    <!-- Label is set up automatically using the view id. When writing a
+         view extension, overlay this menuitem and add a label-<myviewtype>
+         attribute with the correct label -->
+    <menuitem id="calendar-go-menu-previous"
+              label=""
+              label-day="&lightning.toolbar.day.label;"
+              label-week="&lightning.toolbar.week.label;"
+              label-multiweek="&lightning.toolbar.week.label;"
+              label-month="&lightning.toolbar.month.label;"
+              accesskey-day="&lightning.toolbar.day.accesskey;"
+              accesskey-week="&lightning.toolbar.week.accesskey;"
+              accesskey-multiweek="&lightning.toolbar.week.accesskey;"
+              accesskey-month="&lightning.toolbar.month.accesskey;"
+              observes="calendar_view_prev_command"/>
+  </menupopup>
+
+  <menubar id="mail-menubar">
+    <menu id="menu_Event_Task"
+          label="&lightning.menu.eventtask.label;"
+          accesskey="&lightning.menu.eventtask.accesskey;"
+          insertafter="messageMenu">
+      <menupopup id="menu_Event_Task_Popup" onpopupshowing="changeMenuForTask(event)">
+        <menuitem id="ltnNewEvent2"
+                  label="&event.new.event;"
+                  accesskey="&event.new.event.accesskey;"
+                  key="calendar-new-event-key"
+                  command="calendar_new_event_command"
+                  observes="calendar_new_event_command"/>
+        <menuitem id="ltnNewTask2"
+                  label="&event.new.todo;"
+                  accesskey="&event.new.todo.accesskey;"
+                  key="calendar-new-todo-key"
+                  command="calendar_new_todo_command"
+                  observes="calendar_new_todo_command"/>
+        <menuseparator id="before-Calendar-Mode-Section"/>
+        <menuitem id="ltnMenuSwitchToCalendar"
+                  label="&lightning.toolbar.calendar.label;"
+                  accesskey="&lightning.toolbar.calendar.accesskey;"
+                  command="switch2calendar"
+                  key="openLightningKey"/>
+        <menuitem id="ltnMenuSwitchToTask"
+                  label="&lightning.toolbar.task.label;"
+                  accesskey="&lightning.toolbar.task.accesskey;"
+                  command="switch2task"
+                  key="openTasksKey"/>
+        <menuseparator id="ltnBeforeCalendarSection"/>
+        <!-- Menuitems have different schema just to match sunbird -->
+        <menuitem id="calendar-export-menu"
+                  label="&calendar.export.label;"
+                  accesskey="&calendar.export.accesskey;"
+                  command="calendar_export_command"
+                  observes="calendar_export_command"/>
+        <menuitem id="calendar-import-menu"
+                  label="&calendar.import.label;"
+                  accesskey="&calendar.import.accesskey;"
+                  command="calendar_import_command"
+                  observes="calendar_import_command"/>
+        <menuitem id="ltnPublishCalendar"
+                  label="&calendar.publish.label;"
+                  accesskey="&calendar.publish.accesskey;"
+                  commmand="calendar_publish_calendar_command"
+                  observes="calendar_publish_calendar_command"/>
+        <menuitem id="ltnDeleteSelectedCalendar"
+                  label="&calendar.deletecalendar.label;"
+                  accesskey="&calendar.deletecalendar.accesskey;"
+                  command="calendar_delete_calendar_command"
+                  observes="calendar_delete_calendar_command"/>
+        <menuseparator id="ltnBeforeTaskActions"/>
+        <menuitem id="ltnTaskActionsMarkCompletedMenuitem"
+                  type="checkbox"
+                  label="&calendar.context.markcompleted.label;"
+                  accesskey="&calendar.context.markcompleted.accesskey;"
+                  command="calendar_toggle_completed_command"
+                  observes="calendar_toggle_completed_command"/>
+        <menu id="ltnTaskActionsPriorityMenuitem"
+              label="&calendar.context.priority.label;"
+              accesskey="&calendar.context.priority.accesskey;"
+              command="calendar_general-priority_command"
+              observes="calendar_general-priority_command">
+          <menupopup type="task-priority"/>
+        </menu>
+        <menu id="ltnTaskActionsProgressMenuitem"
+              label="&calendar.context.progress.label;"
+              accesskey="&calendar.context.progress.accesskey;"
+              command="calendar_general-progress_command"
+              observes="calendar_general-progress_command">
+          <menupopup type="task-progress"/>
+        </menu>
+        <menuseparator id="ltnBeforeUnifinderSection" />
+        <!-- menuitem has different schema just to match sunbird -->
+        <menuitem id="calendar-show-unifinder-menu"
+                  type="checkbox"
+                  checked="true"
+                  label="&showUnifinderCmd.label;"
+                  accesskey="&showUnifinderCmd.accesskey;"
+                  command="calendar_show_unifinder_command"/>
+      </menupopup>
+    </menu>
+  </menubar>
+
   <window id="messengerWindow">
 
-    <broadcasterset id="calendar_broadcasters">
-      <broadcaster id="filterBroadcaster" value="all"/>
-    </broadcasterset>
-
     <!-- Be sure to keep these sets, since they will be overlayed by
          calendar/base/content/calendar-common-sets.xul -->
     <commandset id="calendar_commands">
       <command id="agenda_delete_event_command" oncommand="agendaListbox.deleteSelectedItem(false);"/>
       <command id="agenda_edit_event_command" oncommand="agendaListbox.editSelectedItem(event);"/>
       <command id="switch2mail" checked="true"
         oncommand="document.getElementById('tabmail').selectTabByMode('folder')"/>
       <command id="switch2calendar"
         oncommand="document.getElementById('tabmail').openTab('calendar', document.getElementById('calendar-tab-button').getAttribute('tooltiptext'))"/>
       <command id="switch2task"
         oncommand="document.getElementById('tabmail').openTab('tasks', document.getElementById('task-tab-button').getAttribute('tooltiptext'))"/>
       <command id="new_calendar_tab"
         oncommand="document.getElementById('tabmail').openTab('calendar', document.getElementById('calendar-tab-button').getAttribute('tooltiptext'))"/>
       <command id="new_task_tab"
         oncommand="document.getElementById('tabmail').openTab('tasks', document.getElementById('task-tab-button').getAttribute('tooltiptext'))"/>
+      <command id="calendar_go_to_today_command"
+               oncommand="document.getElementById('tabmail').openTab('calendar', document.getElementById('calendar-tab-button').getAttribute('tooltiptext')); goToDate(now())"/>
     </commandset>
 
     <keyset id="calendar-keys">
       <key id="openLightningKey" modifiers="accel" key="3" observes="new_calendar_tab"/>
       <key id="openTasksKey" modifiers="accel" key="4" command="new_task_tab"/>
       <key id="todaypanekey" command="calendar_toggle_todaypane_command" keycode="VK_F11"/>
       <key id="calendar-new-event-key" key="&lightning.keys.event.new;" modifiers="accel" command="calendar_new_event_command"/>
       <key id="calendar-new-todo-key" key="&lightning.keys.todo.new;" modifiers="accel" command="calendar_new_todo_command"/>
     </keyset>
 
-    <popupset id="calendar-popupset">
-      <menupopup id="calendar-GoPopupMenu">
-         <menuitem id="ltnGoToToday"
-                   label="&goTodayCmd.label;"
-                   accesskey="&goTodayCmd.accesskey;"
-                   mode="calendar"
-                   observes="calendar_go_to_today_command"
-                   key="calendar-go-to-today-key"/>
-         <menuseparator id="before-ModeMenuItems"/>
-         <menuitem id="ltnMenu_mail"
-                   type="radio"
-                   name="modemenu"
-                   label="&lightning.toolbar.mail.label;"
-                   accesskey="&lightning.toolbar.mail.accesskey;"
-                   command="switch2mail"
-                   key="key_mail" modifiers="accel"/>
-         <menuitem id="ltnMenu_calendar"
-                   type="radio"
-                   name="modemenu"
-                   label="&lightning.toolbar.calendar.label;"
-                   accesskey="&lightning.toolbar.calendar.accesskey;"
-                   command="switch2calendar"
-                   key="openLightningKey"/>
-         <menuitem id="ltnMenu_tasks"
-                   type="radio"
-                   name="modemenu"
-                   label="&lightning.toolbar.task.label;"
-                   accesskey="&lightning.toolbar.task.accesskey;"
-                   command="switch2task"
-                   key="openTasksKey"/>
-         <menuseparator id="before-AddressBook"/>
-         <menuitem id="addressBook-calendar" label="&addressBookCmd.label;"
-                   accesskey="&addressBookCmd.accesskey;"
-                   key="key_addressbook"
-                   oncommand="toAddressBook();"/>
-      </menupopup>
-      <menupopup id="calendarCalendarPopupMenu">
-          <menuitem id="ltnNewEvent2" label="&event.new.event;"
-               accesskey="&event.new.event.accesskey;"
-               key="calendar-new-event-key"
-               observes="calendar_new_event_command"
-               command="calendar_new_event_command"
-               position="2"/>
-          <menuitem id="ltnNewTask2" label="&event.new.todo;"
-               accesskey="&event.new.todo.accesskey;"
-               key="calendar-new-todo-key"
-               observes="calendar_new_todo_command"
-               command="calendar_new_todo_command"
-               position="3"/>
-         <menuseparator id="firstCalendarSeparator" mode="calendar"/>
-         <menuitem id="publishCalendar"
-                   label="&calendar.publish.label;"
-                   accesskey="&calendar.publish.accesskey;"
-                   commmand="calendar_publish_calendar_command"
-                   observes="calendar_publish_calendar_command"/>
-         <menuseparator id="afterSubscription"/>
-         <menuitem label="&calendar.context.newserver.label;"
-                   id="calpopup-new"
-                   accesskey="&calendar.context.newserver.accesskey;"
-                   command="calendar_new_calendar_command"
-                   observes="calendar_new_calendar_command"/>
-        <menuitem id="ltnDeleteSelectedCalendar"
-                  label="&calendar.context.deleteserver.label;"
-                  accesskey="&calendar.context.deleteserver.accesskey;"
-                  command="calendar_delete_calendar_command"
-                  observes="calendar_delete_calendar_command"/>
-        <menuseparator id="beforeProperties"/>
-         <menuitem label="&calendar.properties.label;"
-                   id="calendarproperties"
-                   accesskey="&calendar.properties.accesskey;"
-                   command="calendar_edit_calendar_command"
-                   observes="calendar_edit_calendar_command"/>
-      </menupopup>
-    </popupset>
+    <broadcasterset id="calendar_broadcasters">
+      <broadcaster id="filterBroadcaster" value="all"/>
+    </broadcasterset>
+
+    <popupset id="calendar-popupset"/>
   </window>
 
   <hbox id="tabmail-buttons">
     <toolbarbutton id="calendar-tab-button" command="new_calendar_tab"
       tooltiptext="&lightning.toolbar.calendar.label;"/>
     <toolbarbutton id="task-tab-button" command="new_task_tab"
       tooltiptext="&lightning.toolbar.task.label;"/>
   </hbox>
+
   <tabpanels id="tabpanelcontainer">
     <vbox id="calendarTabPanel">
       <hbox id="calendarContent" flex="1">
         <vbox id="ltnSidebar"
               minwidth="100"
               width="200"
               persist="collapsed width">
           <modevbox id="minimonth-pane" mode="calendar,task" broadcaster="modeBroadcaster" refcontrol="calendar_toggle_minimonthpane_command">
deleted file mode 100644
--- a/calendar/lightning/content/messenger-overlay-toolbar.js
+++ /dev/null
@@ -1,150 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Sun Microsystems code.
- *
- * The Initial Developer of the Original Code is Sun Microsystems.
- * Portions created by the Initial Developer are Copyright (C) 2007
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Michael Buettner <michael.buettner@sun.com>
- *   Philipp Kewisch <mozilla@kewis.ch>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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
- * decision by deleting the provisions above and replace them with the notice
- * 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 ***** */
-
-/**
- * Global variables
- */
-var gCustomizeId;
-
-/**
- * the current mode is set to a string defining the current
- * mode we're in. allowed values are:
- *  - 'mode'
- *  - 'mail'
- *  - 'calendar'
- *  - 'task'
- */
-var gCurrentMode = 'mail';
-
-/**
- * ltnSwitch2Mail() switches to the mail mode
- */
-
-function ltnSwitch2Mail() {
-  if (gCurrentMode != 'mail') {
-    var switch2mail = document.getElementById("switch2mail");
-    var switch2calendar = document.getElementById("switch2calendar");
-    var switch2task = document.getElementById("switch2task");
-    switch2mail.setAttribute("checked", "true");
-    switch2calendar.removeAttribute("checked");
-    switch2task.removeAttribute("checked");
-
-    gCurrentMode = 'mail';
-    swapPopupMenus();
-    document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);
-
-    document.commandDispatcher.updateCommands('calendar_commands');
-
-    // Disable the rotate view menuitem
-    document.getElementById("calendar_toggle_orientation_command")
-            .setAttribute("disabled", "true");
-    window.setCursor("auto");
-  }
-}
-
-/**
- * ltnSwitch2Calendar() switches to the calendar mode
- */
-
-function ltnSwitch2Calendar() {
-  if (gCurrentMode != 'calendar') {
-    var switch2mail = document.getElementById("switch2mail");
-    var switch2calendar = document.getElementById("switch2calendar");
-    var switch2task = document.getElementById("switch2task");
-    switch2mail.removeAttribute("checked");
-    switch2calendar.setAttribute("checked", "true");
-    switch2task.removeAttribute("checked");
-
-    gCurrentMode = 'calendar';    
-    swapPopupMenus();
-    document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);    
-
-    // display the calendar panel on the display deck
-    var viewBox = document.getElementById("calendar-view-box");
-    uncollapseElement(viewBox);
-    var deck = document.getElementById("calendarDisplayDeck");
-    deck.selectedPanel = viewBox;
-
-    // show the last displayed type of calendar view
-    showCalendarView(gLastShownCalendarView);
-
-    document.commandDispatcher.updateCommands('calendar_commands');
-
-    window.setCursor("auto");
-  }
-}
-
-/**
- * ltnSwitch2Task() switches to the task mode
- */
-
-function ltnSwitch2Task() {
-  if (gCurrentMode != 'task') {
-    var switch2mail = document.getElementById("switch2mail");
-    var switch2calendar = document.getElementById("switch2calendar");
-    var switch2task = document.getElementById("switch2task");
-    switch2mail.removeAttribute("checked");
-    switch2calendar.removeAttribute("checked");
-    switch2task.setAttribute("checked", "true");
-
-    gCurrentMode = 'task';
-    swapPopupMenus();
-    document.getElementById("modeBroadcaster").setAttribute("mode", gCurrentMode);    
-
-    // display the task panel on the display deck
-    var taskBox = document.getElementById("calendar-task-box");
-    uncollapseElement(taskBox);
-    var deck = document.getElementById("calendarDisplayDeck");
-    deck.selectedPanel = taskBox;
-
-    document.commandDispatcher.updateCommands('calendar_commands');
-
-    window.setCursor("auto");
-  }
-}
-
-const gCalSetupMailContext = {
-    popup: function gCalSetupMailContext_popup() {
-        var hasSelection = (GetFirstSelectedMessage() != null);
-        // Disable the convert menu altogether.
-        setElementValue("mailContext-calendar-convert-menu",
-                        !hasSelection && "true", "hidden");
-    }
-};
-
-
-
--- a/calendar/lightning/jar.mn
+++ b/calendar/lightning/jar.mn
@@ -35,17 +35,16 @@ lightning.jar:
     content/lightning/lightning-widgets.xml                (content/lightning-widgets.xml)
     content/lightning/messenger-overlay-sidebar.css        (content/messenger-overlay-sidebar.css)
     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/messenger-overlay-toolbar.js         (content/messenger-overlay-toolbar.js)
 *   content/lightning/messenger-overlay-toolbar.xul        (content/messenger-overlay-toolbar.xul)
 % skin lightning classic/1.0 %skin/lightning/
     skin/lightning/imip.css                                (themes/@THEME@/imip.css)
     skin/lightning/lightning.css                           (themes/@THEME@/lightning.css)
     skin/lightning/accountCentral.css                      (themes/@THEME@/accountCentral.css)
     skin/lightning/lightning-widgets.css                   (themes/@THEME@/lightning-widgets.css)
 
 calendar.jar:
--- a/calendar/locales/en-US/chrome/calendar/menuOverlay.dtd
+++ b/calendar/locales/en-US/chrome/calendar/menuOverlay.dtd
@@ -57,24 +57,27 @@
 <!ENTITY calendar.print.label                   "Print…">
 <!ENTITY calendar.print.key                     "P">
 <!ENTITY calendar.print.accesskey               "P">
 
 <!ENTITY calendar.import.label                  "Import…">
 <!ENTITY calendar.import.key                    "I">
 <!ENTITY calendar.import.accesskey              "I">
 
-<!ENTITY calendar.export.calendar.label         "Export Calendar…">
-<!ENTITY calendar.export.calendar.accesskey     "E">
+<!ENTITY calendar.export.label                  "Export…">
+<!ENTITY calendar.export.accesskey              "E">
 <!ENTITY calendar.export.selection.label        "Export Selection…">
 <!ENTITY calendar.export.selection.accesskey    "S">
 
 <!ENTITY calendar.publish.label                 "Publish…">
 <!ENTITY calendar.publish.accesskey             "b">
 
+<!ENTITY calendar.deletecalendar.label          "Delete Selected Calendar…">
+<!ENTITY calendar.deletecalendar.accesskey      "D">
+
 <!ENTITY calendar.menu.customize.label          "Customize…">
 <!ENTITY calendar.menu.customize.accesskey      "C">
 
 <!ENTITY showUnifinderCmd.label                 "Find Events">
 <!ENTITY showUnifinderCmd.accesskey             "F">
 
 <!ENTITY calendar.displaytodos.checkbox.label       "Show Tasks in Calendar">
 <!ENTITY calendar.displaytodos.checkbox.accesskey   "T">
@@ -94,18 +97,13 @@
 <!ENTITY goPreviousCmd.month.label              "Previous Month">
 <!ENTITY goPreviousCmd.accesskey                "P">
 
 <!ENTITY goNextCmd.day.label                    "Next Day">
 <!ENTITY goNextCmd.week.label                   "Next Week">
 <!ENTITY goNextCmd.month.label                  "Next Month">
 <!ENTITY goNextCmd.all.accesskey                "e">
 
-<!ENTITY addressBookCmd.label                   "Address Book">
-<!ENTITY addressBookCmd.accesskey               "A">
-
-<!ENTITY calendar.importcalendar.label          "Import Calendar…">
-
 <!ENTITY showCurrentView.label                  "Current View">
 <!ENTITY showCurrentView.accesskey              "V">
 
 <!ENTITY calendar.properties.label              "Calendar Properties…">
 <!ENTITY calendar.properties.accesskey          "C">
--- a/calendar/locales/en-US/chrome/lightning/lightning.dtd
+++ b/calendar/locales/en-US/chrome/lightning/lightning.dtd
@@ -56,21 +56,25 @@
 <!-- Open menu popup in File menu -->
 <!ENTITY lightning.menupopup.open.label               "Open">
 <!ENTITY lightning.menupopup.open.accesskey           "O">
 <!ENTITY lightning.menupopup.open.message.label       "Saved Message…">
 <!ENTITY lightning.menupopup.open.message.accesskey   "M">
 <!ENTITY lightning.menupopup.open.calendar.label      "Calendar File…">
 <!ENTITY lightning.menupopup.open.calendar.accesskey  "C">
 
-<!-- Messenger Sidebar -->
-<!ENTITY lightning.calendar.label            "Calendar">
-<!ENTITY lightning.calendar.accesskey        "C">
-<!ENTITY lightning.tasks.label               "Tasks">
-<!ENTITY lightning.tasks.accesskey           "T">
+<!-- View Menu -->
+<!ENTITY lightning.menu.view.calendar.label            "Calendar">
+<!ENTITY lightning.menu.view.calendar.accesskey        "n">
+<!ENTITY lightning.menu.view.tasks.label               "Tasks">
+<!ENTITY lightning.menu.view.tasks.accesskey           "k">
+
+<!-- Events and Tasks menu -->
+<!ENTITY lightning.menu.eventtask.label                "Events and Tasks">
+<!ENTITY lightning.menu.eventtask.accesskey            "n">
 
 <!-- Mode Toolbar -->
 <!ENTITY lightning.toolbar.mail.label         "Mail">
 <!ENTITY lightning.toolbar.mail.accesskey     "M">
 <!ENTITY lightning.toolbar.calendar.label     "Calendar">
 <!ENTITY lightning.toolbar.calendar.accesskey "C">
 <!ENTITY lightning.toolbar.task.label         "Tasks">
 <!ENTITY lightning.toolbar.task.accesskey     "T">
--- a/calendar/locales/en-US/chrome/sunbird/menuOverlay.dtd
+++ b/calendar/locales/en-US/chrome/sunbird/menuOverlay.dtd
@@ -159,16 +159,19 @@
 <!ENTITY releaseCmd.accesskey                              "R">
 
 <!ENTITY aboutCmd.label                                    "About &brandFullName;">
 <!ENTITY aboutCmd.accesskey                                "A">
 
 <!ENTITY updateCmd.label                                   "Check for Updates…">
 <!ENTITY updateCmd.accesskey                               "o">
 
+<!ENTITY sunbird.export.calendar.label                     "Export Calendar…">
+<!ENTITY sunbird.export.calendar.accesskey                 "E">
+
 <!-- Mac OS X "Window" menu items -->
 <!ENTITY windowMenu.label                                  "Window">
 <!ENTITY minimizeWindow.label                              "Minimize">
 <!ENTITY zoomWindow.label                                  "Zoom">
 <!ENTITY minimizeWindow.key                                "M">
 <!ENTITY bringAllToFront.label                             "Bring All to Front">
 
 <!-- Mac OS X Application menu items -->
--- a/calendar/resources/content/calendar.js
+++ b/calendar/resources/content/calendar.js
@@ -240,15 +240,9 @@ function sbSwitchToView(newView) {
   if (newView == "multiweek") {
       mwWeeksCommand.removeAttribute("disabled");
   } else {
       mwWeeksCommand.setAttribute("disabled", true);
   }
 
   // Call the common view switching code in calendar-views.js
   switchToView(newView);
-
-  var labelAttribute = "label-" + newView + "-view";
-  var prevCommand = document.getElementById("calendar-go-menu-previous");
-  prevCommand.setAttribute("label", prevCommand.getAttribute(labelAttribute));
-  var nextCommand = document.getElementById("calendar-go-menu-next");
-  nextCommand.setAttribute("label", nextCommand.getAttribute(labelAttribute));
 }
--- a/calendar/sunbird/base/content/calendar-menubar.inc
+++ b/calendar/sunbird/base/content/calendar-menubar.inc
@@ -85,18 +85,18 @@
                      accesskey="&calendar.import.accesskey;"
                      observes="calendar_import_command"/>
            <!-- export: getting data out of existing files -->
            <menuitem id="calendar-export-menu"
                      label="&calendar.export.selection.label;"
                      accesskey="&calendar.export.selection.accesskey;"
                      observes="calendar_export_selection_command"/>
            <menuitem id="calendar-export-calendar-menu"
-                     label="&calendar.export.calendar.label;"
-                     accesskey="&calendar.export.calendar.accesskey;"
+                     label="&sunbird.export.calendar.label;"
+                     accesskey="&sunbird.export.calendar.accesskey;"
                      observes="calendar_export_command"/>
            <menuseparator id="calendar-importexport-sep"/>
            <menuitem id="calendar-publish-menu"
                      label="&calendar.publish.selection.label;"
                      accesskey="&calendar.publish.selection.accesskey;"
                      observes="calendar_publish_selected_events_command"/>
            <menuitem id="calendar-publish-calendar-menu"
                      label="&calendar.publish.calendar.label;"
@@ -345,32 +345,33 @@
                      accesskey="&goTodayCmd.accesskey;"
                      observes="calendar_go_to_today_command"/>
            <menuitem id="calendar-go-menu-date"
                      key="go_to_date_key"
                      label="&goDateCmd.label;"
                      accesskey="&goDateCmd.accesskey;"
                      observes="go_date_command"/>
            <menuseparator/>
-           <!-- Label is set appropriate to the variable newView in 
-                sbSwitchToView(newView) of calendar.js -->
+           <!-- Label is set up automatically using the view id. When writing a
+                view extension, overlay this menuitem and add a label-<myviewtype>
+                attribute with the correct label -->
            <menuitem id="calendar-go-menu-previous"
                      label=""
-                     label-day-view="&goPreviousCmd.day.label;"
-                     label-week-view="&goPreviousCmd.week.label;"
-                     label-multiweek-view="&goPreviousCmd.week.label;"
-                     label-month-view="&goPreviousCmd.month.label;"
+                     label-day="&goPreviousCmd.day.label;"
+                     label-week="&goPreviousCmd.week.label;"
+                     label-multiweek="&goPreviousCmd.week.label;"
+                     label-month="&goPreviousCmd.month.label;"
                      accesskey="&goPreviousCmd.accesskey;"
                      observes="calendar_view_prev_command"/>
            <menuitem id="calendar-go-menu-next"
                      label=""
-                     label-day-view="&goNextCmd.day.label;"
-                     label-week-view="&goNextCmd.week.label;"
-                     label-multiweek-view="&goNextCmd.week.label;"
-                     label-month-view="&goNextCmd.month.label;"
+                     label-day="&goNextCmd.day.label;"
+                     label-week="&goNextCmd.week.label;"
+                     label-multiweek="&goNextCmd.week.label;"
+                     label-month="&goNextCmd.month.label;"
                      accesskey="&goNextCmd.all.accesskey;"
                      observes="calendar_view_next_command"/>
          </menupopup>
        </menu>
 
        <menu id="menu_Tools"
              label="&toolsMenu.label;"
              accesskey="&toolsMenu.accesskey;">
--- a/calendar/sunbird/base/content/calendar-sets.inc
+++ b/calendar/sunbird/base/content/calendar-sets.inc
@@ -66,16 +66,17 @@
 
   <!-- Sunbird specific commands -->
   <command id="open_local_calendar_command" oncommand="openLocalCalendar()"/>
 
   <command id="go_date_command" oncommand="pickAndGoToDate()"/>
   <command id="cmd_quitApplication"     oncommand="goQuitApplication()"/>
 	
   <command id="close_calendar_command" oncommand="closeCalendar()"/>
+  <command id="calendar_go_to_today_command" oncommand="goToDate(now())"/>
 
 #ifdef XP_MACOSX
   <command id="minimizeWindowCmd" oncommand="window.minimize();"/>
   <command id="zoomWindowCmd" oncommand="zoomWindow();"/>
 #endif
 </commandset>
 
 <keyset id="calendar-keys">