summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7348bd1)
raw | patch | inline | side by side (parent: 7348bd1)
author | mental <mental@users.sourceforge.net> | |
Tue, 15 Jan 2008 05:08:28 +0000 (05:08 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Tue, 15 Jan 2008 05:08:28 +0000 (05:08 +0000) |
In order to do this, I got rid of sodipodi:modified in favor of a simple
flag in SPDocument, also renaming SPDocument::{set,is}Modified to
SPDocument::{set,is}ModifiedSinceSave
flag in SPDocument, also renaming SPDocument::{set,is}Modified to
SPDocument::{set,is}ModifiedSinceSave
12 files changed:
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index d664ef729a5cf963c93882693f47425919f18fcf..14d338ed57174914870442c36c9c83148c091f40 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
modified = true;
}
-
- if (modified)
- doc->setModified();
sp_document_set_undo_sensitive(doc, saved);
+
+ if (modified) {
+ doc->setModifiedSinceSave();
+ }
break;
}
case SELECTION_SELECTION: {
modified = true;
}
}
+ sp_document_set_undo_sensitive(doc, saved);
if (modified) {
- doc->setModified();
+ doc->setModifiedSinceSave();
}
-
- sp_document_set_undo_sensitive(doc, saved);
break;
}
default:
diff --git a/src/document-undo.cpp b/src/document-undo.cpp
index 2acd740f2022b5e45216d38b1443fc71bf349818..7df4943b7ab2c15345c219d13d2893a596becda4 100644 (file)
--- a/src/document-undo.cpp
+++ b/src/document-undo.cpp
#include "debug/timestamp.h"
#include "event.h"
-bool SPDocument::isModified() const {
- return rroot ? rroot->attribute("sodipodi:modified") != NULL : false;
-}
-void SPDocument::setModified(bool modified) {
- if (rroot) {
- rroot->setAttribute("sodipodi:modified", "true");
- }
-}
-
/*
* Undo & redo
@@ -208,7 +199,7 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev
doc->actionkey = key;
doc->virgin = FALSE;
- doc->setModified();
+ doc->setModifiedSinceSave();
sp_repr_begin_transaction (doc->rdoc);
sp_repr_undo_log (log->event);
doc->priv->redo = g_slist_prepend (doc->priv->redo, log);
- doc->setModified();
+ doc->setModifiedSinceSave();
doc->priv->undoStackObservers.notifyUndoEvent(log);
ret = TRUE;
sp_repr_replay_log (log->event);
doc->priv->undo = g_slist_prepend (doc->priv->undo, log);
- doc->setModified();
+ doc->setModifiedSinceSave();
doc->priv->undoStackObservers.notifyRedoEvent(log);
ret = TRUE;
diff --git a/src/document.h b/src/document.h
index 6c9ea570d27d28bc2258cb561e6e8da563ec15a5..8a4e65bb373fe57541f868a79aca6c9aafcf1838 100644 (file)
--- a/src/document.h
+++ b/src/document.h
unsigned int keepalive : 1;
unsigned int virgin : 1; ///< Has the document never been touched?
+ unsigned int modified_since_save : 1;
Inkscape::XML::Document *rdoc; ///< Our Inkscape::XML::Document
Inkscape::XML::Node *rroot; ///< Root element of Inkscape::XML::Document
/// Are we currently in a transition between two "known good" states of the document?
bool isSeeking() const;
- bool isModified() const;
- void setModified(bool modified=true);
+ bool isModifiedSinceSave() const { return modified_since_save; }
+ void setModifiedSinceSave(bool modified=true) {
+ modified_since_save = modified;
+ }
private:
SPDocument(SPDocument const &); // no copy
diff --git a/src/event-log.cpp b/src/event-log.cpp
index 54e58678a194eb303b099fd50a80060c30645649..82de44696b7b8b29356fac0fce0d0b22d8a6a219 100644 (file)
--- a/src/event-log.cpp
+++ b/src/event-log.cpp
EventLog::checkForVirginity() {
g_return_if_fail (_document);
if (_curr_event == _last_saved) {
- bool saved = sp_document_get_undo_sensitive(_document);
- sp_document_set_undo_sensitive(_document, false);
- _document->setModified(false);
- sp_document_set_undo_sensitive(_document, saved);
+ _document->setModifiedSinceSave(false);
}
}
index 9b0c990104e438e9ceea186a210a9fe5fcaaef87..b9976595ab67abdde468c008810edc68d0ad3045 100644 (file)
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
/* This kinda overkill as most of these are already set, but I want
to make sure for this release -- TJG */
- bool saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false);
- doc->setModified(false);
- sp_document_set_undo_sensitive(doc, saved);
+ doc->setModifiedSinceSave(false);
sp_document_set_uri(doc, filename);
gchar *saved_dataloss = NULL;
gchar *saved_uri = NULL;
if (!official) {
- saved_modified = doc->isModified();
+ saved_modified = doc->isModifiedSinceSave();
if (repr->attribute("inkscape:output_extension")) {
saved_output_extension = g_strdup(repr->attribute("inkscape:output_extension"));
}
// update attributes:
bool saved = sp_document_get_undo_sensitive(doc);
sp_document_set_undo_sensitive (doc, false);
- doc->setModified(false);
// save the filename for next use
sp_document_set_uri(doc, fileName);
// also save the extension for next use
repr->setAttribute("inkscape:dataloss", "true");
}
sp_document_set_undo_sensitive (doc, saved);
+ doc->setModifiedSinceSave(false);
omod->save(doc, fileName);
@@ -286,11 +283,11 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
if ( !official) {
saved = sp_document_get_undo_sensitive(doc);
sp_document_set_undo_sensitive (doc, false);
- doc->setModified(saved_modified);
repr->setAttribute("inkscape:output_extension", saved_output_extension);
repr->setAttribute("inkscape:dataloss", saved_dataloss);
sp_document_set_uri(doc, saved_uri);
sp_document_set_undo_sensitive (doc, saved);
+ doc->setModifiedSinceSave(saved_modified);
}
if (saved_output_extension) g_free(saved_output_extension);
diff --git a/src/file.cpp b/src/file.cpp
index 58ca463bf0eff55ea4e1666a48bf6c8fc87f31e7..c3e7e7583998a89df4d358d6ed57ca219306c5d8 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
}
bool do_revert = true;
- if (doc->isModified()) {
+ if (doc->isModifiedSinceSave()) {
gchar *text = g_strdup_printf(_("Changes will be lost! Are you sure you want to reload document %s?"), uri);
bool response = desktop->warnDialog (text);
{
bool success = true;
- if (doc->isModified()) {
+ if (doc->isModifiedSinceSave()) {
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
if ( doc->uri == NULL
|| repr->attribute("inkscape:output_extension") == NULL )
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
- if (!doc->uri && !doc->isModified())
+ if (!doc->uri && !doc->isModifiedSinceSave())
return false;
// Get the default extension name
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 4f831e629f271ac964b3caa1a4fbfa59b1cf4b75..cd176c0cfbc7c883d9da135bde77211713fd4f08 100644 (file)
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
Inkscape::XML::Node *repr;
doc = (SPDocument *) l->data;
repr = sp_document_repr_root (doc);
- if (doc->isModified()) {
+ if (doc->isModifiedSinceSave()) {
const gchar *docname, *d0, *d;
gchar n[64], c[1024];
FILE *file;
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 0368262dcc2eef5df8749aa4a08170564db81a9f..481f201cdf97bfbec737cd158114f33767348388 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
bool saved = sp_document_get_undo_sensitive(doc);
sp_document_set_undo_sensitive(doc, false);
-
sp_repr_set_boolean(repr, "showguides", v);
-
- doc->setModified();
sp_document_set_undo_sensitive(doc, saved);
+
+ doc->setModifiedSinceSave();
}
void sp_namedview_show_grids(SPNamedView * namedview, bool show, bool dirty_document)
@@ -897,15 +896,14 @@ void sp_namedview_show_grids(SPNamedView * namedview, bool show, bool dirty_docu
bool saved = sp_document_get_undo_sensitive(doc);
sp_document_set_undo_sensitive(doc, false);
-
sp_repr_set_boolean(repr, "showgrid", namedview->grids_visible);
+ sp_document_set_undo_sensitive(doc, saved);
/* we don't want the document to get dirty on startup; that's when
we call this function with dirty_document = false */
if (dirty_document) {
- doc->setModified();
+ doc->setModifiedSinceSave();
}
- sp_document_set_undo_sensitive(doc, saved);
}
gchar const *SPNamedView::getName() const
index 78cf76096267c95cb022716db74b6b87cb4a7c3a..9ac6aeefd4163f5dddf16b8649a65d3629fdd6bd 100644 (file)
return false;
SPDocument *doc = _desktop->doc();
- if (doc->isModified()) {
+ if (doc->isModifiedSinceSave()) {
gchar *markup;
/// \todo FIXME !!! obviously this will have problems if the document
/// name contains markup characters
index 84d53663b818f2ac55396322b2e2842d3a1ffd42..1364e5a2aa161131e0f8c01df745e835fddb16a1 100644 (file)
bool saved = sp_document_get_undo_sensitive (local_doc);
sp_document_set_undo_sensitive (local_doc, false);
-
if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr);
- local_doc->setModified();
-
sp_document_set_undo_sensitive (local_doc, saved);
+
+ local_doc->setModifiedSinceSave();
if (write_undo) {
local_repr->setAttribute(_key.c_str(), svgstr);
sp_document_done (local_doc, event_type, event_description);
sp_document_set_undo_sensitive (local_doc, false);
local_repr->setAttribute(_ckey.c_str(), c);
sp_repr_set_css_double(local_repr, _akey.c_str(), (rgba & 0xff) / 255.0);
- local_doc->setModified();
sp_document_set_undo_sensitive (local_doc, saved);
+
+ local_doc->setModifiedSinceSave();
sp_document_done (local_doc, SP_VERB_NONE,
/* TODO: annotate */ "registered-widget.cpp: RegisteredColorPicker::on_changed");
index 1c5f9b52190d4d4fc8e47c1eb15d964422946385..0110a6c4c55c536bfc77aedda642305ce3d6314e 100644 (file)
sp_document_set_undo_sensitive (doc, false);
Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
repr->setAttribute(_key.c_str(), os.str().c_str());
- doc->setModified();
sp_document_set_undo_sensitive (doc, saved);
+
+ doc->setModifiedSinceSave();
_wr->setUpdating (false);
}
index ca1121152945109c6d9a14679738c502b2e081cb..4d44b1b26eea4fc682f125b0df3fc91c822721ab 100644 (file)
if (inkscape_is_sole_desktop_for_document(*desktop)) {
SPDocument *doc = desktop->doc();
- if (doc->isModified()) {
+ if (doc->isModifiedSinceSave()) {
GtkWidget *dialog;
/** \todo