+static void on_activate_recent_item (GtkRecentChooser *chooser,
+ VikWindow *self)
+{
+ gchar *filename;
+
+ filename = gtk_recent_chooser_get_current_uri (chooser);
+ if (filename != NULL)
+ {
+ GFile *file = g_file_new_for_uri ( filename );
+ gchar *path = g_file_get_path ( file );
+ g_object_unref ( file );
+ if ( self->filename )
+ {
+ gchar *filenames[] = { path, NULL };
+ g_signal_emit ( G_OBJECT(self), window_signals[VW_OPENWINDOW_SIGNAL], 0, filenames );
+ }
+ else
+ vik_window_open_file ( self, filename, TRUE );
+ g_free ( path );
+ }
+
+ g_free (filename);
+}
+
+static void setup_recent_files (VikWindow *self)
+{
+ GtkRecentManager *manager;
+ GtkRecentFilter *filter;
+ GtkWidget *menu, *menu_item;
+
+ filter = gtk_recent_filter_new ();
+ /* gtk_recent_filter_add_application (filter, g_get_application_name()); */
+ gtk_recent_filter_add_group(filter, "viking");
+
+ manager = gtk_recent_manager_get_default ();
+ menu = gtk_recent_chooser_menu_new_for_manager (manager);
+ gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu), GTK_RECENT_SORT_MRU);
+ gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter);
+
+ menu_item = gtk_ui_manager_get_widget (self->uim, "/ui/MainMenu/File/OpenRecentFile");
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
+
+ g_signal_connect (G_OBJECT (menu), "item-activated",
+ G_CALLBACK (on_activate_recent_item), (gpointer) self);
+}
+
+static void update_recently_used_document(const gchar *filename)
+{
+ /* Update Recently Used Document framework */
+ GtkRecentManager *manager = gtk_recent_manager_get_default();
+ GtkRecentData *recent_data = g_slice_new (GtkRecentData);
+ gchar *groups[] = {"viking", NULL};
+ GFile *file = g_file_new_for_commandline_arg(filename);
+ gchar *uri = g_file_get_uri(file);
+ gchar *basename = g_path_get_basename(filename);
+ g_object_unref(file);
+ file = NULL;
+
+ recent_data->display_name = basename;
+ recent_data->description = NULL;
+ recent_data->mime_type = "text/x-gps-data";
+ recent_data->app_name = (gchar *) g_get_application_name ();
+ recent_data->app_exec = g_strjoin (" ", g_get_prgname (), "%f", NULL);
+ recent_data->groups = groups;
+ recent_data->is_private = FALSE;
+ if (!gtk_recent_manager_add_full (manager, uri, recent_data))
+ {
+ g_warning (_("Unable to add '%s' to the list of recently used documents"), uri);
+ }
+
+ g_free (uri);
+ g_free (basename);
+ g_free (recent_data->app_exec);
+ g_slice_free (GtkRecentData, recent_data);
+}
+