Gtk.RecentFilter
const Gtk = imports.gi.Gtk; let recent_filter = new Gtk.RecentFilter();
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 Gtk.add_pattern), on their mime type (with Gtk.FileFilter.prototype.add_mime_type), on the application that has registered them (with Gtk.add_application), or by a custom filter function (with Gtk.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, see Gtk.RecentChooser.prototype.add_filter, but it is also possible to manually use a filter on a file with Gtk.filter.
Recently used files are supported since GTK+ 2.10.
<refsect2 id="GtkRecentFilter-BUILDER-UI"> <title>GtkRecentFilter as GtkBuildable</title> <para> 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> is the same as calling Gtk.add_mime_type, Gtk.add_pattern or Gtk.add_application.
<example> <title>A UI definition fragment specifying GtkRecentFilter rules</title> <programlisting><![CDATA[ <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> ]]></programlisting> </example> </para> </refsect2>
Hierarchy
-
GObject.Object
-
GObject.InitiallyUnowned
- Gtk.RecentFilter
-
Methods
- Gtk.RecentFilter.prototype.add_age
- Gtk.RecentFilter.prototype.add_application
- Gtk.RecentFilter.prototype.add_custom
- Gtk.RecentFilter.prototype.add_group
- Gtk.RecentFilter.prototype.add_mime_type
- Gtk.RecentFilter.prototype.add_pattern
- Gtk.RecentFilter.prototype.add_pixbuf_formats
- Gtk.RecentFilter.prototype.filter
- Gtk.RecentFilter.prototype.get_name
- Gtk.RecentFilter.prototype.get_needed
- Gtk.RecentFilter.prototype.set_name