Friday, September 01, 2006

Today I found a nice post on Penguin.SWF about what file widget Adobe's Flash Player 9 for Linux should use, and asking for advice about what would be the best choice. A gentleman/lady suggested defaulting it to Gtk+'s file dialog, as, according to him, even KDE users use Firefox for browsing the web(!). As I couldn't stand by his/her words I have been compelled to answer, but as I don't know if Penguin.SWF's moderators will allow it, I've chosen to publish it here too.
Before I paste my answer, I beg your pardon for my past, present and future mispellings and grammatical erros, beg your pardon for being concerned about that piece of closed-source code, complain about the absence of a free and fully compatible alternative, state that open-source desktops may have to handle some closed-source apps from time to time to gain people's minds while a fully open-source alternative is ready, and thank Adobe for their efforts in supporting the Linux (ok, RMS, GNU/Linux, whatever) platform.
Now to the post:

I'm a KDE user and I use Konqueror's khtml and I find it to be a very good engine, so good Apple chosen it to its browser.
KDE's not being tied to any company. It simply uses Trolltech's Qt (GPLed) as widget library. If kw123 tries to be coherent he/she shouldn't use J2SE or OpenOffice.org (as both are tied to Sun) or to ask Adobe (a proprietary software company) to use a "free" library in a closed-source program (I'm waiting kw123 to show me Flash Player's source code... waiting... waintng...). That said, kw123's arguments are moot (if he/she is so concerned about free widget APIs he'she shouldn't be tempted to use Flash Player because of "higher moral stakes").
Pleople should know there are _choices_. Some people prefer to use GNOME, some use KDE. Some programmers prefer C, some C++. Some programmers prefer Gkt+ (C-based) and some prefer Qt (C++-based).
If the purpose of the file dialog is just to get a file descriptor, implementing a wrapper to call a Gtk+ file dialog or a KDE's KFileDialog based on browser's agent string should not be too difficult (OpenOffice.org transparently choses to open files in my _Kubuntu_ machine using a KFileDialog standard dialog. If OpenOffice.org can, why whouldn't Flash Player do the same?).

Little trick:
1. Open a terminal emulator (konsole or rxvt);
2. copy and paste the following:
kdialog --getopenfilename ./

Nice! A perfectly functional KDE's KFileDialog window! Whitout dynamicly linking to Qt, KDE or whatever! Without library dependencies! Without the need to staticly link to Qt or KDE! Without license conflicts! Just plain old shell! :D

Even better trick:
kdialog --getopenurl ~/

Wow! It opens the same file dialog, but allows me not only to select a file in my local filesystem, but _any_ file in any supported protocol (http, ftp, sftp, fish, smb, you name it)!!! And tit returns a properly encoded url, like file:///home/taupter/Motocross%20Radical.png

And if you want to select _more_than_one_ file, just

kdialog --multiple --getopenfilename ~/
or
kdialog --multiple --getopenurl ~/

and you'll se the same nice KFileDialog window and you'll be able to select multiple files!

I don't know how to do the same with Gtk+, but to implement it with a nice KDE interface is just plain easy.

Steps:
1. Check browser's identification string for KHTML (a grep could do it);
2. If (1.==true) Check if kdialog exists ("which kdialog" does this);
3. if ((1.==true)&&(2.==true)) use kdialog!

Please, if browser's identification string has a "KHTML" in it, just use this little kdialog trick and _lots_ of KDE users around the world will be pleased and feel respected by Adobe!