From: johanengelen Date: Sun, 15 Apr 2007 20:57:15 +0000 (+0000) Subject: When no grid is defined but "toggle grid" is pressed => create a default rectangular... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=66722de028e8cf18dfa3cfe302645a4a89dc1b2d;p=inkscape.git When no grid is defined but "toggle grid" is pressed => create a default rectangular grid --- diff --git a/src/desktop.cpp b/src/desktop.cpp index a9c4e5d7f..5ab682cd0 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1105,13 +1105,21 @@ void SPDesktop::clearWaitingCursor() void SPDesktop::toggleGrid() { - if(gridgroup) { - grids_visible = !grids_visible; - if (grids_visible) { - sp_canvas_item_show(SP_CANVAS_ITEM(gridgroup)); - } else { - sp_canvas_item_hide(SP_CANVAS_ITEM(gridgroup)); + if (namedview->grids) { + if(gridgroup) { + grids_visible = !grids_visible; + if (grids_visible) { + sp_canvas_item_show(SP_CANVAS_ITEM(gridgroup)); + } else { + sp_canvas_item_hide(SP_CANVAS_ITEM(gridgroup)); + } } + } else { + //there is no grid present at the moment. add a rectangular grid and make it visible + Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); + Inkscape::CanvasGrid::writeNewGridToRepr(repr, "xygrid"); + grids_visible = true; + sp_canvas_item_show(SP_CANVAS_ITEM(gridgroup)); } }