FileFilter

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 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> elements and listing the rules within. Specifying a <mime-type> or <pattern> has the same effect as as calling [method@Gtk.FileFilter.add_mime_type] or [method@Gtk.FileFilter.add_pattern].

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>
<pattern>*.png</pattern>
</patterns>
</object>

Constructors

this
this(GtkFileFilter* gtkFileFilter, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new GtkFileFilter with no rules added to it.

this
this(Variant variant)

Deserialize a file filter from a GVariant.

Members

Functions

addMimeType
void addMimeType(string mimeType)

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

addPattern
void addPattern(string pattern)

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

addPixbufFormats
void addPixbufFormats()

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

getAttributes
string[] getAttributes()

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

getFileFilterStruct
GtkFileFilter* getFileFilterStruct(bool transferOwnership)

Get the main Gtk struct

getName
string getName()

Gets the human-readable name for the filter.

getStruct
void* getStruct()

the main Gtk struct as a void*

setName
void setName(string name)

Sets a human-readable name of the filter.

toGvariant
Variant toGvariant()

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

Mixins

__anonymous
mixin BuildableT!(GtkFileFilter)
Undocumented in source.

Static functions

getType
GType getType()

Variables

gtkFileFilter
GtkFileFilter* gtkFileFilter;

the main Gtk struct

Inherited Members

From Filter

gtkFilter
GtkFilter* gtkFilter;

the main Gtk struct

getFilterStruct
GtkFilter* getFilterStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
changed
void changed(GtkFilterChange change)

Emits the #GtkFilter::changed signal to notify all users of the filter that the filter changed. Users of the filter should then check items again via gtk_filter_match().

getStrictness
GtkFilterMatch getStrictness()

Gets the known strictness of @filters. If the strictness is not known, %GTK_FILTER_MATCH_SOME is returned.

match
bool match(ObjectG item)

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

addOnChanged
gulong addOnChanged(void delegate(GtkFilterChange, Filter) dlg, ConnectFlags connectFlags)

Emitted whenever the filter changed.

From BuildableIF

getBuildableStruct
GtkBuildable* getBuildableStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
getBuildableId
string getBuildableId()

Gets the ID of the @buildable object.

Meta