/* Save DE to file */
static void
-save_file (PsppireDataWindow *de)
+save_file (PsppireWindow *w)
{
gchar *fn = NULL;
GString *fnx;
struct getl_interface *sss;
struct string file_name ;
+ PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (w);
- g_object_get (de, "filename", &fn, NULL);
+ g_object_get (w, "filename", &fn, NULL);
fnx = g_string_new (fn);
psppire_window_set_filename (PSPPIRE_WINDOW (de), filename->str);
- save_file (de);
+ save_file (PSPPIRE_WINDOW (de));
g_string_free (filename, TRUE);
}
const gchar *fn = psppire_window_get_filename (de);
if ( NULL != fn)
- save_file (PSPPIRE_DATA_WINDOW (de));
+ psppire_window_save (de);
else
data_save_as_dialog (PSPPIRE_DATA_WINDOW (de));
}
static void
psppire_data_window_iface_init (PsppireWindowIface *iface)
{
- iface->save = data_save;
+ iface->save = save_file;
iface->load = load_file;
}
{
gint response = psppire_window_query_save (w);
- if ( response == GTK_RESPONSE_CANCEL)
- return TRUE;
-
- if ( response == GTK_RESPONSE_ACCEPT)
+ switch (response)
{
+ case GTK_RESPONSE_CANCEL:
+ return TRUE;
+ break;
+ case GTK_RESPONSE_APPLY:
psppire_window_save (w);
+ break;
+ case GTK_RESPONSE_REJECT:
+ default:
+ break;
}
}
}
-
-/*
+/*
Ask the user if the buffer should be saved.
Return the response.
*/
{
gint response;
GtkWidget *dialog;
+ GtkWidget *cancel_button;
const gchar *description;
const gchar *filename = psppire_window_get_filename (se);
+ GTimeVal time;
+
+ g_get_current_time (&time);
+
g_object_get (se, "description", &description, NULL);
g_return_val_if_fail (filename != NULL, GTK_RESPONSE_NONE);
+
dialog =
gtk_message_dialog_new (GTK_WINDOW (se),
GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
+ GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
- _("Save contents of %s to \"%s\"?"),
- description,
+ _("Save the changes to \"%s\" before closing?"),
filename);
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_YES,
- GTK_RESPONSE_ACCEPT);
+ g_object_set (dialog, "icon-name", "psppicon", NULL);
+
+ 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);
gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_NO,
+ _("Close _without saving"),
GTK_RESPONSE_REJECT);
+ cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL);
+
gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
+ GTK_STOCK_SAVE,
+ GTK_RESPONSE_APPLY);
+
+ gtk_widget_grab_focus (cancel_button);
response = gtk_dialog_run (GTK_DIALOG (dialog));
}
+
const gchar *
psppire_window_get_filename (PsppireWindow *w)
{
void
psppire_window_set_unsaved (PsppireWindow *w)
{
- w->dirty = TRUE;
+ if ( w->dirty == FALSE)
+ g_get_current_time (&w->savetime);
- g_get_current_time (&w->savetime);
+ w->dirty = TRUE;
psppire_window_set_title (w);
}
g_return_if_fail (i->save);
i->save (w);
+
+ w->dirty = FALSE;
+ psppire_window_set_title (w);
}
extern GtkRecentManager *the_recent_mgr;
-/*
+/*
If FILE_NAME exists in the recent list, then delete it.
*/
static void
gtk_recent_manager_remove_item (rm, uri, NULL);
g_free (uri);
-
}