Index: configure.ac
===================================================================
RCS file: /cvs/gnome/evince/configure.ac,v
retrieving revision 1.161
diff -u -u -r1.161 configure.ac
--- configure.ac	31 Jul 2006 08:42:22 -0000	1.161
+++ configure.ac	4 Aug 2006 11:11:45 -0000
@@ -167,6 +167,14 @@
 fi
 AM_CONDITIONAL(HAVE_NAUTILUS, test x$HAVE_NAUTILUS = "xyes")
 
+dnl Check for GtkRecent
+PKG_CHECK_MODULES(GTK_RECENT, gtk+-2.0 >= 2.10.0, 
+		  [HAVE_GTK_RECENT=yes], [HAVE_GTK_RECENT=no])
+if test x$HAVE_GTK_RECENT = xyes; then
+   AC_DEFINE(HAVE_GTK_RECENT, 1, [defined if GtkRecent is available])
+fi
+AM_CONDITIONAL(HAVE_GTK_RECENT, test x$HAVE_GTK_RECENT = "xyes")
+
 dnl GConf configuration
 AM_GCONF_SOURCE_2
 
Index: cut-n-paste/Makefile.am
===================================================================
RCS file: /cvs/gnome/evince/cut-n-paste/Makefile.am,v
retrieving revision 1.3
diff -u -u -r1.3 Makefile.am
--- cut-n-paste/Makefile.am	9 May 2005 12:03:34 -0000	1.3
+++ cut-n-paste/Makefile.am	4 Aug 2006 11:11:45 -0000
@@ -1 +1,9 @@
-SUBDIRS = recent-files zoom-control toolbar-editor
+SUBDIRS = 
+
+if HAVE_GTK_RECENT
+SUBDIRS += 
+else
+SUBDIRS += recent-files 
+endif
+
+SUBDIRS += zoom-control toolbar-editor
Index: data/evince-ui.xml
===================================================================
RCS file: /cvs/gnome/evince/data/evince-ui.xml,v
retrieving revision 1.44
diff -u -u -r1.44 evince-ui.xml
--- data/evince-ui.xml	17 Jul 2006 19:44:13 -0000	1.44
+++ data/evince-ui.xml	4 Aug 2006 11:11:45 -0000
@@ -9,6 +9,7 @@
       <menuitem name="FilePropertiesMenu" action="FileProperties"/>
       <separator/>
       <placeholder name="RecentFilesMenu"/>
+      <separator/>
       <menuitem name="FileCloseWindowMenu" action="FileCloseWindow"/>
     </menu>
 
Index: shell/Makefile.am
===================================================================
RCS file: /cvs/gnome/evince/shell/Makefile.am,v
retrieving revision 1.68
diff -u -u -r1.68 Makefile.am
--- shell/Makefile.am	23 Jul 2006 19:59:43 -0000	1.68
+++ shell/Makefile.am	4 Aug 2006 11:11:45 -0000
@@ -2,7 +2,6 @@
 	-DDATADIR=\"$(pkgdatadir)\"			\
 	-DGNOMEDATADIR=\"$(datadir)\"			\
 	-I$(top_srcdir)/lib				\
-	-I$(top_srcdir)/cut-n-paste/recent-files/	\
 	-I$(top_srcdir)/cut-n-paste/zoom-control/	\
 	-I$(top_srcdir)/cut-n-paste/toolbar-editor/	\
 	-I$(top_srcdir)/backend				\
@@ -15,6 +14,12 @@
 	$(GNOME_PRINT_CFLAGS)				\
 	$(GTK_PRINT_CFLAGS)
 
+if HAVE_GTK_RECENT
+INCLUDES +=
+else
+INCLUDES += -I$(top_srcdir)/cut-n-paste/recent-files/
+endif
+
 bin_PROGRAMS=evince
 
 evince_SOURCES=				\
@@ -77,13 +82,18 @@
 
 
 evince_LDADD=								\
-	$(top_builddir)/cut-n-paste/recent-files/librecent.la		\
 	$(top_builddir)/cut-n-paste/zoom-control/libephyzoom.la		\
 	$(top_builddir)/cut-n-paste/toolbar-editor/libtoolbareditor.la	\
 	$(top_builddir)/properties/libevproperties.la			\
 	$(top_builddir)/lib/libev.la					\
 	$(SHELL_LIBS)							\
 	$(GNOME_PRINT_LIBS)
+
+if HAVE_GTK_RECENT
+evince_LDADD +=
+else
+evince_LDADD += $(top_builddir)/cut-n-paste/recent-files/librecent.la
+endif
 
 if ENABLE_DJVU
 evince_LDADD +=	$(DJVU_LIBS)
Index: shell/ev-application.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-application.c,v
retrieving revision 1.37
diff -u -u -r1.37 ev-application.c
--- shell/ev-application.c	17 Jul 2006 19:44:12 -0000	1.37
+++ shell/ev-application.c	4 Aug 2006 11:11:46 -0000
@@ -330,10 +330,12 @@
 		application->toolbars_file = NULL;
 	}
 
+#ifndef HAVE_GTK_RECENT
 	if (application->recent_model) {
 		g_object_unref (application->recent_model);
 		application->recent_model = NULL;
 	}
+#endif
 	
 	g_free (application->last_chooser_uri);
 	g_object_unref (application);
@@ -367,7 +369,8 @@
 
 	egg_toolbars_model_set_flags (ev_application->toolbars_model, 0,
 				      EGG_TB_MODEL_NOT_REMOVABLE); 
-				      
+
+#ifndef HAVE_GTK_RECENT
 	ev_application->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
 	/* FIXME we should add a mime type filter but current eggrecent
            has only a varargs style api which does not work well when
@@ -375,6 +378,7 @@
 	egg_recent_model_set_limit (ev_application->recent_model, 5);	
 	egg_recent_model_set_filter_groups (ev_application->recent_model,
     	    	    			    "Evince", NULL);
+#endif /* HAVE_GTK_RECENT */
 }
 
 GList *
@@ -401,10 +405,12 @@
 	return application->toolbars_model;
 }
 
+#ifndef HAVE_GTK_RECENT
 EggRecentModel *ev_application_get_recent_model (EvApplication *application)
 {
 	return application->recent_model;
 }
+#endif
 
 void ev_application_save_toolbars_model (EvApplication *application)
 {
Index: shell/ev-application.h
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-application.h,v
retrieving revision 1.16
diff -u -u -r1.16 ev-application.h
--- shell/ev-application.h	17 Jul 2006 19:44:12 -0000	1.16
+++ shell/ev-application.h	4 Aug 2006 11:11:46 -0000
@@ -29,7 +29,9 @@
 #include "ev-window.h"
 
 #include "egg-toolbars-model.h"
+#ifndef HAVE_GTK_RECENT
 #include "egg-recent-model.h"
+#endif
 
 G_BEGIN_DECLS
 
@@ -51,7 +53,9 @@
 	gchar *toolbars_file;
 	
 	EggToolbarsModel *toolbars_model;
+#ifndef HAVE_GTK_RECENT
 	EggRecentModel  *recent_model;
+#endif
 	
 	gchar *last_chooser_uri;
 };
@@ -86,7 +90,9 @@
 
 EggToolbarsModel *ev_application_get_toolbars_model  (EvApplication   *application);
 void              ev_application_save_toolbars_model (EvApplication   *application);
+#ifndef HAVE_GTK_RECENT
 EggRecentModel   *ev_application_get_recent_model    (EvApplication   *application);
+#endif
 void 		  ev_application_set_chooser_uri     (EvApplication   *application, 
 						      const gchar     *uri);
 const gchar	 *ev_application_get_chooser_uri     (EvApplication   *application);
Index: shell/ev-window.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-window.c,v
retrieving revision 1.291
diff -u -u -r1.291 ev-window.c
--- shell/ev-window.c	4 Aug 2006 08:08:31 -0000	1.291
+++ shell/ev-window.c	4 Aug 2006 11:11:47 -0000
@@ -50,11 +50,15 @@
 #include "ev-jobs.h"
 #include "ev-sidebar-page.h"
 #include "eggfindbar.h"
+
+#ifndef HAVE_GTK_RECENT
 #include "egg-recent-view-uimanager.h"
 #include "egg-recent-view.h"
+#include "egg-recent-model.h"
+#endif
+
 #include "egg-toolbar-editor.h"
 #include "egg-editable-toolbar.h"
-#include "egg-recent-model.h"
 #include "egg-toolbars-model.h"
 #include "ephy-zoom.h"
 #include "ephy-zoom-action.h"
@@ -125,10 +129,15 @@
 	GtkWidget *password_dialog;
 
 	/* UI Builders */
-	GtkActionGroup *action_group;
-	GtkActionGroup *view_popup_action_group;
-	GtkActionGroup *attachment_popup_action_group;
-	GtkUIManager   *ui_manager;
+	GtkActionGroup   *action_group;
+	GtkActionGroup   *view_popup_action_group;
+	GtkActionGroup   *attachment_popup_action_group;
+#ifdef HAVE_GTK_RECENT
+	GtkRecentManager *recent_manager;
+	GtkActionGroup   *recent_action_group;
+	guint             recent_ui_id;
+#endif
+	GtkUIManager     *ui_manager;
 
 	/* Fullscreen mode */
 	GtkWidget *fullscreen_toolbar;
@@ -153,7 +162,9 @@
 	EvPageCache *page_cache;
 	EvWindowPageMode page_mode;
 	EvWindowTitle *title;
+#ifndef HAVE_GTK_RECENT
 	EggRecentViewUIManager *recent_view;
+#endif
 
 	EvJob *xfer_job;
 #ifdef WITH_GNOME_PRINT
@@ -1106,6 +1117,18 @@
 	gtk_widget_show (chooser);
 }
 
+#ifdef HAVE_GTK_RECENT
+static void
+ev_window_cmd_recent_file_activate (GtkAction     *action,
+				    GtkRecentInfo *info)
+{
+	const gchar *uri;
+
+	uri = gtk_recent_info_get_uri (info);
+	
+	ev_application_open_uri (EV_APP, uri, NULL, GDK_CURRENT_TIME, NULL);
+}
+#else
 static void
 ev_window_cmd_recent_file_activate (GtkAction *action,
         	                    EvWindow *ev_window)
@@ -1122,21 +1145,126 @@
 	
 	g_free (uri);
 }
+#endif /* HAVE_GTK_RECENT */
 
 static void
 ev_window_add_recent (EvWindow *window, const char *filename)
 {
+#ifdef HAVE_GTK_RECENT
+	gtk_recent_manager_add_item (window->priv->recent_manager, filename);
+#else
 	EggRecentItem *item;
 
 	item = egg_recent_item_new_from_uri (filename);
 	egg_recent_item_add_group (item, "Evince");
 	egg_recent_model_add_full (ev_application_get_recent_model (EV_APP), item);
+#endif /* HAVE_GTK_RECENT */
 }
 
+#ifdef HAVE_GTK_RECENT
+static gint
+compare_recent_items (GtkRecentInfo *a, GtkRecentInfo *b)
+{
+	gboolean     has_ev_a, has_ev_b;
+	const gchar *evince = g_get_application_name ();
+
+	has_ev_a = gtk_recent_info_has_application (a, evince);
+	has_ev_b = gtk_recent_info_has_application (b, evince);
+	
+	if (has_ev_a && has_ev_b) {
+		time_t time_a, time_b;
+
+		time_a = gtk_recent_info_get_modified (a);
+		time_b = gtk_recent_info_get_modified (b);
+
+		return (time_b - time_a);
+	} else if (has_ev_a) {
+		return -1;
+	} else if (has_ev_b) {
+		return 1;
+	}
+
+	return 0;
+}
+#endif /* HAVE_GTK_RECENT */
+
 static void
 ev_window_setup_recent (EvWindow *ev_window)
 {
+#ifdef HAVE_GTK_RECENT
+	GList        *items, *l;
+	guint         n_items = 0;
+	const gchar  *evince = g_get_application_name ();
+	static guint  i = 0;
+
+	if (ev_window->priv->recent_ui_id > 0) {
+		gtk_ui_manager_remove_ui (ev_window->priv->ui_manager,
+					  ev_window->priv->recent_ui_id);
+		gtk_ui_manager_ensure_update (ev_window->priv->ui_manager);
+	}
+	ev_window->priv->recent_ui_id = gtk_ui_manager_new_merge_id (ev_window->priv->ui_manager);
+
+	if (ev_window->priv->recent_action_group) {
+		gtk_ui_manager_remove_action_group (ev_window->priv->ui_manager,
+						    ev_window->priv->recent_action_group);
+		g_object_unref (ev_window->priv->recent_action_group);
+	}
+	ev_window->priv->recent_action_group = gtk_action_group_new ("RecentFilesActions");
+	gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
+					    ev_window->priv->recent_action_group, 0);
 
+	items = gtk_recent_manager_get_items (ev_window->priv->recent_manager);
+	items = g_list_sort (items, (GCompareFunc) compare_recent_items);
+
+	for (l = items; l && l->data; l = g_list_next (l)) {
+		GtkRecentInfo *info;
+		GtkAction     *action;
+		gchar         *action_name;
+		gchar         *label;
+
+		info = (GtkRecentInfo *) l->data;
+
+		if (!gtk_recent_info_has_application (info, evince))
+			continue;
+
+		action_name = g_strdup_printf ("RecentFile%u", i++);
+		label = g_strdup_printf ("_%d.  %s",
+					 n_items + 1,
+					 gtk_recent_info_get_display_name (info));
+		
+		action = g_object_new (GTK_TYPE_ACTION,
+				       "name", action_name,
+				       "label", label,
+				       NULL);
+
+		g_object_weak_ref (G_OBJECT (action),
+				   (GWeakNotify) gtk_recent_info_unref,
+				   gtk_recent_info_ref (info));
+		g_signal_connect (G_OBJECT (action), "activate",
+				  G_CALLBACK (ev_window_cmd_recent_file_activate),
+				  (gpointer) info);
+
+		gtk_action_group_add_action (ev_window->priv->recent_action_group,
+					     action);
+		g_object_unref (action);
+
+		gtk_ui_manager_add_ui (ev_window->priv->ui_manager,
+				       ev_window->priv->recent_ui_id,
+				       "/MainMenu/FileMenu/RecentFilesMenu",
+				       label,
+				       action_name,
+				       GTK_UI_MANAGER_MENUITEM,
+				       FALSE);
+		g_free (action_name);
+		g_free (label);
+
+		if (++n_items == 5)
+			break;
+	}
+	
+	g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
+	g_list_free (items);
+#else /* HAVE_GTK_RECENT */
 	ev_window->priv->recent_view = egg_recent_view_uimanager_new (ev_window->priv->ui_manager,
 								      "/MainMenu/FileMenu/RecentFilesMenu",
 								      G_CALLBACK (ev_window_cmd_recent_file_activate), 
@@ -1151,6 +1279,7 @@
 	
 	g_signal_connect (ev_window->priv->recent_view, "activate",
 			G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
+#endif /* HAVE_GTK_RECENT */
 }
 
 static void
@@ -3040,11 +3169,6 @@
 		priv->title = NULL;
 	}
 
-	if (priv->recent_view) {
-		g_object_unref (priv->recent_view);
-		priv->recent_view = NULL;
-	}
-
 	if (priv->ui_manager) {
 		g_object_unref (priv->ui_manager);
 		priv->ui_manager = NULL;
@@ -3065,6 +3189,27 @@
 		priv->attachment_popup_action_group = NULL;
 	}
 
+#ifdef HAVE_GTK_RECENT
+	if (priv->recent_action_group) {
+		g_object_unref (priv->recent_action_group);
+		priv->recent_action_group = NULL;
+	}
+
+	if (priv->recent_manager) {
+		g_signal_handlers_disconnect_by_func (priv->recent_manager,
+						      ev_window_setup_recent,
+						      window);
+		priv->recent_manager = NULL;
+	}
+
+	priv->recent_ui_id = 0;
+#else
+	if (priv->recent_view) {
+		g_object_unref (priv->recent_view);
+		priv->recent_view = NULL;
+	}
+#endif /* HAVE_GTK_RECENT */
+
 	if (priv->page_cache) {
 		g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
 		priv->page_cache = NULL;
@@ -3887,7 +4032,17 @@
 		g_warning ("building menus failed: %s", error->message);
 		g_error_free (error);
 	}
-
+	
+#ifdef HAVE_GTK_RECENT
+	ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
+	ev_window->priv->recent_action_group = NULL;
+	ev_window->priv->recent_ui_id = 0;
+	g_signal_connect_swapped (ev_window->priv->recent_manager,
+				  "changed",
+				  G_CALLBACK (ev_window_setup_recent),
+				  ev_window);
+#endif /* HAVE_GTK_RECENT */
+	
 	ev_window->priv->menubar =
 		 gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
 					    "/MainMenu");
