From a0a8d020201e0e38a63d9aa3dce228d7d9e6fb35 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 14 Mar 2013 12:42:39 +0100 Subject: Various changes. (bzr r11608.1.48) --- src/sp-guide.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 6a71cf4f0..9fc0a4c7d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -95,7 +95,7 @@ static void sp_guide_class_init(SPGuideClass *gc) gobject_class->set_property = sp_guide_set_property; gobject_class->get_property = sp_guide_get_property; - sp_object_class->build = sp_guide_build; + //sp_object_class->build = sp_guide_build; sp_object_class->release = sp_guide_release; sp_object_class->set = sp_guide_set; @@ -158,9 +158,10 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); - } +// if (((SPObjectClass *) (parent_class))->build) { +// (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); +// } + // CPPIFY: todo object->readAttr( "inkscape:label" ); object->readAttr( "orientation" ); -- cgit v1.2.3 From 3d7b1356600880a43e44e864cab08fff29cd23af Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:45:33 +0100 Subject: Added "virtual pads" to - SPFeFuncNode - SPFeDistantLight - SPFeMergeNode - SPFePointLight - SPFeSpotLight - SPFilter - SPFont - SPGuide Changes in SPItem and SPNamedView. (bzr r11608.1.49) --- src/sp-guide.cpp | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 133 insertions(+), 9 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 9fc0a4c7d..081a667a3 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -116,8 +116,18 @@ static void sp_guide_class_init(SPGuideClass *gc) (GParamFlags) G_PARAM_READWRITE)); } +CGuide::CGuide(SPGuide* guide) : CObject(guide) { + this->spguide = guide; +} + +CGuide::~CGuide() { +} + static void sp_guide_init(SPGuide *guide) { + guide->cguide = new CGuide(guide); + guide->cobject = guide->cguide; + guide->normal_to_line = Geom::Point(0.,1.); guide->point_on_line = Geom::Point(0.,0.); guide->color = 0x0000ff7f; @@ -156,12 +166,25 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, } } -static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ +//static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ // if (((SPObjectClass *) (parent_class))->build) { // (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); // } - // CPPIFY: todo +// +// object->readAttr( "inkscape:label" ); +// object->readAttr( "orientation" ); +// object->readAttr( "position" ); +// +// /* Register */ +// document->addResource("guide", object); +// ((SPGuide*)object)->cguide->onBuild(document, repr); +//} + +void CGuide::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + CObject::onBuild(document, repr); + + SPGuide* object = this->spguide; object->readAttr( "inkscape:label" ); object->readAttr( "orientation" ); @@ -173,6 +196,26 @@ static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML static void sp_guide_release(SPObject *object) { +// SPGuide *guide = (SPGuide *) object; +// +// while (guide->views) { +// sp_guideline_delete(SP_GUIDELINE(guide->views->data)); +// guide->views = g_slist_remove(guide->views, guide->views->data); +// } +// +// if (object->document) { +// // Unregister ourselves +// object->document->removeResource("guide", object); +// } +// +// if (((SPObjectClass *) parent_class)->release) { +// ((SPObjectClass *) parent_class)->release(object); +// } + ((SPGuide*)object)->cguide->onRelease(); +} + +void CGuide::onRelease() { + SPGuide* object = this->spguide; SPGuide *guide = (SPGuide *) object; while (guide->views) { @@ -185,13 +228,93 @@ static void sp_guide_release(SPObject *object) object->document->removeResource("guide", object); } - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); - } +// if (((SPObjectClass *) parent_class)->release) { +// ((SPObjectClass *) parent_class)->release(object); +// } + CObject::onRelease(); } static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) { +// SPGuide *guide = SP_GUIDE(object); +// +// switch (key) { +// case SP_ATTR_INKSCAPE_LABEL: +// if (value) { +// guide->label = g_strdup(value); +// } else { +// guide->label = NULL; +// } +// +// sp_guide_set_label(*guide, guide->label, false); +// break; +// case SP_ATTR_ORIENTATION: +// { +// if (value && !strcmp(value, "horizontal")) { +// /* Visual representation of a horizontal line, constrain vertically (y coordinate). */ +// guide->normal_to_line = Geom::Point(0., 1.); +// } else if (value && !strcmp(value, "vertical")) { +// guide->normal_to_line = Geom::Point(1., 0.); +// } else if (value) { +// gchar ** strarray = g_strsplit(value, ",", 2); +// double newx, newy; +// unsigned int success = sp_svg_number_read_d(strarray[0], &newx); +// success += sp_svg_number_read_d(strarray[1], &newy); +// g_strfreev (strarray); +// if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) { +// Geom::Point direction(newx, newy); +// direction.normalize(); +// guide->normal_to_line = direction; +// } else { +// // default to vertical line for bad arguments +// guide->normal_to_line = Geom::Point(1., 0.); +// } +// } else { +// // default to vertical line for bad arguments +// guide->normal_to_line = Geom::Point(1., 0.); +// } +// sp_guide_set_normal(*guide, guide->normal_to_line, false); +// } +// break; +// case SP_ATTR_POSITION: +// { +// if (value) { +// gchar ** strarray = g_strsplit(value, ",", 2); +// double newx, newy; +// unsigned int success = sp_svg_number_read_d(strarray[0], &newx); +// success += sp_svg_number_read_d(strarray[1], &newy); +// g_strfreev (strarray); +// if (success == 2) { +// guide->point_on_line = Geom::Point(newx, newy); +// } else if (success == 1) { +// // before 0.46 style guideline definition. +// const gchar *attr = object->getRepr()->attribute("orientation"); +// if (attr && !strcmp(attr, "horizontal")) { +// guide->point_on_line = Geom::Point(0, newx); +// } else { +// guide->point_on_line = Geom::Point(newx, 0); +// } +// } +// } else { +// // default to (0,0) for bad arguments +// guide->point_on_line = Geom::Point(0,0); +// } +// // update position in non-committing way +// // fixme: perhaps we need to add an update method instead, and request_update here +// sp_guide_moveto(*guide, guide->point_on_line, false); +// } +// break; +// default: +// if (((SPObjectClass *) (parent_class))->set) { +// ((SPObjectClass *) (parent_class))->set(object, key, value); +// } +// break; +// } + ((SPGuide*)object)->cguide->onSet(key, value); +} + +void CGuide::onSet(unsigned int key, const gchar *value) { + SPGuide* object = this->spguide; SPGuide *guide = SP_GUIDE(object); switch (key) { @@ -261,9 +384,10 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) } break; default: - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); - } +// if (((SPObjectClass *) (parent_class))->set) { +// ((SPObjectClass *) (parent_class))->set(object, key, value); +// } + CObject::onSet(key, value); break; } } -- cgit v1.2.3 From 957c3e4b7909d42c5a13f1b1dd583f877fc32259 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:46:57 +0100 Subject: Removed function pointers from SPObject and subclasses. Added some missing virtual pads for classes that were hidden by preprocessor macros. (bzr r11608.1.55) --- src/sp-guide.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 081a667a3..7b05e04b3 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -96,8 +96,8 @@ static void sp_guide_class_init(SPGuideClass *gc) gobject_class->get_property = sp_guide_get_property; //sp_object_class->build = sp_guide_build; - sp_object_class->release = sp_guide_release; - sp_object_class->set = sp_guide_set; +// sp_object_class->release = sp_guide_release; +// sp_object_class->set = sp_guide_set; g_object_class_install_property(gobject_class, PROP_COLOR, -- cgit v1.2.3 From 7df6616da5ea2debb86838366ddf746841549cdb Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:56:13 +0100 Subject: Renamed virtual function names. (bzr r11608.1.57) --- src/sp-guide.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index a7900909c..c25c44913 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -134,8 +134,8 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, } } -void CGuide::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { - CObject::onBuild(document, repr); +void CGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { + CObject::build(document, repr); SPGuide* object = this->spguide; @@ -147,7 +147,7 @@ void CGuide::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { document->addResource("guide", object); } -void CGuide::onRelease() { +void CGuide::release() { SPGuide* object = this->spguide; SPGuide *guide = (SPGuide *) object; @@ -161,10 +161,10 @@ void CGuide::onRelease() { object->document->removeResource("guide", object); } - CObject::onRelease(); + CObject::release(); } -void CGuide::onSet(unsigned int key, const gchar *value) { +void CGuide::set(unsigned int key, const gchar *value) { SPGuide* object = this->spguide; SPGuide *guide = SP_GUIDE(object); @@ -235,7 +235,7 @@ void CGuide::onSet(unsigned int key, const gchar *value) { } break; default: - CObject::onSet(key, value); + CObject::set(key, value); break; } } -- cgit v1.2.3 From a5d6e692d661f0bf7648e64e8fcb04588bb8f3ab Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 00:07:00 +0200 Subject: Prepared exchange of casting macros. (bzr r11608.1.63) --- src/sp-guide.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index c25c44913..9083a6ef7 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -92,6 +92,7 @@ CGuide::~CGuide() { static void sp_guide_init(SPGuide *guide) { guide->cguide = new CGuide(guide); + guide->typeHierarchy.insert(typeid(SPGuide)); delete guide->cobject; guide->cobject = guide->cguide; -- cgit v1.2.3 From 69f3b6f1abb2bb422935d43262e1e99aab359954 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 01:41:30 +0200 Subject: Added constructors to SP classes. (bzr r11608.1.67) --- src/sp-guide.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 9083a6ef7..c1fbb1d65 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -56,7 +56,7 @@ enum { static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -G_DEFINE_TYPE(SPGuide, sp_guide, SP_TYPE_OBJECT); +G_DEFINE_TYPE(SPGuide, sp_guide, G_TYPE_OBJECT); static void sp_guide_class_init(SPGuideClass *gc) { @@ -89,20 +89,29 @@ CGuide::CGuide(SPGuide* guide) : CObject(guide) { CGuide::~CGuide() { } -static void sp_guide_init(SPGuide *guide) -{ +SPGuide::SPGuide() : SPObject() { + SPGuide* guide = this; + guide->cguide = new CGuide(guide); guide->typeHierarchy.insert(typeid(SPGuide)); delete guide->cobject; guide->cobject = guide->cguide; + guide->label = NULL; + guide->views = NULL; + guide->normal_to_line = Geom::Point(0.,1.); guide->point_on_line = Geom::Point(0.,0.); guide->color = 0x0000ff7f; guide->hicolor = 0xff00007f; } +static void sp_guide_init(SPGuide *guide) +{ + new (guide) SPGuide(); +} + static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/) { SPGuide &guide = *SP_GUIDE(object); -- cgit v1.2.3 From 61003d31ea058fdf94f4f80c753c3e38426f35e4 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 21:07:38 +0200 Subject: Merged FlowX classes. (bzr r11608.1.79) --- src/sp-guide.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index c1fbb1d65..3e3bc257b 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -56,6 +56,16 @@ enum { static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +#include "sp-factory.h" + +namespace { + SPGuide* createGuide() { + return new SPGuide(); + } + + bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide); +} + G_DEFINE_TYPE(SPGuide, sp_guide, G_TYPE_OBJECT); static void sp_guide_class_init(SPGuideClass *gc) -- cgit v1.2.3 From 7b7e0294b0c06a8d3ec19b73486a91e12cf67adf Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 6 Apr 2013 22:16:05 +0200 Subject: Merged more classes. (bzr r11608.1.84) --- src/sp-guide.cpp | 101 +++++++++++++++++++++++-------------------------------- 1 file changed, 43 insertions(+), 58 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 3e3bc257b..970ba25ba 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -66,60 +66,45 @@ namespace { bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide); } -G_DEFINE_TYPE(SPGuide, sp_guide, G_TYPE_OBJECT); - -static void sp_guide_class_init(SPGuideClass *gc) -{ - GObjectClass *gobject_class = (GObjectClass *) gc; - - gobject_class->set_property = sp_guide_set_property; - gobject_class->get_property = sp_guide_get_property; - - g_object_class_install_property(gobject_class, - PROP_COLOR, - g_param_spec_uint("color", "Color", "Color", - 0, - 0xffffffff, - 0xff000000, - (GParamFlags) G_PARAM_READWRITE)); - - g_object_class_install_property(gobject_class, - PROP_HICOLOR, - g_param_spec_uint("hicolor", "HiColor", "HiColor", - 0, - 0xffffffff, - 0xff000000, - (GParamFlags) G_PARAM_READWRITE)); -} - -CGuide::CGuide(SPGuide* guide) : CObject(guide) { - this->spguide = guide; +//static void sp_guide_class_init(SPGuideClass *gc) +//{ +// GObjectClass *gobject_class = (GObjectClass *) gc; +// +// gobject_class->set_property = sp_guide_set_property; +// gobject_class->get_property = sp_guide_get_property; +// +// g_object_class_install_property(gobject_class, +// PROP_COLOR, +// g_param_spec_uint("color", "Color", "Color", +// 0, +// 0xffffffff, +// 0xff000000, +// (GParamFlags) G_PARAM_READWRITE)); +// +// g_object_class_install_property(gobject_class, +// PROP_HICOLOR, +// g_param_spec_uint("hicolor", "HiColor", "HiColor", +// 0, +// 0xffffffff, +// 0xff000000, +// (GParamFlags) G_PARAM_READWRITE)); +//} +// CPPIFY: properties! + +SPGuide::SPGuide() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; + + this->label = NULL; + this->views = NULL; + + this->normal_to_line = Geom::Point(0.,1.); + this->point_on_line = Geom::Point(0.,0.); + this->color = 0x0000ff7f; + this->hicolor = 0xff00007f; } -CGuide::~CGuide() { -} - -SPGuide::SPGuide() : SPObject() { - SPGuide* guide = this; - - guide->cguide = new CGuide(guide); - guide->typeHierarchy.insert(typeid(SPGuide)); - - delete guide->cobject; - guide->cobject = guide->cguide; - - guide->label = NULL; - guide->views = NULL; - - guide->normal_to_line = Geom::Point(0.,1.); - guide->point_on_line = Geom::Point(0.,0.); - guide->color = 0x0000ff7f; - guide->hicolor = 0xff00007f; -} - -static void sp_guide_init(SPGuide *guide) -{ - new (guide) SPGuide(); +SPGuide::~SPGuide() { } static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/) @@ -154,10 +139,10 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, } } -void CGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPGuide* object = this->spguide; + SPGuide* object = this; object->readAttr( "inkscape:label" ); object->readAttr( "orientation" ); @@ -167,8 +152,8 @@ void CGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { document->addResource("guide", object); } -void CGuide::release() { - SPGuide* object = this->spguide; +void SPGuide::release() { + SPGuide* object = this; SPGuide *guide = (SPGuide *) object; while (guide->views) { @@ -184,8 +169,8 @@ void CGuide::release() { CObject::release(); } -void CGuide::set(unsigned int key, const gchar *value) { - SPGuide* object = this->spguide; +void SPGuide::set(unsigned int key, const gchar *value) { + SPGuide* object = this; SPGuide *guide = SP_GUIDE(object); switch (key) { -- cgit v1.2.3 From 27e2102f96a5554bcd5310ec11435d155773b279 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 7 Apr 2013 18:28:22 +0200 Subject: Merge Object and subclasses. Merging of SP- and C-classes complete. (bzr r11608.1.86) --- src/sp-guide.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 970ba25ba..3182195ff 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -91,10 +91,7 @@ namespace { //} // CPPIFY: properties! -SPGuide::SPGuide() : SPObject(), CObject(this) { - delete this->cobject; - this->cobject = this; - +SPGuide::SPGuide() : SPObject() { this->label = NULL; this->views = NULL; @@ -140,7 +137,7 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, } void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { - CObject::build(document, repr); + SPObject::build(document, repr); SPGuide* object = this; @@ -166,7 +163,7 @@ void SPGuide::release() { object->document->removeResource("guide", object); } - CObject::release(); + SPObject::release(); } void SPGuide::set(unsigned int key, const gchar *value) { @@ -240,7 +237,7 @@ void SPGuide::set(unsigned int key, const gchar *value) { } break; default: - CObject::set(key, value); + SPObject::set(key, value); break; } } -- cgit v1.2.3 From fbb85064cfaaf03cc09bacedb16a8561f61f2b3d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 00:37:18 +0200 Subject: Added prefPaths to contexts; modified SPFactory (bzr r11608.1.94) --- src/sp-guide.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 3182195ff..4fc6e34bb 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -59,7 +59,7 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, #include "sp-factory.h" namespace { - SPGuide* createGuide() { + SPObject* createGuide() { return new SPGuide(); } -- cgit v1.2.3 From 49c324545e713c1ca375b7e559418e02ebe52945 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 1 Aug 2013 01:06:31 +0200 Subject: Replacement of unnecessary variables. (bzr r11608.1.114) --- src/sp-guide.cpp | 56 ++++++++++++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 4fc6e34bb..b0f4aab49 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -139,54 +139,46 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { SPObject::build(document, repr); - SPGuide* object = this; - - object->readAttr( "inkscape:label" ); - object->readAttr( "orientation" ); - object->readAttr( "position" ); + this->readAttr( "inkscape:label" ); + this->readAttr( "orientation" ); + this->readAttr( "position" ); /* Register */ - document->addResource("guide", object); + document->addResource("guide", this); } void SPGuide::release() { - SPGuide* object = this; - SPGuide *guide = (SPGuide *) object; - - while (guide->views) { - sp_guideline_delete(SP_GUIDELINE(guide->views->data)); - guide->views = g_slist_remove(guide->views, guide->views->data); + while (this->views) { + sp_guideline_delete(SP_GUIDELINE(this->views->data)); + this->views = g_slist_remove(this->views, this->views->data); } - if (object->document) { + if (this->document) { // Unregister ourselves - object->document->removeResource("guide", object); + this->document->removeResource("guide", this); } SPObject::release(); } void SPGuide::set(unsigned int key, const gchar *value) { - SPGuide* object = this; - SPGuide *guide = SP_GUIDE(object); - switch (key) { case SP_ATTR_INKSCAPE_LABEL: if (value) { - guide->label = g_strdup(value); + this->label = g_strdup(value); } else { - guide->label = NULL; + this->label = NULL; } - sp_guide_set_label(*guide, guide->label, false); + sp_guide_set_label(*this, this->label, false); break; case SP_ATTR_ORIENTATION: { if (value && !strcmp(value, "horizontal")) { /* Visual representation of a horizontal line, constrain vertically (y coordinate). */ - guide->normal_to_line = Geom::Point(0., 1.); + this->normal_to_line = Geom::Point(0., 1.); } else if (value && !strcmp(value, "vertical")) { - guide->normal_to_line = Geom::Point(1., 0.); + this->normal_to_line = Geom::Point(1., 0.); } else if (value) { gchar ** strarray = g_strsplit(value, ",", 2); double newx, newy; @@ -196,16 +188,16 @@ void SPGuide::set(unsigned int key, const gchar *value) { if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) { Geom::Point direction(newx, newy); direction.normalize(); - guide->normal_to_line = direction; + this->normal_to_line = direction; } else { // default to vertical line for bad arguments - guide->normal_to_line = Geom::Point(1., 0.); + this->normal_to_line = Geom::Point(1., 0.); } } else { // default to vertical line for bad arguments - guide->normal_to_line = Geom::Point(1., 0.); + this->normal_to_line = Geom::Point(1., 0.); } - sp_guide_set_normal(*guide, guide->normal_to_line, false); + sp_guide_set_normal(*this, this->normal_to_line, false); } break; case SP_ATTR_POSITION: @@ -217,23 +209,23 @@ void SPGuide::set(unsigned int key, const gchar *value) { success += sp_svg_number_read_d(strarray[1], &newy); g_strfreev (strarray); if (success == 2) { - guide->point_on_line = Geom::Point(newx, newy); + this->point_on_line = Geom::Point(newx, newy); } else if (success == 1) { // before 0.46 style guideline definition. - const gchar *attr = object->getRepr()->attribute("orientation"); + const gchar *attr = this->getRepr()->attribute("orientation"); if (attr && !strcmp(attr, "horizontal")) { - guide->point_on_line = Geom::Point(0, newx); + this->point_on_line = Geom::Point(0, newx); } else { - guide->point_on_line = Geom::Point(newx, 0); + this->point_on_line = Geom::Point(newx, 0); } } } else { // default to (0,0) for bad arguments - guide->point_on_line = Geom::Point(0,0); + this->point_on_line = Geom::Point(0,0); } // update position in non-committing way // fixme: perhaps we need to add an update method instead, and request_update here - sp_guide_moveto(*guide, guide->point_on_line, false); + sp_guide_moveto(*this, this->point_on_line, false); } break; default: -- cgit v1.2.3 From db53a4b489fbcf45eee9f54a0b1231e6092374dc Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 1 Aug 2013 14:35:39 +0200 Subject: Fixed more mismatched-tags; replaced GObject-properties in SPGuide (bzr r11608.1.115) --- src/sp-guide.cpp | 88 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 34 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index b0f4aab49..36989e0c9 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -47,14 +47,14 @@ using Inkscape::DocumentUndo; using std::vector; -enum { - PROP_0, - PROP_COLOR, - PROP_HICOLOR -}; - -static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +//enum { +// PROP_0, +// PROP_COLOR, +// PROP_HICOLOR +//}; +// +//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); #include "sp-factory.h" @@ -104,38 +104,58 @@ SPGuide::SPGuide() : SPObject() { SPGuide::~SPGuide() { } -static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/) -{ - SPGuide &guide = *SP_GUIDE(object); - - switch (prop_id) { - case PROP_COLOR: - guide.color = g_value_get_uint(value); - for (GSList *l = guide.views; l != NULL; l = l->next) { - sp_guideline_set_color(SP_GUIDELINE(l->data), guide.color); - } - break; +guint32 SPGuide::getColor() const { + return color; +} - case PROP_HICOLOR: - guide.hicolor = g_value_get_uint(value); - break; - } +guint32 SPGuide::getHiColor() const { + return hicolor; } -static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec */*pspec*/) -{ - SPGuide const &guide = *SP_GUIDE(object); +void SPGuide::setColor(guint32 c) { + color = c; - switch (prop_id) { - case PROP_COLOR: - g_value_set_uint(value, guide.color); - break; - case PROP_HICOLOR: - g_value_set_uint(value, guide.hicolor); - break; - } + for (GSList *l = this->views; l != NULL; l = l->next) { + sp_guideline_set_color(SP_GUIDELINE(l->data), this->color); + } +} + +void SPGuide::setHiColor(guint32 h) { + this->hicolor = h; } +//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/) +//{ +// SPGuide &guide = *SP_GUIDE(object); +// +// switch (prop_id) { +// case PROP_COLOR: +// guide.color = g_value_get_uint(value); +// for (GSList *l = guide.views; l != NULL; l = l->next) { +// sp_guideline_set_color(SP_GUIDELINE(l->data), guide.color); +// } +// break; +// +// case PROP_HICOLOR: +// guide.hicolor = g_value_get_uint(value); +// break; +// } +//} +// +//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec */*pspec*/) +//{ +// SPGuide const &guide = *SP_GUIDE(object); +// +// switch (prop_id) { +// case PROP_COLOR: +// g_value_set_uint(value, guide.color); +// break; +// case PROP_HICOLOR: +// g_value_set_uint(value, guide.hicolor); +// break; +// } +//} + void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { SPObject::build(document, repr); -- cgit v1.2.3