XML
  Home arrow XML arrow Page 3 - Skinning Your Custom XUL Applications
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Skinning Your Custom XUL Applications
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2006-05-01

    Table of Contents:
  • Skinning Your Custom XUL Applications
  • Setting up a Stylesheet
  • Register or Not
  • The Moment of Truth

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Skinning Your Custom XUL Applications - Register or Not


    (Page 3 of 4 )

       

    The great thing about XUL (one of the great things), is that while you can register skins with the chrome and reference them in your XUL file, you can also just use a simple XML stylesheet directive and a file path. This means that you can loosely associate the CSS file while you tweak it and experiment with it, then register it when you feel it is ready for general consumption.  To use a basic stylesheet in this way, just add an xml-stylesheet directive:

     <?xml-stylesheet href="default.css" type="text/css"?>

    To register your stylesheet with the chrome, you're going to need a contents.rdf file and a pointer in the installed-chrome file, just like the locale and main content files.  But before you do that, you need to do a spot of organization and create a skin directory structure.

    Create a folder in your package directory called skin, then create a folder with the same name as your skin, and finally create a folder with the same name as your application.  Into this folder will go your CSS file(s), the contents.rdf file and any other skin resources such as images used by the skin:

     

    To create the rdf file, open a text editor and add the following code:

    <?xml version="1.0"?>

    <RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

             xmlns:chrome="http://www.mozilla.org/rdf/chrome#">

    These statements form the cornerstone of any nutritious RDF document and are mandatory requirements consisting of the XML declaration and the opening RDR container, which holds the required namespace attributes.  Next, we define the skin as a Mozilla resource:

    <RDF:Seq about="urn:mozilla:skin:root">

        <RDF:li resource="urn:mozilla:skin:silver/1.7"/>

    </RDF:Seq>

    Now, we can give Mozilla some information about the skin that can be used within Mozilla and the chrome registry. 

    <RDF:Description about="urn:mozilla:skin:silver/1.7"

        chrome:displayName="Silver"

        chrome:author="Dan Wellman"

        chrome:description="A basic silver skin with heavy text."

        chrome:name="silver">

        <chrome:packages>

            <RDF:Seq about="urn:mozilla:skin:silver/1.7:packages">

               <RDF:li
    resource="urn:mozilla:skin:silver/1.7:interface"/>

            </RDF:Seq>

        </chrome:packages>

    </RDF:Description>

    We also list the package that the skin is to be used with; in this case it's the XUL Edit application from previous articles, but it could be any other XUL based application, including any of the Mozilla suite of applications. If you wanted to design an alternative skin for Mozilla itself, you'd go through very similar steps to do it, except your CSS file would be called navigator.css and it would be probably be packaged into a JAR file.  You would also need to install it correctly.  However, as we aren't restyling Mozilla, we're creating a skin for a standalone application, we don't need to worry about this.  Finally, you just need to state the version of your skin and close off the RDF container:

    <RDF:Description about="urn:mozilla:skin:silver/1.7:interface"

        chrome:skinVersion="1.0"/>

    </RDF:RDF>

    Now all you need to do is register the skin with the chrome registry and link the new skin to your application.  To do this, you'll first need to add the following stylesheet directive to your mail application XUL file:

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

    You now need to add a pointer to the installed-chrome file, which is in Mozilla's chrome folder, to tell Mozilla where your skin located:

    skin,install,url,file:///C|/XUL/XULEditLite/skin/silver/
    interface/

    Now save this file, and from the same directory, delete the chrome.rdf file.  Open Mozilla now to recreate the chrome.rdf file and register the skin.  While Mozilla is open, take a moment to open the preferences panel and take a look in the Themes section.  Your skin should be shown alongside any other registered skin packages, and you'll see information from the contents.rdf file such as the Skin name, author and description:

     

    More XML Articles
    More By Dan Wellman


       · Hi,This article describes creating a basic, default skin for your own XUL...
     

    XML ARTICLES

    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway