diff options
Diffstat (limited to 'src/sp-guide.cpp')
| -rw-r--r-- | src/sp-guide.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index bbdf5f260..fd07f76ef 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -43,6 +43,7 @@ #include <2geom/angle.h> #include "document.h" #include "document-undo.h" +#include "helper-fns.h" #include "verbs.h" using Inkscape::DocumentUndo; @@ -51,6 +52,7 @@ using std::vector; SPGuide::SPGuide() : SPObject() , label(NULL) + , locked(0) , views(NULL) , normal_to_line(Geom::Point(0.,1.)) , point_on_line(Geom::Point(0.,0.)) @@ -73,6 +75,7 @@ void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) this->readAttr( "inkscape:color" ); this->readAttr( "inkscape:label" ); + this->readAttr( "inkscape:locked" ); this->readAttr( "orientation" ); this->readAttr( "position" ); @@ -113,6 +116,12 @@ void SPGuide::set(unsigned int key, const gchar *value) { this->set_label(this->label, false); break; + case SP_ATTR_INKSCAPE_LOCKED: + this->locked = helperfns_read_bool(value, false); + if (value) { + this->set_locked(this->locked, false); + } + break; case SP_ATTR_ORIENTATION: { if (value && !strcmp(value, "horizontal")) { @@ -339,6 +348,9 @@ double SPGuide::getDistanceFrom(Geom::Point const &pt) const */ void SPGuide::moveto(Geom::Point const point_on_line, bool const commit) { + if(this->locked) { + return; + } for (GSList *l = views; l != NULL; l = l->next) { sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line); } @@ -385,6 +397,9 @@ void SPGuide::moveto(Geom::Point const point_on_line, bool const commit) */ void SPGuide::set_normal(Geom::Point const normal_to_line, bool const commit) { + if(this->locked) { + return; + } for (GSList *l = this->views; l != NULL; l = l->next) { sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line); } @@ -423,6 +438,18 @@ void SPGuide::set_color(const unsigned r, const unsigned g, const unsigned b, bo } } +void SPGuide::set_locked(const bool locked, bool const commit) +{ + this->locked = locked; + if (views) { + sp_guideline_set_locked(SP_GUIDELINE(views->data), locked); + } + + if (commit) { + getRepr()->setAttribute("inkscape:locked", g_strdup(locked ? "true" : "false")); + } +} + void SPGuide::set_label(const char* label, bool const commit) { if (views) { @@ -482,6 +509,7 @@ char* SPGuide::description(bool const verbose) const descr = g_strconcat(oldDescr, shortcuts, NULL); g_free(oldDescr); } + g_free(shortcuts); } |
