summaryrefslogtreecommitdiffstats
path: root/src/document-undo.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/document-undo.h
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/document-undo.h')
-rw-r--r--src/document-undo.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/document-undo.h b/src/document-undo.h
new file mode 100644
index 0000000..937fa8b
--- /dev/null
+++ b/src/document-undo.h
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** @file
+ * TODO: insert short description here
+ *//*
+ * Authors: see git history
+ *
+ * Copyright (C) 2018 Authors
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+#ifndef SEEN_SP_DOCUMENT_UNDO_H
+#define SEEN_SP_DOCUMENT_UNDO_H
+
+#include <glib.h> // gboolean, gchar
+
+namespace Glib {
+ class ustring;
+}
+
+class SPDocument;
+
+namespace Inkscape {
+
+class DocumentUndo
+{
+public:
+
+ /**
+ * Set undo sensitivity.
+ *
+ * Don't use this to temporarily turn sensitivity off, use ScopedInsensitive instead.
+ */
+ static void setUndoSensitive(SPDocument *doc, bool sensitive);
+
+ static bool getUndoSensitive(SPDocument const *document);
+
+ static void clearUndo(SPDocument *document);
+
+ static void clearRedo(SPDocument *document);
+
+ /* undo_icon is only used in History dialog. */
+ static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon);
+
+ static void maybeDone(SPDocument *document, const gchar *keyconst, Glib::ustring const &event_description, Glib::ustring const &undo_icon);
+
+private:
+ static void finish_incomplete_transaction(SPDocument &document);
+
+ static void perform_document_update(SPDocument &document);
+
+public:
+ static void resetKey(SPDocument *document);
+
+ static void cancel(SPDocument *document);
+
+ static gboolean undo(SPDocument *document);
+
+ static gboolean redo(SPDocument *document);
+
+ /**
+ * RAII-style mechanism for creating a temporary undo-insensitive context.
+ *
+ * \verbatim
+ {
+ DocumentUndo::ScopedInsensitive tmp(document);
+ ... do stuff ...
+ // "tmp" goes out of scope here and automatically restores undo-sensitivity
+ } \endverbatim
+ */
+ class ScopedInsensitive {
+ SPDocument * m_doc;
+ bool m_saved;
+
+ public:
+ ScopedInsensitive(SPDocument *doc)
+ : m_doc(doc)
+ {
+ m_saved = getUndoSensitive(doc);
+ setUndoSensitive(doc, false);
+ }
+ ~ScopedInsensitive() { setUndoSensitive(m_doc, m_saved); }
+ };
+};
+
+} // namespace Inkscape
+
+#endif // SEEN_SP_DOCUMENT_UNDO_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :