Bug 306079 Create a proper prefs file, rather than initializing prefs from .properties, r=mvl

This commit is contained in:
jminta%gmail.com 2006-06-19 16:58:53 +00:00
parent a54888a781
commit 171c85a7a1
12 changed files with 93 additions and 121 deletions

View File

@ -130,6 +130,20 @@
this.calView.mEndMin);
break;
case "calendar.week.d0sundaysoff":
case "calendar.week.d1mondaysoff":
case "calendar.week.d2tuesdaysoff":
case "calendar.week.d3wednesdaysoff":
case "calendar.week.d4thursdaysoff":
case "calendar.week.d5fridaysoff":
case "calendar.week.d6saturdaysoff":
if (this.calView.mWorkdaysOnly) {
this.calView.goToDay(this.calView.selectedDay);
}
break;
case "calendar.week.start":
this.calView.goToDay(this.calView.selectedDay);
break;
case "calendar.view.defaultendhour":
this.calView.mEndMin = subj.getIntPref(pref) * 60;
viewElem = document.getAnonymousElementByAttribute(

View File

@ -116,48 +116,12 @@ unsubscribeCalendarMessage=Are you sure you want to unsubscribe from calendar "%
weekDayMonthLabel=%1$S %2$S %3$S
#
# P R E F S
# Default values for preferences
#
#the default day to start the week on
#0=Sunday 1=Monday 2=Tuesday 3=Wednesday 4=Thursday 5=Friday 6=Saturday
defaultWeekStart=0
# default days off (not in work week)
defaultWeekSundaysOff =true
defaultWeekMondaysOff =false
defaultWeekTuesdaysOff =false
defaultWeekWednesdaysOff=false
defaultWeekThursdaysOff =false
defaultWeekFridaysOff =false
defaultWeekSaturdaysOff =true
defaultWeeksInView=4
defaultPreviousWeeksInView=0
showAlarms=1
showMissed=1
playAlarmSound=0
soundURL=chrome://calendar/content/sound.wav
reloadServersOnLaunch=false
defaultEventLength=60
defaultSnoozeAlarmLength=60
dateFormat=0
storeInGmt=0
defaultStartHour=8
defaultEndHour=17
defaultzone=America/New_York
defaulteventalarmunit=minutes
defaulttodoalarmunit=minutes
Week=Week
WeekTitle=Week %1$S
# Used to format the Multiweek's labels, ie Weeks 2 - 7
WeeksTitle=Weeks %1$S-%2$S
None=None
# Alarm
TooManyAlarmsMessage=You have %1$S total alarms. We've shown you the last 6. Click Acknowledge All to clear them all.
# Error strings
## @name UID_NOT_FOUND
## @loc none

View File

@ -36,4 +36,20 @@
#filter substitution
#the default day to start the week on
#0=Sunday 1=Monday 2=Tuesday 3=Wednesday 4=Thursday 5=Friday 6=Saturday
pref("calendar.week.start", 0);
# default days off (not in work week)
pref("calendar.week.d0sundaysoff", true);
pref("calendar.week.d1mondaysoff", false);
pref("calendar.week.d2tuesdaysoff", false);
pref("calendar.week.d3wednesdaysoff", false);
pref("calendar.week.d4thursdaysoff", false);
pref("calendar.week.d5fridaysoff", false);
pref("calendar.week.d6saturdaysoff", true);
pref("general.useragent.locale", "@AB_CD@");
# categories
pref("calendar.categories.names", "Anniversary,Birthday,Business,Calls,Clients,Competition,Customer,Favorites,Follow up,Gifts,Holidays,Ideas,Issues,Miscellaneous,Personal,Projects,Public Holiday,Status,Suppliers,Travel,Vacation");

View File

@ -18,7 +18,6 @@ calendar-@AB_CD@.jar:
locale/@AB_CD@/calendar/calendar.dtd (%chrome/calendar/calendar.dtd)
locale/@AB_CD@/calendar/calendarCreation.dtd (%chrome/calendar/calendarCreation.dtd)
locale/@AB_CD@/calendar/calendar.properties (%chrome/calendar/calendar.properties)
locale/@AB_CD@/calendar/categories.properties (%chrome/calendar/categories.properties)
locale/@AB_CD@/calendar/dateFormat.properties (%chrome/calendar/dateFormat.properties)
locale/@AB_CD@/calendar/email.properties (%chrome/calendar/email.properties)
locale/@AB_CD@/calendar/global.dtd (%chrome/calendar/global.dtd)

View File

@ -58,23 +58,9 @@
**********
*/
/*-----------------------------------------------------------------
* G L O B A L V A R I A B L E S
*/
// single global instance of CalendarWindow
var gCalendarWindow;
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var rootPrefNode = prefService.getBranch(null); // preferences root node
/*-----------------------------------------------------------------
* G L O B A L C A L E N D A R F U N C T I O N S
*/
@ -278,7 +264,9 @@ function newEvent(startDate, endDate, allDay)
calendarEvent.startDate.jsDate = startDate;
if (!endDate) {
var MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", gCalendarBundle.getString("defaultEventLength" ) );
var pb2 = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var MinutesToAddOn = pb2.getIntPref("calendar.event.defaultlength");
endDate = new Date(startDate);
endDate.setMinutes(endDate.getMinutes() + MinutesToAddOn);
@ -445,62 +433,6 @@ function print()
"printdialog","chrome");
}
function getCharPref (prefObj, prefName, defaultValue)
{
try {
return prefObj.getCharPref (prefName);
} catch (e) {
prefObj.setCharPref( prefName, defaultValue );
return defaultValue;
}
}
function getIntPref(prefObj, prefName, defaultValue)
{
try {
return prefObj.getIntPref(prefName);
} catch (e) {
prefObj.setIntPref(prefName, defaultValue);
return defaultValue;
}
}
function getBoolPref (prefObj, prefName, defaultValue)
{
try
{
return prefObj.getBoolPref (prefName);
}
catch (e)
{
prefObj.setBoolPref( prefName, defaultValue );
return defaultValue;
}
}
function GetUnicharPref(prefObj, prefName, defaultValue)
{
try {
return prefObj.getComplexValue(prefName, Components.interfaces.nsISupportsString).data;
}
catch(e)
{
SetUnicharPref(prefObj, prefName, defaultValue);
return defaultValue;
}
}
function SetUnicharPref(aPrefObj, aPrefName, aPrefValue)
{
try {
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
str.data = aPrefValue;
aPrefObj.setComplexValue(aPrefName, Components.interfaces.nsISupportsString, str);
}
catch(e) {}
}
/* Change the only-workday checkbox */
function changeOnlyWorkdayCheckbox() {
var oldValue = (document.getElementById("toggle_workdays_only")

View File

@ -232,7 +232,6 @@
<script type="application/x-javascript" src="chrome://calendar/content/mouseoverPreviews.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/unifinder.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/unifinderToDo.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/pref/rootCalendarPref.js"/>
<!--<script type="application/x-javascript" src="chrome://calendar/content/email.js"/>-->

View File

@ -278,6 +278,12 @@ function initCalendarManager()
initColors();
var calendarList = document.getElementById("list-calendars-listbox");
calendarList.addEventListener("select", onCalendarListSelect, true);
// Set up a pref listener so the proper UI bits can be refreshed when prefs
// are changed.
var pb2 = prefService.getBranch("").QueryInterface(
Components.interfaces.nsIPrefBranch2);
pb2.addObserver("calendar.", calPrefObserver, false);
}
function finishCalendarManager() {
@ -285,6 +291,7 @@ function finishCalendarManager() {
var pbi = prefService.getBranch("");
pbi = pbi.QueryInterface(Components.interfaces.nsIPrefBranch2);
pbi.removeObserver("calendar.category.color.", categoryPrefObserver);
pbi.removeObserver("calendar.", calPrefObserver);
var calendarList = document.getElementById("list-calendars-listbox");
calendarList.removeEventListener("select", onCalendarListSelect, true);
@ -404,3 +411,35 @@ var categoryPrefObserver =
updateStyleSheetForObject(name);
}
}
var calPrefObserver =
{
observe: function(aSubject, aTopic, aPrefName)
{
subject = aSubject.QueryInterface(Components.interfaces.nsIPrefBranch2);
switch (aPrefName) {
case "calendar.week.start":
document.getElementById("lefthandcalendar").refreshDisplay(true);
break;
case "calendar.date.format":
var currentView = document.getElementById("view-deck").selectedPanel;
currentView.goToDay(currentView.selectedDay);
refreshEventTree();
toDoUnifinderRefresh();
break;
case "calendar.timezone.local":
gDefaultTimezone = subject.getCharPref(aPrefName);
var currentView = document.getElementById("view-deck").selectedPanel;
currentView.goToDay(currentView.selectedDay);
refreshEventTree();
toDoUnifinderRefresh();
break;
default :
break;
}
}
}

View File

@ -139,12 +139,6 @@ var gViewController = new calViewController();
function CalendarWindow( )
{
//setup the preferences
this.calendarPreferences = new calendarPreferences( this );
// miniMonth used by preferences
this.miniMonth = document.getElementById( "lefthandcalendar" );
//setup the calendar event selection
this.EventSelection = new CalendarEventSelection( this );
gViewController.selectionManager = this.EventSelection;

View File

@ -296,15 +296,13 @@
** When you add a pref to this page, you have to add its ID to the following list.
*/
var _elementIDs = [
"dateformat", "defaultlength", "defaultsnoozelength",
"reloadonlaunch", "categories", "storeingmt"
"dateformat", "defaultlength", "defaultsnoozelength", "categories"
];
]]>
</script>
<groupbox align="start" orient="vertical">
<caption label="&pref.mainbox.label;"/>
<checkbox id="storeingmt" preftype="bool" prefstring="calendar.dateformat.storeingmt" label="&pref.dateformat.storeingmt;" />
<hbox>
<description>&pref.dateformat.label;</description>
<menulist id="dateformat" crop="none" prefstring="calendar.date.format">
@ -326,7 +324,6 @@
<label value="&pref.minutes.label;"/>
</hbox>
<checkbox id="reloadonlaunch" preftype="bool" prefstring="calendar.servers.reloadonlaunch" label="&pref.reloadonlaunch;" />
</groupbox>
#ifdef MOZ_SUNBIRD
<groupbox>

View File

@ -87,7 +87,6 @@ calendar.jar:
* content/calendar/pref/calendarPref.xul (content/pref/calendarPref.xul)
content/calendar/pref/prefOverlay.xul (content/pref/prefOverlay.xul)
content/calendar/pref/alarmPrefs.js (content/pref/alarmPrefs.js)
content/calendar/pref/rootCalendarPref.js (content/pref/rootCalendarPref.js)
content/calendar/pref/viewPrefs.xul (content/pref/viewPrefs.xul)
content/calendar/pref/timezonePrefs.xul (content/pref/timezonePrefs.xul)
content/calendar/pref/editCategory.xul (content/pref/editCategory.xul)

View File

@ -40,6 +40,26 @@
// SYNTAX HINTS: dashes are delimiters. Use underscores instead.
// The first character after a period must be alphabetic.
pref("calendar.alarms.show", true);
pref("calendar.alarms.showmissed", true);
pref("calendar.alarms.playsound", true);
pref("calendar.alarms.soundURL", "chrome://calendar/content/sound.wav");
pref("calendar.alarms.onforevents", 0); //XXX this should be a bool
pref("calendar.alarms.onfortodos", 0); //XXX this should be a bool
pref("calendar.alarms.eventalarmlen", 15);
pref("calendar.alarms.todoalarmlen", 15);
pref("calendar.alarms.eventalarmunit", "minutes");
pref("calendar.alarms.todoalarmunit", "minutes");
pref("calendar.alarms.defaultsnoozelength", 60);
pref("calendar.date.format", 0);
pref("calendar.event.defaultlength", 60);
// Do NOT set this. If it is unset, we guess the timezone from the system
//pref("calendar.timezone.local", "America/New_York);
pref("calendar.view.defaultstarthour", 8);
pref("calendar.view.defaultendhour", 17);
pref("calendar.weeks.inview", 4);
pref("calendar.previousweeks.inview", 0);
// pref("startup.homepage_override_url","chrome://browser-region/locale/region.properties");
pref("general.startup.calendar", true);

View File

@ -76,7 +76,6 @@
<script type="application/x-javascript" src="chrome://calendar/content/mouseoverPreviews.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/unifinder.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/unifinderToDo.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/pref/rootCalendarPref.js"/>
<!-- <script type="application/x-javascript" src="chrome://calendar/content/email.js"/>-->