summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/document-properties.cpp
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-09-11 22:47:47 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-09-11 22:47:47 +0000
commit0661bbe927d7847e2d88c3f4ec51e59a549f8c78 (patch)
treebc8a21b3117562758a46d0b0b321c67663042091 /src/ui/dialog/document-properties.cpp
parent(Mostly) fix document unit change for flowed text. (diff)
downloadinkscape-0661bbe927d7847e2d88c3f4ec51e59a549f8c78.tar.gz
inkscape-0661bbe927d7847e2d88c3f4ec51e59a549f8c78.zip
Fix document unit change undo bug.
(bzr r12475.1.14)
Diffstat (limited to 'src/ui/dialog/document-properties.cpp')
-rw-r--r--src/ui/dialog/document-properties.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index 272b85d2a..a2712bf68 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -35,6 +35,7 @@
#include "sp-object-repr.h"
#include "sp-root.h"
#include "sp-script.h"
+#include "svg/stringstream.h"
#include "ui/widget/color-picker.h"
#include "ui/widget/scalar-unit.h"
#include "ui/dialog/filedialog.h"
@@ -172,6 +173,7 @@ DocumentProperties::DocumentProperties()
signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop));
signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop));
+ _rum_deflt._changed_connection.block();
_rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange));
_old_doc_unit = _rum_deflt.getUnit();
}
@@ -1637,6 +1639,17 @@ void DocumentProperties::onDocUnitChange()
SPDocument *doc = SP_ACTIVE_DOCUMENT;
Inkscape::Util::Unit doc_unit = _rum_deflt.getUnit();
+ // Don't execute when change is being undone
+ if (!DocumentUndo::getUndoSensitive(doc)) {
+ return;
+ }
+
+ // Set document unit
+ Inkscape::SVGOStringStream os;
+ os << doc_unit.abbr;
+ Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
+ repr->setAttribute("inkscape:document-units", os.str().c_str());
+
// Set viewBox
Inkscape::Util::Quantity width = doc->getWidth();
Inkscape::Util::Quantity height = doc->getHeight();
@@ -1646,6 +1659,8 @@ void DocumentProperties::onDocUnitChange()
gdouble scale = Inkscape::Util::Quantity::convert(1, _old_doc_unit, doc_unit);
doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px")));
+ doc->setModifiedSinceSave();
+
_old_doc_unit = doc_unit;
DocumentUndo::done(doc, SP_VERB_NONE, _("Changed document unit"));
}