/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2009, 2010, 2011, 2013, 2014 Free Software Foundation
+ Copyright (C) 2009, 2010, 2011, 2013, 2014, 2020 Free Software Foundation
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
{
GString *title = g_string_sized_new (80);
- if (window->dirty)
+ if (window->edited != NULL)
g_string_append_c (title, '*');
if (window->basename || window->id)
PsppireWindowRegister *reg = psppire_window_register_new ();
+ if (window->edited)
+ g_date_time_unref (window->edited);
+
g_signal_handler_disconnect (reg, window->remove_handler);
g_signal_handler_disconnect (reg, window->insert_handler);
psppire_window_register_remove (reg, window->list_name);
{
PsppireWindowRegister *reg = psppire_window_register_new ();
- if (w->dirty)
+ if (w->edited != NULL)
{
gint response = psppire_window_query_save (w);
break;
case GTK_RESPONSE_APPLY:
psppire_window_save (w);
- if (w->dirty)
+ if (w->edited != NULL)
{
/* Save failed, or user exited Save As dialog with Cancel. */
return TRUE;
window->id = NULL;
window->description = NULL;
window->list_name = NULL;
+ window->edited = NULL;
window->menuitem_table = g_hash_table_new (g_str_hash, g_str_equal);
window);
window->added_separator = FALSE;
- window->dirty = FALSE;
g_signal_connect_swapped (window, "delete-event", G_CALLBACK (on_delete), window);
gchar *description;
- GTimeVal time;
-
- g_get_current_time (&time);
+ GDateTime *now = g_date_time_new_now_utc ();
+ GTimeSpan timespan = g_date_time_difference (now, se->edited);
+ g_date_time_unref (now);
if (se->filename)
description = g_filename_display_basename (se->filename);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("If you don't save, changes from the last %ld seconds will be permanently lost."),
- time.tv_sec - se->savetime.tv_sec);
+ timespan / G_TIME_SPAN_SECOND);
gtk_dialog_add_button (GTK_DIALOG (dialog),
_("Close _without saving"),
void
psppire_window_set_unsaved (PsppireWindow *w)
{
- if (w->dirty == FALSE)
- g_get_current_time (&w->savetime);
-
- w->dirty = TRUE;
+ if (w->edited == NULL)
+ w->edited = g_date_time_new_now_utc ();
psppire_window_set_title (w);
}
gboolean
psppire_window_get_unsaved (PsppireWindow *w)
{
- return w->dirty;
+ return w->edited != NULL;
}
else
{
i->save (w);
- w->dirty = FALSE;
+ if (w->edited)
+ g_date_time_unref (w->edited);
+ w->edited = NULL;
+
psppire_window_set_title (w);
}
}
if (ok)
{
psppire_window_set_filename (w, file);
- w->dirty = FALSE;
+ if (w->edited)
+ g_date_time_unref (w->edited);
+ w->edited = NULL;
}
else
delete_recent (file);
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation
+ Copyright (C) 2008, 2009, 2010, 2011, 2013, 2014, 2020 Free Software Foundation
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
guint remove_handler;
gboolean added_separator;
- gboolean dirty;
- GTimeVal savetime;
+
+ /* The time when the contents of the window was last edited subsequent
+ to having been saved, or NULL if it has not been edited since the
+ most recent save. */
+ GDateTime *edited;
};