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)


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

and then assign it to the controls as in:

<vbox>
<groupbox>
<caption label="&nflookup.settings.url;"/>
<textbox id="url" preference="nflookup.url" minwidth="350" />
<description control="url">
<html:p>&nflookup.url.help;</html:p>
</description>
</groupbox>

<groupbox>
<caption label="&nflookup.settings.domains;"/>
<textbox id="domains" preference="nflookup.domains" minwidth="350"/>
<description control="domains">
<html:p>&nflookup.domains.help;</html:p>
</description>
</groupbox>
</vbox>


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: