Package: gtk

Class gtk:file-filter

Superclasses

gtk:filter, gtk:buildable, gobject:object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

mime-types
The mime-types property of type :string (Write / Construct only)
The MIME types that this filter matches. Note: This property is not accessible from the Lisp side. Since 4.10
name
The name property of type :string (Read / Write)
The human-readable name of the filter. This is the name that will be displayed in the file selector user interface if there is a selectable list of filters.
Default value: nil
patterns
The patterns property of type :string (Write / Construct only)
The patterns that this filter matches. Note: This property is not accessible from the Lisp side. Since 4.10
suffixes
The suffixes property of type :string (Write / Construct only)
The suffixes that this filter matches. Note: This property is not accessible from the Lisp side. Since 4.10

Details

The gtk:file-filter object 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 gtk:file-filter-add-pattern function or on their MIME type with the gtk:file-filter-add-mime-type function.

Filtering by MIME types handles aliasing and subclassing of MIME types. For example, 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 object allows wildcards for the subtype of a MIME type, so you can, for example, filter for image/*.

Normally, file filters are used by adding them to a gtk:file-chooser widget, see the gtk:file-chooser-add-filter function, but it is also possible to manually use a file filter on any gtk:filter-list-model object containing g:file-info objects.

GtkFileFilter as GtkBuildable

The gtk:file-filter implementation of the gtk:buildable interface supports adding rules using the <mime-types> and <patterns> elements and listing the rules within. Specifying a <mime-type> or <pattern> element has the same effect as calling the gtk:file-filter-add-mime-type or gtk:file-filter-add-pattern functions.

Examples

An example of a UI definition fragment specifying gtk:file-filter 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>    
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2025-3-13