pjs/xpfe/global/resources/content/nsUserSettings.js

105 строки
2.5 KiB
JavaScript
Исходник Обычный вид История

2000-06-01 10:35:57 +04:00
/**
* nsPreferences - a wrapper around nsIPrefService. Provides built in
2000-06-01 10:35:57 +04:00
* exception handling to make preferences access simpler.
**/
var nsPreferences = {
get mPrefService()
{
return Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
2000-06-01 10:35:57 +04:00
},
setBoolPref: function (aPrefName, aPrefValue)
{
try
{
this.mPrefService.setBoolPref(aPrefName, aPrefValue);
2000-06-01 10:35:57 +04:00
}
catch(e)
{
}
},
getBoolPref: function (aPrefName, aDefVal)
{
try
{
return this.mPrefService.getBoolPref(aPrefName);
2000-06-01 10:35:57 +04:00
}
catch(e)
{
return aDefVal != undefined ? aDefVal : null;
}
2000-09-07 23:47:39 +04:00
return null; // quiet warnings
2000-06-01 10:35:57 +04:00
},
setUnicharPref: function (aPrefName, aPrefValue)
{
try
{
var str = Components.classes["@mozilla.org/supports-wstring;1"]
.createInstance(Components.interfaces.nsISupportsWString);
str.data = aPrefValue;
this.mPrefService.setComplexValue(aPrefName,
Components.interfaces.nsISupportsWString, str);
2000-06-01 10:35:57 +04:00
}
catch(e)
{
}
},
copyUnicharPref: function (aPrefName, aDefVal)
{
try
{
return this.mPrefService.getComplexValue(aPrefName,
Components.interfaces.nsISupportsWString).data;
2000-06-01 10:35:57 +04:00
}
catch(e)
{
return aDefVal != undefined ? aDefVal : null;
}
2000-09-07 23:47:39 +04:00
return null; // quiet warnings
2000-06-01 10:35:57 +04:00
},
setIntPref: function (aPrefName, aPrefValue)
{
try
{
this.mPrefService.setIntPref(aPrefName, aPrefValue);
2000-06-01 10:35:57 +04:00
}
catch(e)
{
}
},
getIntPref: function (aPrefName, aDefVal)
{
try
{
return this.mPrefService.getIntPref(aPrefName);
2000-06-01 10:35:57 +04:00
}
catch(e)
{
return aDefVal != undefined ? aDefVal : null;
}
2000-09-07 23:47:39 +04:00
return null; // quiet warnings
2000-06-01 10:35:57 +04:00
},
getLocalizedUnicharPref: function (aPrefName, aDefVal)
{
try
{
return this.mPrefService.getComplexValue(aPrefName,
Components.interfaces.nsIPrefLocalizedString).data;
}
catch(e)
{
return aDefVal != undefined ? aDefVal : null;
}
2000-09-07 23:47:39 +04:00
return null; // quiet warnings
}
};