diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-07-06 16:43:38 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-07-06 16:43:38 +0000 |
| commit | 49d1acd3a9813ad7a8fda3d204a30401cb35d8fd (patch) | |
| tree | b74755bcefb028fbbd3831dacd47342429cebdef /src/display | |
| parent | Fix for bug #1740146: always get current namedview, because it might have cha... (diff) | |
| download | inkscape-49d1acd3a9813ad7a8fda3d204a30401cb35d8fd.tar.gz inkscape-49d1acd3a9813ad7a8fda3d204a30401cb35d8fd.zip | |
Fix #1740146.
(bzr r3190)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/canvas-axonomgrid.cpp | 22 | ||||
| -rw-r--r-- | src/display/canvas-axonomgrid.h | 2 | ||||
| -rw-r--r-- | src/display/canvas-grid.cpp | 45 | ||||
| -rw-r--r-- | src/display/canvas-grid.h | 10 |
4 files changed, 43 insertions, 36 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 311c56f44..17fa97281 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -195,8 +195,8 @@ attach_all (Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int star } } -CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr) - : CanvasGrid(nv, in_repr), table(1, 1) +CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc) + : CanvasGrid(nv, in_repr, in_doc), table(1, 1) { origin[NR::X] = origin[NR::Y] = 0.0; @@ -223,23 +223,23 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r table.set_spacings(2); vbox.pack_start(table, false, false, 0); - _rumg.init (_("Grid _units:"), "units", _wr, repr); + _rumg.init (_("Grid _units:"), "units", _wr, repr, doc); _rsu_ox.init (_("_Origin X:"), _("X coordinate of grid origin"), - "originx", _rumg, _wr, repr); + "originx", _rumg, _wr, repr, doc); _rsu_oy.init (_("O_rigin Y:"), _("Y coordinate of grid origin"), - "originy", _rumg, _wr, repr); + "originy", _rumg, _wr, repr, doc); _rsu_sy.init (_("Spacing _Y:"), _("Base length of z-axis"), - "spacingy", _rumg, _wr, repr); + "spacingy", _rumg, _wr, repr, doc); _rsu_ax.init (_("Angle X:"), _("Angle of x-axis"), - "gridanglex", _rumg, _wr, repr); + "gridanglex", _rumg, _wr, repr, doc); _rsu_az.init (_("Angle Z:"), _("Angle of z-axis"), - "gridanglez", _rumg, _wr, repr); + "gridanglez", _rumg, _wr, repr, doc); _rcp_gcol.init (_("Grid line _color:"), _("Grid line color"), - _("Color of grid lines"), "color", "opacity", _wr, repr); + _("Color of grid lines"), "color", "opacity", _wr, repr, doc); _rcp_gmcol.init (_("Ma_jor grid line color:"), _("Major grid line color"), _("Color of the major (highlighted) grid lines"), - "empcolor", "empopacity", _wr, repr); - _rsi.init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr); + "empcolor", "empopacity", _wr, repr, doc); + _rsi.init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc); const Gtk::Widget* widget_array[] = { diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 0eaf914de..157982416 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -33,7 +33,7 @@ namespace Inkscape { class CanvasAxonomGrid : public CanvasGrid { public: - CanvasAxonomGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr); + CanvasAxonomGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc); ~CanvasAxonomGrid(); void Update (NR::Matrix const &affine, unsigned int flags); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index e1cafb1fd..6c97e2605 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -150,9 +150,10 @@ grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i NULL /* order_changed */ }; -CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr) +CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc) { repr = in_repr; + doc = in_doc; if (repr) { repr->addListener (&_repr_events, this); } @@ -216,37 +217,41 @@ CanvasGrid::getGridTypeFromName(const char * typestr) * writes an <inkscape:grid> child to repr. */ void -CanvasGrid::writeNewGridToRepr(Inkscape::XML::Node * repr, GridType gridtype) +CanvasGrid::writeNewGridToRepr(Inkscape::XML::Node * repr, SPDocument * doc, GridType gridtype) { if (!repr) return; if (gridtype > GRID_MAXTYPENR) return; // first create the child xml node, then hook it to repr. This order is important, to not set off listeners to repr before the new node is complete. - SPDocument *current_document = sp_desktop_document(SP_ACTIVE_DESKTOP); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node *newnode; newnode = xml_doc->createElement("inkscape:grid"); newnode->setAttribute("type", getSVGName(gridtype)); repr->appendChild(newnode); +// Inkscape::GC::release(repr); FIX THIS. THIS SHOULD BE HERE!!! - sp_document_done(current_document, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid")); + sp_document_done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid")); } /* * Creates a new CanvasGrid object of type gridtype */ CanvasGrid* -CanvasGrid::NewGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, GridType gridtype) +CanvasGrid::NewGrid(SPNamedView * nv, Inkscape::XML::Node * repr, SPDocument * doc, GridType gridtype) { - if (!in_repr) return NULL; + if (!repr) return NULL; + if (!doc) { + g_error("CanvasGrid::NewGrid - doc==NULL"); + return NULL; + } switch (gridtype) { case GRID_RECTANGULAR: - return (CanvasGrid*) new CanvasXYGrid(nv, in_repr); + return (CanvasGrid*) new CanvasXYGrid(nv, repr, doc); case GRID_AXONOMETRIC: - return (CanvasGrid*) new CanvasAxonomGrid(nv, in_repr); + return (CanvasGrid*) new CanvasAxonomGrid(nv, repr, doc); } return NULL; @@ -342,8 +347,8 @@ attach_all (Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int star } } -CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr) - : CanvasGrid(nv, in_repr), table(1, 1) +CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc) + : CanvasGrid(nv, in_repr, in_doc), table(1, 1) { origin[NR::X] = origin[NR::Y] = 0.0; color = DEFAULTGRIDCOLOR; @@ -360,24 +365,24 @@ CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr) table.set_spacings(2); vbox.pack_start(table, false, false, 0); - _rumg.init (_("Grid _units:"), "units", _wr, repr); + _rumg.init (_("Grid _units:"), "units", _wr, repr, doc); _rsu_ox.init (_("_Origin X:"), _("X coordinate of grid origin"), - "originx", _rumg, _wr, repr); + "originx", _rumg, _wr, repr, doc); _rsu_oy.init (_("O_rigin Y:"), _("Y coordinate of grid origin"), - "originy", _rumg, _wr, repr); + "originy", _rumg, _wr, repr, doc); _rsu_sx.init (_("Spacing _X:"), _("Distance between vertical grid lines"), - "spacingx", _rumg, _wr, repr); + "spacingx", _rumg, _wr, repr, doc); _rsu_sy.init (_("Spacing _Y:"), _("Distance between horizontal grid lines"), - "spacingy", _rumg, _wr, repr); + "spacingy", _rumg, _wr, repr, doc); _rcp_gcol.init (_("Grid line _color:"), _("Grid line color"), - _("Color of grid lines"), "color", "opacity", _wr, repr); + _("Color of grid lines"), "color", "opacity", _wr, repr, doc); _rcp_gmcol.init (_("Ma_jor grid line color:"), _("Major grid line color"), _("Color of the major (highlighted) grid lines"), - "empcolor", "empopacity", _wr, repr); - _rsi.init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr); + "empcolor", "empopacity", _wr, repr, doc); + _rsi.init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc); _rcb_dotted.init ( _("_Show dots instead of lines"), _("If set, displays dots at gridpoints instead of gridlines"), - "dotted", _wr, false, repr); + "dotted", _wr, false, repr, doc); const Gtk::Widget* widget_array[] = { diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 046653df2..f3ffd7137 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -31,6 +31,7 @@ struct SPDesktop; struct SPNamedView; +class SPDocument; namespace Inkscape { @@ -66,7 +67,7 @@ GtkType grid_canvasitem_get_type (void); class CanvasGrid { public: - CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr); + CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc); virtual ~CanvasGrid(); static const char * getName(GridType type); @@ -74,8 +75,8 @@ public: static GridType getGridTypeFromSVGName(const char * typestr); static GridType getGridTypeFromName(const char * typestr); - static CanvasGrid* NewGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, GridType gridtype); - static void writeNewGridToRepr(Inkscape::XML::Node * repr, GridType gridtype); + static CanvasGrid* NewGrid(SPNamedView * nv, Inkscape::XML::Node * repr, SPDocument *doc, GridType gridtype); + static void writeNewGridToRepr(Inkscape::XML::Node * repr, SPDocument * doc, GridType gridtype); GridCanvasItem * createCanvasItem(SPDesktop * desktop); @@ -88,6 +89,7 @@ public: virtual Gtk::Widget & getWidget() = 0; Inkscape::XML::Node * repr; + SPDocument *doc; Inkscape::Snapper* snapper; @@ -109,7 +111,7 @@ private: class CanvasXYGrid : public CanvasGrid { public: - CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr); + CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc); ~CanvasXYGrid(); void Update (NR::Matrix const &affine, unsigned int flags); |
