25 January 2011 - 0:39Restartless add-on example code

mfinkle’s recent posts [starkravingfinkle.org] on restartless add-ons reminded me that I was going to write a more detailed post about my restartless GitHub repository, but I’ve been distracted with another project. 😉

So briefly, I’ve put together some helper functions [github.com] that have been useful for developing various restartless add-ons. I’ve organized the repository to have a bunch of “examples/” branches that build on top of other named branches that implement helper functions.

These first few are very simple examples:

examples/autoReload: saves a step when developing a restartless addon by automatically re-enabling when you disable the add-on from about:addons

examples/ensureEnabled: the install method always gets executed even when disabled, so this code makes sure the add-on runs on install; useful when combined with the following..

examples/oneTime: run once and disable itself; useful for debugging problems on other people’s Firefox without doing the usual “copy/paste this into the Error Console”

The next couple helper functions have been incredibly useful for the restartless add-ons I’ve written:

unload: add a callback to run when the add-on is disabled by calling unload(callback). This function makes it easy to ensure Firefox returns to its original state when a restartless add-on is disabled (which is very important for developing as you’re likely to disable and re-enable many times!) (example)

watchWindows: add a callback to run when the main Firefox browser window is open (navigator:browser) by calling watchWindows(callback). The callback will be called immediately for existing windows and future windows, so put whatever browser UI modification code you want inside the callback. (example)

One last helper in the repository is the getString function that adds some l10n support to get the correct .properties file for the current locale. It shows off getting additionally packaged files and picking the right locale and some plural forms. I’ve put together a silly example at examples/l10nDialogs.

Silly l10n example

With all these helper functions, Erik Vold and Nils Maier helped put together some code that loads packaged scripts. We ended up with some code that makes use of getResourceURI so that it correctly works if the addon is .xpi packaged or an extension proxy file. Separating out the code this way lets you better organize the code and makes it easier to share.

3 Comments | Tags: Add-on, Development, Mozilla

22 January 2011 - 13:33Looking for some prototype testers

Edit: The add-on has now been released, so check out the announcement post: Towards Browse-Based Browsing with Home Dash. Thanks for the feedback!

I started hacking on an idea last week in the context of the Prospector experiments [mozillalabs.com]. I’m looking for a small set of people to try it out and give some initial technical feedback. For example, I know I’ve hard-coded some sizes/images that happen to fit my 1280×800 screen on my Mac, but I am curious how it works or doesn’t work on other platforms, window sizes, etc.

You can install the restartless add-on [edit: addons.mozilla.org] if you’re already running Firefox 4 Beta 10 [firefox.com] or later. I’m not really describing it on purpose. 😉 But not to be too confused, below is a sketch from when I started hacking on it. And as usual, you can check out the source first from GitHub [github.com] or directly from the .xpi.

Sketch of Home Dash

You can email me the feedback at edilee@gmail.com or just reply with a comment!

23 Comments | Tags: Development, Mozilla, Search