PrefManager.addPref Member
Syntax
object.addPref(prefName, defaultValue, setter, bundle, group);
Arguments
Argument | Summary |
---|---|
prefName | |
defaultValue | |
setter | |
bundle | |
group |
Returns
Remarks
See Also
Source Code
function pm_addpref(prefName, defaultValue, setter, bundle, group)
{
var prefManager = this;
if (!bundle)
bundle = this.defaultBundle;
function updateArrayPref() { prefManager.updateArrayPref(prefName); };
function prefGetter() { return prefManager.getPref(prefName); };
function prefSetter(value) { return prefManager.setPref(prefName, value); };
if (!ASSERT(!(prefName in this.defaultValues),
"Preference already exists: " + prefName))
{
return;
}
if (!setter)
setter = prefSetter;
if (isinstance(defaultValue, Array))
defaultValue.update = updateArrayPref;
var label = getMsgFrom(bundle, "pref." + prefName + ".label", null, prefName);
var help = getMsgFrom(bundle, "pref." + prefName + ".help", null,
MSG_NO_HELP);
if (group != "hidden")
{
if (label == prefName)
dd("WARNING: !!! Preference without label: " + prefName);
if (help == MSG_NO_HELP)
dd("WARNING: Preference without help text: " + prefName);
}
this.prefRecords[prefName] = new PrefRecord (prefName, defaultValue,
label, help, group);
this.prefNames.push(prefName);
this.prefNames.sort();
this.prefs.__defineGetter__(prefName, prefGetter);
this.prefs.__defineSetter__(prefName, setter);
}