Fix bug 518112 - "New Event/Task" buttons and menu entries don't change the disable/enable status when calendars change mode. r=Decathlon
authorPhilipp Kewisch <mozilla@kewis.ch>
Sun, 29 Aug 2010 12:40:20 +0200
changeset 6289 b0c0a81d13cb4c1f8e10c15b82a8918fafb0f5ff
parent 6288 668e3b62edc356e1fc075fa22073c53eb65ec8b0
child 6290 bcc622bacd07e7304c64e56b62a914fd25d254a5
push idunknown
push userunknown
push dateunknown
reviewersDecathlon
bugs518112
Fix bug 518112 - "New Event/Task" buttons and menu entries don't change the disable/enable status when calendars change mode. r=Decathlon
calendar/base/content/widgets/calendar-list-tree.xml
--- a/calendar/base/content/widgets/calendar-list-tree.xml
+++ b/calendar/base/content/widgets/calendar-list-tree.xml
@@ -110,17 +110,22 @@
                 composite.addCalendar(aCalendar);
             }
         },
 
         onCalendarUnregistering: function cMO_onCalendarUnregistering(aCalendar) {
             this.listTree.removeCalendar(aCalendar);
         },
 
-        onCalendarDeleting: function cMO_onCalendarDeleting(aCalendar) { }
+        onCalendarDeleting: function cMO_onCalendarDeleting(aCalendar) {
+            // Now that the calendar is unregistered, update the commands to
+            // make sure that New Event/Task commands are correctly
+            // enabled/disabled.
+            document.commandDispatcher.updateCommands("calendar_commands");
+        }
       })
       ]]></field>
       <field name="compositeObserver"><![CDATA[
       ({ listTree: this,
 
         QueryInterface: function cO_QueryInterface(aIID) {
             if (!aIID.equals(Components.interfaces.calICompositeObserver) &&
                 !aIID.equals(Components.interfaces.calIObserver) &&
@@ -158,19 +163,25 @@
             if (aNewItem.calendar.type != "caldav") {
                 this.listTree.ensureCalendarVisible(aNewItem.calendar);
             }
         },
         onDeleteItem: function cO_onDeleteItem(aDeletedItem) { },
         onError: function cO_onError(aCalendar, aErrNo, aMessage) { },
 
         onPropertyChanged: function cO_onPropertyChanged(aCalendar,
-                                                          aName,
-                                                          aValue,
-                                                          aOldValue) {
+                                                         aName,
+                                                         aValue,
+                                                         aOldValue) {
+            switch (aName) {
+                case "disabled":
+                case "readOnly":
+                    document.commandDispatcher.updateCommands("calendar_commands");
+                    break;
+            }
         },
 
         onPropertyDeleting: function cO_onPropertyDeleting(aCalendar,
                                                             aName) {
         }
       })
       ]]></field>
     </implementation>