RecentFilterProtocol
public protocol RecentFilterProtocol : InitiallyUnownedProtocol, BuildableProtocol
A GtkRecentFilter
can be used to restrict the files being shown
in a GtkRecentChooser
. Files can be filtered based on their name
(with gtk_recent_filter_add_pattern()
), on their mime type (with
gtk_file_filter_add_mime_type()
), on the application that has
registered them (with gtk_recent_filter_add_application()
), or by
a custom filter function (with gtk_recent_filter_add_custom()
).
Filtering by mime type 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 GtkRecentFilter
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 GtkRecentChooser
,
see gtk_recent_chooser_add_filter()
, but it is also possible to
manually use a filter on a file with gtk_recent_filter_filter()
.
Recently used files are supported since GTK+ 2.10.
GtkRecentFilter as GtkBuildable
The GtkRecentFilter 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>, <pattern> or <application> has the same effect as
calling gtk_recent_filter_add_mime_type()
,
gtk_recent_filter_add_pattern()
or gtk_recent_filter_add_application()
.
An example of a UI definition fragment specifying GtkRecentFilter rules:
<object class="GtkRecentFilter">
<mime-types>
<mime-type>text/plain</mime-type>
<mime-type>image/png</mime-type>
</mime-types>
<patterns>
<pattern>*.txt</pattern>
<pattern>*.png</pattern>
</patterns>
<applications>
<application>gimp</application>
<application>gedit</application>
<application>glade</application>
</applications>
</object>
The RecentFilterProtocol
protocol exposes the methods and properties of an underlying GtkRecentFilter
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see RecentFilter
.
Alternatively, use RecentFilterRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkRecentFilter
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
recent_filter_ptr
Default implementationTyped pointer to the underlying
GtkRecentFilter
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkRecentFilter
instance.Declaration
Swift
var recent_filter_ptr: UnsafeMutablePointer<GtkRecentFilter>! { get }
-
Required Initialiser for types conforming to
RecentFilterProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
addAge(days:
Extension method) Adds a rule that allows resources based on their age - that is, the number of days elapsed since they were last modified.
Declaration
Swift
@inlinable func addAge(days: Int)
-
add(application:
Extension method) Adds a rule that allows resources based on the name of the application that has registered them.
Declaration
Swift
@inlinable func add(application: UnsafePointer<gchar>!)
-
addCustom(needed:
Extension methodfunc: data: dataDestroy: ) Adds a rule to a filter that allows resources 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.Declaration
Swift
@inlinable func addCustom(needed: RecentFilterFlags, func: GtkRecentFilterFunc?, data: gpointer! = nil, dataDestroy: GDestroyNotify?)
-
add(group:
Extension method) Adds a rule that allows resources based on the name of the group to which they belong
Declaration
Swift
@inlinable func add(group: UnsafePointer<gchar>!)
-
add(mimeType:
Extension method) Adds a rule that allows resources based on their registered MIME type.
Declaration
Swift
@inlinable func add(mimeType: UnsafePointer<gchar>!)
-
add(pattern:
Extension method) Adds a rule that allows resources based on a pattern matching their display name.
Declaration
Swift
@inlinable func add(pattern: UnsafePointer<gchar>!)
-
addPixbufFormats()
Extension methodAdds a rule allowing image files in the formats supported by GdkPixbuf.
Declaration
Swift
@inlinable func addPixbufFormats()
-
filter(filterInfo:
Extension method) Tests whether a file should be displayed according to
filter
. TheGtkRecentFilterInfo
filter_info
should include the fields returned fromgtk_recent_filter_get_needed()
, and must set theGtkRecentFilterInfo.contains
field offilter_info
to indicate which fields have been set.This function will not typically be used by applications; it is intended principally for use in the implementation of
GtkRecentChooser
.Declaration
Swift
@inlinable func filter<RecentFilterInfoT>(filterInfo: RecentFilterInfoT) -> Bool where RecentFilterInfoT : RecentFilterInfoProtocol
-
getName()
Extension methodGets the human-readable name for the filter. See
gtk_recent_filter_set_name()
.Declaration
Swift
@inlinable func getName() -> String!
-
getNeeded()
Extension methodGets the fields that need to be filled in for the
GtkRecentFilterInfo
passed togtk_recent_filter_filter()
This function will not typically be used by applications; it is intended principally for use in the implementation of
GtkRecentChooser
.Declaration
Swift
@inlinable func getNeeded() -> RecentFilterFlags
-
set(name:
Extension method) Sets the human-readable name of the filter; this is the string that will be displayed in the recently used resources selector user interface if there is a selectable list of filters.
Declaration
Swift
@inlinable func set(name: UnsafePointer<gchar>!)
-
name
Extension methodGets the human-readable name for the filter. See
gtk_recent_filter_set_name()
.Declaration
Swift
@inlinable var name: String! { get nonmutating set }
-
needed
Extension methodGets the fields that need to be filled in for the
GtkRecentFilterInfo
passed togtk_recent_filter_filter()
This function will not typically be used by applications; it is intended principally for use in the implementation of
GtkRecentChooser
.Declaration
Swift
@inlinable var needed: RecentFilterFlags { get }