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:

  1. The root tag must be an <overlay>.
  2. The id of the <prefpane> must match the id specified in the <prefwindow>
  3. 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:

Posted in Firefox, Howto | 1 Comment

Released: Mailfrom 0.2.5 and Future Development

Mailfrom 0.2.5 was released today.  This version fixed a defect to provide Firefox 3.6 compatibility and provides support for Windows Live Hotmail.

I’ve realised for some time that Firefox now provides limited out-of-the-box support for Yahoo Mail and GMail as the target for mailto links.  So I’m going to change the purpose of mailfrom from replacing the built-in functionality to enhancing it.

As an experiment, I’ve moved the source code management to github.  I’ve not used git before and I’m interested to see what the fuss is about!

Posted in Uncategorized | 4 Comments

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).

Posted in Firefox | 6 Comments

Running with Pineapples

I’m going to be running the Winter Pineapple Classic, a 5K (3 mile) ‘fun’ run over obstacles on Saturday November 14.

The event is to support the Leukemia & Lymphoma Society.  Any and all donations are gratefully accepted and can be made up until December 4, 2009 at this special page.

Posted in Living in America | Comments Off on Running with Pineapples

Released: Modify Headers 0.6.6

Back in April I released Modify Headers 0.6.6.  This version fixes a bug in the import function introduced in 0.6.5.

This last weekend, I tested Modify Headers, XHTML Mobile Profile and Mailfrom on Firefox 3.5b4 successfully.  All the addons are now updated to work with the beta.

Posted in Uncategorized | 26 Comments

Release: Modify Headers 0.6.5

Modify Headers 0.6.5 was released over the weekend. This adds a new column on the list of headers to provide a comment for each entry. In addition an enhancement to float the admin window to the top if a user clicks on the Tools menu item was implemented.

The new release should update automatically for most users, or it can be downloaded At Mozilla Addons.

Posted in Uncategorized | 13 Comments

It’s good to be back

At long last I’ve been able to get the blog back up and running after almost a month of down time.  At the end of June my webhost had a double disk failure on the server that hosts the virtual server and all the data was lost!

Thankfully I had setup a daily cron job to email a backup of all the databases.  It’s taken a few weeks to get everything back up and running.  First I had to get some websites I host restored, second work has been incredibly busy (50 – 80 hrs a week) and on top of that I’ve been working on a new website for a charity here in Seattle.  At long last I’ve had the time to get the blog back.

This should serve as a warning to anyone who has a virtual server: KEEP REGULAR BACKUPS.

Posted in Uncategorized | 3 Comments

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.

Posted in Firefox, Mobile Web | 12 Comments

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.

Posted in Firefox | 9 Comments

Cygwin: died waiting for dll loading

Over the weekend I was trying to use mod_rewrite with apache 2 webserver for cygwin and kept getting the following error:

11086085 [main] httpd2 4492 fork: child 5492 - died waiting for dll loading, errno 11

It seemed obvious that cygwin was unable to load some dependency for mod_rewrite. After a little googling, I found a suggestion to rebase cygwin. The procedure is as follows:

  1. Shutdown cygserver (if running): net stop cygserver.
  2. Close all cygwin windows.
  3. Open Start->Run
  4. rebase has to be run from an ash shell, so type C:\path\to\cygwin\bin\ash.exe
  5. Once the shell window in open: $ cd /bin
  6. $ ./rebaseall
  7. $ exit to close the window

After this, I restarted the cygserver service and apache and mod_rewrite worked perfectly.

Posted in cygwin, Howto | 3 Comments