X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fsyntax-editor.c;h=35749fcd4a6f7e03cb511e5dbca871ce16e59190;hb=5ee84736663824fe12474b78dace867e42893a14;hp=95148d2cf12c46066bac89e6cf93351d8c247a7f;hpb=b4dd1916b76c26b631330a6da615af4433360da4;p=pspp-builds.git diff --git a/src/ui/gui/syntax-editor.c b/src/ui/gui/syntax-editor.c index 95148d2c..35749fcd 100644 --- a/src/ui/gui/syntax-editor.c +++ b/src/ui/gui/syntax-editor.c @@ -1,21 +1,18 @@ -/* - PSPPIRE --- A Graphical User Interface for PSPP - Copyright (C) 2006 Free Software Foundation +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2006 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #include #include @@ -33,6 +30,7 @@ #include "window-manager.h" +#include #include #include #include @@ -77,7 +75,7 @@ save_if_modified (struct syntax_editor *se) GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("Save contents of syntax editor to %s?"), - e->name + e->name ); gtk_dialog_add_button (GTK_DIALOG (dialog), @@ -110,7 +108,7 @@ save_if_modified (struct syntax_editor *se) return ; } - gtk_widget_destroy (e->window); + gtk_widget_destroy (GTK_WIDGET (e->window)); } /* Callback for the File->SaveAs menuitem */ @@ -211,20 +209,10 @@ on_quit (GtkMenuItem *menuitem, gpointer user_data) } static void -execute_syntax (const struct syntax_editor *se, GtkTextIter start, +editor_execute_syntax (const struct syntax_editor *se, GtkTextIter start, GtkTextIter stop) { - getl_append_source (the_source_stream, - create_syntax_editor_source (se, start, stop)); - for (;;) - { - int result = cmd_parse (se->lexer, the_dataset, - proc_has_source (the_dataset) - ? CMD_STATE_DATA : CMD_STATE_INITIAL); - - if (result == CMD_EOF || result == CMD_FINISH) - break; - } + execute_syntax (create_syntax_editor_source (se, start, stop)); } /* Parse and execute all the text in the buffer */ @@ -234,11 +222,10 @@ on_run_all (GtkMenuItem *menuitem, gpointer user_data) GtkTextIter begin, end; struct syntax_editor *se = user_data; - gtk_text_buffer_get_iter_at_line (se->buffer, &begin, 0); - gtk_text_buffer_get_iter_at_line (se->buffer, &end, -1); - + gtk_text_buffer_get_iter_at_offset (se->buffer, &begin, 0); + gtk_text_buffer_get_iter_at_offset (se->buffer, &end, -1); - execute_syntax (se, begin, end); + editor_execute_syntax (se, begin, end); } /* Parse and execute the currently selected text */ @@ -249,7 +236,7 @@ on_run_selection (GtkMenuItem *menuitem, gpointer user_data) struct syntax_editor *se = user_data; if ( gtk_text_buffer_get_selection_bounds (se->buffer, &begin, &end) ) - execute_syntax (se, begin, end); + editor_execute_syntax (se, begin, end); } @@ -276,7 +263,7 @@ on_run_current_line (GtkMenuItem *menuitem, gpointer user_data) gtk_text_buffer_get_iter_at_line (se->buffer, &begin, line); gtk_text_buffer_get_iter_at_line (se->buffer, &end, line + 1); - execute_syntax (se, begin, end); + editor_execute_syntax (se, begin, end); } @@ -305,7 +292,7 @@ on_run_to_end (GtkMenuItem *menuitem, gpointer user_data) gtk_text_buffer_get_iter_at_line (se->buffer, &begin, line); gtk_text_buffer_get_iter_at_line (se->buffer, &end, -1); - execute_syntax (se, begin, end); + editor_execute_syntax (se, begin, end); } @@ -318,8 +305,7 @@ on_run_to_end (GtkMenuItem *menuitem, gpointer user_data) struct syntax_editor * new_syntax_editor (void) { - GladeXML *xml = - glade_xml_new (PKGDATADIR "/syntax-editor.glade", NULL, NULL); + GladeXML *xml = XML_NEW ("syntax-editor.glade"); GtkWidget *text_view; struct syntax_editor *se ; @@ -331,7 +317,7 @@ new_syntax_editor (void) e = (struct editor_window *)se; - e->window = get_widget_assert (xml, "syntax_editor"); + e->window = GTK_WINDOW (get_widget_assert (xml, "syntax_editor")); text_view = get_widget_assert (xml, "syntax_text_view"); se->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); se->lexer = lex_create (the_source_stream); @@ -351,12 +337,6 @@ new_syntax_editor (void) G_CALLBACK (new_data_window), e->window); - g_signal_connect (get_widget_assert (xml,"file_open_data"), - "activate", - G_CALLBACK (open_data_window), - e->window); - - g_signal_connect (get_widget_assert (xml,"help_about"), "activate", G_CALLBACK (about_new), @@ -408,6 +388,13 @@ new_syntax_editor (void) se); + g_signal_connect (get_widget_assert (xml,"windows_minimise_all"), + "activate", + G_CALLBACK (minimise_all_windows), + NULL); + + + g_object_unref (xml); g_signal_connect (e->window, "delete-event", @@ -476,7 +463,7 @@ save_editor_to_file (struct syntax_editor *se, /* Loads the buffer from the file called FILENAME */ -static gboolean +gboolean load_editor_from_file (struct syntax_editor *se, const gchar *filename, GError **err) @@ -502,6 +489,7 @@ 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); @@ -545,7 +533,22 @@ 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 + } gtk_widget_destroy (dialog);