From: John Darrington Date: Thu, 6 Sep 2007 07:43:02 +0000 (+0000) Subject: Fixed buglet managing entries in the recent files lists. X-Git-Tag: v0.6.0~282 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=020c7feaeb2f56ae271c51381798f90c71a7e922;p=pspp-builds.git Fixed buglet managing entries in the recent files lists. --- diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index d37ce56d..6238e0f7 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,13 @@ +2007-09-06 John Darrington + + * helper.c helper.h (execute_syntax): changed return type to + gboolean to indicated if all the syntax executed successfully or not. + + * data-editor.c syntax-editor.c: Fixed update of recent file list + and window title, on data_file_open. They now only change, if + the file_open was successfull. + + 2007-08-25 John Darrington * psppire.c : Enable journal. 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: diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 1ca0df3e..0203999d 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -165,16 +165,17 @@ extern struct dataset *the_dataset; extern struct source_stream *the_source_stream; extern PsppireDataStore *the_data_store; -void +gboolean execute_syntax (struct getl_interface *sss) { struct lexer *lexer; + gboolean retval = TRUE; struct casereader *reader = psppire_data_store_get_reader (the_data_store); proc_set_active_file_data (the_dataset, reader); - g_return_if_fail (proc_has_active_file (the_dataset)); + g_return_val_if_fail (proc_has_active_file (the_dataset), FALSE); lexer = lex_create (the_source_stream); @@ -182,9 +183,17 @@ execute_syntax (struct getl_interface *sss) for (;;) { - int result = cmd_parse (lexer, the_dataset); + enum cmd_result result = cmd_parse (lexer, the_dataset); - if (result == CMD_EOF || result == CMD_FINISH) + if ( cmd_result_is_failure (result)) + { + retval = FALSE; + if ( source_stream_current_error_mode (the_source_stream) + == ERRMODE_STOP ) + break; + } + + if ( result == CMD_EOF || result == CMD_FINISH) break; } @@ -206,6 +215,8 @@ execute_syntax (struct getl_interface *sss) som_flush (); reload_the_viewer (); + + return retval; } diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h index 7ada5b52..eb50bdd2 100644 --- a/src/ui/gui/helper.h +++ b/src/ui/gui/helper.h @@ -26,7 +26,6 @@ #include #include - /* GtkRecentChooserMenu was added in 2.10.0 but it didn't support GtkRecentFilters until @@ -54,8 +53,7 @@ void connect_help (GladeXML *); void reference_manual (GtkMenuItem *, gpointer); struct getl_interface; -void execute_syntax (struct getl_interface *sss); - +gboolean execute_syntax (struct getl_interface *sss); #define XML_NEW(FILE) \ glade_xml_new (relocate(PKGDATADIR "/" FILE), NULL, NULL) diff --git a/src/ui/gui/syntax-editor.c b/src/ui/gui/syntax-editor.c index c3c8cf2b..35749fcd 100644 --- a/src/ui/gui/syntax-editor.c +++ b/src/ui/gui/syntax-editor.c @@ -490,8 +490,6 @@ load_editor_from_file (struct syntax_editor *se, gtk_text_buffer_insert (buffer, &iter, text, -1); - - window_set_name_from_filename ((struct editor_window *)se, filename); gtk_text_buffer_set_modified (buffer, FALSE); @@ -535,18 +533,20 @@ open_syntax_window (GtkMenuItem *menuitem, gpointer parent) struct syntax_editor *se = (struct syntax_editor *) window_create (WINDOW_SYNTAX, file_name); - load_editor_from_file (se, file_name, NULL); - + if ( load_editor_from_file (se, file_name, NULL) ) #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); } +#else + ; #endif }