Snippets code from my daily experience

June 29, 2008

Open a tab using FUEL on Firefox 3

Filed under: extension, firefox, fuel, mozilla, nsIIOService, xpcom, xul — dafi @ 5:41 pm

I want to migrate to Firefox 3 and stop compatibility with FF2.x so I’m starting to use intensively FUEL.

Today I’ve replaced the old “open new tab” code shown below

newTab : function (url) {
const newTab = getBrowser().addTab(url);
getBrowser().selectedTab = newTab;
}

With the FUEL version

newTab : function (url) {
var uri = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newURI(url, null, null);
Application.activeWindow.open(uri);
}

Onestly I found so complicated the FUEL approach.

Why I need to create an URI?

Why open doesn’t work with a simple string?

BTW FUEL is great

March 15, 2008

Komodo and readonly behavior

Filed under: extension, komodo, morekomodo, mozilla, openkomodo, scintilla — dafi @ 12:30 pm

Komodo editor handles read-only in a incomplete manner, at least for me.

The truly question is “what read-only means?” A file can be read-only but also an editor buffer can be read-only.

Komodo handles read-only files is a smart way, it opens file and shows a little lock on editor tab but user can edit the text buffer, it isn’t marked as read-only.

If user tries to save a warning message pops up allowing to choose if saving must be forced or cancelled.

Cool sure but I want to mark editor buffer as temporary read-only irrespective to file flag, this feature is missing on Komodo but scintilla has a readonly property.

I’ve added to MoreKomodo the ability to mark editor buffers as “edit locked”.

I think “edit locked” sounds good then “buffer read-only”.

The code is straightforward, simply sent the scintilla readonly property as shown below

     onToogleLockEdit : function() {
        var view = ko.views.manager.currentView;
        view.scintilla.scimoz.readOnly = !view.scintilla.scimoz.readOnly;
    }

March 11, 2008

XBL, CSS selectors priority and Firefox 3

Filed under: css, firefox, gecko, mozilla, xbl, xul — dafi @ 8:58 pm

I wrote a little XBL component to allow menuitems to have images centered, I added it to Firefox 2 browser context menu and worked fine immediately, after a while I installed component on Firefox 3 beta 4 and surprisingly the menuitem didn’t show the image :(

I’ve asked help on Mozilla IRC and after about an hour the mistery was revealed.

The innocent CSS declaration shown below works fine on Firefox 2

.menuitem-image-center {
-moz-binding: url(‘chrome://morekomodo/content/bindings/menu.xml#menuitemImageCenterBinding’);
}

but requires a little modification on Firefox 3 beta 5pre (at this time the latest available)

.menuitem-image-center {
-moz-binding: url(‘chrome://morekomodo/content/bindings/menu.xml#menuitemImageCenterBinding’)
!important;
}

You must notice the selector without !important attribute works on Firefox 3 when applied on menus different from browser context menu.

I suspect the browser context menu should have some special treatment on new Firefox…

Context menu

February 14, 2008

Extend Firefox 2 Contest and other surprises

Filed under: firefox, mozilla, openkomodo, table2clipboard — dafi @ 9:06 pm

January and February are very important months for my programming activites.

In January ActiveState guys gave me a KomodoIDE license for my contribution to their OpenKomodo wiki, a great unexpected surprise, the first one.

A couple of days ago Mozilla published the Extend Firefox 2 Contest and I discovered my name on “Runners up” list, a great
unexpected surprise, the second one.
I can figure out ViewSourceWith is the winner, no! The winner is Table2Clipboard my outsider extension, a great unexpected surprise, the third one.

I’m happy that other people appreciates my work.

My feed reader alerts me, LifeHacker has new contents, I take a look and found they speak about Table2Clipboard, a great unexpected surprise, the fourth one.

ActivateState gave me a KomodoIDE license, EF2 prices contain a KomodoIDE license, now I have two KomodoIDE license, another surprise the fifth :D

Mumble mumble… may I sell the unused license?

December 20, 2007

Firefox 3 and broken extensions

When I started Richscrollbar (RSB for friends) development I could not figure out a so difficult programming life cycle.

After all its task is simple, add extra buttons to browser scrollbars to speedup movements inside web page.

Gecko is affect by a bug that reduces RSB productivity dramatically but I’ve created it anyway.

Now I discover RSB totally doesn’t work with Firefox 3 beta 2, Mozilla guys changed API and I suspect introduced some regression.

Obviously it is impossibile to explain the problem to Mozilla, they are so busy to fight against the world.

After some frustrating debug I found the problems and fixed them.

Problem nr 1.

The nsIStyleSheetService.USER_AGENT has changed behaviour without documenting it (at least at this date)

I used USER_SHEET in Firefox 2 but under FF3 the same code simply doesn’t work.

I’ve replaced it with the other flag AGENT_SHEET and magically RSB started to work.

Where can I read the new behaviour? Damned Mozilla :P

Problem nr 2.

An horizontal useless scrollbar is always visible only on tab window open at browser startup, if user opens new tab and/or windows this dumb doesn’t appear, sigh!

I found a reasonable workaround hiding the scrollbar inside the notificationbox component.

I hope to publish the fixed RSB on this weekend.

November 2, 2007

Firefox 3, Dr. McCoy and Mr. Spock

Filed under: firefox, mozilla, xul — dafi @ 12:31 pm

Firefox 3 will introduce a new mechanism to ensure update urls are safe.

Every update url used into extension’s manifest must use httpS certified sites.

Due to the fact not all developers can buy certificate or use httpS site a second mechanism allows to sign extension and server update file.

I host my extensions on Sourceforge but Sourceforge doens’t support https so I decided to sign extensions.

Mozilla guys had created McCoy an useful UI from which you can generate public keys and sign files.

McCoy UI doesn’t fit my automated xpi creation process, I prefer a command line approach ;-)

Well, Star Trek’s Dr. McCoy has a good friend, the vulcanian Mr. Spock :-)

From the genius of bard, the Sameplace.cc’s author, borns Spock the McCoy command line missing piece.

Now you can create public keys from cool McCoy UI and complete process from command line with Spock.

Read more at hyperstruct

November 1, 2007

Welcome OpenKomodo

Filed under: gecko, komodo, mozilla, xul — dafi @ 12:15 pm

Finally Komodo is open!

More informations at http://www.openkomodo.com/

Komodo isn’t a promise it is reality.

Open source === Open minds

Why I love it?

I use shanec words

#It allows you to work the way you want to

Sure, you don’t need to fit to your editor but your editor fits to you.

#It’s built for developers by developers

I’ve used ActivePerl for years a step ahead over perl language, a tool designed by programmers with my same needs

Now OpenKomodo is the new frontier, the missing piece: THE EDITOR.

D2D is the right definition: Developer2Developer

# It’s easily extensible using XML, JavaScript, and if you like, Python, and C++

Ok OpenKomodo isn’t perfect for my needs but I can reuse my skills to enhance my programming experience

Use well know technologies to plug new behaviours, I love XUL and you?

The big problems with OpenKomodo are startup-speed and memory usage but these problems are related to Jecko runtime not to ActiveState’s guys implementation.

Do you think I’m a ActiveState employee? No! I’m a programmer that finally founds his programming home.

July 7, 2007

Short-circuits, innocent code and nsIDOMEvent targets

Filed under: firefox, flock, mozilla, xpcom, xul — dafi @ 6:08 pm

An user on AMI tells me that my bonsai RichFeedButton doesn’t work when installed together with another extension.

I install the offended extension and discover that RichFeedButton breaks this little jewel!

The solution was simple but the bug hunting was hard :-(

The problem was into an innocent function associated with a listener that simply checks the nsIDOMEvent’s target id and attrName as shown below
if (event.target.id == “xxx” && event.attrName == “yyy”) {
...
}


For some motivations the “event.target” expression breaks the other extension.

I suspect event.target at some event stage isn’t valid and generates internally some error corrupting (???) the full event queue or simply I’m a bad programmer :-(

The solution??

Simply swaps first equality test with second one

if (event.attrName == “yyy” && event.target.id == “xxx”) {
...
}


The javascript short-circuit evaluation ensures me event.target.id is parsed only if first condition is true. :-)

Every day I learn something about XUL and its implementation… ;-)

How many applications based on XUL exist?

Filed under: firefox, flock, mozilla, xul — dafi @ 11:43 am

Thanks to

Jane Ocean to give me many names to add to this list

marcoos to help me to discover new cool XUL applications

The Mozilla XUL application framework is used to create mainly two types of standalone applications: browsers and email client.

But XUL has all potential to be used to create any complex and cross platform application.

Well, I want to list all applications based on XUL (or XULRunner)

Browsers

absolutely the most significant XUL target

  • Firefox - no words… the browser changed internet ;-)
  • Mozilla Suite - All in one, browser+email+HTML composer
  • SeaMonkey - The Mozilla Suite successor, I think is better than Firefox but I love bell and whistle
  • Flock - A step ahead but actually only a Firefox with some extensions already installed (IMHO)
  • Netscape 8.x - No revolution but contains many interesting features, it’s based on Firefox 1.0
  • Netscape 9.x - it’s based on Firefox 2.0
  • Minimo - Browser for mobile devices
  • Camino - Browser for MacOsX It’s based on Mozilla’s Gecko but isn’t a XUL application
  • Swiftweasel and Iceweasel - Binary optimized Firefox. Iceweasel is under GNU license
  • WebRunner

Email clients

anybody has news about the Eudora porting to XUL??

HTML Editors

nothing so innovative but very usable

  • NVU - why this cool project has been abandoned????
  • kompoZer - the NVU successor

Schedulers, calendars and PIM

I’m waiting to completely remove Outlook

  • Sunbird - Cool, easy and enough stable
  • Lightning - Ok Ok I know! :-( This isn’t a standalone application but sunbird as extension

Developer tools

  • Komodo - Interesting IDE project, cool KomotoEdit full free (added 08 Sep 2007)

Instant Messaging

Other categories

Non stricly web-related XUL applications

  • Celtx - Celtx is a project collaboration tool for people who work in film, TV, theater and New Media
  • Songbird - THE web media player, I really love it but maybe it’s a bit slow and unstable
  • eMusic DLM - Download manager
  • Etna - XML editor
  • Joost - Internet TV viewer and more
  • Miro - Video player
  • Chatzilla - IRC client
  • Second Life client - The well known artificial world (added 28 Jul 2007)
  • Evergreen - An enterprise-class Integrated Library System (ILS) (added 23 Sep 2007)

At this time I found only these but my search continue ;-)

Do you know other XUL based applications?

June 30, 2007

Flock is a bug!!!!

Filed under: firefox, flock, mozilla, xpcom — dafi @ 9:34 am

The browser flock is developed starting from Mozilla Gecko code but has many specific features.

Together with many cool features the flock team has added many bugs not present in original Gecko code!

The last I found involves the DOMAttrModified event listener.
The code below works on Firefox 1.5, 2.x and 3.x (thunks) but doesn’t work on flock!!!

onLoad : function() {

var feedButton = document.getElementById("feed-button");

if (feedButton) {

// add the listener for feedButton

document.addEventListener("DOMAttrModified", RichFeed.onAttrModified, false);

// triggers a modification only to test the listener

feedButton.setAttribute("feeds", "true");

// onAttrModified should receive the modification but this doesn't occur on Flock

var v = feedButton.getAttribute("feeds");

}

}

onAttrModified : function(event) {

if (event.target.id == "feed-button") {

// never called with Flock browser

}

}

So my decision is to stop the flock support on my bonzai extensions, I have no time to search workarounds to all flock bugs.

Who cares for my decision? Nobody I know :-(

Next Page »

Blog at WordPress.com.