From: John Darrington Date: Sat, 7 Mar 2009 08:54:16 +0000 (+0900) Subject: Better abstraction of the unsaved window status. X-Git-Tag: v0.7.3~248 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=917906bd153b0a915facd98ccf919db0150219f4;p=pspp-builds.git Better abstraction of the unsaved window status. Implementations can now only set unsaved to true. Only the abstract base class can set it to false, which it does when the window is saved. --- diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index 7565dbb4..4543dc72 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -485,8 +485,6 @@ save_file (PsppireDataWindow *de) ds_destroy (&file_name); execute_syntax (sss); - - psppire_window_set_unsaved (PSPPIRE_WINDOW (de), FALSE); } @@ -1016,7 +1014,7 @@ resolve_action (GtkBuilder *builder, const gchar *action, const gchar *proxy) static void set_unsaved (gpointer w) { - psppire_window_set_unsaved (PSPPIRE_WINDOW (w), TRUE); + psppire_window_set_unsaved (PSPPIRE_WINDOW (w)); } static void diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index 86d87bb9..a5cc08aa 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -414,10 +414,10 @@ on_text_changed (GtkTextBuffer *buffer, PsppireSyntaxWindow *window) static void on_modified_changed (GtkTextBuffer *buffer, PsppireWindow *window) { - psppire_window_set_unsaved (window, gtk_text_buffer_get_modified (buffer)); + if (gtk_text_buffer_get_modified (buffer)) + psppire_window_set_unsaved (window); } - extern struct source_stream *the_source_stream ; static void diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index 576d3159..e03bd809 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -97,7 +97,7 @@ psppire_window_set_title (PsppireWindow *window) window->basename ? window->basename : "", mdash, window->description); - if ( window->unsaved) + if (window->unsaved) g_string_prepend_c (title, '*'); gtk_window_set_title (GTK_WINDOW (window), title->str); @@ -496,9 +496,9 @@ psppire_window_set_filename (PsppireWindow *w, const gchar *filename) } void -psppire_window_set_unsaved (PsppireWindow *w, gboolean unsaved) +psppire_window_set_unsaved (PsppireWindow *w) { - w->unsaved = unsaved; + w->unsaved = TRUE; psppire_window_set_title (w); } @@ -593,14 +593,17 @@ psppire_window_load (PsppireWindow *w, const gchar *file) g_return_val_if_fail (i->load, FALSE); - ok = i->load (w, file); + ok = i->load (w, file); if ( ok ) - add_most_recent (file, the_recent_mgr); + { + add_most_recent (file, the_recent_mgr); + w->unsaved = FALSE; + } else delete_recent (file, the_recent_mgr); - psppire_window_set_unsaved (w, FALSE); + psppire_window_set_title (w); return ok; } diff --git a/src/ui/gui/psppire-window.h b/src/ui/gui/psppire-window.h index 71c06538..c7025b35 100644 --- a/src/ui/gui/psppire-window.h +++ b/src/ui/gui/psppire-window.h @@ -100,7 +100,7 @@ void psppire_window_set_filename (PsppireWindow *w, const gchar *filename); void psppire_window_minimise_all (void); -void psppire_window_set_unsaved (PsppireWindow *, gboolean ); +void psppire_window_set_unsaved (PsppireWindow *); gboolean psppire_window_get_unsaved (PsppireWindow *);