Extensions for Fennec

As I mentioned in the Fennec M7 release notes, the Add-ons Manager has been hooked up. Therefore, I decided to post some example add-ons for Fennec. Fennec is a XULRunner application and gives extension developers access to the same underlying XPCOM system that is used in Firefox. The process of building extensions is the same as for any other Mozilla based application.

However, there are some things a potential extension developer should know. Fennec is not Firefox. It is a completely different application. Fennec’s UI is also very different than Firefox. This means that you can’t just plop a Firefox (or Thunderbird or Songbird) extension into Fennec and expect anything to work. There are some basic things an extension developer will need to handle when making or porting extensions to Fennec:

  • Fennec uses a different application id: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
  • Fennec has very different XUL UI. Many XUL elements found in Firefox do not exist in Fennec. Update your overlay XUL file accordingly.
  • Fennec uses different JavaScript objects and functions in it’s UI code. Functions and objects you have used in Firefox may not exist or may even represent different things in Fennec. For example, there is a Browser object that encapsulates some of the basic browser features, but there is a BrowerUI object that is the controller for the actual chrome. Also, there is no gBrowser object (yet) and the getBrowser() method does not return a <tabbrowser> as it does in Firefox.

The best way to figure out what’s available is to look at the source code. Also, jump on Mozilla IRC and ask questions in the #mobile channel. Ok, enough of that, let’s look at the sample extensions.

  • fennec-sample: A simple barebones add-on that shows the minimum needed to get an extension running in Fennec. Adds a button to the toolbar and displays an alert when clicked.
  • fennec-readit: A basic add-on that use flite on Maemo to turn text into speech. Toggle the text-to-speech (TTS) mode on and off using the toolbar button. When TTS is on, clicking (touching) text content will cause the text to be read aloud using flite.

Use Fennec M7 and click on the above links to install the extensions.

NOTE: In order to use fennec-readit, you must install flite first. I found a simple binary install for Maemo that seems to work OK. The binary of flite can be found in the Maemo Extras repository. After installing, you can test flite by opening a terminal and typing: flite -t "Hello World"

It might be cool to create an XPCOM version of flite (or use js-ctypes on a shared library version).

Comments are closed.