Class
GtkFileFilter
Description [src]
final class Gtk.FileFilter : GObject.InitiallyUnowned
implements Gtk.Buildable {
/* No available fields */
}
A GtkFileFilter can be used to restrict the files being shown in a
GtkFileChooser
. Files can be filtered based on their name (with
gtk_file_filter_add_pattern()), on their mime type (with
gtk_file_filter_add_mime_type()), or by a custom filter function
(with 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 GtkFileFilter
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 GtkFileChooser
,
see gtk_file_chooser_add_filter(), but it is also possible
to manually use a filter on a file with gtk_file_filter_filter().
GtkFileFilter as GtkBuildable
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>
has the same effect as as calling
gtk_file_filter_add_mime_type()
or gtk_file_filter_add_pattern().
An example of a UI definition fragment specifying GtkFileFilter rules:
<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>
Constructors
gtk_file_filter_new
Creates a new GtkFileFilter
with no rules added to it.
Such a filter doesn’t accept any files, so is not
particularly useful until you add rules with
gtk_file_filter_add_mime_type(), gtk_file_filter_add_pattern(),
or gtk_file_filter_add_custom(). To create a filter
that accepts any file, use:
GtkFileFilter *filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (filter, "*");
since: 2.4
gtk_file_filter_new_from_gvariant
Deserialize a file filter from an a{sv} variant in the format produced by gtk_file_filter_to_gvariant().
since: 3.22
Instance methods
gtk_file_filter_add_custom
Adds rule to a filter that allows files based on a custom callback
function. The bitfield needed
which is passed in provides information
about what sorts of information that the filter function needs;
this allows GTK+ to avoid retrieving expensive information when
it isn’t needed by the filter.
since: 2.4
gtk_file_filter_add_pixbuf_formats
Adds a rule allowing image files in the formats supported by GdkPixbuf.
since: 2.6
gtk_file_filter_filter
Tests whether a file should be displayed according to filter
.
The GtkFileFilterInfo
filter_info
should include
the fields returned from gtk_file_filter_get_needed().
since: 2.4
gtk_file_filter_get_name
Gets the human-readable name for the filter. See gtk_file_filter_set_name().
since: 2.4
gtk_file_filter_get_needed
Gets the fields that need to be filled in for the GtkFileFilterInfo
passed to gtk_file_filter_filter().
since: 2.4
gtk_file_filter_set_name
Sets the human-readable name of the filter; this is the string that will be displayed in the file selector user interface if there is a selectable list of filters.
since: 2.4
Methods inherited from GtkBuildable (10)
gtk_buildable_add_child
Adds a child to buildable
. type
is an optional string
describing how the child should be added.
since: 2.12
gtk_buildable_construct_child
Constructs a child of buildable
with the name name
.
since: 2.12
gtk_buildable_custom_finished
This is similar to gtk_buildable_parser_finished()
but is
called once for each custom tag handled by the buildable
.
since: 2.12
gtk_buildable_custom_tag_end
This is called at the end of each custom element handled by the buildable.
since: 2.12
gtk_buildable_custom_tag_start
This is called for each unknown element under <child>
.
since: 2.12
gtk_buildable_get_internal_child
Get the internal child called childname
of the buildable
object.
since: 2.12
gtk_buildable_get_name
Gets the name of the buildable
object.
since: 2.12
gtk_buildable_parser_finished
Called when the builder finishes the parsing of a
[GtkBuilder UI definition][BUILDER-UI].
Note that this will be called once for each time
gtk_builder_add_from_file()
or gtk_builder_add_from_string()
is called on a builder.
since: 2.12
gtk_buildable_set_buildable_property
Sets the property name name
to value
on the buildable
object.
since: 2.12
gtk_buildable_set_name
Sets the name of the buildable
object.
since: 2.12
Signals
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.