diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-08-03 01:03:43 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-08-03 01:03:43 +0000 |
| commit | bf4a1d2d49850170b936c30cfe2b30e798716406 (patch) | |
| tree | 2632b534325df2eb92933f428979eeb8f5c52225 /src/sp-namedview.cpp | |
| parent | reordered SPDesktop::set_event_context2; fixed last mismatched-tags (diff) | |
| download | inkscape-bf4a1d2d49850170b936c30cfe2b30e798716406.tar.gz inkscape-bf4a1d2d49850170b936c30cfe2b30e798716406.zip | |
Cleaned up.
(bzr r11608.1.117)
Diffstat (limited to 'src/sp-namedview.cpp')
| -rw-r--r-- | src/sp-namedview.cpp | 453 |
1 files changed, 217 insertions, 236 deletions
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 576de312f..14cc7669d 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -97,8 +97,6 @@ SPNamedView::SPNamedView() : SPObjectGroup(), snap_manager(this) { this->default_layer_id = 0; this->connector_spacing = defaultConnSpacing; - - //new (&this->snap_manager) SnapManager(this); } SPNamedView::~SPNamedView() { @@ -193,366 +191,352 @@ static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *doc } void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPNamedView* object = this; - - SPNamedView *nv = (SPNamedView *) object; - SPObjectGroup *og = (SPObjectGroup *) object; - SPObjectGroup::build(document, repr); - object->readAttr( "inkscape:document-units" ); - object->readAttr( "units" ); - object->readAttr( "viewonly" ); - object->readAttr( "showguides" ); - object->readAttr( "showgrid" ); - object->readAttr( "gridtolerance" ); - object->readAttr( "guidetolerance" ); - object->readAttr( "objecttolerance" ); - object->readAttr( "guidecolor" ); - object->readAttr( "guideopacity" ); - object->readAttr( "guidehicolor" ); - object->readAttr( "guidehiopacity" ); - object->readAttr( "showborder" ); - object->readAttr( "inkscape:showpageshadow" ); - object->readAttr( "borderlayer" ); - object->readAttr( "bordercolor" ); - object->readAttr( "borderopacity" ); - object->readAttr( "pagecolor" ); - object->readAttr( "inkscape:pageopacity" ); - object->readAttr( "inkscape:pageshadow" ); - object->readAttr( "inkscape:zoom" ); - object->readAttr( "inkscape:cx" ); - object->readAttr( "inkscape:cy" ); - object->readAttr( "inkscape:window-width" ); - object->readAttr( "inkscape:window-height" ); - object->readAttr( "inkscape:window-x" ); - object->readAttr( "inkscape:window-y" ); - object->readAttr( "inkscape:window-maximized" ); - object->readAttr( "inkscape:snap-global" ); - object->readAttr( "inkscape:snap-bbox" ); - object->readAttr( "inkscape:snap-nodes" ); - object->readAttr( "inkscape:snap-others" ); - object->readAttr( "inkscape:snap-from-guide" ); - object->readAttr( "inkscape:snap-center" ); - object->readAttr( "inkscape:snap-smooth-nodes" ); - object->readAttr( "inkscape:snap-midpoints" ); - object->readAttr( "inkscape:snap-object-midpoints" ); - object->readAttr( "inkscape:snap-text-baseline" ); - object->readAttr( "inkscape:snap-bbox-edge-midpoints" ); - object->readAttr( "inkscape:snap-bbox-midpoints" ); - object->readAttr( "inkscape:snap-to-guides" ); - object->readAttr( "inkscape:snap-grids" ); - object->readAttr( "inkscape:snap-intersection-paths" ); - object->readAttr( "inkscape:object-paths" ); - object->readAttr( "inkscape:snap-perpendicular" ); - object->readAttr( "inkscape:snap-tangential" ); - object->readAttr( "inkscape:snap-path-clip" ); - object->readAttr( "inkscape:snap-path-mask" ); - object->readAttr( "inkscape:object-nodes" ); - object->readAttr( "inkscape:bbox-paths" ); - object->readAttr( "inkscape:bbox-nodes" ); - object->readAttr( "inkscape:snap-page" ); - object->readAttr( "inkscape:current-layer" ); - object->readAttr( "inkscape:connector-spacing" ); + this->readAttr( "inkscape:document-units" ); + this->readAttr( "units" ); + this->readAttr( "viewonly" ); + this->readAttr( "showguides" ); + this->readAttr( "showgrid" ); + this->readAttr( "gridtolerance" ); + this->readAttr( "guidetolerance" ); + this->readAttr( "objecttolerance" ); + this->readAttr( "guidecolor" ); + this->readAttr( "guideopacity" ); + this->readAttr( "guidehicolor" ); + this->readAttr( "guidehiopacity" ); + this->readAttr( "showborder" ); + this->readAttr( "inkscape:showpageshadow" ); + this->readAttr( "borderlayer" ); + this->readAttr( "bordercolor" ); + this->readAttr( "borderopacity" ); + this->readAttr( "pagecolor" ); + this->readAttr( "inkscape:pageopacity" ); + this->readAttr( "inkscape:pageshadow" ); + this->readAttr( "inkscape:zoom" ); + this->readAttr( "inkscape:cx" ); + this->readAttr( "inkscape:cy" ); + this->readAttr( "inkscape:window-width" ); + this->readAttr( "inkscape:window-height" ); + this->readAttr( "inkscape:window-x" ); + this->readAttr( "inkscape:window-y" ); + this->readAttr( "inkscape:window-maximized" ); + this->readAttr( "inkscape:snap-global" ); + this->readAttr( "inkscape:snap-bbox" ); + this->readAttr( "inkscape:snap-nodes" ); + this->readAttr( "inkscape:snap-others" ); + this->readAttr( "inkscape:snap-from-guide" ); + this->readAttr( "inkscape:snap-center" ); + this->readAttr( "inkscape:snap-smooth-nodes" ); + this->readAttr( "inkscape:snap-midpoints" ); + this->readAttr( "inkscape:snap-object-midpoints" ); + this->readAttr( "inkscape:snap-text-baseline" ); + this->readAttr( "inkscape:snap-bbox-edge-midpoints" ); + this->readAttr( "inkscape:snap-bbox-midpoints" ); + this->readAttr( "inkscape:snap-to-guides" ); + this->readAttr( "inkscape:snap-grids" ); + this->readAttr( "inkscape:snap-intersection-paths" ); + this->readAttr( "inkscape:object-paths" ); + this->readAttr( "inkscape:snap-perpendicular" ); + this->readAttr( "inkscape:snap-tangential" ); + this->readAttr( "inkscape:snap-path-clip" ); + this->readAttr( "inkscape:snap-path-mask" ); + this->readAttr( "inkscape:object-nodes" ); + this->readAttr( "inkscape:bbox-paths" ); + this->readAttr( "inkscape:bbox-nodes" ); + this->readAttr( "inkscape:snap-page" ); + this->readAttr( "inkscape:current-layer" ); + this->readAttr( "inkscape:connector-spacing" ); /* Construct guideline list */ - for (SPObject *o = og->firstChild() ; o; o = o->getNext() ) { + for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) { if (SP_IS_GUIDE(o)) { SPGuide * g = SP_GUIDE(o); - nv->guides = g_slist_prepend(nv->guides, g); + this->guides = g_slist_prepend(this->guides, g); //g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); - g->setColor(nv->guidecolor); - g->setHiColor(nv->guidehicolor); + g->setColor(this->guidecolor); + g->setHiColor(this->guidehicolor); } } // backwards compatibility with grid settings (pre 0.46) - sp_namedview_generate_old_grid(nv, document, repr); + sp_namedview_generate_old_grid(this, document, repr); } void SPNamedView::release() { - SPNamedView* object = this; - SPNamedView *namedview = (SPNamedView *) object; - - if (namedview->guides) { - g_slist_free(namedview->guides); - namedview->guides = NULL; + if (this->guides) { + g_slist_free(this->guides); + this->guides = NULL; } // delete grids: - while ( namedview->grids ) { - Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data; // get first entry + while ( this->grids ) { + Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)this->grids->data; // get first entry delete gr; - namedview->grids = g_slist_remove_link(namedview->grids, namedview->grids); // deletes first entry + this->grids = g_slist_remove_link(this->grids, this->grids); // deletes first entry } SPObjectGroup::release(); - - //namedview->snap_manager.~SnapManager(); } void SPNamedView::set(unsigned int key, const gchar* value) { - SPNamedView* object = this; - - SPNamedView *nv = SP_NAMEDVIEW(object); - switch (key) { case SP_ATTR_VIEWONLY: - nv->editable = (!value); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->editable = (!value); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SHOWGUIDES: if (!value) { // show guides if not specified, for backwards compatibility - nv->showguides = TRUE; + this->showguides = TRUE; } else { - nv->showguides = sp_str_to_bool(value); + this->showguides = sp_str_to_bool(value); } - sp_namedview_setup_guides(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + sp_namedview_setup_guides(this); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SHOWGRIDS: if (!value) { // don't show grids if not specified, for backwards compatibility - nv->grids_visible = false; + this->grids_visible = false; } else { - nv->grids_visible = sp_str_to_bool(value); + this->grids_visible = sp_str_to_bool(value); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GRIDTOLERANCE: - nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDETOLERANCE: - nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_OBJECTTOLERANCE: - nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDECOLOR: - nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00); + this->guidecolor = (this->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00); if (value) { - nv->guidecolor = (nv->guidecolor & 0xff) | sp_svg_read_color(value, nv->guidecolor); + this->guidecolor = (this->guidecolor & 0xff) | sp_svg_read_color(value, this->guidecolor); } - for (GSList *l = nv->guides; l != NULL; l = l->next) { + for (GSList *l = this->guides; l != NULL; l = l->next) { //g_object_set(G_OBJECT(l->data), "color", nv->guidecolor, NULL); - SP_GUIDE(l->data)->setColor(nv->guidecolor); + SP_GUIDE(l->data)->setColor(this->guidecolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDEOPACITY: - nv->guidecolor = (nv->guidecolor & 0xffffff00) | (DEFAULTGUIDECOLOR & 0xff); - sp_nv_read_opacity(value, &nv->guidecolor); + this->guidecolor = (this->guidecolor & 0xffffff00) | (DEFAULTGUIDECOLOR & 0xff); + sp_nv_read_opacity(value, &this->guidecolor); - for (GSList *l = nv->guides; l != NULL; l = l->next) { + for (GSList *l = this->guides; l != NULL; l = l->next) { //g_object_set(G_OBJECT(l->data), "color", nv->guidecolor, NULL); - SP_GUIDE(l->data)->setColor(nv->guidecolor); + SP_GUIDE(l->data)->setColor(this->guidecolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDEHICOLOR: - nv->guidehicolor = (nv->guidehicolor & 0xff) | (DEFAULTGUIDEHICOLOR & 0xffffff00); + this->guidehicolor = (this->guidehicolor & 0xff) | (DEFAULTGUIDEHICOLOR & 0xffffff00); if (value) { - nv->guidehicolor = (nv->guidehicolor & 0xff) | sp_svg_read_color(value, nv->guidehicolor); + this->guidehicolor = (this->guidehicolor & 0xff) | sp_svg_read_color(value, this->guidehicolor); } - for (GSList *l = nv->guides; l != NULL; l = l->next) { + for (GSList *l = this->guides; l != NULL; l = l->next) { //g_object_set(G_OBJECT(l->data), "hicolor", nv->guidehicolor, NULL); - SP_GUIDE(l->data)->setHiColor(nv->guidehicolor); + SP_GUIDE(l->data)->setHiColor(this->guidehicolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDEHIOPACITY: - nv->guidehicolor = (nv->guidehicolor & 0xffffff00) | (DEFAULTGUIDEHICOLOR & 0xff); - sp_nv_read_opacity(value, &nv->guidehicolor); + this->guidehicolor = (this->guidehicolor & 0xffffff00) | (DEFAULTGUIDEHICOLOR & 0xff); + sp_nv_read_opacity(value, &this->guidehicolor); - for (GSList *l = nv->guides; l != NULL; l = l->next) { + for (GSList *l = this->guides; l != NULL; l = l->next) { //g_object_set(G_OBJECT(l->data), "hicolor", nv->guidehicolor, NULL); - SP_GUIDE(l->data)->setHiColor(nv->guidehicolor); + SP_GUIDE(l->data)->setHiColor(this->guidehicolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SHOWBORDER: - nv->showborder = (value) ? sp_str_to_bool (value) : TRUE; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->showborder = (value) ? sp_str_to_bool (value) : TRUE; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_BORDERLAYER: - nv->borderlayer = SP_BORDER_LAYER_BOTTOM; - if (value && !strcasecmp(value, "true")) nv->borderlayer = SP_BORDER_LAYER_TOP; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->borderlayer = SP_BORDER_LAYER_BOTTOM; + if (value && !strcasecmp(value, "true")) this->borderlayer = SP_BORDER_LAYER_TOP; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_BORDERCOLOR: - nv->bordercolor = (nv->bordercolor & 0xff) | (DEFAULTBORDERCOLOR & 0xffffff00); + this->bordercolor = (this->bordercolor & 0xff) | (DEFAULTBORDERCOLOR & 0xffffff00); if (value) { - nv->bordercolor = (nv->bordercolor & 0xff) | sp_svg_read_color (value, nv->bordercolor); + this->bordercolor = (this->bordercolor & 0xff) | sp_svg_read_color (value, this->bordercolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_BORDEROPACITY: - nv->bordercolor = (nv->bordercolor & 0xffffff00) | (DEFAULTBORDERCOLOR & 0xff); - sp_nv_read_opacity(value, &nv->bordercolor); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->bordercolor = (this->bordercolor & 0xffffff00) | (DEFAULTBORDERCOLOR & 0xff); + sp_nv_read_opacity(value, &this->bordercolor); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_PAGECOLOR: - nv->pagecolor = (nv->pagecolor & 0xff) | (DEFAULTPAGECOLOR & 0xffffff00); + this->pagecolor = (this->pagecolor & 0xff) | (DEFAULTPAGECOLOR & 0xffffff00); if (value) { - nv->pagecolor = (nv->pagecolor & 0xff) | sp_svg_read_color(value, nv->pagecolor); + this->pagecolor = (this->pagecolor & 0xff) | sp_svg_read_color(value, this->pagecolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_PAGEOPACITY: - nv->pagecolor = (nv->pagecolor & 0xffffff00) | (DEFAULTPAGECOLOR & 0xff); - sp_nv_read_opacity(value, &nv->pagecolor); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->pagecolor = (this->pagecolor & 0xffffff00) | (DEFAULTPAGECOLOR & 0xff); + sp_nv_read_opacity(value, &this->pagecolor); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_PAGESHADOW: - nv->pageshadow = value? atoi(value) : 2; // 2 is the default - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->pageshadow = value? atoi(value) : 2; // 2 is the default + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SHOWPAGESHADOW: - nv->showpageshadow = (value) ? sp_str_to_bool(value) : TRUE; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->showpageshadow = (value) ? sp_str_to_bool(value) : TRUE; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_ZOOM: - nv->zoom = value ? g_ascii_strtod(value, NULL) : 0; // zero means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->zoom = value ? g_ascii_strtod(value, NULL) : 0; // zero means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CX: - nv->cx = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->cx = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CY: - nv->cy = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->cy = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_WIDTH: - nv->window_width = value? atoi(value) : -1; // -1 means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_width = value? atoi(value) : -1; // -1 means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_HEIGHT: - nv->window_height = value ? atoi(value) : -1; // -1 means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_height = value ? atoi(value) : -1; // -1 means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_X: - nv->window_x = value ? atoi(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_x = value ? atoi(value) : 0; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_Y: - nv->window_y = value ? atoi(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_y = value ? atoi(value) : 0; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED: - nv->window_maximized = value ? atoi(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_maximized = value ? atoi(value) : 0; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GLOBAL: - nv->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_NODE: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY, value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY, value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OTHERS: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OTHERS_CATEGORY, value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OTHERS_CATEGORY, value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GRID: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GUIDE: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PATH: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PERP: - nv->snap_manager.snapprefs.setSnapPerp(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setSnapPerp(value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_TANG: - nv->snap_manager.snapprefs.setSnapTang(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setSnapTang(value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PATH_CLIP: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_CLIP, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_CLIP, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PATH_MASK: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_MASK, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_MASK, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CORNER, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CORNER, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PAGE_BORDER: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PAGE_BORDER, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PAGE_BORDER, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CURRENT_LAYER: - nv->default_layer_id = value ? g_quark_from_string(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->default_layer_id = value ? g_quark_from_string(value) : 0; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CONNECTOR_SPACING: - nv->connector_spacing = value ? g_ascii_strtod(value, NULL) : + this->connector_spacing = value ? g_ascii_strtod(value, NULL) : defaultConnSpacing; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_DOCUMENT_UNITS: { /* The default unit if the document doesn't override this: e.g. for files saved as @@ -591,8 +575,8 @@ void SPNamedView::set(unsigned int key, const gchar* value) { /* fixme: Don't use g_log (see above). */ } } - nv->doc_units = new_unit; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->doc_units = new_unit; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } case SP_ATTR_UNITS: { @@ -615,8 +599,8 @@ void SPNamedView::set(unsigned int key, const gchar* value) { /* fixme: Don't use g_log (see above). */ } } - nv->units = new_unit; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->units = new_unit; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } default: @@ -667,34 +651,33 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des } void SPNamedView::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPNamedView* object = this; - - SPNamedView *nv = (SPNamedView *) object; - SPObjectGroup::child_added(child, ref); if (!strcmp(child->name(), "inkscape:grid")) { - sp_namedview_add_grid(nv, child, NULL); + sp_namedview_add_grid(this, child, NULL); } else { - SPObject *no = object->document->getObjectByRepr(child); - if ( !SP_IS_OBJECT(no) ) + SPObject *no = this->document->getObjectByRepr(child); + if ( !SP_IS_OBJECT(no) ) { return; + } if (SP_IS_GUIDE(no)) { SPGuide *g = (SPGuide *) no; - nv->guides = g_slist_prepend(nv->guides, g); + this->guides = g_slist_prepend(this->guides, g); - //g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); - g->setColor(nv->guidecolor); - g->setHiColor(nv->guidehicolor); + //g_object_set(G_OBJECT(g), "color", this->guidecolor, "hicolor", this->guidehicolor, NULL); + g->setColor(this->guidecolor); + g->setHiColor(this->guidehicolor); - if (nv->editable) { - for (GSList *l = nv->views; l != NULL; l = l->next) { + if (this->editable) { + for (GSList *l = this->views; l != NULL; l = l->next) { g->SPGuide::showSPGuide(static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event); - if (static_cast<SPDesktop*>(l->data)->guides_active) - g->sensitize(sp_desktop_canvas(static_cast<SPDesktop*> (l->data)), - TRUE); - sp_namedview_show_single_guide(SP_GUIDE(g), nv->showguides); + + if (static_cast<SPDesktop*>(l->data)->guides_active) { + g->sensitize(sp_desktop_canvas(static_cast<SPDesktop*> (l->data)), TRUE); + } + + sp_namedview_show_single_guide(SP_GUIDE(g), this->showguides); } } } @@ -702,27 +685,27 @@ void SPNamedView::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *r } void SPNamedView::remove_child(Inkscape::XML::Node *child) { - SPNamedView* object = this; - SPNamedView *nv = (SPNamedView *) object; - if (!strcmp(child->name(), "inkscape:grid")) { - for ( GSList *iter = nv->grids ; iter ; iter = iter->next ) { + for ( GSList *iter = this->grids ; iter ; iter = iter->next ) { Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)iter->data; + if ( gr->repr == child ) { delete gr; - nv->grids = g_slist_remove_link(nv->grids, iter); + this->grids = g_slist_remove_link(this->grids, iter); break; } } } else { - GSList **ref = &nv->guides; - for ( GSList *iter = nv->guides ; iter ; iter = iter->next ) { + GSList **ref = &this->guides; + for ( GSList *iter = this->guides ; iter ; iter = iter->next ) { + if ( reinterpret_cast<SPObject *>(iter->data)->getRepr() == child ) { *ref = iter->next; iter->next = NULL; g_slist_free_1(iter); break; } + ref = &iter->next; } } @@ -731,15 +714,13 @@ void SPNamedView::remove_child(Inkscape::XML::Node *child) { } Inkscape::XML::Node* SPNamedView::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPNamedView* object = this; - if ( ( flags & SP_OBJECT_WRITE_EXT ) && - repr != object->getRepr() ) + repr != this->getRepr() ) { if (repr) { - repr->mergeFrom(object->getRepr(), "id"); + repr->mergeFrom(this->getRepr(), "id"); } else { - repr = object->getRepr()->duplicate(xml_doc); + repr = this->getRepr()->duplicate(xml_doc); } } |
