diff --git a/src/document-undo.cpp b/src/document-undo.cpp
index 09bb4e85729da13d2927cbdc5ce37bde63e5841c..9ce1dad603fa8f59af769b9aef213d579b989939 100644 (file)
--- a/src/document-undo.cpp
+++ b/src/document-undo.cpp
* Lauris Kaplinski <lauris@kaplinski.com>
* MenTaLguY <mental@rydia.net>
*
+ * Copyright (C) 2007 MenTaLguY <mental@rydia.net>
* Copyright (C) 1999-2003 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Since undo sensitivity needs to be nested, setting undo sensitivity
* should be done like this:
*\verbatim
- gboolean saved = sp_document_get_undo_sensitive(document);
- sp_document_set_undo_sensitive(document, FALSE);
+ bool saved = sp_document_get_undo_sensitive(document);
+ sp_document_set_undo_sensitive(document, false);
... do stuff ...
sp_document_set_undo_sensitive(document, saved); \endverbatim
*/
void
-sp_document_set_undo_sensitive (SPDocument *doc, gboolean sensitive)
+sp_document_set_undo_sensitive (SPDocument *doc, bool sensitive)
{
g_assert (doc != NULL);
g_assert (doc->priv != NULL);
- if ( !(sensitive) == !(doc->priv->sensitive) )
+ if ( sensitive == doc->priv->sensitive )
return;
if (sensitive) {
);
}
- doc->priv->sensitive = !!sensitive;
+ doc->priv->sensitive = sensitive;
}
-gboolean sp_document_get_undo_sensitive(SPDocument const *document) {
+/*TODO: Throughout the inkscape code tree set/get_undo_sensitive are used for
+ * as is shown above. Perhaps it makes sense to create new functions,
+ * undo_ignore, and undo_recall to replace the start and end parts of the above.
+ * The main complexity with this is that they have to nest, so you have to store
+ * the saved bools in a stack. Perhaps this is why the above solution is better.
+ */
+
+bool sp_document_get_undo_sensitive(SPDocument const *document) {
g_assert(document != NULL);
g_assert(document->priv != NULL);
@@ -144,9 +152,8 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev
}
if (key && doc->actionkey && !strcmp (key, doc->actionkey) && doc->priv->undo) {
- doc->priv->undo->data =
- new Inkscape::Event(sp_repr_coalesce_log (((Inkscape::Event *)
- doc->priv->undo->data)->event, log));
+ ((Inkscape::Event *)doc->priv->undo->data)->event =
+ sp_repr_coalesce_log (((Inkscape::Event *)doc->priv->undo->data)->event, log);
} else {
Inkscape::Event *event = new Inkscape::Event(log, event_type, event_description);
doc->priv->undo = g_slist_prepend (doc->priv->undo, event);
g_warning ("Incomplete undo transaction:");
priv.partial = sp_repr_coalesce_log(priv.partial, log);
sp_repr_debug_print_log(priv.partial);
- priv.undo = g_slist_prepend(priv.undo, priv.partial);
+ Inkscape::Event *event = new Inkscape::Event(priv.partial);
+ priv.undo = g_slist_prepend(priv.undo, event);
+ priv.undoStackObservers.notifyUndoCommitEvent(event);
priv.partial = NULL;
}
}
g_assert (doc->priv->sensitive);
doc->priv->sensitive = FALSE;
+ doc->priv->seeking = true;
doc->actionkey = NULL;
sp_repr_begin_transaction (doc->rdoc);
doc->priv->sensitive = TRUE;
+ doc->priv->seeking = false;
if (ret)
inkscape_external_change();
g_assert (doc->priv->sensitive);
doc->priv->sensitive = FALSE;
+ doc->priv->seeking = true;
doc->actionkey = NULL;
sp_repr_begin_transaction (doc->rdoc);
doc->priv->sensitive = TRUE;
+ doc->priv->seeking = false;
if (ret)
inkscape_external_change();
void
sp_document_clear_undo (SPDocument *doc)
{
+ if (doc->priv->undo)
+ doc->priv->undoStackObservers.notifyClearUndoEvent();
+
while (doc->priv->undo) {
GSList *current;
void
sp_document_clear_redo (SPDocument *doc)
{
+ if (doc->priv->redo)
+ doc->priv->undoStackObservers.notifyClearRedoEvent();
+
while (doc->priv->redo) {
GSList *current;