Package ch.bailu.gtk.gtk
Class FileFilter
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.Filter
ch.bailu.gtk.gtk.FileFilter
- All Implemented Interfaces:
PointerInterface
`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:
```xml
<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>
```
`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:
```xml
<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>
```
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gtk.Filter
Filter.OnChanged
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gtk.Filter
SIGNAL_ON_CHANGED
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionCreates a new `GtkFileFilter` with no rules added to it.FileFilter
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMimeType
(Str mime_type) Adds a rule allowing a given mime type to @filter.void
addMimeType
(String mime_type) Adds a rule allowing a given mime type to @filter.void
addPattern
(Str pattern) Adds a rule allowing a shell style glob to a filter.void
addPattern
(String pattern) Adds a rule allowing a shell style glob to a filter.void
Adds a rule allowing image files in the formats supported
by GdkPixbuf.void
Adds a suffix match rule to a filter.void
Adds a suffix match rule to a filter.Implements interfaceBuildable
.Gets the attributes that need to be filled in for the `GFileInfo`
passed to this filter.static ClassHandler
static int
getName()
Gets the human-readable name for the filter.static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
static FileFilter
newFromGvariantFileFilter
(Variant variant) Deserialize a file filter from a `GVariant`.void
Sets a human-readable name of the filter.void
Sets a human-readable name of the filter.Serialize a file filter to an `a{sv}` variant.Methods inherited from class ch.bailu.gtk.gtk.Filter
changed, getStrictness, match, onChanged
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
FileFilter
-
FileFilter
public FileFilter()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
[method@Gtk.FileFilter.add_mime_type],
[method@Gtk.FileFilter.add_pattern],
[method@Gtk.FileFilter.add_suffix] or
[method@Gtk.FileFilter.add_pixbuf_formats].
To create a filter that accepts any file, use:
```c
GtkFileFilter *filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (filter, "*");
```
-
-
Method Details
-
getClassHandler
-
newFromGvariantFileFilter
Deserialize a file filter from a `GVariant`.
The variant must be in the format produced by
[method@Gtk.FileFilter.to_gvariant].- Parameters:
variant
- an `a{sv}` `GVariant`- Returns:
- a new `GtkFileFilter` object
-
addMimeType
Adds a rule allowing a given mime type to @filter.- Parameters:
mime_type
- name of a MIME type
-
addMimeType
Adds a rule allowing a given mime type to @filter.- Parameters:
mime_type
- name of a MIME type
-
addPattern
Adds a rule allowing a shell style glob to a filter.
Note that it depends on the platform whether pattern
matching ignores case or not. On Windows, it does, on
other platforms, it doesn't.- Parameters:
pattern
- a shell style glob
-
addPattern
Adds a rule allowing a shell style glob to a filter.
Note that it depends on the platform whether pattern
matching ignores case or not. On Windows, it does, on
other platforms, it doesn't.- Parameters:
pattern
- a shell style glob
-
addPixbufFormats
public void addPixbufFormats()Adds a rule allowing image files in the formats supported
by GdkPixbuf.
This is equivalent to calling [method@Gtk.FileFilter.add_mime_type]
for all the supported mime types. -
addSuffix
Adds a suffix match rule to a filter.
This is similar to adding a match for the pattern
"*.@suffix".
In contrast to pattern matches, suffix matches
are *always* case-insensitive.- Parameters:
suffix
- filename suffix to match
-
addSuffix
Adds a suffix match rule to a filter.
This is similar to adding a match for the pattern
"*.@suffix".
In contrast to pattern matches, suffix matches
are *always* case-insensitive.- Parameters:
suffix
- filename suffix to match
-
getAttributes
Gets the attributes that need to be filled in for the `GFileInfo`
passed to this filter.
This function will not typically be used by applications;
it is intended principally for use in the implementation
of `GtkFileChooser`.- Returns:
- the attributes
-
getName
Gets the human-readable name for the filter.
See [method@Gtk.FileFilter.set_name].- Returns:
- The human-readable name of the filter
-
setName
Sets a human-readable name of the filter.
This is the string that will be displayed in the file chooser
if there is a selectable list of filters.- Parameters:
name
- the human-readable-name for the filter, or %NULL to remove any existing name.
-
setName
Sets a human-readable name of the filter.
This is the string that will be displayed in the file chooser
if there is a selectable list of filters.- Parameters:
name
- the human-readable-name for the filter, or %NULL to remove any existing name.
-
toGvariant
Serialize a file filter to an `a{sv}` variant.- Returns:
- a new, floating, `GVariant`
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Returns:
Buildable
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-