Synopsis
#include <gtk/gtk.h>
GtkFileFilter;
GtkFileFilterInfo;
enum GtkFileFilterFlags;
gboolean (*GtkFileFilterFunc) (const GtkFileFilterInfo *filter_info,
gpointer data);
GtkFileFilter* gtk_file_filter_new (void);
void gtk_file_filter_set_name (GtkFileFilter *filter,
const gchar *name);
const gchar* gtk_file_filter_get_name (GtkFileFilter *filter);
void gtk_file_filter_add_mime_type (GtkFileFilter *filter,
const gchar *mime_type);
void gtk_file_filter_add_pattern (GtkFileFilter *filter,
const gchar *pattern);
void gtk_file_filter_add_pixbuf_formats (GtkFileFilter *filter);
void gtk_file_filter_add_custom (GtkFileFilter *filter,
GtkFileFilterFlags needed,
GtkFileFilterFunc func,
gpointer data,
GDestroyNotify notify);
GtkFileFilterFlags gtk_file_filter_get_needed (GtkFileFilter *filter);
gboolean gtk_file_filter_filter (GtkFileFilter *filter,
const GtkFileFilterInfo *filter_info);
Description
A GtkFileFilter can be used to restrict the files being shown
in a GtkFileChooser. Files can be filtered based on their name
(with Filtering by mime types handles aliasing and subclassing of mime types; e.g. a filter for text/plain also matches a file with mime type application/rtf, since application/rtf is a subclass of text/plain. Note that GtkFileFilter allows wildcards for the subtype of a mime type, so you can e.g. filter for image/*.
Normally, filters are used by adding them to a GtkFileChooser,
see DetailsGtkFileFiltertypedef struct _GtkFileFilter GtkFileFilter; The GtkFileFilter struct contains only private fields and should not be directly accessed. GtkFileFilterInfotypedef struct {
GtkFileFilterFlags contains;
const gchar *filename;
const gchar *uri;
const gchar *display_name;
const gchar *mime_type;
} GtkFileFilterInfo;
A GtkFileFilterInfo struct is used
to pass information about the tested file to
enum GtkFileFilterFlagstypedef enum {
GTK_FILE_FILTER_FILENAME = 1 << 0,
GTK_FILE_FILTER_URI = 1 << 1,
GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
GTK_FILE_FILTER_MIME_TYPE = 1 << 3
} GtkFileFilterFlags;
These flags indicate what parts of a GtkFileFilterInfo struct are filled or need to be filled. GtkFileFilterFunc ()gboolean (*GtkFileFilterFunc) (const GtkFileFilterInfo *filter_info, gpointer data);
The type of function that is used with custom filters,
see
gtk_file_filter_new ()GtkFileFilter* gtk_file_filter_new (void);
Creates a new GtkFileFilter with no rules added to it.
Such a filter doesn't accept any files, so is not
particularly useful until you add rules with
GtkFileFilter *filter = gtk_file_filter_new (); gtk_file_filter_add_pattern (filter, "*");
Since 2.4 gtk_file_filter_set_name ()void gtk_file_filter_set_name (GtkFileFilter *filter, const gchar *name); Sets the human-readable name of the filter; this is the string that will be displayed in the file selector user interface if there is a selectable list of filters.
Since 2.4 gtk_file_filter_get_name ()const gchar* gtk_file_filter_get_name (GtkFileFilter *filter);
Gets the human-readable name for the filter. See
Since 2.4 gtk_file_filter_add_mime_type ()void gtk_file_filter_add_mime_type (GtkFileFilter *filter, const gchar *mime_type);
Adds a rule allowing a given mime type to
Since 2.4 gtk_file_filter_add_pattern ()void gtk_file_filter_add_pattern (GtkFileFilter *filter, const gchar *pattern); Adds a rule allowing a shell style glob to a filter.
Since 2.4 gtk_file_filter_add_pixbuf_formats ()void gtk_file_filter_add_pixbuf_formats (GtkFileFilter *filter); Adds a rule allowing image files in the formats supported by GdkPixbuf.
Since 2.6 gtk_file_filter_add_custom ()void gtk_file_filter_add_custom (GtkFileFilter *filter, GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data, GDestroyNotify notify);
Adds rule to a filter that allows files based on a custom callback
function. The bitfield
Since 2.4 gtk_file_filter_get_needed ()GtkFileFilterFlags gtk_file_filter_get_needed (GtkFileFilter *filter);
Gets the fields that need to be filled in for the structure
passed to This function will not typically be used by applications; it is intended principally for use in the implementation of GtkFileChooser.
Since 2.4 gtk_file_filter_filter ()gboolean gtk_file_filter_filter (GtkFileFilter *filter, const GtkFileFilterInfo *filter_info);
Tests whether a file should be displayed according to This function will not typically be used by applications; it is intended principally for use in the implementation of GtkFileChooser.
Since 2.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||