GtkFileChooser filter API
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list gnome org
- Subject: GtkFileChooser filter API
- Date: 17 Jul 2003 16:50:20 -0400
One of the open issues for the GtkFileChooser API is that of filters.
There was some discussion of this earlier, though nothing was exactly
resolved.
Here's an API proposal:
==========
/* GtkFileFilter is an opaque GtkObject for for Float/Sink
*/
typedef struct _GtkFileFilter GtkFileFilter;
GtkFileFilter *gtk_file_filter_new (void);
/* Name to display in selectable list */
void gtk_file_filter_set_name (GtkFileFilter *filter,
const gchar *name);
/* Shell-style glob */
void gtk_file_filter_add_pattern (GtkFileFilter *filter,
const gchar *pattern);
/* Mime-type */
void gtk_file_filter_add_mime_type (GtkFileFilter *filter
const gchar *mime_type);
/* Sets the current filter; can be called with an empty list
* of user selectable filters
*/
void gtk_file_filter_set_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
/* List of user selectable filters
*/
void gtk_file_chooser_add_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
void gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
GList *gtk_file_filter_list_filters (GtkFileChooser *choooser);
=========
One possible variation is to to make GtkFileFilter an abstract
base class:
====
GtkFileFilter *gtk_file_filter_pattern_new (const gchar *pattern);
GtkFileFilter *gtk_file_filter_mime_new (const gchar *mime_type);
GtkFileFilter *gtk_file_filter_multi_new (void);
void gtk_file_filter_multi_add_filter (GtkFileFilterMulti *filter_multi,
GtkFileFilter *filter);
====
This is a bit conceptually cleaner and you could even allow custom
derivation from GtkFileFilter if you did that. I'm not sure it's worth
the complexity however.
A different way to allow custom filters without the derivation
thing going on would be:
===
gboolean (*GtkFileFilterFunc) (const gchar *filename,
const gchar *uri,
const gchar *mime_type,
gpointer data);
void gtk_file_filter_add_custom (GtkFileFilter *filter,
GtkFileFilterFunc func,
gointer data,
GDestroyNotify notify);
===
Any sort of custom filter system will cause difficulties for
an out-of-process implementation of GtkFileChooser; that's not
something I'm particularly interested in, but there have been
requests to leave the possibility open for the future.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]