Snippets code from my daily experience

October 29, 2009

PluginChecker v0.2

Filed under: Uncategorized — dafi @ 6:46 pm

I’ve received great and unexpected feedback about PluginChecker on my previous post so I’ve decided to refactor its code and better integrate with the standard Extensions Manager.

The original ugly dialog has been removed and informations about the new installed plugins are shown directly onto the Extensions Manager.

PluginChecker

PluginChecker v0.2 can be downloaded from SourceForge and from AMO.

December 28, 2008

Spread XUL (Sunday Thought)

Filed under: sunday_thought, xul — dafi @ 11:26 am

My friend Hamen made me a question about context menu on statusbarpanels, the answer was very trivial for me but I realized should be complicated to find XUL snippets using only web search engines (eg googling).

Are duplicated informations present on the web the hell?

Suppose you need to write some code to read a socket in C/C++ or Java or your preferred language and you use Google or Yahoo to find a snippet, your search produces millions of  interesting results so the information is duplicated and this duplication can confuse you but it has a great advantage, you can copy and paste like a monkey :P discovering the code fits your needs.

Please consider duplication different from clone, duplication from my point of view means “the same topic explained many times in different manner”, clone means “exactly the same code reported in many different places”.

I don’t consider duplicated informations the hell because you can compare found results, you can discover new techniques or simply you can study deeply some aspect of the original problem.

Today XUL/XPCOM searches rarely produces hundreds (certain not millions) of results, the developer is like a pioneer.

I like to be a pioneer ;) but a novice developer can feel discouraged.

XUL developer isn’t alone, he/she has many friends

Ok, actually web search results about XUL are not comparable to other programming languages but developer can use al least two types of resources: human and software

  • Human

The irc channels are great, I always found people ready to help me, also forums and mailing lists are very useful.
Honestly I consider some forum less useful, rarely I’ve received reply to my posts but I’m sure my ugly english didn’t helped me.

  • Software

lxr is the first resource developer must learn to use, searching XUL code directly inside code

MDC and XUL Planet don’t require presentation ;)

Many novice developers don’t know DOMInspector, this is also due to the fact last Firefox releases removed it from standard installation

Help the community to help you

I admit, IRC is my preferred way to ask help but to speed up the process I try to prepare the code to discuss about so developer encounter another friend, the pastebin service.

I’ve written a Komodo macro that quickly submits a code selection to pastebin detecting language and other stuff.

You can find more info here, I’m sure other text editors allow similar solutions  (if they don’t, drop them and use Komodo)

Unzip the world

Dear novice XUL developer, you must simply unzip the world!

What you are trying to do probably is already yet been done, so unzip extensions and take a look at their javascript/xul code.

The 80% of extensions don’t contain platform specific binary code so you can find all inside the XPI.

If you can’t access to Internet try to obtain a tarball with Firefox (or any other Mozilla application) source code and use your editor ‘Find in Files’ feature.

Take a look also inside the chrome directory of your installed Firefox ;)

I will try to spread XUL

Using this blog I want to create duplicated informations :D (garbage??)

I will start a new section dedicated to XUL snippets for beginners users (like me at all), this snippets will be ready to run (when possibile).

I hope to spread XUL know-how starting from the basics.

December 24, 2008

Dear Santa Claus…

Filed under: Uncategorized — dafi @ 2:22 pm

… I would like

  • to get a Mac Book Pro
  • to be invited to participate to a Mozilla event
  • to be hired for an amazing job possibly where I can use my XUL know-how
  • to mate a wonderful blond girl (like this) :P
  • to watch the last Heroes and Lost series

October 8, 2008

nsIProcess, Windows and Unicode

ViewSourceWith (VSW for friends) existence was impossible without nsIProcess, VSW must run programs and pass them at least one file name.

When arguments passed to nsIProcess are ASCII strings all works like a charm but you enter the hell if strings contain Unicode characters like those contained in Cyrillic or Japanese alphabets.

nsIProcess, especially under Microsoft Windows, doesn’t work very well with UTF-8 strings (see bugs 229379, 408923, 411511).

On VSW forum an user asked to me to fix the problem but it isn’t strictly related to VSW because the problem affects the XPCOM implementation.

After many attempts I surrendered and I decided to write my Win32 (Win64??) XPCOM component.

My IWinProcess has the same nsIProcess’s method signatures (Init, Run) but accepts wstrings and calls the unicode CreateProcessW Win32 API instead of its sibling CreateProcessA.

The Javascript caller (eg VSW) must pass UTF-8 strings but this is the only constraint.
Now finally I can open local files containing Unicode characters without tweaking the Windows ‘Regional Options’.

Linux seems to work fine (at least on my Gutsy box) simply converting Unicode strings with nsIScriptableUnicodeConverter.ConvertFromUnicode, no other special workarounds.

I don’t know if MacOSX works like Linux, I’m unable to test under Apple machines.

I don’t like code containing platform checks (if Windows … else if Linux … ) but to simplify VSW development the ‘if’ statement sounds reasonable.

The IWinProcess source and DLL are present on dafizilla SVN repository.

The next VSW release (0.4) will contain the IWinProcess component

June 7, 2008

Overload same xul element twice

Filed under: chrome-manifest, overloading, xul — dafi @ 10:26 am

My extension MoreKomodo overloads many elements

  • command set
  • toolbar buttons
  • menu items
  • find results tab

Due to my laziness I’ve added all these overloaded elements in main morekomodoOverlay.xul file.

It contains not-strictly-related code all together, for example the find results tab code is separated from other UI elements.

I’ve found very useful to overload more than once the same element inside chrome.manifest to isolate xul code and also javascript code.

It’s very easy

overlay  chrome://komodo/content/komodo.xul chrome://morekomodo/content/modokomodoOverlay.xul
overlay  chrome://komodo/content/komodo.xul chrome://morekomodo/content/findResultsOverlay.xul

That’s all folks :P

March 23, 2008

Central extensions repositories

Filed under: extension, firefox, flock, komodo, songbird — dafi @ 10:21 pm

I spend my time to created extensions based on Gecko expecially for

  • Firefox, Thunderbird and SeaMonkey (all under Mozilla umbrella)
  • Songbird
  • Flock
  • KomodoEdit/KomodoIDE

Every product has its own developer website where you can upload your extensions (Komodo hasn’t a dedicated upload zone).

From a visitor/user feedback’s point of view Flock is the best.

Flock addons site is cool I love it, extension informations are very complete, you can see also the locales supported by extensions.

Songbird has a cool addons site simple and very quick, extension informations are complete.

Mozilla with AMO is the most important but is also the worst.

The outsider KomodoEdit addons site not yet really exists, registered users can’t upload their extensions.
I hope Komodo guys take a look at Flock addons site if they decide to create a similar place.

From a developer feedback’s point of view Songbird is the best.
After signup you can immediately upload and publish extension on Songbird site, the upload process is easy and publication policy very developer friendly.

AMO upload mechanism is simple but publication mechanism is awful. I don’t like its approval mechanism based on sandbox, my RichFeedButton waits approval for an year.

Flock allows to upload extensions immediately after signup but publication waits approval, after a couple of days I’m yet waiting ;)

The most mature and important addons site AMO, has IMHO the worst user/developer experience.

I don’t like so much Flock but it has a great develope/user website

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?

January 8, 2008

Richscrollbar top ten download sorted by locale

Filed under: richscrollbar — dafi @ 7:58 pm

I’ve created statistics about Richscrollbar, I’m very proud to find Japan at 2nd place.

Place Download count Locale
1 138 en-US
2 78 ja
3 19 it
4 18 fr
5 17 en-GB
6 14 de
7 14 ru
8 12 es-ES
9 7 zh-TW
10 4 zh-CN

Italy, my country is 3th :-(

January 7, 2008

OpenKomodo namespace API

Filed under: komodo, openkomodo — dafi @ 7:30 pm

When you want to write extensions or macros for OpenKomodo you discover many new XPCOM interfaces to use, they are so much that you can be confused.

Komodo programmers fortunately have simplified XPCOM usage wrapping a bunch of them in easy-to-call functions.

These function are incapsulated in namespace as modern Javascript dictates, every namespace can contains several functions.

Table below shows OpenKomodo namespaces, good luck ;-)

Namespace Description
ko.browse Functions to launch browsers
ko.commands Functions to handling commands
ko.dragDrop Functions to handle drag&drop of files onto Komodo
ko.eggs Easter egg
ko.filepicker Functions to wrap nsIFilePicker
ko.help Functions to simplify launch help pages
ko.inputBuffer Functions to capture user input while a slow XUL window is loading
ko.interpolate Functions to easily use the KoIInterpolationService from JavaScript
ko.isearch Functions to handle incremental searches
ko.launch Functions to launch dialogs like Extension Manager, Watcher, Diff
ko.lint Functions to access lint from Javascript
ko.logging Functions to access the logging system from Javascript
ko.main Functions to hook Komodo startup/shutdown
ko.markers Scintilla image markers used in Komodo
ko.mru Functions to handle MRU
ko.open Functions to open buffer editors
ko.printing Functions to handle printer
ko.run.output Functions to handle run output window
ko.statusBar Functions to handle status bar
ko.stringutils Functions to work with strings
ko.uilayout Functions to handle various UI features
ko.uriparse Functions to convert/parse strings representing URLs
ko.window Functions to get window informations
ko.windowManager Functions to handle windows

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.

Blog at WordPress.com.