Tuesday, February 13, 2007

SimpleXULApp

In this post I will introduce the simplest possible XULRunner application. I tried to run some of the other tutorial I have found on the web and, for one reasons or another I was not able to do it. Maybe they were a bit outdated. This SimpleXULApp will run on XULRunner 1.9a3 and 1.8.0.4: these are the two versions I tried.

  • Download a copy of XULRunner from here.
  • Download SimpleXULApp.
  • On Windows I extracted XULRunner in a folder and added that folder to the PATH variable.
  • Extract SimpleXULApp in another folder.
  • Open a DOS Window and type XULRunner -register-global
  • cd into the SimpleXULApp folder .
  • type XULRunner application.ini -jsconsole
  • Actually you do not need the "-js-console" but it comes handy because it shows the Javascript console where you can dump messages.

What's inside the archive?

Well it is really the bare minimum that you need to open a window. First of all it is important to notice the folders structure:

  • SimpleXULApp
  • SimpleXULApp\chrome
  • SimpleXULApp\chrome\content
  • SimpleXULApp\defaults
  • SimpleXULApp\defaults\preferences

inside these folders we got:

  • SimpleXULApp\application.ini
  • SimpleXULApp\chrome\chrome.manifest
  • SimpleXULApp\chrome\content\main.xul
  • SimpleXULApp\defaults\preferences\SimpleXULApp.js

application.ini

It is a simple file that identifies our application:

[App]
Name=SimpleXULApp
Version=1.0
Vendor=TrickySoft
BuildID=20070213

[Gecko]
MinVersion=1.8
MaxVersion=1.9

There is not much to say, just that I put the strictly necessary tags. It is interesting to note the MinVersion and MaxVersion tags in the the [Gecko] section: XULRunner checks them in order to see if the application can run with the current runtime version.

chrome.manifest

By now, for me, its content is a simple act of faith:

content SimpleXULApp file:content/

It has something to do with telling XULRunner where to look for content.

SimpleXULApp.js

Here too it is still a leap of faith:-)

pref("general.startup.SimpleXULApp",true);
pref("toolkit.defaultChromeURI", "chrome://SimpleXULApp/content/main.xul");

It indicates somehow where to start from, i.e. the main.xul

And main.xul? well I did not forget about that, it is the main piece here, but.. that is XUL, so let's introduce it another time. Today I just wanted to introduce the bare minimum needed to start with XULRunner and what made it work for me.

No comments:

Joost

Joost™ the best of tv and the internet