From: John Darrington Date: Wed, 4 Mar 2009 13:19:47 +0000 (+0900) Subject: Improve behaviour of recent file lists. X-Git-Tag: v0.7.3~256 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f9780e0184a3115d87783fdcfa39f89877a775e;p=pspp-builds.git Improve behaviour of recent file lists. The code now deletes an item from the recent list, after an unsuccessfull attempt to open it. They are now sorted in most recently used order. --- diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index b17b1913..5849df4a 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -362,6 +362,10 @@ psppire_data_window_load_file (PsppireDataWindow *de, psppire_window_set_filename (PSPPIRE_WINDOW (de), file_name); add_most_recent (file_name, the_recent_mgr); } + else + { + delete_recent (file_name, the_recent_mgr); + } psppire_window_set_unsaved (PSPPIRE_WINDOW (de), FALSE); } @@ -1585,7 +1589,7 @@ psppire_data_window_init (PsppireDataWindow *de) G_CALLBACK (regression_dialog), de); } - { + { GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER)); GtkWidget *recent_data = @@ -1609,6 +1613,8 @@ psppire_data_window_init (PsppireDataWindow *de) gtk_recent_filter_add_pattern (filter, "*.por"); gtk_recent_filter_add_pattern (filter, "*.POR"); + gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu_data), GTK_RECENT_SORT_MRU); + gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu_data), filter); } @@ -1625,6 +1631,8 @@ psppire_data_window_init (PsppireDataWindow *de) gtk_recent_filter_add_pattern (filter, "*.sps"); gtk_recent_filter_add_pattern (filter, "*.SPS"); + gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu_files), GTK_RECENT_SORT_MRU); + gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu_files), filter); } diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index d47b59b3..e5998cc6 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -399,6 +399,10 @@ open_syntax_window (GtkMenuItem *menuitem, gpointer parent) { add_most_recent (file_name, the_recent_mgr); } + else + { + delete_recent (file_name, the_recent_mgr); + } gtk_widget_show (se); } diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index 628ed45c..6bd6603b 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -592,3 +592,20 @@ add_most_recent (const char *file_name, GtkRecentManager *rm) g_free (uri); } + + +/* + If FILE_NAME exists in the recent list, then delete it. + */ +void +delete_recent (const char *file_name, GtkRecentManager *rm) +{ + gchar *uri = g_filename_to_uri (file_name, NULL, NULL); + + if ( uri ) + gtk_recent_manager_remove_item (rm, uri, NULL); + + g_free (uri); + +} + diff --git a/src/ui/gui/psppire-window.h b/src/ui/gui/psppire-window.h index e3da271e..67440ccd 100644 --- a/src/ui/gui/psppire-window.h +++ b/src/ui/gui/psppire-window.h @@ -108,6 +108,7 @@ gint psppire_window_query_save (PsppireWindow *); void psppire_window_save (PsppireWindow *w); void add_most_recent (const char *file_name, GtkRecentManager *rm); +void delete_recent (const char *file_name, GtkRecentManager *rm); G_END_DECLS