Bug 248795 Menu item 'Refresh Remote Calendars' should be disabled when there are no remote calendars

This commit is contained in:
jminta%gmail.com 2006-06-12 19:51:19 +00:00
Родитель 337f7b9c61
Коммит 7be7e40d2a
7 изменённых файлов: 55 добавлений и 0 удалений

Просмотреть файл

@ -80,6 +80,11 @@ interface calICalendar : nsISupports
*/
attribute boolean readOnly;
/**
* Whether or not it makes sense to call refresh() on this calendar.
*/
readonly attribute boolean canRefresh;
/**
* In combination with the other parameters to getItems(), these
* constants provide for a very basic filtering mechanisms for use

Просмотреть файл

@ -146,6 +146,11 @@ calDavCalendar.prototype = {
this.mReadOnly = bool;
},
get canRefresh() {
// refresh() is currently not implemented, but we may want to change that
return false;
},
// attribute nsIURI uri;
mUri: null,
get uri() { return this.mUri; },

Просмотреть файл

@ -272,6 +272,10 @@ calCompositeCalendar.prototype = {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
},
get canRefresh() {
return true;
},
// void addObserver( in calIObserver observer );
mCompositeObservers: Array(),
mObservers: Array(),

Просмотреть файл

@ -125,6 +125,10 @@ calICSCalendar.prototype = {
this.mReadOnly = bool;
},
get canRefresh() {
return true;
},
mUri: null,
get uri() { return this.mUri },
set uri(aUri) {

Просмотреть файл

@ -112,6 +112,10 @@ calMemoryCalendar.prototype = {
this.mReadOnly = bool;
},
get canRefresh() {
return false;
},
// attribute nsIURI uri;
mUri: null,
get uri() { return this.mUri; },

Просмотреть файл

@ -271,6 +271,10 @@ calStorageCalendar.prototype = {
this.mReadOnly = bool;
},
get canRefresh() {
return false;
},
mURI: null,
// attribute nsIURI uri;
get uri() { return this.mURI; },

Просмотреть файл

@ -64,6 +64,11 @@ var calCalendarManagerObserver = {
setCalendarManagerUI();
document.getElementById("new_command").removeAttribute("disabled");
document.getElementById("new_todo_command").removeAttribute("disabled");
if (aCalendar.canRefresh) {
var remoteCommand = document.getElementById("reload_remote_calendars");
remoteCommand.removeAttribute("disabled");
}
},
onCalendarUnregistering: function(aCalendar) {
@ -78,6 +83,19 @@ var calCalendarManagerObserver = {
document.getElementById("new_todo_command").setAttribute("disabled", true);
}
}
if (aCalendar.canRefresh) {
// We may have just removed our last remote cal. Then we'd need to
// disabled the reload-remote-calendars command
var calendars = getCalendarManager().getCalendars({});
function calCanRefresh(cal) {
return (cal.canRefresh && !cal.uri.equals(aCalendar.uri));
}
if (!calendars.some(calCanRefresh)) {
var remoteCommand = document.getElementById("reload_remote_calendars");
remoteCommand.setAttribute("disabled", true);
}
}
},
onCalendarDeleting: function(aCalendar) {
@ -192,7 +210,12 @@ function setCalendarManagerUI()
var composite = getDisplayComposite();
var calmgr = getCalendarManager();
var calendars = calmgr.getCalendars({});
var hasRefreshableCal = false;
for each (var calendar in calendars) {
if (calendar.canRefresh) {
hasRefreshableCal = true;
}
var listItem = document.createElement("listitem");
var checkCell = document.createElement("listcell");
@ -220,6 +243,12 @@ function setCalendarManagerUI()
if (calendarList.selectedIndex == -1)
calendarList.selectedIndex = 0;
}
var remoteCommand = document.getElementById("reload_remote_calendars");
if (!hasRefreshableCal) {
remoteCommand.setAttribute("disabled", true);
} else {
remoteCommand.removeAttribute("disabled");
}
}
function onCalendarListSelect() {