1.162 <GtkRecentManager>

Class: <GtkRecentManager>

It derives from <GObject>.

Manages and looks 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.

The recently used files list is per user.

<GtkRecentManager> acts like a database of all the recently used files. You can create new <GtkRecentManager> 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 <GtkRecentManager> 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 recent-manager: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 recent-manager:get-items, which returns a list of <GtkRecentInfo>.

Note that the maximum age of the recently used files list is controllable through the settings:gtk-recent-files-max-age property.

Properties

Property: recent-manager:filename self

The full path to the file to be used to store and read the recently used resources list

Its value is a string, or #f.

It can only be set when the object is made, with #:filename.

Property: recent-manager:size self

The size of the recently used resources list.

Its value is a 32-bit integer.

It is read only.

Procedures

Method: recent-manager:add-full? self uri recent-data ⇒ %return
Method: add-full? self uri recent-data ⇒ %return

Adds a new resource, pointed by uri, into the recently used resources list, using the metadata specified inside the <GtkRecentData> passed in recent-data.

The passed URI will be used to identify this resource inside the list.

In order to register the new recently used resource, metadata about the resource must be passed as well as the URI; the metadata is stored in a <GtkRecentData>, which must contain the MIME type of the resource pointed by the URI; the name of the application that is registering the item, and a command line to be used when launching the item.

Optionally, a <GtkRecentData> might contain a UTF-8 string to be used when viewing the item instead of the last component of the URI; a short description of the item; whether the item should be considered private - that is, should be displayed only by the applications that have registered it.

self

Passed: a <GtkRecentManager>.

a <GtkRecentManager>

uri

Passed: a string.

a valid URI

recent-data

Passed: a <GtkRecentData>.

metadata of the resource

%return

Returned: a boolean.

#t if the new item was successfully added to the recently used resources list, #f otherwise

Method: recent-manager:add-item? self uri ⇒ %return
Method: add-item? self uri ⇒ %return

Adds a new resource, pointed by uri, into the recently used resources list.

This function automatically retrieves some of the needed metadata and setting other metadata to common default values; it then feeds the data to recent-manager:add-full?.

See recent-manager:add-full? if you want to explicitly define the metadata for the resource pointed by uri.

self

Passed: a <GtkRecentManager>.

a <GtkRecentManager>

uri

Passed: a string.

a valid URI

%return

Returned: a boolean.

#t if the new item was successfully added to the recently used resources list

Procedure: recent-manager:get-default ⇒ %return

Gets a unique instance of <GtkRecentManager> that you can share in your application without caring about memory management.

%return

Returned: a <GtkRecentManager>.

A unique <GtkRecentManager>. Do not ref or unref it.

Method: recent-manager:get-items self ⇒ %return
Method: get-items self ⇒ %return

Gets the list of recently used resources.

self

Passed: a <GtkRecentManager>.

a <GtkRecentManager>

%return

Returned: a list, each a <GtkRecentInfo>.

a list of newly allocated GtkRecentInfo objects. Use recent-info:unref on each item inside the list, and then free the list itself using g_list_free().

Method: recent-manager:has-item? self uri ⇒ %return
Method: has-item? self uri ⇒ %return

Checks whether there is a recently used resource registered with uri inside the recent manager.

self

Passed: a <GtkRecentManager>.

a <GtkRecentManager>

uri

Passed: a string.

a URI

%return

Returned: a boolean.

#t if the resource was found, #f otherwise

Method: recent-manager:lookup-item self uri ⇒ %return
Method: lookup-item self uri ⇒ %return

Searches for a URI inside the recently used resources list, and returns a <GtkRecentInfo> containing information about the resource like its MIME type, or its display name.

self

Passed: a <GtkRecentManager>.

a <GtkRecentManager>

uri

Passed: a string.

a URI

%return

Returned: a <GtkRecentInfo>, or #f.

a <GtkRecentInfo> containing information about the resource pointed by uri, or #f if the URI was not registered in the recently used resources list. Free with recent-info:unref.

Method: recent-manager:move-item? self uri [new-uri] ⇒ %return
Method: move-item? self uri [new-uri] ⇒ %return

Changes the location of a recently used resource from uri to new-uri.

Please note that this function will not affect the resource pointed by the URIs, but only the URI used in the recently used resources list.

self

Passed: a <GtkRecentManager>.

a <GtkRecentManager>

uri

Passed: a string.

the URI of a recently used resource

new-uri

Passed, or left out: a string, or #f.

the new URI of the recently used resource, or #f to remove the item pointed by uri in the list

%return

Returned: a boolean.

#t on success

Procedure: recent-manager:new ⇒ %return

Creates a new recent manager object.

Recent manager objects are used to handle the list of recently used resources. A <GtkRecentManager> object monitors the recently used resources list, and emits the recent-manager:changed signal each time something inside the list changes.

<GtkRecentManager> objects are expensive: be sure to create them only when needed. You should use recent-manager:get-default instead.

%return

Returned: a <GtkRecentManager>.

A newly created <GtkRecentManager> object

Method: recent-manager:purge-items self ⇒ %return
Method: purge-items self ⇒ %return

Purges every item from the recently used resources list.

self

Passed: a <GtkRecentManager>.

a <GtkRecentManager>

%return

Returned: a 32-bit integer.

the number of items that have been removed from the recently used resources list

Method: recent-manager:remove-item? self uri ⇒ %return
Method: remove-item? self uri ⇒ %return

Removes a resource pointed by uri from the recently used resources list handled by a recent manager.

self

Passed: a <GtkRecentManager>.

a <GtkRecentManager>

uri

Passed: a string.

the URI of the item you wish to remove

%return

Returned: a boolean.

#t if the item pointed by uri has been successfully removed by the recently used resources list, and #f otherwise

Signals

Signal: recent-manager:changed

Connect a handler with (connect object recent-manager:changed handler). It is called as (handler self).

Emitted when the current recently used resources manager changes its contents.

This can happen either by calling recent-manager:add-item? or by another application.

self

Passed: a <GtkRecentManager>.

Virtual methods

Virtual method: recent-manager:do-changed implementor self

To override it in a new class, give register-type #:vfuncs `((changed . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkRecentManager>, or a class that derives from it, or its GType number.

self

Passed: a <GtkRecentManager>.