File powerbox for Gtk applications

Implemented in gtk-powerbox-hook/gtk-powerbox.c

The powerbox/Gtk integration reimplements Gtk's GtkFileChooserDialog interface so that it opens a file powerbox for choosing files or directories. This means that existing, unmodified Gtk applications can use the powerbox.

GtkFileChooserDialog is replaced using an LD_PRELOADed shared object (powerbox-for-gtk.so), which replaces the gtk_file_chooser_dialog_*() functions. This shared object will work across different versions of Gtk. (Perhaps in the future, it could be compiled into Gtk.)

The powerbox/Gtk integration does not change the older GtkFileSelection interface, which is deprecated and exposes too many internal details to change.

How it works

The replacement GtkFileChooserDialog class inherits from GtkDialog, and hence from GtkWindow etc. However, it must prevent GtkWindow from ever opening a window on the screen; this is done by the powerbox manager instead. GtkFileChooserDialog achieves this by overriding the GtkWidget "map" method with code that does not pass the call on to GtkWindow. Instead, the "map" method invokes the powerbox API.

Limitations

The following GtkFileChooser API functions are currently missing:

Earlier version of the GtkFileChooserDialog replacement

My first attempt at a replacement GtkFileChooserDialog class did not inherit from the GtkDialog class, on the grounds that it did not need to open a GtkDialog window itself. It inherited from GtkObject and nothing else.

This caused some problems, because applications expect GtkFileChooserDialog to inherit from GtkDialog (and so, indirectly, from GtkWindow, GtkWidget, etc.) as documented. This did not cause applications to crash: the Gtk API functions just print a warning and return if passed objects that don't belong to the expected class.

The old version is still included, as src/gtk-powerbox-noninherit.c.

GtkFilePowerboxHook (last edited 2008-07-12 22:27:23 by MarkSeaborn)