ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

XULRunner - XUL & JS For Desktop Applications

(1/2) > >>

Ehtyar:
Hey all. I imagine just about anyone who has ever done a Firefox extension has wished that creating cross-platform desktop applications was that easy. Naturally, Mozilla has had the foresight to make this possible for quite some time, they just suck at marketing ;)

Meet XULRunner. This application allows programmers do use XUL and JavaScript to create fully featured desktop applications with all the functionality of XPCOM. This makes coding your application that much easier, and that every single Firefox extension potentially contains example code that a developer can leverage to their benefit.

XULRunner itself currently occupies about 20 megabytes on disk, but can be compressed to ~6mb using lzma or bzip2. It is recommended that you package XULRunner with your application, however if you make an update URL available (XULRunner has a built in updater similar to Firefox's) you can use Firefox or Mozilla to run your application in a separate instance and update it should a platform update break your application.

For anyone interested, as an example, let's take Alice Corbin's excellent XUL sample here, and turn it into an XULRunner application. She very kindly makes it available in zip which can be downloaded here. First, we'll need a copy of XULRunner from here (SDK w/ runtime here). To follow certain steps later on, you should execute 'xulrunner --register-user' after extracting it. To start, we'll create a directory called 'top' where you'd like the application to be, and beneath it create a structure like this:
|-application.ini
|-chrome
  |-chrome.manifest
  \-content
|-defaults
  |-preferences
    \-prefs.js

--- End quote ---
Application.ini stores your program's metadata, it will look like this (where <GUID> is a globally unique identifier; it can be a guid or your email address etc):
[App]
Name=top
Version=1.0
BuildID=20060105
ID=<GUID>

[Gecko]
MinVersion=1.8
MaxVersion=1.9

--- End quote ---

Fairly self explanatory I think. Next we'll open chrome/chrome.manifest. In here we'll tell Gecko where to find the actual content of our application by adding this line:
content top content/

--- End quote ---
This tells Gecko that the content of our application can be found in the subdirectory 'content'. The content directive supports full relative paths, so you can place your content in a folder beside application.ini and use "content top ../content/" if you'd prefer. NOTE: The directory you specify *must* end in a slash.

Next, we open defaults/preferences/prefs.js. In here you can set all your default preferences, but for this application we will need only this line:
pref("toolkit.defaultChromeURI", "chrome://top/content/top.xul");

--- End quote ---
This line tells Gecko which file from the content directory we would like it to create the initial window from (similar in a sense to index.html/default.htm).

Finally, we'll extract the contents of xulpt.zip into the chrome/content directory. You'll notice the zip contains the top.xul file referenced above. Now we can test out our new application by launching it with XULRunner. To do this, open a command prompt and navigate to the folder where you installed XULRunner. Say you put your application in the 'top' directory beneath your XULRunner directory, you would execute "xulrunner top\application.ini" and you'll see your new application appear on the desktop.

For anyone interested in distributing applications they create, XULRunner harbors the same installer system as Firefox, though it is invoked in a different fashion. What you'll need to do to make use of it is zip up your application into top.zip (with application.ini in the root). Rename top.zip to top.xpi. Then, execute 'xulrunner --install-app C:\path\to\top.xpi C:\path\to\install\to'. This will install your application to the specified path (or the default path if the last parameter is omitted), and XULRunner will create a friendly stub application that users can use to launch your application with requiring a console.

XULRunner - XUL & JS For Desktop Applications   XULRunner - XUL & JS For Desktop Applications
Finally, here are some links for potential developers to peruse:
-XULRunner Hall of Fame Applications
-Chrome Registration
-Installer Bundles
-The Chrome URI
-Mark Finkle's XUL Blog
-Richard Crowley's XULRunner Blog
-XUL Code Snippets
-XUL/JS Example Code

Hope this helps some people, and please leave any constructive criticism in a reply. If anything doesn't work for you leave a comment in the replies and I'll see if i can help.

Ehtyar.

mahesh2k:
Thanks Ehtyar
My friend is Working on FF these days, this info will definitely helpful for him..
 :Thmbsup:

mouser:
Very cool stuff.. has anyone here done any XUL application building? I have a book on it but i've only just skimmed it.

VideoInPicture:
I'll have to check this out when I get more time. I'll have to see how easy it is to code with.

I'm currently re-learning Java development so I'm wondering what advantages XULRunner would have over Java since they are both cross-platform.

wuwei23:
I'm currently re-learning Java development so I'm wondering what advantages XULRunner would have over Java since they are both cross-platform.
-VideoInPicture (September 14, 2008, 01:49 PM)
--- End quote ---
The BIG advantage I can see is it isn't Java ;)

Seriously though, I can see it being more useful to people who are primarily experienced as web developers. XULRunner lets you create desktop apps using HTML/CSS/Javascript, which is a powerful combo if you're already using them.

While I haven't tried it, I do plan on using XULRunner for at least a small project sometime soon, especially as its easy to use Python while doing so: Python XULRunner Application

Navigation

[0] Message Index

[#] Next page

Go to full version