From 66722de028e8cf18dfa3cfe302645a4a89dc1b2d Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sun, 15 Apr 2007 20:57:15 +0000 Subject: [PATCH] When no grid is defined but "toggle grid" is pressed => create a default rectangular grid --- src/desktop.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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)); } } -- 2.30.2