slopjong/OpenSpace — Issue #9: Accessing the preferences easily with FUEL
Author: slopjong
Created: 2012-03-04 02:33:00+00:00
State: open

Read this documentation about [Handling Preferences](https://developer.mozilla.org/en/XUL_School/Handling_Preferences).

With FUEL:

// chrome code.
Application.something

// non-chrome code.
let application =
Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication);
application.something

With XPCOM:

this._prefService =
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
// ...
get count() {
return this._prefService.getIntPref("extensions.xulschoolhello.message.count");
},
increment : function() {
let currentCount =
this._prefService.getIntPref("extensions.xulschoolhello.message.count");

this._prefService.setIntPref("extensions.xulschoolhello.message.count", currentCount + 1);
}