Difference between revisions of "How to do a Hello World application using XULRunner"

From CDOT Wiki
Jump to: navigation, search
(Setting up the chrome.manifest file)
(Setting up the prefs.js file)
Line 46: Line 46:
== Setting up the prefs.js file ==
== Setting up the prefs.js file ==
The prefs.js file tells XULRunner which XUL file contains the main window.  The following was used for this simple application.
The following was used for this simple application.
  pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");
  pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");

Revision as of 19:31, 13 November 2006

Note: This page is still under construction

Setting up an application file structure

First set up the application file structure to the following:

       your app files

This file structure is used on a Linux platform. If your using a different platform, please visit Deploying XULRunner 1.8 to find the file struture for your specific platform.


Users can change the name of the italicized filename and folders

Setting up the application.ini file

The following is a sample application.ini file.

 Name=Hello World Application
 Copyright=Copyright (c) 2006 

Setting up the chrome.manifest file

For this example, the chrome.manifest file contains the following:

 content myapp file:content/

Setting up the prefs.js file

The following was used for this simple application.

pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");

The pref function needs to be passed in two arguements. In this scenario, this document provided an explaination on what those two arguements are:

  • toolkit.defaultChromeURI is a preferences which allows a simple XULRunner-based application to open a new window
  • chrome://myapp/content/main.xul is the location of the main XUL file.

Creating some XUL

For the similicity of this application, we're going to create a simple XUL window that says hello world.

  <?xml version="1.0"?>
  <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

  <window id="main" title="My App" width="300" height="300"
    <caption label="Hello World"/>

Running the application

To run the application, type the following:

If your on Windows:

 xulrunner.exe application.ini

If your on Linux:

xulrunner application.ini

If your on Mac:

 /Library/Frameworks/XUL.framework/xulrunner-bin application.ini

Make sure your in the application level of the XULRunner application.