Code

emf import: redefine the device scale (Bug 341847)
[inkscape.git] / src / sp-namedview.cpp
index 86da7a93a40f5634bc83fceca8d909ca99ec56ec..59ef4762da6f8433a8d804a942bffb82324e7355 100644 (file)
@@ -1,22 +1,25 @@
-#define __SP_NAMEDVIEW_C__
-
 /*
  * <sodipodi:namedview> implementation
  *
  * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   bulia byak <buliabyak@users.sf.net>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006      Johan Engelen <johan@shouraizou.nl>
- * Copyright (C) 1999-2005 Authors
+ * Copyright (C) 1999-2008 Authors
  * Copyright (C) 2000-2001 Ximian, Inc.
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
 #include "config.h"
+#include <cstring>
+#include <string>
 
 #include "display/canvas-grid.h"
+#include "display/guideline.h"
 #include "helper/units.h"
 #include "svg/svg-color.h"
 #include "xml/repr.h"
 #include "sp-guide.h"
 #include "sp-item-group.h"
 #include "sp-namedview.h"
-#include "prefs-utils.h"
+#include "preferences.h"
 #include "desktop.h"
 #include "conn-avoid-ref.h" // for defaultConnSpacing.
 
-#include "isnan.h" //temp fix for isnan().  include last
+using Inkscape::DocumentUndo;
 
-#define DEFAULTTOLERANCE 0.4
 #define DEFAULTGRIDCOLOR 0x3f3fff25
 #define DEFAULTGRIDEMPCOLOR 0x3f3fff60
 #define DEFAULTGRIDEMPSPACING 5
@@ -51,12 +53,12 @@ static void sp_namedview_release(SPObject *object);
 static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *value);
 static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
 static void sp_namedview_remove_child(SPObject *object, Inkscape::XML::Node *child);
-static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
 static void sp_namedview_setup_guides(SPNamedView * nv);
+static void sp_namedview_show_single_guide(SPGuide* guide, bool show);
 
 static gboolean sp_str_to_bool(const gchar *str);
-static gboolean sp_nv_read_length(const gchar *str, guint base, gdouble *val, const SPUnit **unit);
 static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color);
 
 static SPObjectGroupClass * parent_class;
@@ -68,15 +70,15 @@ sp_namedview_get_type()
     if (!namedview_type) {
         GTypeInfo namedview_info = {
             sizeof(SPNamedViewClass),
-            NULL,      /* base_init */
-            NULL,      /* base_finalize */
+            NULL,       /* base_init */
+            NULL,       /* base_finalize */
             (GClassInitFunc) sp_namedview_class_init,
-            NULL,      /* class_finalize */
-            NULL,      /* class_data */
+            NULL,       /* class_finalize */
+            NULL,       /* class_data */
             sizeof(SPNamedView),
-            16,        /* n_preallocs */
+            16, /* n_preallocs */
             (GInstanceInitFunc) sp_namedview_init,
-            NULL,      /* value_table */
+            NULL,       /* value_table */
         };
         namedview_type = g_type_register_static(SP_TYPE_OBJECTGROUP, "SPNamedView", &namedview_info, (GTypeFlags)0);
     }
@@ -105,6 +107,7 @@ static void sp_namedview_init(SPNamedView *nv)
 {
     nv->editable = TRUE;
     nv->showguides = TRUE;
+    nv->grids_visible = false;
     nv->showborder = TRUE;
     nv->showpageshadow = TRUE;
 
@@ -119,6 +122,94 @@ static void sp_namedview_init(SPNamedView *nv)
     new (&nv->snap_manager) SnapManager(nv);
 }
 
+static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *document, Inkscape::XML::Node *repr) {
+    bool old_grid_settings_present = false;
+
+    // set old settings
+    const char* gridspacingx    = "1px";
+    const char* gridspacingy    = "1px";
+    const char* gridoriginy     = "0px";
+    const char* gridoriginx     = "0px";
+    const char* gridempspacing  = "5";
+    const char* gridcolor       = "#0000ff";
+    const char* gridempcolor    = "#0000ff";
+    const char* gridopacity     = "0.2";
+    const char* gridempopacity  = "0.4";
+
+    const char* value = NULL;
+    if ((value = repr->attribute("gridoriginx"))) {
+        gridspacingx = value;
+        old_grid_settings_present = true;
+    }
+    if ((value = repr->attribute("gridoriginy"))) {
+        gridoriginy = value;
+        old_grid_settings_present = true;
+    }
+    if ((value = repr->attribute("gridspacingx"))) {
+        gridspacingx = value;
+        old_grid_settings_present = true;
+    }
+    if ((value = repr->attribute("gridspacingy"))) {
+        gridspacingy = value;
+        old_grid_settings_present = true;
+    }
+    if ((value = repr->attribute("gridcolor"))) {
+        gridcolor = value;
+        old_grid_settings_present = true;
+    }
+    if ((value = repr->attribute("gridempcolor"))) {
+        gridempcolor = value;
+        old_grid_settings_present = true;
+    }
+    if ((value = repr->attribute("gridempspacing"))) {
+        gridempspacing = value;
+        old_grid_settings_present = true;
+    }
+    if ((value = repr->attribute("gridopacity"))) {
+        gridopacity = value;
+        old_grid_settings_present = true;
+    }
+    if ((value = repr->attribute("gridempopacity"))) {
+        gridempopacity = value;
+        old_grid_settings_present = true;
+    }
+
+    if (old_grid_settings_present) {
+        // generate new xy grid with the correct settings
+        // 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.
+
+        Inkscape::XML::Document *xml_doc = document->getReprDoc();
+        Inkscape::XML::Node *newnode = xml_doc->createElement("inkscape:grid");
+        newnode->setAttribute("id", "GridFromPre046Settings");
+        newnode->setAttribute("type", Inkscape::CanvasGrid::getSVGName(Inkscape::GRID_RECTANGULAR));
+        newnode->setAttribute("originx", gridoriginx);
+        newnode->setAttribute("originy", gridoriginy);
+        newnode->setAttribute("spacingx", gridspacingx);
+        newnode->setAttribute("spacingy", gridspacingy);
+        newnode->setAttribute("color", gridcolor);
+        newnode->setAttribute("empcolor", gridempcolor);
+        newnode->setAttribute("opacity", gridopacity);
+        newnode->setAttribute("empopacity", gridempopacity);
+        newnode->setAttribute("empspacing", gridempspacing);
+
+        repr->appendChild(newnode);
+        Inkscape::GC::release(newnode);
+
+        // remove all old settings
+        repr->setAttribute("gridoriginx", NULL);
+        repr->setAttribute("gridoriginy", NULL);
+        repr->setAttribute("gridspacingx", NULL);
+        repr->setAttribute("gridspacingy", NULL);
+        repr->setAttribute("gridcolor", NULL);
+        repr->setAttribute("gridempcolor", NULL);
+        repr->setAttribute("gridopacity", NULL);
+        repr->setAttribute("gridempopacity", NULL);
+        repr->setAttribute("gridempspacing", NULL);
+
+//        SPDocumentUndo::done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid from pre0.46 grid settings"));
+    }
+}
+
 static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
 {
     SPNamedView *nv = (SPNamedView *) object;
@@ -128,54 +219,66 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
         (* ((SPObjectClass *) (parent_class))->build)(object, document, repr);
     }
 
-    sp_object_read_attr(object, "inkscape:document-units");
-    sp_object_read_attr(object, "viewonly");
-    sp_object_read_attr(object, "showguides");
-    sp_object_read_attr(object, "showgrid");
-    sp_object_read_attr(object, "gridtolerance");
-    sp_object_read_attr(object, "guidetolerance");
-    sp_object_read_attr(object, "objecttolerance");
-    sp_object_read_attr(object, "guidecolor");
-    sp_object_read_attr(object, "guideopacity");
-    sp_object_read_attr(object, "guidehicolor");
-    sp_object_read_attr(object, "guidehiopacity");
-    sp_object_read_attr(object, "showborder");
-    sp_object_read_attr(object, "inkscape:showpageshadow");
-    sp_object_read_attr(object, "borderlayer");
-    sp_object_read_attr(object, "bordercolor");
-    sp_object_read_attr(object, "borderopacity");
-    sp_object_read_attr(object, "pagecolor");
-    sp_object_read_attr(object, "inkscape:pageopacity");
-    sp_object_read_attr(object, "inkscape:pageshadow");
-    sp_object_read_attr(object, "inkscape:zoom");
-    sp_object_read_attr(object, "inkscape:cx");
-    sp_object_read_attr(object, "inkscape:cy");
-    sp_object_read_attr(object, "inkscape:window-width");
-    sp_object_read_attr(object, "inkscape:window-height");
-    sp_object_read_attr(object, "inkscape:window-x");
-    sp_object_read_attr(object, "inkscape:window-y");
-    sp_object_read_attr(object, "inkscape:snap-bbox");
-    sp_object_read_attr(object, "inkscape:snap-nodes");
-    sp_object_read_attr(object, "inkscape:snap-guide");
-    sp_object_read_attr(object, "inkscape:snap-center");
-    sp_object_read_attr(object, "inkscape:snap-intersection-grid-guide");
-    sp_object_read_attr(object, "inkscape:snap-intersection-line-segments");
-    sp_object_read_attr(object, "inkscape:object-paths");
-    sp_object_read_attr(object, "inkscape:object-nodes");
-    sp_object_read_attr(object, "inkscape:bbox-paths");
-    sp_object_read_attr(object, "inkscape:bbox-nodes");    
-    sp_object_read_attr(object, "inkscape:current-layer");
-    sp_object_read_attr(object, "inkscape:connector-spacing");
+    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-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-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: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" );
 
     /* Construct guideline list */
-
-    for (SPObject *o = sp_object_first_child(SP_OBJECT(og)) ; o != NULL; o = SP_OBJECT_NEXT(o) ) {
+    for (SPObject *o = SP_OBJECT(og)->firstChild() ; o; o = o->getNext() ) {
         if (SP_IS_GUIDE(o)) {
             SPGuide * g = SP_GUIDE(o);
             nv->guides = g_slist_prepend(nv->guides, g);
             g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL);
         }
     }
+
+    // backwards compatibility with grid settings (pre 0.46)
+    sp_namedview_generate_old_grid(nv, document, repr);
 }
 
 static void sp_namedview_release(SPObject *object)
@@ -189,9 +292,9 @@ static void sp_namedview_release(SPObject *object)
 
     // delete grids:
     while ( namedview->grids ) {
-        Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data;
+        Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data; // get first entry
         delete gr;
-        namedview->grids = g_slist_remove_link(namedview->grids, namedview->grids);
+        namedview->grids = g_slist_remove_link(namedview->grids, namedview->grids); // deletes first entry
     }
 
     if (((SPObjectClass *) parent_class)->release) {
@@ -204,6 +307,7 @@ static void sp_namedview_release(SPObject *object)
 static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *value)
 {
     SPNamedView *nv = SP_NAMEDVIEW(object);
+    // TODO investigate why we grab this and then never use it
     SPUnit const &px = sp_unit_get_by_id(SP_UNIT_PX);
 
     switch (key) {
@@ -221,7 +325,7 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_SHOWGRIDS:
-            if (!value) { // show grids if not specified, for backwards compatibility
+            if (!value) { // don't show grids if not specified, for backwards compatibility
                 nv->grids_visible = false;
             } else {
                 nv->grids_visible = sp_str_to_bool(value);
@@ -229,29 +333,17 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_GRIDTOLERANCE:
-            nv->gridtoleranceunit = &px;
-            nv->gridtolerance = DEFAULTTOLERANCE;
-            if (value) {
-                sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->gridtolerance, &nv->gridtoleranceunit);
-            }
-            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-            break;
+        nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
     case SP_ATTR_GUIDETOLERANCE:
-            nv->guidetoleranceunit = &px;
-            nv->guidetolerance = DEFAULTTOLERANCE;
-            if (value) {
-                sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->guidetolerance, &nv->guidetoleranceunit);
-            }
-            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-            break;
+        nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
     case SP_ATTR_OBJECTTOLERANCE:
-            nv->objecttoleranceunit = &px;
-            nv->objecttolerance = DEFAULTTOLERANCE;
-            if (value) {
-                sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->objecttolerance, &nv->objecttoleranceunit);
-            }
-            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-            break;
+        nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
     case SP_ATTR_GUIDECOLOR:
             nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00);
             if (value) {
@@ -304,12 +396,12 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             }
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-       case SP_ATTR_BORDEROPACITY:
+    case SP_ATTR_BORDEROPACITY:
             nv->bordercolor = (nv->bordercolor & 0xffffff00) | (DEFAULTBORDERCOLOR & 0xff);
             sp_nv_read_opacity(value, &nv->bordercolor);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-       case SP_ATTR_PAGECOLOR:
+    case SP_ATTR_PAGECOLOR:
             nv->pagecolor = (nv->pagecolor & 0xff) | (DEFAULTPAGECOLOR & 0xffffff00);
             if (value) {
                 nv->pagecolor = (nv->pagecolor & 0xff) | sp_svg_read_color(value, nv->pagecolor);
@@ -350,51 +442,87 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_WINDOW_X:
-            nv->window_x = value ? atoi(value) : -1; // -1 means not set
+            nv->window_x = value ? atoi(value) : 0;
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_WINDOW_Y:
-            nv->window_y = value ? atoi(value) : -1; // -1 means not set
+            nv->window_y = value ? atoi(value) : 0;
+            object->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);
+        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);
             break;
     case SP_ATTR_INKSCAPE_SNAP_BBOX:
-               nv->snap_manager.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE);
+            nv->snap_manager.snapprefs.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_SNAP_NODES:
-            nv->snap_manager.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE);
+            nv->snap_manager.snapprefs.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_SNAP_CENTER:
-            nv->snap_manager.setIncludeItemCenter(value ? sp_str_to_bool(value) : FALSE);
+            nv->snap_manager.snapprefs.setIncludeItemCenter(value ? sp_str_to_bool(value) : FALSE);
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            break;
+    case SP_ATTR_INKSCAPE_SNAP_GRIDS:
+        nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
+    case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES:
+        nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
+    case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES:
+            nv->snap_manager.snapprefs.setSnapSmoothNodes(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_INKSCAPE_SNAP_GUIDE:
-            nv->snap_manager.setSnapModeGuide(value ? sp_str_to_bool(value) : FALSE);
+    case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS:
+            nv->snap_manager.snapprefs.setSnapLineMidpoints(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE:
-            nv->snap_manager.setSnapIntersectionGG(value ? sp_str_to_bool(value) : TRUE);
+    case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS:
+        nv->snap_manager.snapprefs.setSnapObjectMidpoints(value ? sp_str_to_bool(value) : FALSE);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
+    case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS:
+        nv->snap_manager.snapprefs.setSnapBBoxEdgeMidpoints(value ? sp_str_to_bool(value) : FALSE);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
+    case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS:
+        nv->snap_manager.snapprefs.setSnapBBoxMidpoints(value ? sp_str_to_bool(value) : FALSE);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
+    case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE:
+            nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : TRUE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_INKSCAPE_SNAP_INTERS_LINESEGM:
-            nv->snap_manager.setSnapIntersectionLS(value ? sp_str_to_bool(value) : FALSE);
+    case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS:
+            nv->snap_manager.snapprefs.setSnapIntersectionCS(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_OBJECT_PATHS:
-            nv->snap_manager.object.setSnapToItemPath(value ? sp_str_to_bool(value) : FALSE);
+            nv->snap_manager.snapprefs.setSnapToItemPath(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_OBJECT_NODES:
-            nv->snap_manager.object.setSnapToItemNode(value ? sp_str_to_bool(value) : FALSE);
+            nv->snap_manager.snapprefs.setSnapToItemNode(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_BBOX_PATHS:
-            nv->snap_manager.object.setSnapToBBoxPath(value ? sp_str_to_bool(value) : FALSE);
+            nv->snap_manager.snapprefs.setSnapToBBoxPath(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_BBOX_NODES:
-            nv->snap_manager.object.setSnapToBBoxNode(value ? sp_str_to_bool(value) : FALSE);            
+            nv->snap_manager.snapprefs.setSnapToBBoxNode(value ? sp_str_to_bool(value) : FALSE);
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            break;
+    case SP_ATTR_INKSCAPE_SNAP_PAGE:
+            nv->snap_manager.snapprefs.setSnapToPageBorder(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_CURRENT_LAYER:
@@ -447,6 +575,30 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     }
+    case SP_ATTR_UNITS: {
+            SPUnit const *new_unit = NULL;
+
+            if (value) {
+                SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value);
+                if ( req_unit == NULL ) {
+                    g_warning("Unrecognized unit `%s'", value);
+                    /* fixme: Document errors should be reported in the status bar or
+                     * the like (e.g. as per
+                     * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log
+                     * should be only for programmer errors. */
+                } else if ( req_unit->base == SP_UNIT_ABSOLUTE ||
+                            req_unit->base == SP_UNIT_DEVICE     ) {
+                    new_unit = req_unit;
+                } else {
+                    g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'",
+                              value);
+                    /* fixme: Don't use g_log (see above). */
+                }
+            }
+            nv->units = new_unit;
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            break;
+    }
     default:
             if (((SPObjectClass *) (parent_class))->set) {
                 ((SPObjectClass *) (parent_class))->set(object, key, value);
@@ -474,18 +626,12 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des
     if (!grid) {
         //create grid object
         Inkscape::GridType gridtype = Inkscape::CanvasGrid::getGridTypeFromSVGName(repr->attribute("type"));
-        SPDocument *doc = NULL;
-        if (desktop)
-            doc = sp_desktop_document(desktop);
-        else
-            doc = sp_desktop_document(static_cast<SPDesktop*>(nv->views->data));
-        grid = Inkscape::CanvasGrid::NewGrid(nv, repr, doc, gridtype);
+        if (!nv->document) {
+            g_warning("sp_namedview_add_grid - how come doc is null here?!");
+            return NULL;
+        }
+        grid = Inkscape::CanvasGrid::NewGrid(nv, repr, nv->document, gridtype);
         nv->grids = g_slist_append(nv->grids, grid);
-        //Initialize the snapping parameters for the new grid
-        bool enabled_node = nv->snap_manager.getSnapModeNode();
-        bool enabled_bbox = nv->snap_manager.getSnapModeBBox();
-        grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled_node);
-        grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled_bbox);
     }
 
     if (!desktop) {
@@ -523,20 +669,11 @@ static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *chil
             g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL);
             if (nv->editable) {
                 for (GSList *l = nv->views; l != NULL; l = l->next) {
-                    sp_guide_show(g, static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event);
+                    g->SPGuide::showSPGuide(static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event);
                     if (static_cast<SPDesktop*>(l->data)->guides_active)
-                        sp_guide_sensitize(g,
-                                           sp_desktop_canvas(static_cast<SPDesktop*> (l->data)),
+                        g->sensitize(sp_desktop_canvas(static_cast<SPDesktop*> (l->data)),
                                            TRUE);
-                    if (nv->showguides) {
-                        for (GSList *v = SP_GUIDE(g)->views; v != NULL; v = v->next) {
-                            sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
-                        }
-                    } else {
-                        for (GSList *v = SP_GUIDE(g)->views; v != NULL; v = v->next) {
-                            sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
-                        }
-                    }
+                    sp_namedview_show_single_guide(SP_GUIDE(g), nv->showguides);
                 }
             }
         }
@@ -574,7 +711,7 @@ static void sp_namedview_remove_child(SPObject *object, Inkscape::XML::Node *chi
     }
 }
 
-static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags)
 {
     if ( ( flags & SP_OBJECT_WRITE_EXT ) &&
          repr != SP_OBJECT_REPR(object) )
@@ -582,8 +719,7 @@ static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::
         if (repr) {
             repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
-             /// \todo FIXME:  Plumb an appropriate XML::Document into this
-             repr = SP_OBJECT_REPR(object)->duplicate(NULL);
+             repr = SP_OBJECT_REPR(object)->duplicate(doc);
         }
     }
 
@@ -593,19 +729,11 @@ static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::
 void SPNamedView::show(SPDesktop *desktop)
 {
     for (GSList *l = guides; l != NULL; l = l->next) {
-        sp_guide_show(SP_GUIDE(l->data), desktop->guides, (GCallback) sp_dt_guide_event);
+        SP_GUIDE(l->data)->showSPGuide( desktop->guides, (GCallback) sp_dt_guide_event);
         if (desktop->guides_active) {
-            sp_guide_sensitize(SP_GUIDE(l->data), sp_desktop_canvas(desktop), TRUE);
-        }
-        if (showguides) {
-            for (GSList *v = SP_GUIDE(l->data)->views; v != NULL; v = v->next) {
-                sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
-            }
-        } else {
-            for (GSList *v = SP_GUIDE(l->data)->views; v != NULL; v = v->next) {
-                sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
-            }
+            SP_GUIDE(l->data)->sensitize(sp_desktop_canvas(desktop), TRUE);
         }
+        sp_namedview_show_single_guide(SP_GUIDE(l->data), showguides);
     }
 
     views = g_slist_prepend(views, desktop);
@@ -625,37 +753,48 @@ void SPNamedView::show(SPDesktop *desktop)
 
 #define MIN_ONSCREEN_DISTANCE 50
 
+void SPNamedView::writeNewGrid(SPDocument *document,int gridtype)
+{
+    g_assert(this->getRepr() != NULL);
+    Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast<Inkscape::GridType>(gridtype));
+}
+
 /*
  * Restores window geometry from the document settings or defaults in prefs
  */
 void sp_namedview_window_from_document(SPDesktop *desktop)
 {
     SPNamedView *nv = desktop->namedview;
-    gint geometry_from_file =
-        (1==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    bool geometry_from_file = prefs->getBool("/options/savewindowgeometry/value");
 
     // restore window size and position stored with the document
     if (geometry_from_file) {
-        gint w = MIN(gdk_screen_width(), nv->window_width);
-        gint h = MIN(gdk_screen_height(), nv->window_height);
-        gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
-        gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y);
-        if (w>0 && h>0 && x>0 && y>0) {
-            x = MIN(gdk_screen_width() - w, x);
-            y = MIN(gdk_screen_height() - h, y);
-        }
-        if (w>0 && h>0) {
-            desktop->setWindowSize(w, h);
-        }
-        if (x>0 && y>0) {
-            desktop->setWindowPosition(NR::Point(x, y));
+        if (nv->window_maximized) {
+            Gtk::Window *win = desktop->getToplevel();
+            if (win){
+                win->maximize();
+            }
+        } else {
+            gint w = MIN(gdk_screen_width(), nv->window_width);
+            gint h = MIN(gdk_screen_height(), nv->window_height);
+            // prevent the window from moving off the screen to the right or to the bottom
+            gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
+            gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y);
+            // prevent the window from moving off the screen to the left or to the top
+            x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x);
+            y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y);
+            if (w>0 && h>0) {
+                desktop->setWindowSize(w, h);
+                desktop->setWindowPosition(Geom::Point(x, y));
+            }
         }
     }
 
     // restore zoom and view
-    if (nv->zoom != 0 && nv->zoom != HUGE_VAL && !isNaN(nv->zoom)
-        && nv->cx != HUGE_VAL && !isNaN(nv->cx)
-        && nv->cy != HUGE_VAL && !isNaN(nv->cy)) {
+    if (nv->zoom != 0 && nv->zoom != HUGE_VAL && !IS_NAN(nv->zoom)
+        && nv->cx != HUGE_VAL && !IS_NAN(nv->cx)
+        && nv->cy != HUGE_VAL && !IS_NAN(nv->cy)) {
         desktop->zoom_absolute(nv->cx, nv->cy, nv->zoom);
     } else if (sp_desktop_document(desktop)) { // document without saved zoom, zoom to its page
         desktop->zoom_page();
@@ -668,6 +807,17 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
     }
 }
 
+bool SPNamedView::getSnapGlobal() const
+{
+    return this->snap_manager.snapprefs.getSnapEnabledGlobally();
+}
+
+void SPNamedView::setSnapGlobal(bool v)
+{
+    g_assert(this->getRepr() != NULL);
+    sp_repr_set_boolean(this->getRepr(), "inkscape:snap-global", v);
+}
+
 void sp_namedview_update_layers_from_document (SPDesktop *desktop)
 {
     SPObject *layer = NULL;
@@ -682,8 +832,7 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop)
     }
     // if that didn't work out, look for the topmost layer
     if (!layer) {
-        SPObject *iter = sp_object_first_child(SP_DOCUMENT_ROOT(document));
-        for ( ; iter ; iter = SP_OBJECT_NEXT(iter) ) {
+        for ( SPObject *iter = document->getRoot()->firstChild(); iter ; iter = iter->getNext() ) {
             if (desktop->isLayer(iter)) {
                 layer = iter;
             }
@@ -699,18 +848,18 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop)
 
 void sp_namedview_document_from_window(SPDesktop *desktop)
 {
-    gint save_geometry_in_file =
-        (1==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    bool save_geometry_in_file = prefs->getBool("/options/savewindowgeometry/value", 0);
     Inkscape::XML::Node *view = SP_OBJECT_REPR(desktop->namedview);
-    NR::Rect const r = desktop->get_display_area();
+    Geom::Rect const r = desktop->get_display_area();
 
     // saving window geometry is not undoable
-    bool saved = sp_document_get_undo_sensitive(sp_desktop_document(desktop));
-    sp_document_set_undo_sensitive(sp_desktop_document(desktop), false);
+    bool saved = DocumentUndo::getUndoSensitive(sp_desktop_document(desktop));
+    DocumentUndo::setUndoSensitive(sp_desktop_document(desktop), false);
 
     sp_repr_set_svg_double(view, "inkscape:zoom", desktop->current_zoom());
-    sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[NR::X]);
-    sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[NR::Y]);
+    sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[Geom::X]);
+    sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[Geom::Y]);
 
     if (save_geometry_in_file) {
         gint w, h, x, y;
@@ -719,12 +868,13 @@ void sp_namedview_document_from_window(SPDesktop *desktop)
         sp_repr_set_int(view, "inkscape:window-height", h);
         sp_repr_set_int(view, "inkscape:window-x", x);
         sp_repr_set_int(view, "inkscape:window-y", y);
+        sp_repr_set_int(view, "inkscape:window-maximized", desktop->is_maximized());
     }
 
-    view->setAttribute("inkscape:current-layer", SP_OBJECT_ID(desktop->currentLayer()));
+    view->setAttribute("inkscape:current-layer", desktop->currentLayer()->getId());
 
     // restore undoability
-    sp_document_set_undo_sensitive(sp_desktop_document(desktop), saved);
+    DocumentUndo::setUndoSensitive(sp_desktop_document(desktop), saved);
 }
 
 void SPNamedView::hide(SPDesktop const *desktop)
@@ -733,17 +883,10 @@ void SPNamedView::hide(SPDesktop const *desktop)
     g_assert(g_slist_find(views, desktop));
 
     for (GSList *l = guides; l != NULL; l = l->next) {
-        sp_guide_hide(SP_GUIDE(l->data), sp_desktop_canvas(desktop));
+        SP_GUIDE(l->data)->hideSPGuide(sp_desktop_canvas(desktop));
     }
 
     views = g_slist_remove(views, desktop);
-
-    // delete grids:
-    while ( grids ) {
-        Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)grids->data;
-        delete gr;
-        grids = g_slist_remove_link(grids, grids);
-    }
 }
 
 void SPNamedView::activateGuides(gpointer desktop, gboolean active)
@@ -754,21 +897,26 @@ void SPNamedView::activateGuides(gpointer desktop, gboolean active)
     SPDesktop *dt = static_cast<SPDesktop*>(desktop);
 
     for (GSList *l = guides; l != NULL; l = l->next) {
-        sp_guide_sensitize(SP_GUIDE(l->data), sp_desktop_canvas(dt), active);
+        SP_GUIDE(l->data)->sensitize( sp_desktop_canvas(dt), active);
     }
 }
 
 static void sp_namedview_setup_guides(SPNamedView *nv)
 {
     for (GSList *l = nv->guides; l != NULL; l = l->next) {
-        if (nv->showguides) {
-            for (GSList *v = SP_GUIDE(l->data)->views; v != NULL; v = v->next) {
-                sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
-            }
+        sp_namedview_show_single_guide(SP_GUIDE(l->data), nv->showguides);
+    }
+}
+
+static void sp_namedview_show_single_guide(SPGuide* guide, bool show)
+{
+    for (GSList *v = guide->views; v != NULL; v = v->next) {
+        if (show) {
+            sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
+            sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin));
         } else {
-            for (GSList *v = SP_GUIDE(l->data)->views; v != NULL; v = v->next) {
-                sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
-            }
+            sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
+            sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin));
         }
     }
 }
@@ -783,13 +931,12 @@ void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr)
         v = !v;
     }
 
-    bool saved = sp_document_get_undo_sensitive(doc);
-    sp_document_set_undo_sensitive(doc, false);
-
+    bool saved = DocumentUndo::getUndoSensitive(doc);
+    DocumentUndo::setUndoSensitive(doc, false);
     sp_repr_set_boolean(repr, "showguides", v);
+    DocumentUndo::setUndoSensitive(doc, saved);
 
-    doc->rroot->setAttribute("sodipodi:modified", "true");
-    sp_document_set_undo_sensitive(doc, saved);
+    doc->setModifiedSinceSave();
 }
 
 void sp_namedview_show_grids(SPNamedView * namedview, bool show, bool dirty_document)
@@ -799,24 +946,23 @@ void sp_namedview_show_grids(SPNamedView * namedview, bool show, bool dirty_docu
     SPDocument *doc = SP_OBJECT_DOCUMENT (namedview);
     Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview);
 
-    bool saved = sp_document_get_undo_sensitive(doc);
-    sp_document_set_undo_sensitive(doc, false);
-
+    bool saved = DocumentUndo::getUndoSensitive(doc);
+    DocumentUndo::setUndoSensitive(doc, false);
     sp_repr_set_boolean(repr, "showgrid", namedview->grids_visible);
+    DocumentUndo::setUndoSensitive(doc, saved);
 
     /* we don't want the document to get dirty on startup; that's when
        we call this function with dirty_document = false */
     if (dirty_document) {
-        doc->rroot->setAttribute("sodipodi:modified", "true");
+        doc->setModifiedSinceSave();
     }
-    sp_document_set_undo_sensitive(doc, saved);
 }
 
 gchar const *SPNamedView::getName() const
 {
     SPException ex;
     SP_EXCEPTION_INIT(&ex);
-    return sp_object_getAttribute(SP_OBJECT(this), "id", &ex);
+    return SP_OBJECT(this)->getAttribute("id", &ex);
 }
 
 guint SPNamedView::getViewCount()
@@ -845,58 +991,6 @@ static gboolean sp_str_to_bool(const gchar *str)
     return FALSE;
 }
 
-/* fixme: Collect all these length parsing methods and think common sane API */
-
-static gboolean sp_nv_read_length(const gchar *str, guint base, gdouble *val, const SPUnit **unit)
-{
-    if (!str) {
-        return FALSE;
-    }
-
-    gchar *u;
-    gdouble v = g_ascii_strtod(str, &u);
-    if (!u) {
-        return FALSE;
-    }
-    while (isspace(*u)) {
-        u += 1;
-    }
-
-    if (!*u) {
-        /* No unit specified - keep default */
-        *val = v;
-        return TRUE;
-    }
-
-    if (base & SP_UNIT_DEVICE) {
-        if (u[0] && u[1] && !isalnum(u[2]) && !strncmp(u, "px", 2)) {
-            *unit = &sp_unit_get_by_id(SP_UNIT_PX);
-            *val = v;
-            return TRUE;
-        }
-    }
-
-    if (base & SP_UNIT_ABSOLUTE) {
-        if (!strncmp(u, "pt", 2)) {
-            *unit = &sp_unit_get_by_id(SP_UNIT_PT);
-        } else if (!strncmp(u, "mm", 2)) {
-            *unit = &sp_unit_get_by_id(SP_UNIT_MM);
-        } else if (!strncmp(u, "cm", 2)) {
-            *unit = &sp_unit_get_by_id(SP_UNIT_CM);
-        } else if (!strncmp(u, "m", 1)) {
-            *unit = &sp_unit_get_by_id(SP_UNIT_M);
-        } else if (!strncmp(u, "in", 2)) {
-            *unit = &sp_unit_get_by_id(SP_UNIT_IN);
-        } else {
-            return FALSE;
-        }
-        *val = v;
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
 static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color)
 {
     if (!str) {
@@ -926,13 +1020,54 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id)
         return (SPNamedView *) nv;
     }
 
-    while (nv && strcmp(nv->id, id)) {
+    while (nv && strcmp(nv->getId(), id)) {
         nv = sp_item_group_get_child_by_name((SPGroup *) document->root, nv, "sodipodi:namedview");
     }
 
     return (SPNamedView *) nv;
 }
 
+void SPNamedView::setGuides(bool v)
+{
+    g_assert(this->getRepr() != NULL);
+    sp_repr_set_boolean(this->getRepr(), "showguides", v);
+    sp_repr_set_boolean(this->getRepr(), "inkscape:guide-bbox", v);
+}
+
+/**
+ * Gets page fitting margin information from the namedview node in the XML.
+ * \param nv_repr reference to this document's namedview
+ * \param key the same key used by the RegisteredScalarUnit in
+ *        ui/widget/page-sizer.cpp
+ * \param margin_units units for the margin
+ * \param return_units units to return the result in
+ * \param width width in px (for percentage margins)
+ * \param height height in px (for percentage margins)
+ * \param use_width true if the this key is left or right margins, false
+ *        otherwise.  Used for percentage margins.
+ * \return the margin size in px, else 0.0 if anything is invalid.
+ */
+double SPNamedView::getMarginLength(gchar const * const key,
+                             SPUnit const * const margin_units,
+                             SPUnit const * const return_units,
+                             double const width,
+                             double const height,
+                             bool const use_width)
+{
+    double value;
+    if(!this->storeAsDouble(key,&value)) {
+        return 0.0;
+    }
+    if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) {
+        return (use_width)? width * value : height * value; 
+    }
+    if (!sp_convert_distance (&value, margin_units, return_units)) {
+        return 0.0;
+    }
+    return value;
+}
+
+
 /**
  * Returns namedview's default metric.
  */
@@ -945,6 +1080,37 @@ SPMetric SPNamedView::getDefaultMetric() const
     }
 }
 
+/**
+ * Returns the first grid it could find that isEnabled(). Returns NULL, if none is enabled
+ */
+Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedview)
+{
+    for (GSList const * l = namedview->grids; l != NULL; l = l->next) {
+        Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data;
+        if (grid->isEnabled())
+            return grid;
+    }
+
+    return NULL;
+}
+
+void SPNamedView::translateGuides(Geom::Translate const &tr) {
+    for (GSList *l = guides; l != NULL; l = l->next) {
+        SPGuide &guide = *SP_GUIDE(l->data);
+        Geom::Point point_on_line = guide.point_on_line;
+        point_on_line[0] += tr[0];
+        point_on_line[1] += tr[1];
+        sp_guide_moveto(guide, point_on_line, true);
+    }
+}
+
+void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) {
+        for(GSList *l = views; l; l = l->next) {
+            SPDesktop *desktop = static_cast<SPDesktop *>(l->data);
+            desktop->scroll_world_in_svg_coords(dx, dy, is_scrolling);
+        }
+}
+
 
 /*
   Local Variables:
@@ -955,4 +1121,4 @@ SPMetric SPNamedView::getDefaultMetric() const
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :