Snippets code from my daily experience

November 21, 2008

Komodo ViewAbout

Filed under: extension,komodo,mozilla,openkomodo,xul — dafi @ 7:42 pm

After reading ViewAbout post written by Gary Kwong I was curious to see what Komodo should have shown.

Komodo doesn’t require to write an extension to implement a similar feature, it is sufficient to write a macro 😉

So I’ve written the code that adds a popup menu inside Help menu and amazing it worked immediately 😀

The macro can be triggered at startup but the menu will be added only on first open window because Komodo doesn’t have a “on open new window” macro event but it can be easily simulated adding a listener.

The code shown below is the complete Komodo Javascript macro, nothing else is necessary. (EDIT Thanks to Mook to point me how to remove the hardcoded abouts list)


var abouts = [];
for (var c in Components.classes) {
    var m = c.split(/=/);
    if (m[0] == ";1?what") {
        if (m[1]) {

var menuAbouts = document.createElement("menu");
menuAbouts.setAttribute("label", "All abouts:");

var menuAboutsPopup = document.createElement("menupopup");

var helpMenuSeparator = document.getElementById("menu_helpShowKeybindings").nextSibling;
var helpMenu = helpMenuSeparator.parentNode;
helpMenu.insertBefore(menuAbouts, helpMenuSeparator);

for (i in abouts) {
    var menuitem = document.createElement("menuitem"); = abouts[i];
    menuitem.openAbout = openAbout;
    menuitem.setAttribute("label", abouts[i]);
    menuitem.setAttribute("oncommand", "this.openAbout('" + abouts[i] + "')");

function openAbout(about) {
    var docSvc = Components.classes[';1']
    var doc = docSvc.createDocumentFromURI("about:" + about);
    ko.views.manager.topView.createViewFromDocument(doc, "browser");


  1. Hi.. Is there a central space where people can share their macros ? I really love komodo for web development. I am looking for some template based solution for maintaining my website.

    Comment by Jigar Shah — November 22, 2008 @ 8:01 am

  2. Actually the ActiveState community web site collects all macros but not in a well defined from. It is also available the cookbook website

    Comment by dafi — November 22, 2008 @ 8:35 am

  3. Bah, hard coded list? 😉

    var abouts = []; for (var c in Components.classes) { var m = c.split(/=/); if (m[0] == “;1?what”) abouts.push(m[1]); }

    Comment by Mook — November 22, 2008 @ 11:00 am

  4. @Mook thanks for your hint, modified the code 😉

    Comment by dafi — November 22, 2008 @ 11:18 am

RSS feed for comments on this post.

Create a free website or blog at

%d bloggers like this: