new lightning pref overlays for thunderbird. bug 296108 r=vlad

added a way to enumerate the list of supported timezones. bug 296109 r=vlad
new recurrence editing dialog
(not part of default build. a=chase)
This commit is contained in:
pavlov%pavlov.net 2005-05-31 21:42:21 +00:00
parent d9e7208935
commit 8a12538df4
11 changed files with 532 additions and 4 deletions

View File

@ -111,7 +111,7 @@ function loadDialog()
/* event default calendar */
if (event.parent) {
var calendarList = document.getElementById('event-calendar');
var calendarList = document.getElementById("event-calendar");
var calendars = getCalendarManager().getCalendars({});
for (i in calendars) {
if (event.parent.uri.equals(calendars[i].uri))
@ -184,6 +184,16 @@ function saveDialog(event)
event.alarmTime = alarmTime;
}
if (getElementValue("event-recurrence", "checked")) {
if (window.recurrenceInfo) {
dump("setting recurrenceInfo!\n");
event.recurrenceInfo = window.recurrenceInfo;
} else
dump("not setting recurrenceInfo\n");
} else {
event.recurrenceInfo = null;
}
}
@ -247,7 +257,23 @@ function updateAlarm()
prevAlarmItem = alarmItem;
}
function editRecurrence()
{
var args = new Object();
args.calendarEvent = window.calendarEvent;
args.recurrenceInfo = window.calendarEvent.recurrenceInfo;
var savedWindow = window;
args.onOk = function(recurrenceInfo) {
savedWindow.recurrenceInfo = recurrenceInfo;
};
// wait cursor will revert to auto in eventDialog.js loadCalendarEventDialog
window.setCursor("wait");
// open the dialog modally
openDialog("chrome://calendar/content/calendar-recurrence-dialog.xul", "_blank", "chrome,titlebar,modal", args);
}

View File

@ -45,7 +45,7 @@
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<dialog
id="calendar-editwindow"
id="calendar-edit-dialog"
title="Edit Event"
buttons="accept,cancel"
ondialogaccept="return onAccept();"
@ -106,7 +106,7 @@
<hbox align="center">
<checkbox id="event-recurrence" oncommand="updateRecurrence();"/>
<spacer flex="1"/>
<button id="set-recurrence" label="set..."/>
<button id="set-recurrence" label="set..." oncommand="editRecurrence();"/>
</hbox>
</row>

View File

@ -0,0 +1,185 @@
/* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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 Oracle Corporation code.
*
* The Initial Developer of the Original Code is Oracle Corporation
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <stuart.parmenter@oracle.com>
*
* 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 ***** */
/* dialog stuff */
function onLoad()
{
var args = window.arguments[0];
window.onAcceptCallback = args.onOk;
window.calendarEvent = args.calendarEvent;
window.originalRecurrenceInfo = args.recurrenceInfo;
loadDialog();
updateDeck();
opener.setCursor("auto");
self.focus();
}
function onAccept()
{
var event = window.calendarEvent;
var recurrenceInfo = saveDialog();
window.onAcceptCallback(recurrenceInfo);
return true;
}
function onCancel()
{
}
function loadDialog()
{
}
function saveDialog()
{
var deckNumber = Number(getElementValue("period-list"));
dump("decknumber = " + deckNumber + "\n");
var recurrenceInfo = createRecurrenceInfo();
recurrenceInfo.initialize(window.calendarEvent);
var recRule = new calRecurrenceRule();
switch (deckNumber) {
case 0:
dump("daily recurrence\n");
recRule.type = "DAILY";
var ndays = Number(getElementValue("daily-days"));
if (ndays == null)
ndays = 1;
recRule.interval = ndays;
break;
case 1: // weekly
recRule.type = "WEEKLY";
break;
case 2: // monthly
recRule.type = "MONTHLY";
break;
case 3: // annually
recRule.type = "YEARLY";
break;
}
switch(document.getElementById("recurrence-duration").selectedItem.value) {
case "forever":
dump("setting forever!\n");
recRule.count = -1;
break;
case "ntimes":
recRule.count = Math.max(1, getElementValue("ntimes-count"));
break;
case "until":
//var recurEndDate = getElementValue("repeat-end-date-picker");
//recRule.endDate = jsDateToDateTime(recurEndDate);
break;
default:
dump("error finding duration\n");
break;
}
recurrenceInfo.appendRecurrenceItem(recRule);
return recurrenceInfo;
}
function updateDeck()
{
document.getElementById("period-deck").selectedIndex = Number(getElementValue("period-list"));
}
/* utility functions */
function setEventProperty(event, propertyName, value)
{
if (value)
event.setProperty(propertyName, value);
}
function setElementValue(elementName, value, name)
{
var element = document.getElementById(elementName);
if (!element) {
dump("unable to find " + elementName + "\n");
return;
}
if (value === false) {
element.removeAttribute(name ? name : "value");
} else if (name) {
//dump("element.setAttribute(" + name + ", " + value + ")\n");
element.setAttribute(name, value);
} else {
//dump("element.value = " + value + "\n");
element.value = value;
}
}
function getElementValue(elementName, name)
{
var element = document.getElementById(elementName);
if (!element) {
dump("unable to find " + elementName + "\n");
return null;
}
if (name)
return element[name];
return element.value;
}
function enableElement(elementId)
{
setElementValue(elementId, false, "disabled");
}
function disableElement(elementId)
{
setElementValue(elementId, "true", "disabled");
}

View File

@ -0,0 +1,192 @@
<?xml version="1.0"?>
<!-- -*- Mode: xml; indent-tabs-mode: nil; -*- -->
<!--
- ***** 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 calendar views.
-
- The Initial Developer of the Original Code is Oracle Corporation
- Portions created by the Initial Developer are Copyright (C) 2005
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Stuart Parmenter <stuart.parmenter@oracle.com>
-
- 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 *****
-->
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<dialog
id="calendar-recurrence-dialog"
title="Recurrence Event"
buttons="accept,cancel"
ondialogaccept="return onAccept();"
ondialogcancel="return onCancel();"
onload="onLoad()"
persist="screenX screenY"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://calendar/content/calendar-recurrence-dialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<vbox>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<label value="Frequency"/>
<menulist id="period-list" oncommand="updateDeck();">
<menupopup>
<menuitem label="Daily" value="0"/>
<menuitem label="Weekly" value="1"/>
<menuitem label="Monthly" value="2"/>
<menuitem label="Annually" value="3"/>
</menupopup>
</menulist>
</row>
<row>
<spacer/>
<deck id="period-deck">
<!-- Daily -->
<hbox align="top">
<textbox id="daily-days" width="30"/>
<label value="days"/>
</hbox>
<!-- Weekly -->
<vbox>
<menulist>
<menupopup>
<menuitem label="every"/>
<menuitem label="every first"/>
<menuitem label="every second"/>
<menuitem label="every third"/>
<menuitem label="every fourth"/>
<menuitem label="every fifth"/>
<menuitem label="every last"/>
</menupopup>
</menulist>
<hbox>
<vbox>
<checkbox label="Monday"/>
<checkbox label="Tuesday"/>
<checkbox label="Wednesday"/>
<checkbox label="Thursday"/>
</vbox>
<vbox>
<checkbox label="Friday"/>
<checkbox label="Saturday"/>
<checkbox label="Sunday"/>
</vbox>
</hbox>
</vbox>
<hbox align="center">
<label value="Repeat on the"/>
<textbox value="10,23,29" width="70"/>
</hbox>
<hbox align="top">
<textbox width="30"/>
<label value="years"/>
</hbox>
</deck>
</row>
</rows>
</grid>
</vbox>
<spacer flex="1"/>
<vbox>
<radiogroup id="recurrence-duration">
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows equalsize="always">
<row align="center">
<radio label="Repeat forever" value="forever" selected="true"/>
<spacer/>
</row>
<row>
<radio label="Repeat for" value="ntimes"/>
<hbox>
<textbox id="ntimes-count" size="3"/>
<spacer flex="0.5"/>
<menulist>
<menupopup>
<menuitem label="day(s)"/>
<menuitem label="week(s)"/>
<menuitem label="month(s)"/>
<menuitem label="year(s)"/>
</menupopup>
</menulist>
<spacer flex="1"/>
</hbox>
</row>
<row>
<radio label="Repeat until" value="until"/>
<hbox>
<textbox size="3"/>
<spacer flex="1"/>
</hbox>
</row>
</rows>
</grid>
</radiogroup>
</vbox>
<spacer flex="1"/>
<vbox>
<label value="Exceptions:"/>
<hbox align="center">
<listbox id="recurrence-dates-listbox" rows="8" flex="1"/>
<vbox>
<button label="Add..."/>
<button label="Remove"/>
</vbox>
</hbox>
</vbox>
</dialog>

View File

@ -45,6 +45,7 @@ interface calIItemBase;
interface calIDateTime;
interface calIIcalProperty;
interface nsIUTF8StringEnumerator;
[ptr] native icalpropertyptr(struct icalproperty_impl);
[ptr] native icalcomponentptr(struct icalcomponent_impl);
@ -57,7 +58,7 @@ interface calIIcalProperty;
* general, you want to do as little manipulation of your FooContainers as
* possible while iterating over them.
*/
[scriptable,uuid(4d7e456b-cfd0-4ebf-8794-c57789dafdc3)]
[scriptable,uuid(c4637c40-3c4c-4ecd-b802-8b5b46bdf5a4)]
interface calIIcalComponent : nsISupports
{
/**
@ -192,4 +193,6 @@ interface calIICSService : nsISupports
calIIcalComponent getTimezone(in AUTF8String tzid);
AUTF8String getTimezoneLatitude(in AUTF8String tzid);
AUTF8String getTimezoneLongitude(in AUTF8String tzid);
readonly attribute nsIUTF8StringEnumerator timezoneIds;
};

View File

@ -44,6 +44,7 @@
#include "nsInterfaceHashtable.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsStringEnumerator.h"
#include "nsCRT.h"
#include "calIEvent.h"
@ -1043,6 +1044,24 @@ get_timezone_data_struct_for_tzid(const char *tzid)
return nsnull;
}
NS_IMETHODIMP
calICSService::GetTimezoneIds(nsIUTF8StringEnumerator **aTzids)
{
NS_ENSURE_ARG_POINTER(aTzids);
PRUint32 length = sizeof(ical_timezone_data) / sizeof(ical_timezone_data[0]);
nsCStringArray *array = new nsCStringArray(length);
if (!array)
return NS_ERROR_OUT_OF_MEMORY;
for (int i = 0; ical_timezone_data[i].tzid != NULL; i++) {
array->AppendCString(nsDependentCString(ical_timezone_data[i].tzid));
}
array->Sort();
return NS_NewAdoptingUTF8StringEnumerator(aTzids, array);
}
NS_IMETHODIMP
calICSService::GetTimezone(const nsACString& tzid,
calIIcalComponent **_retval)

View File

@ -1,6 +1,7 @@
content lightning jar:chrome/lightning.jar!/content/lightning/
locale lightning en-US jar:chrome/en-US.jar!/locale/en-US/lightning/
overlay chrome://messenger/content/messenger.xul chrome://lightning/content/messenger-overlay-sidebar.xul
overlay chrome://messenger/content/preferences/preferences.xul chrome://lightning/content/messenger-overlay-preferences.xul
overlay chrome://lightning/content/lightning-standalone.xul chrome://lightning/content/messenger-overlay-sidebar.xul
skin lightning classic/1.0 jar:chrome/classic.jar!/skin/classic/lightning/
# shared pieces for chrome://calendar/

View File

@ -0,0 +1,57 @@
/* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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 Oracle Corporation code.
*
* The Initial Developer of the Original Code is Oracle Corporation
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <stuart.parmenter@oracle.com>
*
* 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 ***** */
var gLightningPane = {
init: function() {
var tzListBox = document.getElementById("timezone-listbox");
var icsService = Components.classes["@mozilla.org/calendar/ics-service;1"].createInstance(Components.interfaces.calIICSService);
var timezones = icsService.timezoneIds;
while (timezones.hasMore()) {
var tzid = timezones.getNext();
var item = document.createElement('listitem');
item.setAttribute("label", tzid);
tzListBox.appendChild(item);
}
},
getTimezoneResult: function() {
var tzListBox = document.getElementById("timezone-listbox");
if (tzListBox.selectedItems.length > 0)
return tzListBox.selectedItems[0].getAttribute("label");
},
}

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<overlay id="AdvancedPaneOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="paneLightning" onpaneload="gLightningPane.init()">
<script type="application/x-javascript" src="chrome://lightning/content/lightning-prefs.js"/>
<preferences>
<preference id="calendar.alarms.playsound"
name="calendar.alarms.playsound"
type="bool"/>
<preference id="calendar.timezone.local"
name="calendar.timezone.local"
type="string"/>
</preferences>
<groupbox flex="1">
<caption label="Alarms"/>
<checkbox label="Play sound" preference="calendar.alarms.playsound"/>
</groupbox>
<groupbox flex="1">
<caption label="Timezone"/>
<listbox id="timezone-listbox" preference="calendar.timezone.local" onpreferencewrite="return gLightningPane.getTimezoneResult();"/>
</groupbox>
</prefpane>
</overlay>

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefwindow id="MailPreferences">
<prefpane id="paneLightning" label="Lightning"
src="chrome://lightning/content/lightning-prefs.xul"/>
</prefwindow>
</overlay>

View File

@ -6,6 +6,9 @@ lightning.jar:
content/lightning/lightning-widgets.css (content/lightning-widgets.css)
content/lightning/agenda-tree.js (content/agenda-tree.js)
content/lightning/lightning-standalone.xul (content/lightning-standalone.xul)
content/lightning/messenger-overlay-preferences.xul (content/messenger-overlay-preferences.xul)
content/lightning/lightning-prefs.xul (content/lightning-prefs.xul)
content/lightning/lightning-prefs.js (content/lightning-prefs.js)
en-US.jar:
locale/en-US/lightning/lightning.dtd (locale/lightning.dtd)
@ -32,6 +35,8 @@ calendar.jar:
content/calendar/calendar-event-dialog.js (/calendar/base/content/calendar-event-dialog.js)
content/calendar/calendar-event-dialog.xul (/calendar/base/content/calendar-event-dialog.xul)
content/calendar/calendar-event-dialog.css (/calendar/base/content/calendar-event-dialog.css)
content/calendar/calendar-recurrence-dialog.js (/calendar/base/content/calendar-recurrence-dialog.js)
content/calendar/calendar-recurrence-dialog.xul (/calendar/base/content/calendar-recurrence-dialog.xul)
calendar-en-US.jar:
locale/en-US/calendar/global.dtd (/calendar/resources/locale/en-US/global.dtd)