In the previous article in this series, we put together the main interface file. Before you can see how it will look, however, you need to describe it in a language that Mozilla can understand. This article will show you how to create the appropriate RDF file, register it with Mozilla's chrome directory, and in general get to the point where you can see the fruits of your labors over the previous two articles.
Back to XUL: Uniting XUL and RDF - Tell the Interface What to Do (Page 4 of 4 )
Lastly, we need to tell the main interface file to actually use the DTD. At the top of interface.xul, just before the opening <window> tag, add the following line of code:
<!DOCTYPE window SYSTEM "chrome://interface/locale/">
Now that the main interface.xul file, the interface.dtd file and both of the associated rdf files have been created, and everything has been registered, we should finally be able to view the interface in Mozilla or its own window.
To access the file correctly, in the Mozilla address bar type:
chrome://interface/content
To open it in its own window, open a command prompt and type:
Mozilla –chrome chrome://interface/content
There it is, in all its glory! As you can see, the command we type to view the file is very similar to the command we type when we tell the interface file which DTD file to use. Because these elements of the application are registered, we do not need a full path, we just say "use the interface content," or "use the interface locale." This is the power of the chrome URL.
Now, for international support, you could simply create a new folder in the locale directory, named for the locale code (de represents German language for example) and into this put a DTD with the text strings in the alternative language. An rdf file is also used for registration purposes. Unlike some websites that can switch between languages at the click of a button, these alternative localization files/settings would normally be determined at install time, either through part of the installation asking the user which language to install the application in, or in some cases, the installer would be configured to choose whichever localization the operating system is set to.
Admittedly, because there is no logic, none of the menu commands or buttons on the interface actually do anything. At this stage, all it does is sit there and look pretty. This is a situation that needs to be rectified as quickly as possible, so the next article will show you how to construct the JavaScript file that will turn our interface from something that just looks good into something that not only looks good but also does what it was intended for – create XUL files.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.