FileFilter

open class FileFilter(pointer: <Error class: unknown class><<Error class: unknown class>>) : Filter, Buildable

GtkFileFilter filters files by name or mime type.

GtkFileFilter can be used to restrict the files being shown in a GtkFileChooser. Files can be filtered based on their name (with method@Gtk.FileFilter.add_pattern or method@Gtk.FileFilter.add_suffix) or on their mime type (with method@Gtk.FileFilter.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 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 GtkFileChooser (see method@Gtk.FileChooser.add_filter), but it is also possible to manually use a file filter on any class@Gtk.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 method@Gtk.FileFilter.add_mime_type or method@Gtk.FileFilter.add_pattern or method@Gtk.FileFilter.add_suffix.

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>

Skipped during bindings generation

  • method mime-types: Property has no getter nor setter

  • method patterns: Property has no getter nor setter

  • method suffixes: Property has no getter nor setter

Constructors

Link copied to clipboard
constructor()

Creates a new GtkFileFilter with no rules added to it.

constructor(variant: <Error class: unknown class>)

Deserialize a file filter from a GVariant.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val gtkBuildablePointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
val gtkFileFilterPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
val gtkFilterPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open var name: String?

The human-readable name of the filter.

Functions

Link copied to clipboard
open fun addMimeType(mimeType: String)

Adds a rule allowing a given mime type to @filter.

Link copied to clipboard
open fun addPattern(pattern: String)

Adds a rule allowing a shell style glob to a filter.

Link copied to clipboard
open fun addPixbufFormats()

Adds a rule allowing image files in the formats supported by GdkPixbuf.

Link copied to clipboard
open fun addSuffix(suffix: String)

Adds a suffix match rule to a filter.

Link copied to clipboard
open fun changed(change: FilterChange)

Notifies all users of the filter that it has changed.

Link copied to clipboard
fun connectChanged(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (change: FilterChange) -> Unit): <Error class: unknown class>

Emitted whenever the filter changed.

Link copied to clipboard

Gets the attributes that need to be filled in for the GFileInfo passed to this filter.

Link copied to clipboard
open fun getBuildableId(): String?

Gets the ID of the @buildable object.

Link copied to clipboard

Gets the known strictness of @filters.

Link copied to clipboard
open fun match(item: <Error class: unknown class>): Boolean

Checks if the given @item is matched by the filter or not.

Link copied to clipboard
open fun toGvariant(): <Error class: unknown class>

Serialize a file filter to an a{sv} variant.