summaryrefslogtreecommitdiffstats
path: root/src/sp-guide.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-12-08 11:05:08 +0000
committerjabiertxof <jabier.arraiza@marker.es>2015-12-08 11:05:08 +0000
commitd79bd642b3214f1c44d7c1268e8adcb7bd55fffc (patch)
tree74a8529da5f23996ba4b358c045a7588f8c27f24 /src/sp-guide.cpp
parentminor changes (diff)
parentmerge lp:~inkscape.dev/inkscape/lock_guides (diff)
downloadinkscape-d79bd642b3214f1c44d7c1268e8adcb7bd55fffc.tar.gz
inkscape-d79bd642b3214f1c44d7c1268e8adcb7bd55fffc.zip
update to trunk
(bzr r14272.1.11)
Diffstat (limited to 'src/sp-guide.cpp')
-rw-r--r--src/sp-guide.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index 4e1c5913d..fd07f76ef 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -26,6 +26,7 @@
#include "display/sp-canvas.h"
#include "display/guideline.h"
#include "svg/svg.h"
+#include "svg/svg-color.h"
#include "svg/stringstream.h"
#include "attributes.h"
#include "sp-guide.h"
@@ -42,6 +43,7 @@
#include <2geom/angle.h>
#include "document.h"
#include "document-undo.h"
+#include "helper-fns.h"
#include "verbs.h"
using Inkscape::DocumentUndo;
@@ -50,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.))
@@ -70,7 +73,9 @@ void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr)
{
SPObject::build(document, repr);
+ this->readAttr( "inkscape:color" );
this->readAttr( "inkscape:label" );
+ this->readAttr( "inkscape:locked" );
this->readAttr( "orientation" );
this->readAttr( "position" );
@@ -95,9 +100,14 @@ void SPGuide::release()
void SPGuide::set(unsigned int key, const gchar *value) {
switch (key) {
+ case SP_ATTR_INKSCAPE_COLOR:
+ if (value) {
+ this->setColor(sp_svg_read_color(value, 0x0000ff00) | 0x7f);
+ }
+ break;
case SP_ATTR_INKSCAPE_LABEL:
- if (this->label) g_free(this->label);
-
+ // this->label already freed in sp_guideline_set_label (src/display/guideline.cpp)
+ // see bug #1498444, bug #1469514
if (value) {
this->label = g_strdup(value);
} else {
@@ -106,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")) {
@@ -332,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);
}
@@ -378,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);
}
@@ -416,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) {
@@ -475,6 +509,7 @@ char* SPGuide::description(bool const verbose) const
descr = g_strconcat(oldDescr, shortcuts, NULL);
g_free(oldDescr);
}
+
g_free(shortcuts);
}