summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 11af28b)
raw | patch | inline | side by side (parent: 11af28b)
author | mental <mental@users.sourceforge.net> | |
Tue, 15 Jan 2008 04:27:00 +0000 (04:27 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Tue, 15 Jan 2008 04:27:00 +0000 (04:27 +0000) |
12 files changed:
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index d26a5cde15dbc326528db9a67424ea45c94d87d8..d664ef729a5cf963c93882693f47425919f18fcf 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
}
if (modified)
- repr->setAttribute("sodipodi:modified", "TRUE");
+ doc->setModified();
sp_document_set_undo_sensitive(doc, saved);
break;
}
}
if (modified) {
- Inkscape::XML::Node * repr = sp_document_repr_root(doc);
- repr->setAttribute("sodipodi:modified", "TRUE");
+ doc->setModified();
}
sp_document_set_undo_sensitive(doc, saved);
diff --git a/src/document-undo.cpp b/src/document-undo.cpp
index 7556d2e8fed7df52a16ad5c00f551d8a006b62af..2acd740f2022b5e45216d38b1443fc71bf349818 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
@@ -199,9 +208,7 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev
doc->actionkey = key;
doc->virgin = FALSE;
- if (!doc->rroot->attribute("sodipodi:modified")) {
- doc->rroot->setAttribute("sodipodi:modified", "true");
- }
+ doc->setModified();
sp_repr_begin_transaction (doc->rdoc);
sp_repr_undo_log (log->event);
doc->priv->redo = g_slist_prepend (doc->priv->redo, log);
- doc->rroot->setAttribute("sodipodi:modified", "true");
+ doc->setModified();
doc->priv->undoStackObservers.notifyUndoEvent(log);
ret = TRUE;
sp_repr_replay_log (log->event);
doc->priv->undo = g_slist_prepend (doc->priv->undo, log);
- doc->rroot->setAttribute("sodipodi:modified", "true");
+ doc->setModified();
doc->priv->undoStackObservers.notifyRedoEvent(log);
ret = TRUE;
diff --git a/src/document.h b/src/document.h
index 462d2a15a2b25b669483a998870c069090e4a022..6c9ea570d27d28bc2258cb561e6e8da563ec15a5 100644 (file)
--- a/src/document.h
+++ b/src/document.h
/// 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);
+
private:
SPDocument(SPDocument const &); // no copy
void operator=(SPDocument const &); // no assign
diff --git a/src/event-log.cpp b/src/event-log.cpp
index 4c2ef9c7add8a2a2d9a7c4d9dda76f6a071d0f29..54e58678a194eb303b099fd50a80060c30645649 100644 (file)
--- a/src/event-log.cpp
+++ b/src/event-log.cpp
EventLog::checkForVirginity() {
g_return_if_fail (_document);
if (_curr_event == _last_saved) {
- Inkscape::XML::Node *repr = sp_document_repr_root(_document);
bool saved = sp_document_get_undo_sensitive(_document);
sp_document_set_undo_sensitive(_document, false);
- repr->setAttribute("sodipodi:modified", NULL);
+ _document->setModified(false);
sp_document_set_undo_sensitive(_document, saved);
}
}
index 0372e4aa051f242a61f7e24bcf9667fe0de82ab4..9b0c990104e438e9ceea186a210a9fe5fcaaef87 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 */
- Inkscape::XML::Node *repr = sp_document_repr_root(doc);
bool saved = sp_document_get_undo_sensitive(doc);
sp_document_set_undo_sensitive(doc, false);
- repr->setAttribute("sodipodi:modified", NULL);
+ doc->setModified(false);
sp_document_set_undo_sensitive(doc, saved);
sp_document_set_uri(doc, filename);
@@ -249,14 +248,12 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
// remember attributes in case this is an unofficial save
- gchar *saved_sodipodi_modified = NULL;
+ bool saved_modified = false;
gchar *saved_output_extension = NULL;
gchar *saved_dataloss = NULL;
gchar *saved_uri = NULL;
if (!official) {
- if (repr->attribute("sodipodi:modified")) {
- saved_sodipodi_modified = g_strdup(repr->attribute("sodipodi:modified"));
- }
+ saved_modified = doc->isModified();
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);
- repr->setAttribute("sodipodi:modified", NULL);
+ doc->setModified(false);
// save the filename for next use
sp_document_set_uri(doc, fileName);
// also save the extension for next use
@@ -289,14 +286,13 @@ 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);
- repr->setAttribute("sodipodi:modified", saved_sodipodi_modified);
+ 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);
}
- if (saved_sodipodi_modified) g_free(saved_sodipodi_modified);
if (saved_output_extension) g_free(saved_output_extension);
if (saved_dataloss) g_free(saved_dataloss);
if (saved_uri) g_free(saved_uri);
diff --git a/src/file.cpp b/src/file.cpp
index 355b1c50ab461dcdd215a6f8cfff3ffb8d047513..58ca463bf0eff55ea4e1666a48bf6c8fc87f31e7 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
}
bool do_revert = true;
- if (repr->attribute("sodipodi:modified") != NULL) {
+ if (doc->isModified()) {
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;
- Inkscape::XML::Node *repr = sp_document_repr_root(doc);
-
- gchar const *fn = repr->attribute("sodipodi:modified");
- if (fn != NULL) {
+ if (doc->isModified()) {
+ Inkscape::XML::Node *repr = sp_document_repr_root(doc);
if ( doc->uri == NULL
|| repr->attribute("inkscape:output_extension") == NULL )
{
return sp_file_save_dialog(parentWindow, doc, FALSE);
} else {
- fn = g_strdup(doc->uri);
+ gchar const *fn = g_strdup(doc->uri);
gchar const *ext = repr->attribute("inkscape:output_extension");
success = file_save(parentWindow, doc, fn, Inkscape::Extension::db.get(ext), FALSE, TRUE);
g_free((void *) fn);
static bool gotSuccess = false;
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
- // Verify whether the document is saved, so save this as temporary
- char *str = (char *) repr->attribute("sodipodi:modified");
- if ((!doc->uri) && (!str))
+ if (!doc->uri && !doc->isModified())
return false;
- // Get the default extension name
+ // Get the default extension name
Glib::ustring default_extension = "org.inkscape.output.svg.inkscape";
char formatBuf[256];
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 8b84416aa8c950e2ca11a6d1a7f1fac6a96cb11d..4f831e629f271ac964b3caa1a4fbfa59b1cf4b75 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 (repr->attribute("sodipodi:modified")) {
+ if (doc->isModified()) {
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 f738828e537c398de284bd4bb1e41f05a6c10bff..0368262dcc2eef5df8749aa4a08170564db81a9f 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
sp_repr_set_boolean(repr, "showguides", v);
- doc->rroot->setAttribute("sodipodi:modified", "true");
+ doc->setModified();
sp_document_set_undo_sensitive(doc, saved);
}
@@ -903,7 +903,7 @@ void sp_namedview_show_grids(SPNamedView * namedview, bool show, bool dirty_docu
/* 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->rroot->setAttribute("sodipodi:modified", "true");
+ doc->setModified();
}
sp_document_set_undo_sensitive(doc, saved);
}
index ff8b288fdc2dc2881dafe60b47b8d8418939a828..78cf76096267c95cb022716db74b6b87cb4a7c3a 100644 (file)
return false;
SPDocument *doc = _desktop->doc();
- if (sp_document_repr_root(doc)->attribute("sodipodi:modified") != NULL)
- {
+ if (doc->isModified()) {
gchar *markup;
/// \todo FIXME !!! obviously this will have problems if the document
/// name contains markup characters
index aac9ff25ce8c47b50f5ed310a65aa90c569bde89..84d53663b818f2ac55396322b2e2842d3a1ffd42 100644 (file)
sp_document_set_undo_sensitive (local_doc, false);
if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr);
- local_doc->rroot->setAttribute("sodipodi:modified", "true");
+ local_doc->setModified();
sp_document_set_undo_sensitive (local_doc, saved);
if (write_undo) {
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->rroot->setAttribute("sodipodi:modified", "true");
+ local_doc->setModified();
sp_document_set_undo_sensitive (local_doc, saved);
sp_document_done (local_doc, SP_VERB_NONE,
/* TODO: annotate */ "registered-widget.cpp: RegisteredColorPicker::on_changed");
index 4db82d88008872de509a0d1585d00eb7f7302214..1c5f9b52190d4d4fc8e47c1eb15d964422946385 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->rroot->setAttribute("sodipodi:modified", "true");
+ doc->setModified();
sp_document_set_undo_sensitive (doc, saved);
_wr->setUpdating (false);
index 4c2ebf21cda4797265221df657fb3fa99a0361ec..ca1121152945109c6d9a14679738c502b2e081cb 100644 (file)
if (inkscape_is_sole_desktop_for_document(*desktop)) {
SPDocument *doc = desktop->doc();
- if (sp_document_repr_root(doc)->attribute("sodipodi:modified") != NULL) {
+ if (doc->isModified()) {
GtkWidget *dialog;
/** \todo