Snippets code from my daily experience

May 30, 2008

Annoying RadioStateChange usage

Filed under: radiogroup,RadioStateChange,xul — dafi @ 8:09 pm

radiogroup is the worst XUL widget I’ve ever used, its usage is made boring due to RadioStateChange listener but the real annoying behavior comes on when you want to change radio selection from code.

It is very innatural because changing radiogroup’s selectionIndex doesn’t trigger RadioStateChange and you need to create an event by hand and trigger it.

var myEvent = document.createEvent(“Events”);
myEvent.initEvent(“RadioStateChange”, true, true);

But this is not sufficient, the RadioStateChange handler is called twice, the first one to “unselect” and second one to “select”.

Doesn’t exist a simple manner to determine if handler is called to “unselect” or “select” so you can’t use the radiogroup’s selected propery.

The solution consists to test all radios selected property to find the checked element.

if (document.getElementById(“folders-radio”).selected) {

} else if (document.getElementById(“files-radio”).selected) {



May 9, 2008

How to detect XUL trees scroll event

My extension VisualDiffer contains two nsITreeViews that must synchronize scrolling, when user scrolls one the other tree moves the selection to the corresponding row.

Apparently XUL trees don’t have any event handler to intercept scrolling operations so I run the risk to became crazy.

After days spent to find a solution (using google) without result I’ve tried to use the DOMAttrModified event and amazingly it worked.

First I add a listener to the tree (VisualDiffer adds listeners to left and right trees)

function(event) { gFolderDiffer.onLeftScroll(event);}, false);

The onScroll simply checks if event.attrName is “curpos” and if it’s true the tree has been scrolled by user

onLeftScroll : function(event) { if (event.attrName == “curpos”) {

This solution works fine but maybe exists a better way…

May 5, 2008

GIMP doesn’t reuse running instance under Windows

Filed under: gimp,gimp-remote,gimp-win-remote,viewsourcewith — dafi @ 7:44 pm

A ViewSourceWith‘s user posted an interesting question on forum: how to reuse an already running GIMP instance.

I’ve never incurred on this problem on my Linux box so I was very surprised.

Booting under Windows I’ve found this different behavior, very strange because the GIMP documentation explains how to obtain the opposite effect using command line switches, i.e. running always new instances.

IMHO the reuse technique under Windows is bugged so I found a workaround using the not so famous gimp-win-remote executable program present on bin directory.

gimp-win-remote checks (correctly) if GIMP is already running and reuse it.

I’m curious to know if Mac OS/X complains to unix world, if you have a Mac and would satisfy my curiosity I will update the ViewSourceWith FAQ page 😉

May 3, 2008

Unsuccessful is…

Filed under: mental-hangover — dafi @ 9:41 am

Today my planet.mozilla feed contains a post from ActiveState‘s technical leader Shane Caraveo.

Shane’s post title is “Success is…” where incidentally speaks about my VisualDiffer, he tries to define success from different points of view.

I think his team success arrives from good (and very hard) work.

Now I try to define unsuccessful from my personal point of view.

Unsuccessful is

when you born in wrong place at right time

when you work with stupid people, in stupid companies

when you must leave a software company unable to help you to work better

when smart developers find your work interesting but you can’t work with them

have a blog with two visits per month

speak (or write) a bad english

VisualDiffer: a new Komodo extension

Filed under: extension,komodo,xul — dafi @ 9:17 am

When I migrated to Ubuntu I loose some important developer tools like UltraEdit and Beyond Compare two closed-source commercial applications representing the state-of-art like editor and file comparator.

I’ve created MoreKomodo (the original name was UltraKomodo 😛 ) to add to KomodoEdit the UltraEdit features I need.

Folders and files comparison tools under Gnome are poor so I’ve decided to create my own differ application based on KomodoEdit for at least three reasons

KomodoEdit is open source

KomodoEdit is XUL based so I can develop re-using my know-how

KomodoEdit is multiplatform (thanks to Mozilla Gecko Engine)

Finally I’ve finished the first stable version of VisualDiffer, it misses many features but I hope to add them.

Blog at