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 :D

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)

aboutview



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");
}

November 8, 2008

Four years of ViewSourceWith: Version 0.4 released

Filed under: nsIProcess,viewsourcewith — dafi @ 11:49 am

Today I’ve released VSW 0.4, this version mainly contains bug fixes but it is the first version using the IWinProcess the nsIProcess component replacement.
I hope people using non latin charset can appreciate this little improvement.

I’ve also added SeaMonkey 2.0a1 support, this required me some time but SM2 is very cool and can’t be ignored.

Since November 2004 when VSW 0.0.1 was published many other similar extensions have been created and those extensions today are very cool and maybe VSW has arrived to the end, I’m not sure its development is still useful for the developer community.

The only feature a never seen in other extensions is the ability to edit richbox text like Gmail content messages or WordPress HTML posts but probably I missed the extensions doing it ;)

November 7, 2008

Java plugin with Prism under Ubuntu 64 bit

Filed under: 64bit,java plugin,linux,prism,ubuntu — dafi @ 8:54 pm

This post in mainly for my own usage, my brain loose very quickly informations :P

I use Ubuntu Intrepid Ibex 64bit version with Firefox Linux x86_64 and occasionally I need to visit some website using Java applets, as well known to run Java plugin you need to use the Firefox 32bit version because the Java plugin exists only for this architecture.

I don’t want to trash my FF 64bit (also Swiftweasel) only for Java plugin so I’ve decided to configure Prism to use the websites needing java plugin.

  • Install the 32bit version of java
    sudo apt-get install ia32-sun-java6-bin
  • Create a symlink to plugin
    sudo
    ln -s /usr/lib/jvm/ia32-java-6-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so /home/dave/.mozilla/plugins/
  • Create a prism webapp, for example using the Sun test page

The destination path /home/dave/.mozilla/plugins/ must be modified according to your settings

This confirms Prism is rock ;)

EDIT (05 July 2009) After Sun released the plugin compatible with 64bit platforms you can change the symlink to

ln -s $JDK_INSTALLED_DIR/jre/lib/amd64/libnpjp2.so /home/dave/.mozilla/plugins/

as described at PluginDoc web page

November 4, 2008

Komodo 5 released

Filed under: komodo — dafi @ 7:37 pm

The day has come, Komodo Edit 5 and its big brother Komodo IDE 5 have been released.

You can read complete feature list here, I want to speak about some technical aspects.

  • Komodo is the best text editor using Mozilla technologies now based on Firefox 3 (i.e. gecko 1.9)
  • Now the old mono-window notification-based mechanism is no more supported (read here) because multi windows works greatly
  • Simplified many document operation (read here)
  • Many cool extensions already compatible with 5.0 (read here)
  • Many Firefox extensions works like a charm (I love DOM Inspector*)
  • New APIs for extension developers

I’ve some problems to run it under Linux (also Ubuntu 8.10) because crashes but ko5 is amazing.

I’ve updated the wiki adding “View Events” but I want to change radically approach, something like MDC where APIs are well documented.

Documenting API is a very complex work but I will try ASAP ;)

* Running DOM Inspector can require the following macro
window.openDialog(“chrome://inspector/content/”, “_blank”, “chrome,all,dialog=no”);

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.