Gtk.FileFilter
const Gtk = imports.gi.Gtk; let file_filter = new Gtk.FileFilter();
A GtkFileFilter can be used to restrict the files being shown in a Gtk.FileChooser. Files can be filtered based on their name (with Gtk.add_pattern), on their mime type (with Gtk.add_mime_type), or by a custom filter function (with Gtk.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.FileFilter 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.FileChooser, see Gtk.FileChooser.prototype.add_filter, but it is also possible to manually use a filter on a file with Gtk.filter.
<refsect2 id="GtkFileFilter-BUILDER-UI"> <title>GtkFileFilter as GtkBuildable</title> <para> The GtkFileFilter implementation of the GtkBuildable interface supports adding rules using the <mime-types>, <patterns> and <applications> elements and listing the rules within. Specifying a <mime-type> or <pattern> is the same as calling Gtk.add_mime_type or Gtk.add_pattern
<example> <title>A UI definition fragment specifying GtkFileFilter rules</title> <programlisting><![CDATA[ <object class="GtkFileFilter"> <mime-types> <mime-type>text/plain</mime-type> <mime-type>image/*</mime-type> </mime-types> <patterns> <pattern>*.txt</pattern> <pattern>*.png</pattern> </patterns> </object> ]]></programlisting> </example> </para> </refsect2>
Hierarchy
-
GObject.Object
-
GObject.InitiallyUnowned
- Gtk.FileFilter
-