Commit b9bb5d2e authored by Morten Welinder's avatar Morten Welinder
Browse files

Doc: track document state instead of tracking dirtiness directly.

parent b5b32c30
......@@ -35,6 +35,7 @@ Morten:
* Dead kitten in css.
* Improve the drawing of filter combos.
* Allow theming of grid color.
* Fix dirty-tracking. [#554]
--------------------------------------------------------------------------
Gnumeric 1.12.48
......
......@@ -166,7 +166,7 @@ PKG_PROG_PKG_CONFIG(0.18)
dnl *****************************
libspreadsheet_reqs="
libgoffice-${GOFFICE_API_VER} >= 0.10.48
libgoffice-${GOFFICE_API_VER} >= 0.10.49
libgsf-1 >= 1.14.33
libxml-2.0 >= 2.4.12
"
......
......@@ -398,8 +398,7 @@ command_undo (WorkbookControl *wbc)
update_after_action (cmd->sheet, wbc);
if (!cmd->workbook_modified_before_do)
go_doc_set_dirty (GO_DOC (wb), FALSE);
go_doc_set_state (GO_DOC (wb), cmd->state_before_do);
/*
* A few commands clear the undo queue. For those, we do not
......@@ -449,8 +448,7 @@ command_redo (WorkbookControl *wbc)
g_object_ref (cmd);
cmd->workbook_modified_before_do =
go_doc_is_dirty (wb_control_get_doc (wbc));
cmd->state_before_do = go_doc_get_state (wb_control_get_doc (wbc));
/* TRUE indicates a failure to redo. Leave the command where it is */
if (!klass->redo_cmd (cmd, wbc)) {
......@@ -720,8 +718,7 @@ gnm_command_push_undo (WorkbookControl *wbc, GObject *obj)
g_return_val_if_fail (wbc != NULL, TRUE);
cmd = GNM_COMMAND (obj);
cmd->workbook_modified_before_do =
go_doc_is_dirty (wb_control_get_doc (wbc));
cmd->state_before_do = go_doc_get_state (wb_control_get_doc (wbc));
g_return_val_if_fail (cmd != NULL, TRUE);
......
......@@ -40,7 +40,7 @@ typedef struct {
char const *cmd_descriptor;
/* State of workbook before the commands was undo. */
gboolean workbook_modified_before_do;
guint64 state_before_do;
} GnmCommand;
typedef gboolean (* UndoCmd) (GnmCommand *self, WorkbookControl *wbc);
......
......@@ -5169,7 +5169,7 @@ sheet_mark_dirty (Sheet *sheet)
g_return_if_fail (IS_SHEET (sheet));
if (sheet->workbook)
go_doc_set_dirty (GO_DOC (sheet->workbook), TRUE);
workbook_mark_dirty (sheet->workbook);
}
/****************************************************************************/
......
......@@ -1215,6 +1215,8 @@ workbook_view_save_as (WorkbookView *wbv, GOFileSaver *fs, char const *uri,
if (go_doc_set_uri (GO_DOC (wb), uri)) {
GDateTime *modtime;
go_doc_set_saved_state (GO_DOC (wb),
go_doc_get_state (GO_DOC (wb)));
go_doc_set_dirty (GO_DOC (wb), FALSE);
/* See 634792. */
go_doc_set_pristine (GO_DOC (wb), FALSE);
......@@ -1286,6 +1288,8 @@ workbook_view_save (WorkbookView *wbv, GOCmdContext *context)
if (gnm_debug_flag ("modtime"))
g_printerr ("Modtime set\n");
g_date_time_unref (modtime);
go_doc_set_saved_state (GO_DOC (wb),
go_doc_get_state (GO_DOC (wb)));
go_doc_set_dirty (GO_DOC (wb), FALSE);
}
if (has_error || has_warning)
......@@ -1399,7 +1403,9 @@ workbook_view_new_from_input (GsfInput *input,
workbook_queue_volatile_recalc (new_wb);
workbook_recalc (new_wb);
workbook_update_graphs (new_wb);
go_doc_set_dirty (GO_DOC (new_wb), FALSE);
go_doc_set_saved_state
(GO_DOC (new_wb),
go_doc_get_state (GO_DOC (new_wb)));
if (uri && workbook_get_file_exporter (new_wb))
workbook_set_last_export_uri
(new_wb, uri);
......
......@@ -463,11 +463,19 @@ workbook_new_with_sheets (int sheet_count)
gnm_sheet_suggest_size (&cols, &rows);
while (sheet_count-- > 0)
workbook_sheet_add (wb, -1, cols, rows);
go_doc_set_dirty (GO_DOC (wb), FALSE);
// Restore to pristine state
go_doc_set_state (GO_DOC (wb), go_doc_get_saved_state (GO_DOC (wb)));
go_doc_set_pristine (GO_DOC (wb), TRUE);
return wb;
}
void
workbook_mark_dirty (Workbook *wb)
{
go_doc_bump_state (GO_DOC (wb));
}
/**
* workbook_set_saveinfo:
* @wb: the workbook to modify
......@@ -1031,7 +1039,7 @@ workbook_sheet_attach_at_pos (Workbook *wb, Sheet *new_sheet, int pos)
/* Do not signal until after adding the views [#314208] */
post_sheet_index_change (wb);
go_doc_set_dirty (GO_DOC (wb), TRUE);
workbook_mark_dirty (wb);
}
/**
......@@ -1159,7 +1167,7 @@ workbook_sheet_delete (Sheet *sheet)
g_object_unref (sheet);
if (!wb->during_destruction)
go_doc_set_dirty (GO_DOC (wb), TRUE);
workbook_mark_dirty (wb);
g_signal_emit (G_OBJECT (wb), signals[SHEET_DELETED], 0);
if (!wb->during_destruction)
......@@ -1204,7 +1212,7 @@ workbook_sheet_move (Sheet *sheet, int direction)
post_sheet_index_change (wb);
go_doc_set_dirty (GO_DOC (wb), TRUE);
workbook_mark_dirty (wb);
}
/**
......
......@@ -16,6 +16,8 @@ GType workbook_get_type (void);
Workbook *workbook_new (void);
Workbook *workbook_new_with_sheets (int sheet_count);
void workbook_mark_dirty (Workbook *wb);
/* Sheet support routines */
GPtrArray *workbook_sheets (Workbook const *wb);
int workbook_sheet_count (Workbook const *wb);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment