Recently Used Documents
gtkmm provides an easy way to manage recently used documents. The classes involved in implementing this functionality are RecentManager, RecentChooserDialog, RecentChooserMenu, RecentChooserWidget, RecentAction, and RecentFilter.
Each item in the list of recently used files is identified by its URI, and can have associated metadata. The metadata can be used to specify how the file should be displayed, a description of the file, its mime type, which application registered it, whether it's private to the registering application, and several other things.

RecentManager
RecentManager acts as a database of recently used files. You use this class to register new files, remove files from the list, or look up recently used files. There is one list of recently used files per user.
You can create a new RecentManager, but you'll most likely just want to use the default one. You can get a reference to the default RecentManager with get_default().
RecentManager is the model of a model-view pattern, where the view is a class that implements the RecentChooser interface.

Adding Items to the List of Recent Files
To add a new file to the list of recent documents, in the simplest case, you only need to provide the URI. For example:

Glib::RefPtr<Gtk::RecentManager> recent_manager = Gtk::RecentManager::get_default();
recent_manager->add_item(uri);

If you want to register a file with metadata, you can pass a RecentManager::Data parameter to add_item(). The metadata that can be set on a particular file item is as follows:
app_exec: The command line to be used to launch this resource. This string may contain the "f" and "u" escape characters which will be expanded to the resource file path and URI respectively
app_name: The name of the application that registered the resource
description: A short description of the resource as a UTF-8 encoded string
display_name: The name of the resource to be used for display as a UTF-8 encoded string
groups: A list of groups associated with this item. Groups are essentially arbitrary strings associated with a particular resource. They can be thought of as 'categories' (such as "email", "graphics", etc) or tags for the resource.
is_private: Whether this resource should be visible only to applications that have registered it or not
mime_type: The MIME type of the resource
In addition to adding items to the list, you can also look up items from the list and modify or remove items.

Looking up Items in the List of Recent Files
To look up recently used files, RecentManager provides several functions. To look up a specific item by its URI, you can use the lookup_item() function, which will return a RecentInfo class. If the specified URI did not exist in the list of recent files, lookup_item() throws a RecentManagerError exception. For example:

Glib::RefPtr<Gtk::RecentInfo> info;
try
{
  info = recent_manager->lookup_item(uri);
}
catch(const Gtk::RecentManagerError& ex)
{
  std::cerr << "RecentManagerError: " << ex.what() << std::endl;
}
if (info)
{
  // item was found
}

A RecentInfo object is essentially an object containing all of the metadata about a single recently-used file. You can use this object to look up any of the properties listed above.
If you don't want to look for a specific URI, but instead want to get a list of all recently used items, RecentManager provides the get_items() function. The return value of this function is a std::vector of all recently used files. The following code demonstrates how you might get a list of recently used files:

std::vector< Glib::RefPtr<Gtk::RecentInfo> > info_list = recent_manager->get_items();

The maximum age of items in the recently used files list can be set with Gtk::Settings::property_gtk_recent_files_max_age(). Default value: 30 days.

Modifying the List of Recent Files
There may be times when you need to modify the list of recent files. For instance, if a file is moved or renamed, you may need to update the file's location in the recent files list so that it doesn't point to an incorrect location. You can update an item's location by using move_item().
In addition to changing a file's URI, you can also remove items from the list, either one at a time or by clearing them all at once. The former is accomplished with remove_item(), the latter with purge_items().
The functions move_item(), remove_item() and purge_items() have no effect on the actual files that are referred to by the URIs, they only modify the list of recent files.

RecentChooser
RecentChooser is an interface that can be implemented by widgets displaying the list of recently used files. gtkmm provides four built-in implementations for choosing recent files: RecentChooserWidget, RecentChooserDialog, RecentChooserMenu, and RecentAction.
RecentChooserWidget is a simple widget for displaying a list of recently used files. RecentChooserWidget is the basic building block for RecentChooserDialog, but you can embed it into your user interface if you want to.
RecentChooserMenu and RecentAction allow you to list recently used files as a menu.

Simple RecentChooserDialog example
Shown below is a simple example of how to use the RecentChooserDialog and the RecentAction classes in a program. This simple program has a menubar with a Recent Files Dialog menu item. When you select this menu item, a dialog pops up showing the list of recently used files.
If this is the first time you're using a program that uses the Recent Files framework, the dialog may be empty at first. Otherwise it should show the list of recently used documents registered by other applications.
After selecting the Recent Files Dialog menu item, you should see something similar to the following window.
Source Code
File: examplewindow.h (For use with gtkmm 3, not gtkmm 2)

#ifndef GTKMM_EXAMPLEWINDOW_H
#define GTKMM_EXAMPLEWINDOW_H

#include <gtkmm.h>

class ExampleWindow : public Gtk::Window
{
public:
  ExampleWindow();
  virtual ~ExampleWindow();

protected:
  //Signal handlers:
  void on_menu_file_recent_files_item();
  void on_menu_file_recent_files_dialog();
  void on_menu_file_quit();
  void on_menu_file_new();

  //Child widgets:
  Gtk::Box m_Box;

  Glib::RefPtr<Gtk::Builder> m_refBuilder;
  Glib::RefPtr<Gio::SimpleActionGroup> m_refActionGroup;

  Glib::RefPtr<Gtk::RecentManager> m_refRecentManager;
};

#endif //GTKMM_EXAMPLEWINDOW_H

File: examplewindow.cc (For use with gtkmm 3, not gtkmm 2)

#include "examplewindow.h"
#include <iostream>

ExampleWindow::ExampleWindow()
: m_Box(Gtk::ORIENTATION_VERTICAL),
  m_refRecentManager(Gtk::RecentManager::get_default())
{
  set_title("recent files example");
  set_default_size(200, 200);

  //We can put a MenuBar at the top of the box and other stuff below it.
  add(m_Box);

  //Create actions for menus and toolbars:
  m_refActionGroup = Gio::SimpleActionGroup::create();

  //File menu:
  m_refActionGroup->add_action("new",
    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_new));

  //A menu item to open the recent-files dialog:
  m_refActionGroup->add_action("recent-files-dialog",
    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_recent_files_dialog) );

  m_refActionGroup->add_action("quit",
    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_quit) );

  insert_action_group("example", m_refActionGroup);


  m_refBuilder = Gtk::Builder::create();

  //TODO: add_accel_group(m_refBuilder->get_accel_group());

  //Layout the actions in a menubar and toolbar:
  const char* ui_info =
    "<interface>"
    "  <menu id='menubar'>"
    "    <submenu>"
    "      <attribute name='label' translatable='yes'>_File</attribute>"
    "      <item>"
    "        <attribute name='label' translatable='yes'>_New</attribute>"
    "        <attribute name='action'>example.new</attribute>"
    "        <attribute name='accel'>&lt;Primary&gt;n</attribute>"
    "      </item>"
    "      <item>"
    "        <attribute name='label' translatable='yes'>Recent Files _Dialog</attribute>"
    "        <attribute name='action'>example.recent-files-dialog</attribute>"
    "        <attribute name='accel'>&lt;Primary&gt;o</attribute>"
    "      </item>"
    "      <item>"
    "        <attribute name='label' translatable='yes'>_Quit</attribute>"
    "        <attribute name='action'>example.quit</attribute>"
    "        <attribute name='accel'>&lt;Primary&gt;q</attribute>"
    "      </item>"
    "    </submenu>"
    "  </menu>";

/* TODO: 
        "  <toolbar  name='ToolBar'>"
        "    <toolitem action='FileNew'/>"
        "    <toolitem action='FileQuit'/>"
        "  </toolbar>"
        "</ui>";
*/

  try
  {
    m_refBuilder->add_from_string(ui_info);
  }
  catch(const Glib::Error& ex)
  {
    std::cerr << "building menus failed: " <<  ex.what();
  }

  //Get the menubar and toolbar widgets, and add them to a container widget:
  Glib::RefPtr<Glib::Object> object =
    m_refBuilder->get_object("menubar");
  Glib::RefPtr<Gio::Menu> gmenu =
    Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
  if(!gmenu)
    g_warning("GMenu not found");

  //Menubar:
  Gtk::MenuBar* pMenubar = new Gtk::MenuBar(gmenu);
  m_Box.pack_start(*pMenubar, Gtk::PACK_SHRINK);

/* TODO:
  Gtk::Widget* pToolbar = m_refBuilder->get_widget("/ToolBar");
  if(pToolbar)
    m_Box.pack_start(*pToolbar, Gtk::PACK_SHRINK);
*/

  show_all_children();
}

ExampleWindow::~ExampleWindow()
{
}

void ExampleWindow::on_menu_file_new()
{
  std::cout << " New File" << std::endl;
}

void ExampleWindow::on_menu_file_quit()
{
  hide(); //Closes the main window to stop the app->run().
}

void ExampleWindow::on_menu_file_recent_files_dialog()
{
  Gtk::RecentChooserDialog dialog(*this, "Recent Files", m_refRecentManager);
  dialog.add_button("Select File", Gtk::RESPONSE_OK);
  dialog.add_button("_Cancel", Gtk::RESPONSE_CANCEL);

  const int response = dialog.run();
  dialog.hide();
  if(response == Gtk::RESPONSE_OK)
  {
    std::cout << "URI selected = " << dialog.get_current_uri() << std::endl;
  }
}

File: main.cc (For use with gtkmm 3, not gtkmm 2)

#include "examplewindow.h"
#include <gtkmm/application.h>

int main(int argc, char *argv[])
{
  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

  ExampleWindow window;

  //Shows the window and returns when it is closed.
  return app->run(window);
}

The constructor for ExampleWindow creates the menu using UIManager (see Menus and Toolbars for more information). It then adds the menu and the toolbar to the window.

Filtering Recent Files
For any of the RecentChooser classes, if you don't wish to display all of the items in the list of recent files, you can filter the list to show only those that you want. You can filter the list with the help of the RecentFilter class. This class allows you to filter recent files by their name (add_pattern()), their mime type (add_mime_type()), the application that registered them (add_application()), or by a custom filter function (add_custom()). It also provides the ability to filter based on how long ago the file was modified and which groups it belongs to.
After you've created and set up the filter to match only the items you want, you can apply a filter to a chooser widget with the RecentChooser::add_filter() function.