2008-01-21

PHP-GTK experience

Recently, I've been extensively involved in desktop application development using PHP-GTK.

PHP-GTK logo

At first, I just needed a cross-platform, Markdown/Texy-capable desktop blogging tool that would publish to (and open/batch backup from) Blogger, preferably Scintilla-based. I looked around quite a bit and didn't like what I found, so I decided to do myself a favor and just sit down and make it already. Then I weighed some choices on how to actually do it:

First Choice - HOW DO I DO IT?

Quickly, hack together a bunch of batch files
Blah. Obvious. Ugly. Not cross platform.
Make some pretty witty shell script(s) instead
Blah. Uninspired. Not cross platform.
Do it properly
Hmm ... OK, let's try that. Sigh, more choices.

Second Choice - AGAIN, HOW DO I DO IT?

C/C++
Nah.
C#, Mono
Nyeee ... I'm not very familiar with neither the language itself, nor Mono.
Java
Nyeee ... an option. Or is it, really? An option?
Python GTK/QT
Hmmm ... definitely an option.
PHP GTK/QT
Well, let's take a look at that first.

Once settled upon that, the choice between QT or GTK bindings wasn't really much of a choice, actually. QT bindings for PHP are still quite young in development, plus the documentation is still virtually non-existent. Furthermore, as attached as I used to be to QT appearance, I recently switched to GNOME (at least until KDE 4.1) and learned to actually like it, so a GTK interface would be a natural choice for me right now.

Enough. Let's get on with it already

Now, once again, I had but a rhetorical choice between PHP-GKT versions 1 and 2. In its second version it provides a good OO API, some new components and quite stable foundation - although still in beta - so I obviously decided for V2. The new components (at least GtkHtml and MozEmbed, as I wanted to have HTML preview) turned out to be either non-existant, not (yet) fully cross platform, or quite buggy, so I left them out for now. No HTML preview. Pah.

What I did got, free of any charge, is the excellent GtkScintilla component - however, it turned out to be poorly documented and still somewhat rough around the edges. Oh, well. I used some of this, some of that, some looking at the GtkScintilla source coupled with some blind luck, and it turned out OK - which I hope to explain more thoroughly in a future post.

Anyway, the ease of use really amazed me - without Glade or any other GUI-editing IDE, it took just about a day or two to get a fully functional editor/blogging tool. The OO API allowed for easy custom control creation which greatly improved the speed of development. So much so, that I decided to use it for a pending project for a client.