Common File Format Chooser
Applications supporting multiple file formats needs a file-format chooser in their file saving dialog. Several GNOME apps implement very similiar file-format choosers - so it makes sense to me, to add this widget to GTK+ (see Bug 440431, Thread on gtk-devel). The code is commited to libegg: http://svn.gnome.org/viewcvs/libegg/trunk/libegg/fileformatchooser/
- ✔ API to modify the list of formats
guint egg_file_format_chooser_add_format (EggFileFormatChooser *self, guint parent, const gchar *name, const gchar *icon, ...) G_GNUC_NULL_TERMINATED; void egg_file_format_chooser_remove_format (EggFileFormatChooser *self, guint format);
- A format consists of name, icon, extensions and surrogate key.
void egg_file_format_chooser_set_format (EggFileFormatChooser *self, guint format); guint egg_file_format_chooser_get_format (EggFileFormatChooser *self, const gchar *filename);
- The widget emits a signal called "selection-changed".
- The application shall handle this with the help of this little API:
gchar* egg_file_format_chooser_append_suffix (EggFileFormatChooser *self, guint format, const gchar *filename);
✔ How do we deal with API explosion? See Havoc's mail. We can probably have a GtkFileChooserFileFormat object onto which we can add more API later if needed.
The format chooser is a separate widget. A separate GtkFileChooserFileFormat object also was my favorite, but it has been rejected by the community due the boilerplate overhead it might introduce.
- For attaching custom data the following API exists:
void egg_file_format_chooser_set_format_data (EggFileFormatChooser *self, guint format, gpointer data, GDestroyNotify destroy); gpointer egg_file_format_chooser_get_format_data (EggFileFormatChooser *self, guint format);
GIMP uses a special file chooser dialog:
The dialog embbeds a specialized tree view using plug-in provided callbacks to build its model:
I like the look, but the API is very GIMP specific.
Dia directly uses GtkFileChooserDialog and builds its file format chooser ad-hoc:
It looks very old fashioned and therefore would greatly benefit from some common widget.
Inkscape used the GtkFileChooserDialog wrapper of gtkmm and builds its file format chooser ad-hoc:
OpenOffice.org uses a pretty tree view similiar to the one used by GIMP. Unfortunatly I have/had no clue where to look for the source code of its implementation. That project is just too large for mortals like me.
Gnumeric uses a drop-down list.
Moves file format selection into the main window: