A filter for selecting a file subset
A GtkFileFilter can be used to restrict the files being shown in a
<gtk-file-chooser>
. Files can be filtered based on their name (with
gtk-file-filter-add-pattern
), on their mime type (with
gtk-file-filter-add-mime-type
), or by a custom filter function (with
gtk-file-filter-add-custom
).
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 <gtk-file-filter>
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 <gtk-file-chooser>
, see
gtk-file-chooser-add-filter
, but it is also possible to manually use a
filter on a file with gtk-file-filter-filter
.
<gtk-file-filter>
)Creates a new
<gtk-file-filter>
with no rules added to it. Such a filter doesn't accept any files, so is not particularly useful until you add rules withgtk-file-filter-add-mime-type
,gtk-file-filter-add-pattern
, orgtk-file-filter-add-custom
. To create a filter that accepts any file, use:GtkFileFilter *filter = gtk_file_filter_new (); gtk_file_filter_add_pattern (filter, "*");
- ret
- a new
<gtk-file-filter>
Since 2.4
<gtk-file-filter>
) (name mchars
)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.
- filter
- a
<gtk-file-filter>
- name
- the human-readable-name for the filter, or ‘
#f
’ to remove any existing name.Since 2.4
<gtk-file-filter>
) ⇒ (ret mchars
)Gets the human-readable name for the filter. See
gtk-file-filter-set-name
.
- filter
- a
<gtk-file-filter>
- ret
- The human-readable name of the filter, or ‘
#f
’. This value is owned by GTK+ and must not be modified or freed.Since 2.4
<gtk-file-filter>
) (mime_type mchars
)Adds a rule allowing a given mime type to filter.
- filter
- A
<gtk-file-filter>
- mime-type
- name of a MIME type
Since 2.4
<gtk-file-filter>
) (pattern mchars
)Adds a rule allowing a shell style glob to a filter.
- filter
- a
<gtk-file-filter>
- pattern
- a shell style glob
Since 2.4
<gtk-file-filter>
)Adds a rule allowing image files in the formats supported by GdkPixbuf.
- filter
- a
<gtk-file-filter>
Since 2.6
<gtk-file-filter>
) ⇒ (ret <gtk-file-filter-flags>
)Gets the fields that need to be filled in for the structure passed to
gtk-file-filter-filter
This function will not typically be used by applications; it is intended principally for use in the implementation of
<gtk-file-chooser>
.
- filter
- a
<gtk-file-filter>
- ret
- bitfield of flags indicating needed fields when calling
gtk-file-filter-filter
Since 2.4