Snippets code from my daily experience

July 28, 2008

Komodo logging facilities

Filed under: extension,komodo,xul — dafi @ 7:04 pm

Any programmer needs an easy way to log messages to trace bugs or to simplify problem diagnostic.

Mozilla extensions developers have two way to log messages; the dump function and the nsIConsoleService interface, both are invaluable developer friends.

Who lands on Komodo extension development finds a very rich set of methods to make log, so rich the dump and nsIConsoleService lose their value.

The namespace ko.logging wraps the koILoggingService methods and more over.

The code shown below print a warning and an error message


The getLogger works like a singleton, it uses a map to store requested loggers, this minimize the memory allocated reusing already-instantiated logger objects.

I use the practice to pass a string in “” form. This naming technique simplify searching into log and splits komodo from thirdy parts (extensions) log messages.

There are two important caveats:

  • How to use ko.logging namespace
  • Where output goes

How to use ko.logging namespace

ko.logging is available to all elements overlaying komodo.xul (menus, tab panels, and  so on) but if you need it inside your xul dialog you need to use a ugly syntax like opener.ko.logging or opener.opener.ko.logging (when you call from a dialog open from a parent dialog).

Lucky a better solution consists to include javascript files and use the clean ko.logging syntax.

Add the line shown below to your xul dialog and all will work fine

<script type=”application/x-javascript” src=”chrome://komodo/content/library/logging.js” />

Where output goes

Output is visible when you start komodo with the verbose flag.

I use the script shown below in my Ubuntu box to always log messages, the script deletes the komodo.log file when its size is greater than 500000 bytes.

CURR_SIZE=` ls -l ~/komodo.log | awk ‘{print $5}’`
if [ $CURR_SIZE -gt 500000 ];
rm ~/komodo.log

/opt/devel/mozilla/Komodo-Edit-4/bin/komodo 2>>~/komodo.log -v

Under Windows Komodo opens an annoyng dos window where output is displayed and I was unable to write it to file 😦


July 27, 2008

Overlay popupset under Komodo

Filed under: komodo,xul — dafi @ 9:26 am

When you need to add elements to a popupset, for example a tooltip, you can find useful to overlay the extensionPopupSet element defined by Komodo.

It isn’t mandatory, you can add elements where you want (maybe) but I consider a good practice using element dedicated to extension authors.

The code shown below is taken from MoreKomodo 1.4

<popupset id=“extensionPopupSet”>
<tooltip id=“morekomodo-refresh-tooltip” orient=“vertical”>
<description value=“&morekomodo.refresh.pattern;” />
<label id=“morekomodo-refresh-tooltip-pattern” value=“” />

The importance of donations for indipendent software developers

Filed under: sunday_thought — dafi @ 9:06 am

Today is Sunday so I do some thought…

My bonsai Mozilla extensions are used by many users, I receive many ‘Feature Request’ on related forums and I try to satisfy users when their ideas are compatible with my free time.

Users can donate to me and 5% of donations go to SourceForge, where I host my bonsai extensions.

Since 2005 I’ve received only one donation (5 US dollars) so I think my donation requests have failed.

ViewSourceWith and Table2Clipboard receive many new feature requests but nobody donate to them.

I’ve a laptop ASUS L2420 with 512 Mb (RAM) and 20Gb (HD) and I want to replace it, believe me it is very difficult to run KomodoEdit and Firefox 3 together under Feisty.

I love MacBook (Pro) but it is impossibile to buy it for me at this time, my budget is 300-500 euros (500-800 US dollars).

I found a real PC (not Asus EEEPC) at 500 euro but if I have had some donation…

Suppose all my extensions are daily used by 500 satisfied users and all decide to donate 5$.

After subtracting SF fees and SF donation 5% I receive 3.8$, -3% of paypal fee I arrive to ~3.6$.

3.6 * 500 = 1800$ enough to buy a MacBook (no PRO) with 4Gb of RAM…

But I’ve only 5 dollars…

July 15, 2008

Mozilla Gecko Extensions Developers on Linkedin

Filed under: linkedin,xul — dafi @ 9:00 am

When, a couple of months ago, I created the Extension developer group at Linkedin I could not imagine people subscribes to it…

Now we are a little group but I hope to create a centralized place where smart people can share its professional knowledge about XUL.

Bear in mind this is linkedin group so isn’t a strictly technical related group.

Anybody using XUL in professional environments can join the group and describes what he/she expects from a professional XUL world.

July 12, 2008

KomodoEdit localization

Filed under: babelzilla,localization,openkomodo — dafi @ 8:01 am

I’ve asked to babelzilla community if they are interested to translating KomodoEdit and immediately they reply to me that this is possible.

So I’ve posted into Komodo forum to understand if ActiveState is interested, too.

Well, all is ready and I’m glad to have started this process.

I don’t know what this experiment will produce but I’m happy to see collaborations between so different communities.

I hope to see very soon the first KomodoEdit in non english language 😛

July 1, 2008

Determine if the current view is a macro in Komodo

Filed under: komodo — dafi @ 6:23 pm

Komodo allows to edit macros in editor windows, this feature simplifies the macro code writing.

Do you need to know if you are editing a macro? Well You must fight with koIPart interface.

After digging into Komodo IDLs I found a way to know if current view is a macro, take a look at code shown below.

var currView = ko.views.manager.currentView;
var fileURL = currView.document.file.URI;
var macroPart = ko.toolboxes.user.toolbox.getChildByURL(fileURL);
var isMacro = macroPart != null && macroPart.type == “macro”;

I’ve asked at channel and mixedpuppy confirmed me this is the best way.

Blog at