https://sourceforge.net/tracker/?func=detail&aid=3249971&group_id=163434&atid=827735 When using GtkRecent for the management of recently used files, Xournal's recently used files also appear in the shell. That's very convenient for the new document-centric shells such as Gnome Shell and Unity. Timo Kluck ( tkluck ) - 2011-03-27 10:40:08 PDT === modified file 'src/main.c' --- src/main.c 2011-03-10 18:14:21 +0000 +++ src/main.c 2011-03-27 16:32:52 +0000 @@ -334,7 +334,6 @@ if (bgpdf.status != STATUS_NOT_INIT) shutdown_bgpdf(); - save_mru_list(); if (ui.auto_save_prefs) save_config_to_file(); return 0; === modified file 'src/xo-callbacks.c' --- src/xo-callbacks.c 2011-03-10 18:14:21 +0000 +++ src/xo-callbacks.c 2011-03-27 16:32:52 +0000 @@ -3101,32 +3101,36 @@ void -on_mru_activate (GtkMenuItem *menuitem, +on_mru_activate (GtkRecentChooser *recentChooser, gpointer user_data) { - int which; gboolean success; + gchar *uri, *name; GtkWidget *dialog; end_text(); if (!ok_to_close()) return; // user aborted on save confirmation - for (which = 0 ; which < MRU_SIZE; which++) { - if (ui.mrumenu[which] == GTK_WIDGET(menuitem)) break; - } - if (which == MRU_SIZE || ui.mru[which] == NULL) return; // not found... - + uri = gtk_recent_chooser_get_current_uri (recentChooser); + name = g_filename_from_uri (uri, NULL, NULL); set_cursor_busy(TRUE); - success = open_journal(ui.mru[which]); + success = open_journal(name); set_cursor_busy(FALSE); - if (success) return; + if (success) { + g_free(uri); + g_free(name); + return; + } /* open failed */ dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), ui.mru[which]); + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), name); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - delete_mru_entry(which); + + delete_mru_entry(name); + g_free(uri); + g_free(name); } === modified file 'src/xo-callbacks.h' --- src/xo-callbacks.h 2011-03-10 18:14:21 +0000 +++ src/xo-callbacks.h 2011-03-27 16:32:52 +0000 @@ -481,7 +481,7 @@ gpointer user_data); void -on_mru_activate (GtkMenuItem *menuitem, +on_mru_activate (GtkRecentChooser *recentChooser, gpointer user_data); void === modified file 'src/xo-file.c' --- src/xo-file.c 2011-03-10 18:14:21 +0000 +++ src/xo-file.c 2011-03-27 17:09:20 +0000 @@ -1211,99 +1211,53 @@ } } -// initialize the recent files list +// initialize GtkRecentManager. Also backwards compatibility: import recent files into GtkRecentManager void init_mru(void) { - int i; + GtkRecentFilter *recentFilter = gtk_recent_filter_new (); + gtk_recent_filter_add_application ( recentFilter, "xournal"); + gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (GET_COMPONENT("fileRecentFiles_menu")), recentFilter); + gsize lfptr; - char s[5]; GIOChannel *f; - gchar *str; + gchar *str, *uri; GIOStatus status; + GtkRecentManager *recentManager = gtk_recent_manager_get_default (); - g_strlcpy(s, "mru0", 5); - for (s[3]='0', i=0; i0) { str[lfptr] = 0; - ui.mru[i] = str; - i++; + uri = g_filename_to_uri (str, NULL, NULL); + gtk_recent_manager_add_item (recentManager, uri); + g_free(uri); + g_free(str); } } if (f) { g_io_channel_shutdown(f, FALSE, NULL); g_io_channel_unref(f); } - update_mru_menu(); -} - -void update_mru_menu(void) -{ - int i; - gboolean anyone = FALSE; - gchar *tmp; - for (i=0; i=1; j--) ui.mru[j] = ui.mru[j-1]; - ui.mru[0] = g_strdup(name); - update_mru_menu(); -} - -void delete_mru_entry(int which) -{ - int i; - - if (ui.mru[which]!=NULL) g_free(ui.mru[which]); - for (i=which+1;i