Snippets code from my daily experience

December 28, 2008

Spread XUL (Sunday Thought)

Filed under: sunday_thought,Uncategorized,xul — dafi @ 11:26 am

My friend Hamen made me a question about context menu on statusbarpanels, the answer was very trivial for me but I realized should be complicated to find XUL snippets using only web search engines (eg googling).

Are duplicated informations present on the web the hell?

Suppose you need to write some code to read a socket in C/C++ or Java or your preferred language and you use Google or Yahoo to find a snippet, your search produces millions of  interesting results so the information is duplicated and this duplication can confuse you but it has a great advantage, you can copy and paste like a monkey 😛 discovering the code fits your needs.

Please consider duplication different from clone, duplication from my point of view means “the same topic explained many times in different manner”, clone means “exactly the same code reported in many different places”.

I don’t consider duplicated informations the hell because you can compare found results, you can discover new techniques or simply you can study deeply some aspect of the original problem.

Today XUL/XPCOM searches rarely produces hundreds (certain not millions) of results, the developer is like a pioneer.

I like to be a pioneer 😉 but a novice developer can feel discouraged.

XUL developer isn’t alone, he/she has many friends

Ok, actually web search results about XUL are not comparable to other programming languages but developer can use al least two types of resources: human and software

  • Human

The irc channels are great, I always found people ready to help me, also forums and mailing lists are very useful.
Honestly I consider some forum less useful, rarely I’ve received reply to my posts but I’m sure my ugly english didn’t helped me.

  • Software

lxr is the first resource developer must learn to use, searching XUL code directly inside code

MDC and XUL Planet don’t require presentation 😉

Many novice developers don’t know DOMInspector, this is also due to the fact last Firefox releases removed it from standard installation

Help the community to help you

I admit, IRC is my preferred way to ask help but to speed up the process I try to prepare the code to discuss about so developer encounter another friend, the pastebin service.

I’ve written a Komodo macro that quickly submits a code selection to pastebin detecting language and other stuff.

You can find more info here, I’m sure other text editors allow similar solutions  (if they don’t, drop them and use Komodo)

Unzip the world

Dear novice XUL developer, you must simply unzip the world!

What you are trying to do probably is already yet been done, so unzip extensions and take a look at their javascript/xul code.

The 80% of extensions don’t contain platform specific binary code so you can find all inside the XPI.

If you can’t access to Internet try to obtain a tarball with Firefox (or any other Mozilla application) source code and use your editor ‘Find in Files’ feature.

Take a look also inside the chrome directory of your installed Firefox 😉

I will try to spread XUL

Using this blog I want to create duplicated informations 😀 (garbage??)

I will start a new section dedicated to XUL snippets for beginners users (like me at all), this snippets will be ready to run (when possibile).

I hope to spread XUL know-how starting from the basics.



  1. It has always seemed to me that there are add-ons and extensions on that could be a resource. Some of them are posted with their code, but it seems to be hard to navigate that code. I think one has to drill down a few pages and then download an opaque bunch of files. Perhaps sites at mozilla, such as AMO, can be made to better support code browsing.

    For example, as one is looking at the add-ons, I cannot even tell which share their code….

    Comment by Ray Kiddy — December 30, 2008 @ 1:44 am

  2. You are right, should be great to be able to navigate code directly on AMO.
    I host my extensions source code on SVN repository at SourceForge but also navigate SVN seems a bit complicated.

    I believe in snippets, simple examples very easy to study and use, MDC already contains many snippet in documentation but they cover only a few of documentation.

    Comment by dafi — December 30, 2008 @ 8:51 am

RSS feed for comments on this post.

Create a free website or blog at

%d bloggers like this: