Gtk.RecentManager
const Gtk = imports.gi.Gtk;
let recent_manager = new Gtk.RecentManager({
filename: value,
});
Gtk.RecentManager provides a facility for adding, removing and looking up recently used files. Each recently used file is identified by its URI, and has meta-data associated to it, like the names and command lines of the applications that have registered it, the number of time each application has registered the same file, the mime type of the file and whether the file should be displayed only by the applications that have registered it.
<note><para>The recently used files list is per user.</para></note>
The Gtk.RecentManager acts like a database of all the recently used files. You can create new Gtk.RecentManager objects, but it is more efficient to use the default manager created by GTK+.
Adding a new recently used file is as simple as:
|[ GtkRecentManager *manager;
manager = gtk_recent_manager_get_default (); gtk_recent_manager_add_item (manager, file_uri); ]|
The Gtk.RecentManager will try to gather all the needed information from the file itself through GIO.
Looking up the meta-data associated with a recently used file given its URI requires calling Gtk.lookup_item:
|[ GtkRecentManager *manager; GtkRecentInfo *info; GError *error = NULL;
manager = gtk_recent_manager_get_default (); info = gtk_recent_manager_lookup_item (manager, file_uri, &error); if (error) { g_warning ("Could not find the file: %s", error->message); g_error_free (error); } else { /* Use the info object */ gtk_recent_info_unref (info); } ]|
In order to retrieve the list of recently used files, you can use Gtk.get_items, which returns a list of Gtk.RecentInfo structures.
A Gtk.RecentManager is the model used to populate the contents of one, or more Gtk.RecentChooser implementations.
<note><para>The maximum age of the recently used files list is controllable through the Gtk.gtk-recent-files-max-age property.</para></note>
Recently used files are supported since GTK+ 2.10.
Since 2.10
Hierarchy
-
GObject.Object
- Gtk.RecentManager
Methods
- Gtk.RecentManager.prototype.add_full
- Gtk.RecentManager.prototype.add_item
- Gtk.RecentManager.prototype.get_items
- Gtk.RecentManager.prototype.has_item
- Gtk.RecentManager.prototype.lookup_item
- Gtk.RecentManager.prototype.move_item
- Gtk.RecentManager.prototype.purge_items
- Gtk.RecentManager.prototype.remove_item