Package org.gnome.gtk

Class FileFilter

java.lang.Object
All Implemented Interfaces:
Proxy, Buildable

@Generated("io.github.jwharm.JavaGI") public class FileFilter extends Filter implements Buildable
Filters files by name or mime type.

GtkFileFilter can be used to restrict the files being shown in a file chooser. Files can be filtered based on their name (with addPattern(java.lang.String) or addSuffix(java.lang.String)) or on their mime type (with addMimeType(java.lang.String)).

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, file filters are used by adding them to a file chooser (see FileDialog.setFilters(org.gnome.gio.ListModel)), but it is also possible to manually use a file filter on any FilterListModel containing GFileInfo objects.

GtkFileFilter as GtkBuildable
The GtkFileFilter implementation of the GtkBuildable interface supports adding rules using the <mime-types> and <patterns> and <suffixes> elements and listing the rules within. Specifying a <mime-type> or <pattern> or <suffix> has the same effect as as calling addMimeType(java.lang.String) or addPattern(java.lang.String) or addSuffix(java.lang.String).

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>
   </patterns>
   <suffixes>
     <suffix>png</suffix>
   </suffixes>
 </object>