Search completed in 1.16 seconds.
31 results for "nsIPref":
Your results are loading. Please wait...
Component; nsIPrefBranch
component: nsiprefbranch modules/libpref/public/nsiprefbranch.idlscriptable this interface is used to manipulate the preferences data.
... this object may be obtained from the preferences service (nsiprefservice) and used to get and set default and/or user preferences across the application.
...on preference changes, the following arguments will be passed to nsiobserver.observe(): asubject - the nsiprefbranch object (this).
...And 6 more matches
nsIPrefService
modules/libpref/public/nsiprefservice.idlscriptable this interface is the main entry point into the back end preferences management library.
... inherits from: nsisupports last changed in gecko 1.7 method overview nsiprefbranch getbranch(in string aprefroot); nsiprefbranch getdefaultbranch(in string aprefroot); void readuserprefs(in nsifile afile); void resetprefs(); void resetuserprefs(); void savepreffile(in nsifile afile); methods getbranch() call to get a preferences "branch" which accesses user preference data.
... nsiprefbranch getbranch( in string aprefroot ); parameters aprefroot the preference root tree on which to base this branch.
...And 4 more matches
nsIPrefBranch2
in gecko 13 this interface was merged into the nsiprefbranch interface.
...on preference changes, the following arguments will be passed to nsiobserver.observe(): asubject - the nsiprefbranch object (this).
... note: you must call removeobserver method on the same nsiprefbranch2 instance on which you called addobserver() method in order to remove aobserver; otherwise, the observer will not be removed.
nsIPrefLocalizedString
modules/libpref/public/nsipreflocalizedstring.idlscriptable this interface is simply a wrapper interface for nsisupportsstring so the preferences service can have a unique identifier to distinguish between requests for normal wide strings nsisupportsstring) and 'localized' wide strings, which get their default values from properites files.
Preferences - Archive of obsolete content
two used interfaces are nsiprefservice and nsiprefbranch.
...to get an nsiprefbranch, either queryinterface() the pref service (that will give you the root branch) or call nsiprefservice.getbranch() to get a sub-branch.
... here are two examples: // get the root branch var prefs = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefbranch); // get the "extensions.myext." branch var prefs = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice); prefs = prefs.getbranch("extensions.myext."); simple types there are three types of preferences: string, integer, and boolean.
...And 27 more matches
XPCOM Objects - Archive of obsolete content
clicking on the link for the getbranch method takes you to the nsiprefservice documentation page, where you can see more details on the interface and the method.
... this._prefservice = cc["@mozilla.org/preferences-service;1"].getservice(ci.nsiprefbranch); this._prefvalue = this._prefservice.getboolpref("somepreferencename"); this._prefservice.queryinterface(ci.nsiprefbranch2); this._prefservice.addobserver("somepreferencename", this, false); this._prefservice.queryinterface(ci.nsiprefbranch); this is a common piece of code you'll see when initializing components or jsm that rely on preferences.
...these methods are in the nsiprefbranch interface.
...And 4 more matches
Adding preferences to an extension - Archive of obsolete content
the javascript code in order to monitor changes to our preferences, we need to install an observer using the nsiprefbranch2 interface.
... var stockwatcher = { prefs: null, tickersymbol: "", // initialize the extension startup: function() { // register to receive notifications of preference changes this.prefs = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice) .getbranch("extensions.stockwatcher2."); this.prefs.addobserver("", this, false); this.tickersymbol = this.prefs.getcharpref("symbol").touppercase(); this.refreshinformation(); window.setinterval(this.refreshinformation, 10*60*1000); } }, our object has two member variables.
... second, we call nsiprefservice.getbranch().
...And 3 more matches
Chapter 4: Using XPCOM—Implementing advanced processes - Archive of obsolete content
listing 18: converting text from iso-2022-jp to unicode converter.charset = 'iso-2022-jp'; var unicode_str = converter.converttounicode(iso2022jp_str); reading and writing preferences you can use the nsiprefbranch function to access firefox's preferences system.
... note: the value returned by nsiprefbranch.getcharpref() is a utf-8 bytestring; here, we are converting it to utf-16 using escape() and decodeuricomponent().
... listing 19: reading a text-string setting var pref = components.classes['@mozilla.org/preferences-service;1'] .getservice(components.interfaces.nsiprefbranch); var dir = pref.getcharpref('browser.download.lastdir'); alert(decodeuricomponent(escape(dir))); writing preferences listing 20 shows the opposite operation, writing a text string to a unique preference.
... note: the value for the second parameter of nsiprefbranch.setcharpref() is a utf-8 bytestring; here, we are converting a utf-16 to utf-8 using unescape() and encodeuricomponent().
preferences - Archive of obsolete content
</preferences> attributes these ought to be readonly; three of these could be merged into a single member attribute nsiprefservice service; the preferences service.
... attribute nsiprefbranch rootbranch; the root prefs branch.
... attribute nsiprefbranch defaultbranch; the root branch of the tree with default values.
... attribute nsiprefbranch2 rootbranchinternal; the root prefs branch (nsiprefbranch2).
Index
MozillaTechXPCOMIndex
159 component; nsiprefbranch interfaces, interfaces:scriptable, web development, xpcom, xpcom api reference, xpcom api article, xpcom interface reference this object is created with a "root" value which describes the base point in the preferences "tree" from which this "branch" stems.
... 830 nsiprefbranch2 interfaces, interfaces:scriptable, xpcom, xpcom api reference, xpcom interface reference add a preference change observer.
... on preference changes, the following arguments will be passed to nsiobserver.observe(): 831 nsipreflocalizedstring interfaces, interfaces:scriptable, preferences, xpcom, xpcom interface reference used to set the contents of this object.
... 832 nsiprefservice interfaces, interfaces:scriptable, xpcom, xpcom api reference, xpcom interface reference call to get a preferences "branch" which accesses user preference data.
Handling Preferences - Archive of obsolete content
managing preferences with xpcom we use the preferences service in order to get and set preference values: this._prefservice = cc["@mozilla.org/preferences-service;1"].getservice(ci.nsiprefbranch); // ...
... preference listeners the xpcom way to add a listener was mentioned in the xpcom section when describing the queryinterface method: this._prefservice.queryinterface(ci.nsiprefbranch2); this._prefservice.addobserver(prefname, this, false); this._prefservice.queryinterface(ci.nsiprefbranch); all the qi'ing is necessary because the addobserver method is in a different interface, and other than for adding and removing observers, we use the nsiprefbranch interface for everything related to preferences.
... } }, always remember to remove the observer when you don't need it anymore: this._prefservice.queryinterface(ci.nsiprefbranch2); this._prefservice.removeobserver(prefname, this); preference windows it's very common for extensions to have a few settings that their users can change to tailor them to their needs.
JS XPCOM - Archive of obsolete content
getting an xpcom service var preferences = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice); you can then call any methods in the nsiprefservice interface on the preferences object.
...with the preferences service from the previous example we can do the following: var preferences = preferences.queryinterface(components.interfaces.nsiprefbranch2); this allows you to use the methods in the nsiprefbranch2 interface.
Overview of Mozilla embedding APIs
contract-id: ns_pref_contractid implemented interfaces: nsiprefservice nsiprefbranch related interfaces: nsipreflistener profile manager service contract-id: implemented interfaces: document loader service (webprogress) eventually, this service will be replaced by thewebprogress service...
...interface definition: nsiprefs interface status...
XPCOM Interface Reference
component; nsiprefbranchextensionmanager (toolkit)iaccessible2iaccessibleactioniaccessibleapplicationiaccessiblecomponentiaccessibleeditabletextiaccessiblehyperlinkiaccessiblehypertextiaccessibleimageiaccessiblerelationiaccessibletableiaccessibletable2iaccessibletablecelliaccessibletextiaccessiblevalueidispatchijsdebuggeramiinstallcallbackamiinstalltriggeramiwebinstallinfoamiwebinstalllisteneramiwebinstallpromptamiwebinstallerimgicacheimgicontainerimgicontainerobserverimgidecoderimgidecoderobserverimgiencoderimgiloaderimgirequestinidomutilsjsdistackframemoziasyncfaviconsmoziasynchistorymozicoloranalyzermozijssubscriptloadermozipersonaldictionarymoziplaceinfomoziplacesautocompletemoziregistrymozirepresentativeco...
...ryresultobservernsinavhistoryresulttreeviewernsinavhistoryresultviewobservernsinavhistoryresultviewernsinavhistoryservicensinavhistoryvisitresultnodensinetworklinkservicensiobservernsiobserverservicensioutputstreamnsioutputstreamcallbacknsiparentalcontrolsservicensiparserutilsnsipasswordnsipasswordmanagernsipermissionnsipermissionmanagernsipipensiplacesimportexportservicensiplacesviewnsipluginhostnsiprefbranch2nsipreflocalizedstringnsiprefservicensiprincipalnsiprinterenumeratornsiprintingpromptnsiprivatebrowsingservicensiprocessnsiprocess2nsiprocessscriptloadernsiprofilensiprofilelocknsiprofileunlockernsiprogramminglanguagensiprogresseventsinknsipromptnsipromptservicensipropertiesnsipropertynsipropertybagnsipropertybag2nsipropertyelementnsiprotocolhandlernsiprotocolproxycallbacknsiprotocolproxyfi...
browser.preferences - Archive of obsolete content
« xul reference preferences type: nsiprefservice this read-only property contains an nsipref object for getting and setting user preferences.
Using nsIXULAppInfo - Archive of obsolete content
getappid() { var id; if("@mozilla.org/xre/app-info;1" in components.classes) { // running under mozilla 1.8 or later id = components.classes["@mozilla.org/xre/app-info;1"] .getservice(components.interfaces.nsixulappinfo).id; } else { try { id = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefbranch) .getcharpref("app.id"); } catch(e) { // very old version dump(e); } } return id; } alert(getappid()); see also mxr: nsixulappinfo.idl ...
XUL Questions and Answers - Archive of obsolete content
others, like <listbox>, cannot be so tied, but one can always write a script that updates preferences explicitly, via nsiprefbranch interface.
browser - Archive of obsolete content
preferences type: nsiprefservice this read-only property contains an nsipref object for getting and setting user preferences.
preference - Archive of obsolete content
(this always accesses the nsiprefbranch apis regardless of the instantapply mode in effect).
How to enable locale switching in a XULRunner application - Archive of obsolete content
getservice(components.interfaces.nsiprefbranch); prefs.setcharpref("general.useragent.locale", newlocale); // restart application var appstartup = components.classes["@mozilla.org/toolkit/app-startup;1"] .getservice(components.interfaces.nsiappstartup); appstartup.quit(components.interfaces.nsiappstartup.erestart | components.interfaces.nsiappstartup.eattemptquit); } catch(err) { ...
Make your xulrunner app match the system locale - Archive of obsolete content
from xpcom import components ps_cls = components.classes["@mozilla.org/preferences-service;1"] ps = ps_cls.getservice(components.interfaces.nsiprefservice) branch = ps.getbranch("general.useragent.") branch.setcharpref("locale", lang) i also set the language environment variable to match the system locale so that python's gettext functionality will work (it pulls straight from language instead of using setlocale): os.environ["language"] = lang ...
XULRunner tips - Archive of obsolete content
browser.download.manager.focuswhenstarting", false); pref("browser.download.manager.flashcount", 2); // pref("alerts.slideincrement", 1); pref("alerts.slideincrementtime", 10); pref("alerts.totalopentime", 4000); pref("alerts.height", 50); if you are missing preferences that a dialog requires, you will get the following errors: component returned failure code: 0x8000ffff (ns_error_unexpected) [nsiprefbranch.getboolpref] error: dialog has no properties source file: chrome://mozapps/content/downloads/u...ontenttype.xul line: 1 enabling password manager these preferences seem to be the default in firefox, however, they are missing in xulrunner.
Using workers in extensions - Archive of obsolete content
let's take a look: startup: function() { // register to receive notifications of preference changes this.prefs = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice) .getbranch("stockwatcher2."); this.prefs.queryinterface(components.interfaces.nsiprefbranch2); this.prefs.addobserver("", this, false); this.tickersymbol = this.prefs.getcharpref("symbol").touppercase(); this.worker = new worker("chrome://stockwatcher2/content/ticker_worker.js"); // small little dance to get 'this' to refer to stockwatcher, not the // wo...
Embedding API for Accessibility
be aware that in debug builds, this can cause a great number of assertions (bug 71598) to use prefs in embedding, use something like the following code: #include "nsipref.h"; nsresult rv; nscomptr<nsipref> prefs(do_getservice(ns_pref_contractid, &rv)); prefs->setboolpref("bool.pref.name", pr_true /* or pr_false */); prefs->setintpref("int.pref.name", newvalue); prefs->setcharpref("string.pref.name", newcharstarvalue); to manually add a pref to your settings, add a line like the following to your prefs.js: user_pref("accessibility.browsewithcaret", true); ...
Interfacing with the Add-on Repository
to make the service work for the time being, you can use code like this when your extension starts up: var prefsservice = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice); var prefbranch = prefsservice.getbranch("extensions."); var recurl = ""; try { recurl = prefbranch.getcharpref("getaddons.recommended.url"); } catch(e) { recurl = ""; } if (recurl == "") { prefbranch.setcharpref("getaddons.recommended.url", "https://services.addons.mozilla.org/%locale%/%app%/api/%api_version%/list/recommended/all/%max_results%/%os%/%version%?
Services.jsm
anager service metro nsiwinmetroutils 2 mm nsimessagebroadcaster nsiframescriptloader global frame message manager3 obs nsiobserverservice observer service perms nsipermissionmanager permission manager service ppmm nsimessagebroadcaster nsiprocessscriptloader global parent process message manager3 prefs nsiprefbranch nsiprefbranch2 nsiprefservice preferences service prompt nsipromptservice prompt service scriptloader mozijssubscriptloader javascript subscript loader service scriptsecuritymanager nsiscriptsecuritymanager script security manager search nsibrowsersearchservice browser search service startup nsiappstartup ...
Preferences API
interfaces the preferences api is exposed as a set of xpcom components and interfaces: nsiprefservice, nsiprefbranch.
nsIContentSniffer
let charset = "iso-8859-1"; try { // this pref has been removed, see bug 910192 charset = services.prefs.getcomplexvalue("intl.charset.default", ci.nsipreflocalizedstring).data; } catch (e) { } let conv = cc["@mozilla.org/intl/scriptableunicodeconverter"] .createinstance(ci.nsiscriptableunicodeconverter); conv.charset = charset; try { let str = conv.convertfrombytearray(adata, alength); if (str.substring(0, 5) == "%pdf-") return "application/pdf...
XPCOM Interface Reference by grouping
nsidnsservice nsiftpchannel nsiftpeventsink nsihttpchannel nsihttpchannelinternal nsihttpheadervisitor nsiidnservice nsiprotocolhandler nsiprotocolproxycallback nsiprotocolproxyfilter nsiprotocolproxyservice nsiproxyinfo preferences nsiiniparser nsiiniparserfactory nsiprefbranch nsiprefbranch2 nsipreflocalizedstring nsiprefservice nsistringbundle nsistringbundleservice security cookies nsicookie nsicookie2 nsicookieacceptdialog nsicookieconsent nsicookiemanager nsicookiemanager2 nsicookiepermis...
Get Thunderbird version
0b4 else // code for < 3.0b4 for versions prior to 3.0b3pre, you can use something like this: var version; if ( "@mozilla.org/xre/app-info;1" in components.classes ) version = components.classes["@mozilla.org/xre/app-info; 1"].getservice(components.interfaces.nsixulappinfo).version; else version = components.classes["@mozilla.org/preferences-service; 1"].getservice(components.interfaces.nsiprefbranch).getcharpref ("app.version"); var versionchecker = components.classes["@mozilla.org/xpcom/version- comparator;1"].getservice(components.interfaces.nsiversioncomparator); if ( versionchecker.compare( version, "3.0b3" ) >= 0 ) // code for >= 3.0b3 else // code for < 3.0b3 ...
Working with windows in chrome code
example: var prefs = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice); var branch = prefs.getbranch("extensions.myext."); var var1 = branch.getboolpref("var1"); // get a pref see also code snippets:dialogs ...