XUL is an XML variant that can be used to create application user interfaces. It can also be used as an element in creating entire applications. This article, the first in a series, introduces you to the idea and helps you get your system ready to start creating.
Back to XUL: Introduction and Preparation - Creating applications with XUL (Page 2 of 4 )
XUL is just an XML variant used to describe interfaces, you may be thinking, so how can you create entire applications with it? Well, the truth is, you can’t. You need something else to glue the various elements together and turn them into functioning entities that work together to actually do things.
XUL provides an excellent introduction to application programming; especially for those that have a good understanding of web design, because it gives you familiar tools to work with that can help to teach you some of the finer points of what is required to make a working application. The language that is used to create the behind the scenes logic that makes the program work is the web programmer’s old friend JavaScript.
Although, that in itself is not entirely true either. While JavaScript can handle many of the more basic operations used when interface elements are interacted with, there are some things for which it is simply not powerful enough; you can’t use it, for example, to launch an operating system specific ‘open file’ dialog box. JavaScript is still the gateway to these higher functions though, and can be used to write XPCOM components that interact with the interfaces and components used in Mozilla. XPCOM stands for Cross Platform Component Object Model, but while XPCOM, like XUL itself, is platform independent, expect very little support for it outside of Mozilla; MSIE for example falls over when trying to open XUL applications, having neither the interfaces nor the chrome architecture that are required.
The chrome architecture provides a method for granting special permissions to XUL files, such as permission to open or write to files, among other things. XUL files that have these permissions are accessed using a chrome URL, much in the same way as a web page is accessed via an HTTP URL. Chrome includes all interface, presentation and locale files present and registered for you with Mozilla; it is a kind of catch-all term for these so when you add, say, a new toolbar to Mozilla, you are adding chrome.
Like a browser that interprets HTML elements and displays them on-screen, XUL elements are rendered according to the Gecko layout engine, which controls, in part, how the components of the Mozilla browser and the files it displays appear.
All of these things and more combine with XUL to form fully functional applications that can run either within Mozilla or as separate applications in their own right (although components of Mozilla will be used when doing this). During the course of these articles we will look at these in more detail.
Make no mistake however; the combination of XUL, JavaScript and XPCOM is not true application code, it’s not C++ or anything. It was designed to make browsers and other network applications, and it does this extremely well, but don’t expect to see a XUL version of Photoshop in the near future.