Package: gtk

Class gtk-file-filter

Superclasses

g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

None

Details

A gtk-file-filter class can be used to restrict the files being shown in a gtk-file-chooser widget. Files can be filtered based on their name with the function gtk-file-filter-add-pattern, on their mime type with the function gtk-file-filter-add-mime-type, or by a custom filter function with the function 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 the gtk-file-filter class 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 widget, see the function gtk-file-chooser-add-filter, but it is also possible to manually use a filter on a file with the function gtk-file-filter-filter.

GtkFileFilter as GtkBuildable

The gtk-file-filter implementation of the gtk-buildable 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 the functions gtk-file-filter-add-mime-type or gtk-file-filter-add-pattern.

Example: A UI definition fragment specifying gtk-file-filter rules
<object class="GtkFileFilter">
  <mime-types>
    <mime-type>text/plain</mime-type>
    <mime-type>image/&ast;</mime-type>
  </mime-types>
  <patterns>
    <pattern>*.txt</pattern>
    <pattern>*.png</pattern>
  </patterns>
</object>    
 

Inherited Slot Access Functions

See also

*2021-1-29