+2007-09-06 John Darrington <john@darrington.wattle.id.au>
+
+ * 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 <john@darrington.wattle.id.au>
* psppire.c : Enable journal.
#include "data-editor.h"
#include "syntax-editor.h"
#include <language/syntax-string-source.h>
+#include <language/command.h>
#include <libpspp/syntax-gen.h>
#include "window-manager.h"
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
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
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:
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);
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;
}
som_flush ();
reload_the_viewer ();
+
+ return retval;
}
#include <gtk/gtk.h>
#include <glade/glade.h>
-
/*
GtkRecentChooserMenu was added in 2.10.0
but it didn't support GtkRecentFilters until
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)
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);
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
}