gtk.RecentFilter — A filter for selecting a subset of recently used files (new in PyGTK 2.10)
class gtk.RecentFilter(gtk.Object): |
A gtk.RecentFilter can be used to restrict the files being shown in a gtk.RecentChooser. Files can be filtered based on their name (with the gtk.RecentFilter.add_pattern() method), on their mime type (with the gtk.FileFilter.add_mime_type() method), on the application that has registered them (with the gtk.RecentFilter.add_application() method), or by a custom filter function (with the gtk.RecentFilter.add_custom() method).
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, see the gtk.RecentChooser.add_filter() method, but it is also possible to manually use a filter on a file with the gtk.RecentFilter.filter() method.
Recently used files are supported since GTK+ 2.10.
|
Returns : | a new gtk.RecentFilter |
This constructor is available in PyGTK 2.10 and above.
Creates a new gtk.RecentFilter with no rules added to it. Such a filter does not accept any recently used resources, so is not particularly useful until you add rules with the gtk.RecentFilter.add_pattern(), gtk.RecentFilter.add_mime_type(), gtk.RecentFilter.add_application(), gtk.RecentFilter.add_age() methods. To create a filter that accepts any recently used resource, use:
filter = gtk.RecentFilter() filter.add_pattern("*") |
|
name : | the human readable name |
This method is available in PyGTK 2.10 and above.
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.
|
Returns : | the name of the filter, or None. |
This method is available in PyGTK 2.10 and above.
Returns the human-readable name for the filter. See the gtk.RecentFilter.set_name() method.
|
mime_type : | a MIME type |
This method is available in PyGTK 2.10 and above.
Adds a rule that filters resources based on their registered MIME type.
|
pattern : | a file pattern |
This method is available in PyGTK 2.10 and above.
Adds a rule that filters resources based on a pattern matching their display name.
|
This method is available in PyGTK 2.10 and above.
Adds a rule that filters image files based on the formats supported by gtk.gdk.Pixbuf.
|
application : | an application name |
This method is available in PyGTK 2.10 and above.
Adds a rule that filters resources based on the name of the application that has registered them.
|
group : | a group name |
This method is available in PyGTK 2.10 and above.
Adds a rule that filters resources based on the name of the group to which they belong
|
days : | number of days |
This method is available in PyGTK 2.10 and above.
Adds a rule that filters resources based on their age - that is, the number of days elapsed since they were last modified.
|
needed : | a combination of the GTK Recent Filter Flags indicating the information that the custom filter function needs. |
func : | callback function; if the function returns TRUE, then the file will be displayed. |
data : | data to pass to func |
This method is available in PyGTK 2.10 and above.
Adds a rule to a filter that filters resources based on a custom callback function. needed is a combination of the GTK Recent Filter Flags which provides information about what sorts of information that the filter function needs; this allows PyGTK to avoid retrieving expensive information when it isn't needed by the filter.
The signature of the filter function is:
def func(filterinfo, user_data): |
where filterinfo is a dict containing the info requested by needed as key-value pairs and user_data is data. The possible filterinfo keys are: "uri", "display_name", "mime_type", "applications", "age" and "groups".
|
Returns : | a combination of the GTK Recent Filter Flags indicating what fields are used for filtering when calling the gtk.RecentFilter.filter() method |
This method is available in PyGTK 2.10 and above.
Returns a combination of the GTK Recent Filter Flags indicating what fields are used for filtering.
This method will not typically be used by applications; it is intended principally for use in the implementation of gtk.RecentChooser.
|
filter_info : | a filter info dict containing information about a recently used resource |
Returns : | TRUE if the file should be displayed |
This method is available in PyGTK 2.10 and above.
Returns TRUE if a file should be displayed. filter_info is a dict that should include the key-value pairs as specified by the return flags from the gtk.RecentFilter.get_needed() method. The possible filter_info keys are: "uri", "display_name", "mime_type", "applications", "age" and "groups".
This method will not typically be used by applications; it is intended principally for use in the implementation of gtk.RecentChooser.