An Introduction to XUL Part 6 - Adding the Code to our XUL
(Page 4 of 4 )
Finally, open the XUL file created in the example from the last article. Add this code to the top of the file, just below the XML declaration:
<?xml-stylesheet href="chrome://openclose/skin/myskin.css"
type="text/css"?>
Once that is saved delete the chrome.rdf file from the Mozilla chrome directory and then launch Mozilla. The XUL file is reference in the same was as before, and once open, you will see the changes laid out in the example stylesheet. Adding alternative locale files to you applications is done in a similar way, using contents.rdf files to describe them and DTD instead of CSS Files.
If you’re creating multiple skins, it would be wise to package them up in JAR files yourself. When doing this, the format that you use to register them in the installed-chrome.txt file changes. You should store your own JAR archive in the Mozilla chrome folder along with the others and add the next line of code to the bottom of the file:
skin,install,url,jar:resource:/chrome/yourjarname.jar!
If you have a directory structure within the JAR file, the location of the stylesheet will need to come directly are the exclamation mark, so if there was folder inside the JAR file called skin, then a folder inside that called metallic, which contained a stylesheet that gave interface elements a silver and grey colour scheme, the line of code would need to read:
skin,install,url,jar:resource:/chrome/yourjarname.jar!/
skin/metallic/
The concepts in this article have related to defining element bindings using XBL and stylesheets, and changing the theme of your applications by using skins. What I’ve shown you is just the beginning, there is far more than the scope of these articles can hope to include.
XUL is an incredibly easy language to learn and is effective and powerful in what it can do. I hope that this introduction to it will inspire you to learn more and to put this newfound knowledge into projects of your own to create new applications.
| 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. |