FileFilter


Object Hierarchy:

Object hierarchy for FileFilter

Description:

[ CCode ( type_id = "gtk_file_filter_get_type ()" ) ]
public class FileFilter : Filter, Buildable

A GtkFileFilter can be used to restrict the files being shown in a FileChooser.

Files can be filtered based on their name (with add_pattern) or on their mime type (with add_mime_type).

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 FileFilter allows wildcards for the subtype of a mime type, so you can e.g. filter for image/\*.

Normally, file filters are used by adding them to a FileChooser (see add_filter), but it is also possible to manually use a file filter on any FilterListModel containing FileInfo objects.

GtkFileFilter as GtkBuildable

The GtkFileFilter implementation of the GtkBuildable interface supports adding rules using the <mime-types> and <patterns> elements and listing the rules within. Specifying a <mime-type> or <pattern> has the same effect as as calling add_mime_type or add_pattern.

An example of a UI definition fragment specifying GtkFileFilter rules:

<object class="GtkFileFilter">
<property name="name" translatable="yes">Text and Images</property>
<mime-types>
<mime-type>text/plain</mime-type>
<mime-type>image/ *</mime-type>
</mime-types>
<patterns>
<pattern>*.txt</pattern>
<pattern>*.png</pattern>
</patterns>
</object>


Namespace: Gtk
Package: gtk4

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Filter