X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fdata-editor.c;h=812d8fb8109a3baa098953454f1c2c7e53d02d1a;hb=610159421fde49f3f24622c60e193cf415086a64;hp=722ac2e851a9772a528408d8f5db230f6bec6828;hpb=c24e23657fdb65d4565b85d3d05396531618d8df;p=pspp-builds.git diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index 722ac2e8..812d8fb8 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -47,6 +47,7 @@ #include "data-editor.h" #include "syntax-editor.h" #include +#include #include #include "window-manager.h" @@ -160,6 +161,27 @@ transformation_change_callback (bool transformations_pending, static void open_data_file (const gchar *, struct data_editor *); +/* Puts FILE_NAME into the recent list. + If it's already in the list, it moves it to the top +*/ +static void +add_most_recent (const char *file_name) +{ +#if RECENT_LISTS_AVAILABLE + + GtkRecentManager *manager = gtk_recent_manager_get_default(); + gchar *uri = g_filename_to_uri (file_name, NULL, NULL); + + gtk_recent_manager_remove_item (manager, uri, NULL); + + if ( ! gtk_recent_manager_add_item (manager, uri)) + g_warning ("Could not add item %s to recent list\n",uri); + + g_free (uri); +#endif +} + + #if RECENT_LISTS_AVAILABLE @@ -1492,14 +1514,17 @@ open_data_file (const gchar *file_name, struct data_editor *de) sss = create_syntax_string_source ("GET FILE=%s.", ds_cstr (&filename)); - - execute_syntax (sss); ds_destroy (&filename); - window_set_name_from_filename ((struct editor_window *) de, file_name); + if (execute_syntax (sss) ) + { + window_set_name_from_filename ((struct editor_window *) de, file_name); + add_most_recent (file_name); + } } + /* Callback for the data_open action. Prompts for a filename and opens it */ static void @@ -1550,19 +1575,6 @@ open_data_dialog (GtkAction *action, struct data_editor *de) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); open_data_file (de->file_name, de); - -#if RECENT_LISTS_AVAILABLE - { - GtkRecentManager *manager = gtk_recent_manager_get_default(); - gchar *uri = g_filename_to_uri (de->file_name, NULL, NULL); - - if ( ! gtk_recent_manager_add_item (manager, uri)) - g_warning ("Could not add item %s to recent list\n",uri); - - g_free (uri); - } -#endif - } break; default: