#include <gtkmm.h>

class Columns: public Gtk::TreeModel::ColumnRecord
{
public:
	Gtk::TreeModelColumn<Glib::RefPtr<Gtk::RecentInfo> > col_info;
	Columns() { add(col_info); }
};

void on_cell_data(Gtk::CellRenderer* renderer, const Gtk::TreeIter& iter, Columns& cols)
{
	Gtk::CellRendererText& renderer_text = dynamic_cast<Gtk::CellRendererText&>(*renderer);
	Glib::RefPtr<Gtk::RecentInfo> info = (*iter)[cols.col_info];
	renderer_text.property_text() = info->get_display_name();
}

int main(int argc, char* argv[])
{
	Gtk::Main kit(argc, argv);

	Gtk::Window window;
	Gtk::ScrolledWindow scroll;
	Columns columns;
	Glib::RefPtr<Gtk::ListStore> store(Gtk::ListStore::create(columns));

	Gtk::TreeView view(store);
	Gtk::CellRendererText renderer;
	Gtk::TreeViewColumn viewcol("Recently used files");
	viewcol.pack_start(renderer, true);
	viewcol.set_cell_data_func(renderer, sigc::bind(sigc::ptr_fun(&on_cell_data), sigc::ref(columns)));
	view.append_column(viewcol);

	Glib::RefPtr<Gtk::RecentManager> manager(Gtk::RecentManager::get_default());
	Gtk::RecentManager::ListHandle_RecentInfos list(manager->get_items());
	for(Gtk::RecentManager::ListHandle_RecentInfos::iterator iter = list.begin(); iter != list.end(); ++ iter)
	{
		Glib::RefPtr<Gtk::RecentInfo> info = *iter;
		Gtk::TreeIter tree_iter = store->append();
		(*tree_iter)[columns.col_info] = info;
	}

	scroll.add(view);
	window.add(scroll);
	window.set_default_size(400, 400);
	window.show_all();
	kit.run(window);
	return 0;
}
