| Top |
| gboolean | (*CtkRecentFilterFunc) () |
| CtkRecentFilter * | ctk_recent_filter_new () |
| const gchar * | ctk_recent_filter_get_name () |
| void | ctk_recent_filter_set_name () |
| void | ctk_recent_filter_add_mime_type () |
| void | ctk_recent_filter_add_pattern () |
| void | ctk_recent_filter_add_pixbuf_formats () |
| void | ctk_recent_filter_add_application () |
| void | ctk_recent_filter_add_group () |
| void | ctk_recent_filter_add_age () |
| void | ctk_recent_filter_add_custom () |
| CtkRecentFilterFlags | ctk_recent_filter_get_needed () |
| gboolean | ctk_recent_filter_filter () |
A CtkRecentFilter can be used to restrict the files being shown
in a CtkRecentChooser. Files can be filtered based on their name
(with ctk_recent_filter_add_pattern()), on their mime type (with
ctk_file_filter_add_mime_type()), on the application that has
registered them (with ctk_recent_filter_add_application()), or by
a custom filter function (with ctk_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 CtkRecentFilter 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 CtkRecentChooser,
see ctk_recent_chooser_add_filter(), but it is also possible to
manually use a filter on a file with ctk_recent_filter_filter().
Recently used files are supported since CTK+ 2.10.
The CtkRecentFilter implementation of the CtkBuildable 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 ctk_recent_filter_add_mime_type(),
ctk_recent_filter_add_pattern() or ctk_recent_filter_add_application().
An example of a UI definition fragment specifying CtkRecentFilter rules:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<object class="CtkRecentFilter"> <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> |
gboolean (*CtkRecentFilterFunc) (const CtkRecentFilterInfo *filter_info,gpointer user_data);
The type of function that is used with custom filters,
see ctk_recent_filter_add_custom().
filter_info |
a CtkRecentFilterInfo that is filled according
to the |
|
user_data |
user data passed to |
CtkRecentFilter *
ctk_recent_filter_new (void);
Creates a new CtkRecentFilter with no rules added to it.
Such filter does not accept any recently used resources, so is not
particularly useful until you add rules with
ctk_recent_filter_add_pattern(), ctk_recent_filter_add_mime_type(),
ctk_recent_filter_add_application(), ctk_recent_filter_add_age().
To create a filter that accepts any recently used resource, use:
1 2 |
CtkRecentFilter *filter = ctk_recent_filter_new (); ctk_recent_filter_add_pattern (filter, "*"); |
Since: 2.10
const gchar *
ctk_recent_filter_get_name (CtkRecentFilter *filter);
Gets the human-readable name for the filter.
See ctk_recent_filter_set_name().
the name of the filter, or NULL. The returned string
is owned by the filter object and should not be freed.
[nullable]
Since: 2.10
void ctk_recent_filter_set_name (CtkRecentFilter *filter,const gchar *name);
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.
Since: 2.10
void ctk_recent_filter_add_mime_type (CtkRecentFilter *filter,const gchar *mime_type);
Adds a rule that allows resources based on their registered MIME type.
Since: 2.10
void ctk_recent_filter_add_pattern (CtkRecentFilter *filter,const gchar *pattern);
Adds a rule that allows resources based on a pattern matching their display name.
Since: 2.10
void
ctk_recent_filter_add_pixbuf_formats (CtkRecentFilter *filter);
Adds a rule allowing image files in the formats supported by GdkPixbuf.
Since: 2.10
void ctk_recent_filter_add_application (CtkRecentFilter *filter,const gchar *application);
Adds a rule that allows resources based on the name of the application that has registered them.
Since: 2.10
void ctk_recent_filter_add_group (CtkRecentFilter *filter,const gchar *group);
Adds a rule that allows resources based on the name of the group to which they belong
Since: 2.10
void ctk_recent_filter_add_age (CtkRecentFilter *filter,gint days);
Adds a rule that allows resources based on their age - that is, the number of days elapsed since they were last modified.
Since: 2.10
void ctk_recent_filter_add_custom (CtkRecentFilter *filter,CtkRecentFilterFlags needed,CtkRecentFilterFunc func,gpointer data,GDestroyNotify data_destroy);
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 CTK+ to avoid retrieving expensive information when
it isn’t needed by the filter.
filter |
||
needed |
bitfield of flags indicating the information that the custom filter function needs. |
|
func |
callback function; if the function returns |
|
data |
data to pass to |
|
data_destroy |
function to call to free |
Since: 2.10
CtkRecentFilterFlags
ctk_recent_filter_get_needed (CtkRecentFilter *filter);
Gets the fields that need to be filled in for the CtkRecentFilterInfo
passed to ctk_recent_filter_filter()
This function will not typically be used by applications; it is intended principally for use in the implementation of CtkRecentChooser.
Since: 2.10
gboolean ctk_recent_filter_filter (CtkRecentFilter *filter,const CtkRecentFilterInfo *filter_info);
Tests whether a file should be displayed according to filter
.
The CtkRecentFilterInfo filter_info
should include
the fields returned from ctk_recent_filter_get_needed(), and
must set the CtkRecentFilterInfo.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 CtkRecentChooser.
filter |
||
filter_info |
a CtkRecentFilterInfo containing information about a recently used resource |
Since: 2.10
struct CtkRecentFilterInfo {
CtkRecentFilterFlags contains;
const gchar *uri;
const gchar *display_name;
const gchar *mime_type;
const gchar **applications;
const gchar **groups;
gint age;
};
A CtkRecentFilterInfo struct is used
to pass information about the tested file to ctk_recent_filter_filter().
CtkRecentFilterFlags |
CtkRecentFilterFlags to indicate which fields are set. |
|
The URI of the file being tested. |
[nullable] | |
The string that will be used to display the file in the recent chooser. |
[nullable] | |
MIME type of the file. |
[nullable] | |
The list of applications that have registered the file. |
[nullable][array zero-terminated=1] | |
The groups to which the file belongs to. |
[nullable][array zero-terminated=1] | |
The number of days elapsed since the file has been registered. |
These flags indicate what parts of a CtkRecentFilterInfo struct are filled or need to be filled.