Saturday, January 07, 2006

XUL preferences in Thunderbird 1.5

While migrating a little thunderbird extension to 1.5 I decided to use the new preferences system introduced by FF/TB 1.5, which is quite good stuff; keeps all the burden from read/wrinting to the preferences file from you (as well as obtaining the services, etc, etc)

However I ran into a little problem with naming the elemens and preferences.
Here's what worked (within a prefpane, within a prefwindow)

<preference id="nflookup.url" name="extensions.nflookup.url" defaultvalue="somedefault" type="string"/>
<preference id="" name="" type="string"/>

and then assign it to the controls as in:

<caption label="&nflookup.settings.url;"/>
<textbox id="url" preference="nflookup.url" minwidth="350" />
<description control="url">

<caption label="&;"/>
<textbox id="domains" preference="" minwidth="350"/>
<description control="domains">

Notice that the preference attribute of the textbox has to match the id attribute of the corresponding preference. Also (and this was my mistake) to not use the same values as in the id (of the textbox), it seems to be the same namespace (which would be quite obvious).
But this one was hard to identify, since there was no visible error, but the preference items just were not read from or written to the preference file. Took me quite some time.

No comments: