Gtk.RecentFilter¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gtk.RecentFilter(**kwargs)¶
- Bases:
- Abstract:
No
A
Gtk.RecentFilter
can be used to restrict the files being shown in aGtk.RecentChooser
. Files can be filtered based on their name (withGtk.RecentFilter.add_pattern
()), on their mime type (withGtk.FileFilter.add_mime_type
()), on the application that has registered them (withGtk.RecentFilter.add_application
()), or by a custom filter function (withGtk.RecentFilter.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
Gtk.RecentFilter
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
Gtk.RecentChooser
, seeGtk.RecentChooser.add_filter
(), but it is also possible to manually use a filter on a file withGtk.RecentFilter.filter
().Recently used files are supported since GTK+ 2.10.
The
Gtk.RecentFilter
implementation of theGtk.Buildable
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 callingGtk.RecentFilter.add_mime_type
(),Gtk.RecentFilter.add_pattern
() orGtk.RecentFilter.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>
- classmethod new()[source]¶
- Returns:
a new
Gtk.RecentFilter
- Return type:
Creates a new
Gtk.RecentFilter
with no rules added to it. Such filter does not accept any recently used resources, so is not particularly useful until you add rules withGtk.RecentFilter.add_pattern
(),Gtk.RecentFilter.add_mime_type
(),Gtk.RecentFilter.add_application
(),Gtk.RecentFilter.add_age
(). To create a filter that accepts any recently used resource, use:GtkRecentFilter *filter = gtk_recent_filter_new (); gtk_recent_filter_add_pattern (filter, "*");
New in version 2.10.
- add_age(days)[source]¶
- Parameters:
days (
int
) – number of days
Adds a rule that allows resources based on their age - that is, the number of days elapsed since they were last modified.
New in version 2.10.
- add_application(application)[source]¶
- Parameters:
application (
str
) – an application name
Adds a rule that allows resources based on the name of the application that has registered them.
New in version 2.10.
- add_custom(needed, func, *data)[source]¶
- Parameters:
needed (
Gtk.RecentFilterFlags
) – bitfield of flags indicating the information that the custom filter function needs.func (
Gtk.RecentFilterFunc
) – callback function; if the function returnsTrue
, then the file will be displayed.
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.
New in version 2.10.
- add_group(group)[source]¶
- Parameters:
group (
str
) – a group name
Adds a rule that allows resources based on the name of the group to which they belong
New in version 2.10.
- add_mime_type(mime_type)[source]¶
- Parameters:
mime_type (
str
) – a MIME type
Adds a rule that allows resources based on their registered MIME type.
New in version 2.10.
- add_pattern(pattern)[source]¶
- Parameters:
pattern (
str
) – a file pattern
Adds a rule that allows resources based on a pattern matching their display name.
New in version 2.10.
- add_pixbuf_formats()[source]¶
Adds a rule allowing image files in the formats supported by
GdkPixbuf.Pixbuf
.New in version 2.10.
- filter(filter_info)[source]¶
- Parameters:
filter_info (
Gtk.RecentFilterInfo
) – aGtk.RecentFilterInfo
containing information about a recently used resource- Returns:
True
if the file should be displayed- Return type:
Tests whether a file should be displayed according to self. The
Gtk.RecentFilterInfo
filter_info should include the fields returned fromGtk.RecentFilter.get_needed
(), and must set the Gtk.RecentFilterInfo.contains field of filter_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
Gtk.RecentChooser
.New in version 2.10.
- get_name()[source]¶
- Returns:
the name of the filter, or
None
. The returned string is owned by the filter object and should not be freed.- Return type:
Gets the human-readable name for the filter. See
Gtk.RecentFilter.set_name
().New in version 2.10.
- get_needed()[source]¶
- Returns:
bitfield of flags indicating needed fields when calling
Gtk.RecentFilter.filter
()- Return type:
Gets the fields that need to be filled in for the
Gtk.RecentFilterInfo
passed toGtk.RecentFilter.filter
()This function will not typically be used by applications; it is intended principally for use in the implementation of
Gtk.RecentChooser
.New in version 2.10.