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] == "@mozilla.org/network/protocol/about;1?what") {
if (m[1]) {
abouts.push(m[1]);
}
}
}
var menuAbouts = document.createElement("menu");
menuAbouts.setAttribute("label", "All abouts:");
var menuAboutsPopup = document.createElement("menupopup");
menuAbouts.appendChild(menuAboutsPopup);
var helpMenuSeparator = document.getElementById("menu_helpShowKeybindings").nextSibling;
var helpMenu = helpMenuSeparator.parentNode;
helpMenu.insertBefore(menuAbouts, helpMenuSeparator);
for (i in abouts) {
var menuitem = document.createElement("menuitem");
menuitem.id = abouts[i];
menuitem.openAbout = openAbout;
menuitem.setAttribute("label", abouts[i]);
menuitem.setAttribute("oncommand", "this.openAbout('" + abouts[i] + "')");
menuAboutsPopup.appendChild(menuitem);
}
function openAbout(about) {
var docSvc = Components.classes['@activestate.com/koDocumentService;1']
.getService(Components.interfaces.koIDocumentService);
var doc = docSvc.createDocumentFromURI("about:" + about);
ko.views.manager.topView.createViewFromDocument(doc, "browser");
}


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 |
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 |
Bah, hard coded list?
var abouts = []; for (var c in Components.classes) { var m = c.split(/=/); if (m[0] == “@mozilla.org/network/protocol/about;1?what”) abouts.push(m[1]); }
Comment by Mook — November 22, 2008 @ 11:00 am |
@Mook thanks for your hint, modified the code
Comment by dafi — November 22, 2008 @ 11:18 am |