[Project_owners] Setting preferences in new firefox

Jaap Haitsma jaap at haitsma.org
Thu Aug 5 22:09:20 EDT 2004


Jawahar Swaminathan wrote:
> Hi.
> 
> I'm trying to set some user_pref for my extension at installation
> time and cannot get it to work.
> 
> Using firefox 0.9.1
> 
> The file extension.js is in the directory path 
> extension/defaults/preferences/
> 
> and contains the following lines
> 
> user_pref("biobar.sequences", true); user_pref("biobar.structures",
> true); user_pref("biobar.function", true);
> 
> The extension is then zipped and installs and everythings seems okay.
> 
> 
> However on doing an about:config for getting the settings I get
> 
> Preference Name              Status            Type         Value
> 
> biobar.sequences               default           boolean 
> biobar.structures                default           boolean
> 
> There is no value, which should have been true !!
> 
> Any idea what is going on ? I've tried this with a new profile etc.
> 
> Thanks. Any help greately appreciated.
> 
I solve it in a different way. I check if they exist and then write the
default values to them. Excerpt from code I use is below

Cheers,

Jaap

---------------------------------------------------------

var dictionarySearchPrefs= 
Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService).getBranch("dictionarysearch.");

if (!dictionarySearchPrefs.prefHasUserValue("menutext1")){
   // Assign default values
   dictionarySearchPrefs.setCharPref("url1", 
dictionarySearchStrBundle.getString("dictionarysearch.default.URL"));
   dictionarySearchPrefs.setCharPref("menutext1", 
dictionarySearchStrBundle.getString("dictionarysearch.default.menutext"));
   dictionarySearchPrefs.setCharPref("accesskey1", 
dictionarySearchStrBundle.getString("dictionarysearch.default.accesskey")); 
}




More information about the Project_owners mailing list