Using XUL prefwindow and prefpanes
The combination of <prefwindow> and <prefpane>'s provides Firefox addon developers with an effective mechanism for creating a preferences dialog. The best example of <prefwindow> usage is the Firefox options dialog.
This tech note will focus on getting all the elements of the <prefwindow> framework right as it is fairly easy to miss one small element, leaving you scratching your head. Below is a screenshot of the end result.
Setting up the <prefwindow>
The code below a minimal <prefwindow> page with two <prefpane>'s. If only one <prefpane> is used, the navigation bar is not displayed. When two or more <prefpane>'s are used, a navigation bar is added at the top of the page.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css"?>
<prefwindow id="modifyheadersPreferences"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="width: 42em; min-height: 37.5em;">
<prefpane id="paneProfiles" label="Profiles"
src="chrome://modifyheaders/content/profiles.xul"/>
<prefpane id="paneHeaders" label="Headers"
src="chrome://modifyheaders/content/headers.xul"/>
</prefwindow>
For this example, the contents of each <prefpane> are contained in external files, but you can place content directly between <prefpane> start and end tags. No content should appear above between the opening <prefwindow> element and the <prefpane> elements. If any scripts or other content must be defined, place them after the last <prefpane>.
Defining <prefpane> panels
There are several rules for defining <prefpane>s in external files:
- The root tag must be an
<overlay>. - The id of the
<prefpane>must match the id specified in the<prefwindow> - A
<preferences>element must be specified, even if it is empty
Here is an example for the <prefpane> with id="paneProfiles".
<?xml version="1.0"?>
<overlay id="modifyheaders-profiles-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="paneProfiles" label="Profiles">
<preferences/>
<vbox id="modifyheaders-profiles">
<description>Edit Site Profiles</description>
</vbox>
</prefpane>
</overlay>
This markup is repeated for each <prefpane> you need to define. Only the id attribute must be unique.
Opening the <prefwindow> using javascript
This is the bit that caught me out. You have to be careful about which features are specified for the window. Typically for a XUL dialog, you would use:
window.openDialog("chrome://modifyheaders/content/dialog.xul", "modifyheadersDialog", "resizable,dialog,centerscreen,modal", this);
The third argument lists the features for the dialog. In this case: resizable, dialog, centerscreen, modal. For a <prefwindow>, you have to make sure the toolbar feature is specified. Resizeable can be ignored as it seems to have no affect on this type of window:
window.openDialog("chrome://modifyheaders/content/preferences.xul", "modifyheadersPreferences", "chrome,titlebar,toolbar,centerscreen,modal", this);
That about wraps it up. As you can see, it is straightforward enough. For further information, here are some further references from MDC:
Firefox 3.6 Compatibility
Quick update on Firefox 3.6. Modify Headers and XHTMLMP have both been successfully tested in beta 4. The max version for each has been bumped at AMO and both are now available for install into 3.6.
Initial Mailfrom testing has revealed a couple of defects. I'm going to work on those over the next week and hopefully have it done before GA release or Christmas (whichever comes first).
Released: Modify Headers 0.6.4 and XHTML Mobile Profile 0.5.3
Both Modify Headers and XHTML Mobile Profile have been updated this week.
Version 0.6.4 of Modify Headers fixes a nsIObserver interface problem with the add-on working in Firefox 3 beta. XHTML Mobile Profile 0.5.3 adds support for the content type application/vnd.wap.multipart.mime.
Mailfrom 0.2 Released
Mailfrom 0.2 was released over the weekend. This adds support for AOL Mail and handling for subject lines in mailto links.
Download from Mozilla Addons.
Announcing Mailfrom v0.1: compose mailto links in webmail
I'm pleased to announce a new Firefox addon, Mailfrom, that enables mailto links to be composed in your favourite webmail service.
Version 0.1 is an early access release and provides support for GMail and Yahoo Mail only. If you wish to have a service added, request an enhancement or encounter a problem, please file a bug report.
Mailfrom is available for download from the Mozilla Addons Sandbox (login required).
To make the addon available in the public repository, it requires reviews. If you like the addon, please post a review here.
Released: Modify Headers 0.6.3
Happy New Year to you all.
Before Christmas I released version 0.6.3 of Modify Headers. This version adds support for the Firefox 3 beta 2. For current users this will automatically update, otherwise, please download from Mozilla Addons.
Update: XHTML Mobile Profile 0.5.2 has been updated to support Firefox 3 beta 2.
Announcing: XHTML Mobile Profile v0.5.2 for Firefox
Yesterday, version 0.5.2 of the XHTML Mobile Profile add-on for Firefox was released. Please install from Mozilla Add-ons.
This is the second bugfix release of version 0.5, (which was not announced when released last month, oops). Version 0.5 adds support for rendering multipart mixed content in Firefox.
Please report any defects or enhancement requests in Mozdev Bugzilla.
Released: Modify Headers 0.6.0
Version 0.6.0 of Modify Headers is now available. The main new feature for version 0.6.0 is the ability to export and import headers. The wizard can be found on the configuration tab.
Please post any bugs to bugzilla.mozdev.org.
Released: XHTML Mobile Profile 0.3.7
This release adds the string [XHTML-MP] to the title of a document that is being handled using the XHTML Mobile Profile addon. Go to Mozilla Update to install.
Finding a Theme
Today the Firefox addon, Web Developers Toolbar, was updated. After restarting, none of the icons were displayed on the toolbar. The problem was the theme used: Phoenity. Turns out that Phoenity is no longer supported by its author. So looking for a new theme I found Blue Ice. Its simple, understated and supports the web developer toolbar icons.
This made me look at the theme for this blog. It had been using the Neat (link no longer available) theme, but I've decided its too dull. So until I can find (or design) a better one, the default theme is going to have to do.
