Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / dialogs / clonetiler.cpp
index dec60ed46f752ed9607bcf4a45f188bb0fdc9b64..8045675b4022ac097f522747e6523d2f60774551 100644 (file)
@@ -1,14 +1,14 @@
-#define __SP_CLONE_TILER_C__
-
-/*
+/** @file
  * Clone tiling dialog
- *
- * Authors:
+ */
+/* Authors:
  *   bulia byak <buliabyak@users.sf.net>
  *   Johan Engelen <goejendaagh@zonnet.nl>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2006 Authors
- * Released under GNU GPL
+ * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
 #ifdef HAVE_CONFIG_H
 #include <gtk/gtk.h>
 #include <glibmm/i18n.h>
 
-#include "application/application.h"
-#include "application/editor.h"
-#include "helper/window.h"
+#include "../desktop.h"
+#include "../desktop-handles.h"
+#include "dialog-events.h"
+#include "display/nr-arena.h"
+#include "display/nr-arena-item.h"
+#include "../document.h"
+#include "../filter-chemistry.h"
 #include "helper/unit-menu.h"
 #include "helper/units.h"
-#include "widgets/icon.h"
+#include "helper/window.h"
 #include "../inkscape.h"
-#include "../prefs-utils.h"
-#include "dialog-events.h"
-#include "../macros.h"
-#include "../verbs.h"
 #include "../interface.h"
+#include "../macros.h"
+#include "../message-stack.h"
+#include "preferences.h"
 #include "../selection.h"
-#include "../style.h"
-#include "../desktop.h"
-#include "../desktop-handles.h"
+#include "../sp-filter.h"
 #include "../sp-namedview.h"
-#include "../document.h"
-#include "../message-stack.h"
 #include "../sp-use.h"
-#include "unclump.h"
-
-#include "xml/repr.h"
-
-#include "svg/svg.h"
+#include "../style.h"
 #include "svg/svg-color.h"
-
-#include "libnr/nr-matrix-fns.h"
-#include "libnr/nr-matrix-ops.h"
-
-#include "libnr/nr-matrix-translate-ops.h"
-#include "libnr/nr-translate-ops.h"
-#include "libnr/nr-translate-rotate-ops.h"
-#include "libnr/nr-translate-scale-ops.h"
-
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
-
+#include "svg/svg.h"
+#include "ui/icon-names.h"
 #include "ui/widget/color-picker.h"
+#include "unclump.h"
+#include "../verbs.h"
+#include "widgets/icon.h"
+#include "xml/repr.h"
 
-#include "../sp-filter.h"
-#include "../filter-chemistry.h"
+using Inkscape::DocumentUndo;
 
 #define MIN_ONSCREEN_DISTANCE 50
 
@@ -68,7 +56,7 @@ static win_data wd;
 
 // impossible original values to make sure they are read from prefs
 static gint x = -1000, y = -1000, w = 0, h = 0;
-static gchar *prefs_path = "dialogs.clonetiler";
+static Glib::ustring const prefs_path = "/dialogs/clonetiler/";
 
 #define SB_MARGIN 1
 #define VB_MARGIN 4
@@ -97,15 +85,7 @@ static Inkscape::UI::Widget::ColorPicker *color_picker;
 static void
 clonetiler_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ )
 {
-    if (Inkscape::NSApplication::Application::getNewGui())
-    {
-        _shutdown_connection.disconnect();
-        _dialogs_hidden_connection.disconnect();
-        _dialogs_unhidden_connection.disconnect();
-        _desktop_activated_connection.disconnect();
-    } else {
-        sp_signal_disconnect_by_data (INKSCAPE, dlg);
-    }
+    sp_signal_disconnect_by_data (INKSCAPE, dlg);
     _color_changed_connection.disconnect();
 
     delete color_picker;
@@ -124,20 +104,16 @@ clonetiler_dialog_delete (GtkObject */*object*/, GdkEvent * /*event*/, gpointer
     if (x<0) x=0;
     if (y<0) y=0;
 
-    prefs_set_int_attribute (prefs_path, "x", x);
-    prefs_set_int_attribute (prefs_path, "y", y);
-    prefs_set_int_attribute (prefs_path, "w", w);
-    prefs_set_int_attribute (prefs_path, "h", h);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setInt(prefs_path + "x", x);
+    prefs->setInt(prefs_path + "y", y);
+    prefs->setInt(prefs_path + "w", w);
+    prefs->setInt(prefs_path + "h", h);
 
     return FALSE; // which means, go ahead and destroy it
 
 }
 
-static void on_delete()
-{
-    (void)clonetiler_dialog_delete (0, 0, NULL);
-}
-
 static void
 on_picker_color_changed (guint rgba)
 {
@@ -147,10 +123,10 @@ on_picker_color_changed (guint rgba)
 
     is_updating = true;
 
-    Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, prefs_path);
     gchar c[32];
     sp_svg_write_color(c, sizeof(c), rgba);
-    repr->setAttribute("initial_color", c);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setString(prefs_path + "initial_color", c);
 
     is_updating = false;
 }
@@ -220,7 +196,7 @@ enum {
 };
 
 
-static NR::Matrix
+static Geom::Matrix
 clonetiler_get_transform (
 
     // symmetry group
@@ -311,7 +287,7 @@ clonetiler_get_transform (
     if ( shifty_exp != 1.0 ) shiftj = pow( shiftj, shifty_exp );
 
     // Final shift
-    NR::Matrix rect_translate (NR::translate (w * shifti, h * shiftj));
+    Geom::Matrix rect_translate (Geom::Translate (w * shifti, h * shiftj));
 
     // Rotation (in degrees) ------------
     double delta_rotationi = 0.0;
@@ -394,25 +370,25 @@ clonetiler_get_transform (
 
 
     // Calculate transformation matrices, translating back to "center of tile" (rotation center) before transforming
-    NR::Matrix drot_c   = NR::translate(-cx, -cy) * NR::rotate (M_PI*dr/180)    * NR::translate(cx, cy);
+    Geom::Matrix drot_c   = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI*dr/180)    * Geom::Translate(cx, cy);
 
-    NR::Matrix dscale_c = NR::translate(-cx, -cy) * NR::scale (scalex, scaley)  * NR::translate(cx, cy);
+    Geom::Matrix dscale_c = Geom::Translate(-cx, -cy) * Geom::Scale (scalex, scaley)  * Geom::Translate(cx, cy);
 
-    NR::Matrix d_s_r = dscale_c * drot_c;
+    Geom::Matrix d_s_r = dscale_c * drot_c;
 
-    NR::Matrix rotate_180_c  = NR::translate(-cx, -cy) * NR::rotate (M_PI)      * NR::translate(cx, cy);
+    Geom::Matrix rotate_180_c  = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI)      * Geom::Translate(cx, cy);
 
-    NR::Matrix rotate_90_c   = NR::translate(-cx, -cy) * NR::rotate (-M_PI/2)   * NR::translate(cx, cy);
-    NR::Matrix rotate_m90_c  = NR::translate(-cx, -cy) * NR::rotate ( M_PI/2)   * NR::translate(cx, cy);
+    Geom::Matrix rotate_90_c   = Geom::Translate(-cx, -cy) * Geom::Rotate (-M_PI/2)   * Geom::Translate(cx, cy);
+    Geom::Matrix rotate_m90_c  = Geom::Translate(-cx, -cy) * Geom::Rotate ( M_PI/2)   * Geom::Translate(cx, cy);
 
-    NR::Matrix rotate_120_c  = NR::translate(-cx, -cy) * NR::rotate (-2*M_PI/3) * NR::translate(cx, cy);
-    NR::Matrix rotate_m120_c = NR::translate(-cx, -cy) * NR::rotate ( 2*M_PI/3) * NR::translate(cx, cy);
+    Geom::Matrix rotate_120_c  = Geom::Translate(-cx, -cy) * Geom::Rotate (-2*M_PI/3) * Geom::Translate(cx, cy);
+    Geom::Matrix rotate_m120_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( 2*M_PI/3) * Geom::Translate(cx, cy);
 
-    NR::Matrix rotate_60_c   = NR::translate(-cx, -cy) * NR::rotate (-M_PI/3)   * NR::translate(cx, cy);
-    NR::Matrix rotate_m60_c  = NR::translate(-cx, -cy) * NR::rotate ( M_PI/3)   * NR::translate(cx, cy);
+    Geom::Matrix rotate_60_c   = Geom::Translate(-cx, -cy) * Geom::Rotate (-M_PI/3)   * Geom::Translate(cx, cy);
+    Geom::Matrix rotate_m60_c  = Geom::Translate(-cx, -cy) * Geom::Rotate ( M_PI/3)   * Geom::Translate(cx, cy);
 
-    NR::Matrix flip_x        = NR::translate(-cx, -cy) * NR::scale (-1, 1)      * NR::translate(cx, cy);
-    NR::Matrix flip_y        = NR::translate(-cx, -cy) * NR::scale (1, -1)      * NR::translate(cx, cy);
+    Geom::Matrix flip_x        = Geom::Translate(-cx, -cy) * Geom::Scale (-1, 1)      * Geom::Translate(cx, cy);
+    Geom::Matrix flip_y        = Geom::Translate(-cx, -cy) * Geom::Scale (1, -1)      * Geom::Translate(cx, cy);
 
 
     // Create tile with required symmetry
@@ -537,9 +513,9 @@ clonetiler_get_transform (
 
     case TILE_P4:
     {
-        NR::Matrix ori  (NR::translate ((w + h) * pow((i/2), shiftx_exp) + dx,  (h + w) * pow((j/2), shifty_exp) + dy));
-        NR::Matrix dia1 (NR::translate (w/2 + h/2, -h/2 + w/2));
-        NR::Matrix dia2 (NR::translate (-w/2 + h/2, h/2 + w/2));
+        Geom::Matrix ori  (Geom::Translate ((w + h) * pow((i/2), shiftx_exp) + dx,  (h + w) * pow((j/2), shifty_exp) + dy));
+        Geom::Matrix dia1 (Geom::Translate (w/2 + h/2, -h/2 + w/2));
+        Geom::Matrix dia2 (Geom::Translate (-w/2 + h/2, h/2 + w/2));
         if (j % 2 == 0) {
             if (i % 2 == 0) {
                 return d_s_r * ori;
@@ -559,28 +535,28 @@ clonetiler_get_transform (
     case TILE_P4M:
     {
         double max = MAX(w, h);
-        NR::Matrix ori (NR::translate ((max + max) * pow((i/4), shiftx_exp) + dx,  (max + max) * pow((j/2), shifty_exp) + dy));
-        NR::Matrix dia1 (NR::translate ( w/2 - h/2, h/2 - w/2));
-        NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 - h/2));
+        Geom::Matrix ori (Geom::Translate ((max + max) * pow((i/4), shiftx_exp) + dx,  (max + max) * pow((j/2), shifty_exp) + dy));
+        Geom::Matrix dia1 (Geom::Translate ( w/2 - h/2, h/2 - w/2));
+        Geom::Matrix dia2 (Geom::Translate (-h/2 + w/2, w/2 - h/2));
         if (j % 2 == 0) {
             if (i % 4 == 0) {
                 return d_s_r * ori;
             } else if (i % 4 == 1) {
                 return d_s_r * flip_y * rotate_m90_c * dia1 * ori;
             } else if (i % 4 == 2) {
-                return d_s_r * rotate_m90_c * dia1 * NR::translate (h, 0) * ori;
+                return d_s_r * rotate_m90_c * dia1 * Geom::Translate (h, 0) * ori;
             } else if (i % 4 == 3) {
-                return d_s_r * flip_x * NR::translate (w, 0) * ori;
+                return d_s_r * flip_x * Geom::Translate (w, 0) * ori;
             }
         } else {
             if (i % 4 == 0) {
-                return d_s_r * flip_y * NR::translate(0, h) * ori;
+                return d_s_r * flip_y * Geom::Translate(0, h) * ori;
             } else if (i % 4 == 1) {
-                return d_s_r * rotate_90_c * dia2 * NR::translate(0, h) * ori;
+                return d_s_r * rotate_90_c * dia2 * Geom::Translate(0, h) * ori;
             } else if (i % 4 == 2) {
-                return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate(h, 0) * NR::translate(0, h) * ori;
+                return d_s_r * flip_y * rotate_90_c * dia2 * Geom::Translate(h, 0) * Geom::Translate(0, h) * ori;
             } else if (i % 4 == 3) {
-                return d_s_r * flip_y * flip_x * NR::translate(w, 0) * NR::translate(0, h) * ori;
+                return d_s_r * flip_y * flip_x * Geom::Translate(w, 0) * Geom::Translate(0, h) * ori;
             }
         }
     }
@@ -589,9 +565,9 @@ clonetiler_get_transform (
     case TILE_P4G:
     {
         double max = MAX(w, h);
-        NR::Matrix ori (NR::translate ((max + max) * pow((i/4), shiftx_exp) + dx,  (max + max) * pow(j, shifty_exp) + dy));
-        NR::Matrix dia1 (NR::translate ( w/2 + h/2, h/2 - w/2));
-        NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 + h/2));
+        Geom::Matrix ori (Geom::Translate ((max + max) * pow((i/4), shiftx_exp) + dx,  (max + max) * pow(j, shifty_exp) + dy));
+        Geom::Matrix dia1 (Geom::Translate ( w/2 + h/2, h/2 - w/2));
+        Geom::Matrix dia2 (Geom::Translate (-h/2 + w/2, w/2 + h/2));
         if (((i/4) + j) % 2 == 0) {
             if (i % 4 == 0) {
                 return d_s_r * ori;
@@ -604,13 +580,13 @@ clonetiler_get_transform (
             }
         } else {
             if (i % 4 == 0) {
-                return d_s_r * flip_y * NR::translate (0, h) * ori;
+                return d_s_r * flip_y * Geom::Translate (0, h) * ori;
             } else if (i % 4 == 1) {
-                return d_s_r * flip_y * rotate_m90_c * dia1 * NR::translate (-h, 0) * ori;
+                return d_s_r * flip_y * rotate_m90_c * dia1 * Geom::Translate (-h, 0) * ori;
             } else if (i % 4 == 2) {
-                return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate (h, 0) * ori;
+                return d_s_r * flip_y * rotate_90_c * dia2 * Geom::Translate (h, 0) * ori;
             } else if (i % 4 == 3) {
-                return d_s_r * flip_x * NR::translate (w, 0) * ori;
+                return d_s_r * flip_x * Geom::Translate (w, 0) * ori;
             }
         }
     }
@@ -620,20 +596,20 @@ clonetiler_get_transform (
     {
         double width;
         double height;
-        NR::Matrix dia1;
-        NR::Matrix dia2;
+        Geom::Matrix dia1;
+        Geom::Matrix dia2;
         if (w > h) {
             width  = w + w * cos60;
             height = 2 * w * sin60;
-            dia1 = NR::Matrix (NR::translate (w/2 + w/2 * cos60, -(w/2 * sin60)));
-            dia2 = dia1 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60)));
+            dia1 = Geom::Matrix (Geom::Translate (w/2 + w/2 * cos60, -(w/2 * sin60)));
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (0, 2 * (w/2 * sin60)));
         } else {
             width = h * cos (M_PI/6);
             height = h;
-            dia1 = NR::Matrix (NR::translate (h/2 * cos30, -(h/2 * sin30)));
-            dia2 = dia1 * NR::Matrix (NR::translate (0, h/2));
+            dia1 = Geom::Matrix (Geom::Translate (h/2 * cos30, -(h/2 * sin30)));
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (0, h/2));
         }
-        NR::Matrix ori (NR::translate (width * pow((2*(i/3) + j%2), shiftx_exp) + dx,  (height/2) * pow(j, shifty_exp) + dy));
+        Geom::Matrix ori (Geom::Translate (width * pow((2*(i/3) + j%2), shiftx_exp) + dx,  (height/2) * pow(j, shifty_exp) + dy));
         if (i % 3 == 0) {
             return d_s_r * ori;
         } else if (i % 3 == 1) {
@@ -646,36 +622,36 @@ clonetiler_get_transform (
 
     case TILE_P31M:
     {
-        NR::Matrix ori;
-        NR::Matrix dia1;
-        NR::Matrix dia2;
-        NR::Matrix dia3;
-        NR::Matrix dia4;
+        Geom::Matrix ori;
+        Geom::Matrix dia1;
+        Geom::Matrix dia2;
+        Geom::Matrix dia3;
+        Geom::Matrix dia4;
         if (w > h) {
-            ori = NR::Matrix(NR::translate (w * pow((i/6) + 1/2 * (j%2), shiftx_exp) + dx,  (w * cos30) * pow(j, shifty_exp) + dy));
-            dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) );
-            dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
-            dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
-            dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
+            ori = Geom::Matrix(Geom::Translate (w * pow((i/6) + 0.5*(j%2), shiftx_exp) + dx,  (w * cos30) * pow(j, shifty_exp) + dy));
+            dia1 = Geom::Matrix (Geom::Translate (0, h/2) * Geom::Translate (w/2, 0) * Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, -h/2 * sin30) );
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30));
+            dia3 = dia2 * Geom::Matrix (Geom::Translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
+            dia4 = dia3 * Geom::Matrix (Geom::Translate (-h * cos30, h * sin30));
         } else {
-            ori  = NR::Matrix (NR::translate (2*h * cos30  * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx,  (2*h - h * sin30) * pow(j, shifty_exp) + dy));
-            dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30));
-            dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
-            dia3 = dia2 * NR::Matrix (NR::translate (0, h/2));
-            dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
+            ori  = Geom::Matrix (Geom::Translate (2*h * cos30  * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx,  (2*h - h * sin30) * pow(j, shifty_exp) + dy));
+            dia1 = Geom::Matrix (Geom::Translate (0, -h/2) * Geom::Translate (h/2 * cos30, h/2 * sin30));
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30));
+            dia3 = dia2 * Geom::Matrix (Geom::Translate (0, h/2));
+            dia4 = dia3 * Geom::Matrix (Geom::Translate (-h * cos30, h * sin30));
         }
-        if (x % 6 == 0) {
+        if (i % 6 == 0) {
             return d_s_r * ori;
-        } else if (x % 6 == 1) {
+        } else if (i % 6 == 1) {
             return d_s_r * flip_y * rotate_m120_c * dia1 * ori;
-        } else if (x % 6 == 2) {
+        } else if (i % 6 == 2) {
             return d_s_r * rotate_m120_c * dia2 * ori;
-        } else if (x % 6 == 3) {
+        } else if (i % 6 == 3) {
             return d_s_r * flip_y * rotate_120_c * dia3 * ori;
-        } else if (x % 6 == 4) {
+        } else if (i % 6 == 4) {
             return d_s_r * rotate_120_c * dia4 * ori;
-        } else if (x % 6 == 5) {
-            return d_s_r * flip_y * NR::translate(0, h) * ori;
+        } else if (i % 6 == 5) {
+            return d_s_r * flip_y * Geom::Translate(0, h) * ori;
         }
     }
     break;
@@ -684,76 +660,76 @@ clonetiler_get_transform (
     {
         double width;
         double height;
-        NR::Matrix dia1;
-        NR::Matrix dia2;
-        NR::Matrix dia3;
-        NR::Matrix dia4;
+        Geom::Matrix dia1;
+        Geom::Matrix dia2;
+        Geom::Matrix dia3;
+        Geom::Matrix dia4;
         if (w > h) {
             width = w + w * cos60;
             height = 2 * w * sin60;
-            dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) );
-            dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
-            dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
-            dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
+            dia1 = Geom::Matrix (Geom::Translate (0, h/2) * Geom::Translate (w/2, 0) * Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, -h/2 * sin30) );
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30));
+            dia3 = dia2 * Geom::Matrix (Geom::Translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
+            dia4 = dia3 * Geom::Matrix (Geom::Translate (-h * cos30, h * sin30));
         } else {
             width = 2 * h * cos (M_PI/6);
             height = 2 * h;
-            dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30));
-            dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
-            dia3 = dia2 * NR::Matrix (NR::translate (0, h/2));
-            dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
+            dia1 = Geom::Matrix (Geom::Translate (0, -h/2) * Geom::Translate (h/2 * cos30, h/2 * sin30));
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30));
+            dia3 = dia2 * Geom::Matrix (Geom::Translate (0, h/2));
+            dia4 = dia3 * Geom::Matrix (Geom::Translate (-h * cos30, h * sin30));
         }
-        NR::Matrix ori (NR::translate (width * pow((2*(i/6) + j%2), shiftx_exp) + dx,  (height/2) * pow(i, shifty_exp) + dy));
-        if (x % 6 == 0) {
+        Geom::Matrix ori (Geom::Translate (width * pow((2*(i/6) + j%2), shiftx_exp) + dx,  (height/2) * pow(j, shifty_exp) + dy));
+        if (i % 6 == 0) {
             return d_s_r * ori;
-        } else if (x % 6 == 1) {
+        } else if (i % 6 == 1) {
             return d_s_r * flip_y * rotate_m120_c * dia1 * ori;
-        } else if (x % 6 == 2) {
+        } else if (i % 6 == 2) {
             return d_s_r * rotate_m120_c * dia2 * ori;
-        } else if (x % 6 == 3) {
+        } else if (i % 6 == 3) {
             return d_s_r * flip_y * rotate_120_c * dia3 * ori;
-        } else if (x % 6 == 4) {
+        } else if (i % 6 == 4) {
             return d_s_r * rotate_120_c * dia4 * ori;
-        } else if (x % 6 == 5) {
-            return d_s_r * flip_y * NR::translate(0, h) * ori;
+        } else if (i % 6 == 5) {
+            return d_s_r * flip_y * Geom::Translate(0, h) * ori;
         }
     }
     break;
 
     case TILE_P6:
     {
-        NR::Matrix ori;
-        NR::Matrix dia1;
-        NR::Matrix dia2;
-        NR::Matrix dia3;
-        NR::Matrix dia4;
-        NR::Matrix dia5;
+        Geom::Matrix ori;
+        Geom::Matrix dia1;
+        Geom::Matrix dia2;
+        Geom::Matrix dia3;
+        Geom::Matrix dia4;
+        Geom::Matrix dia5;
         if (w > h) {
-            ori = NR::Matrix(NR::translate (w * pow((2*(i/6) + (j%2)), shiftx_exp) + dx,  (2*w * sin60) * pow(j, shifty_exp) + dy));
-            dia1 = NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60));
-            dia2 = dia1 * NR::Matrix (NR::translate (w/2, 0));
-            dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, w/2 * sin60));
-            dia4 = dia3 * NR::Matrix (NR::translate (-w/2 * cos60, w/2 * sin60));
-            dia5 = dia4 * NR::Matrix (NR::translate (-w/2, 0));
+            ori = Geom::Matrix(Geom::Translate (w * pow((2*(i/6) + (j%2)), shiftx_exp) + dx,  (2*w * sin60) * pow(j, shifty_exp) + dy));
+            dia1 = Geom::Matrix (Geom::Translate (w/2 * cos60, -w/2 * sin60));
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (w/2, 0));
+            dia3 = dia2 * Geom::Matrix (Geom::Translate (w/2 * cos60, w/2 * sin60));
+            dia4 = dia3 * Geom::Matrix (Geom::Translate (-w/2 * cos60, w/2 * sin60));
+            dia5 = dia4 * Geom::Matrix (Geom::Translate (-w/2, 0));
         } else {
-            ori = NR::Matrix(NR::translate (2*h * cos30 * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx,  (h + h * sin30) * pow(j, shifty_exp) + dy));
-            dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60));
-            dia2 = dia1 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60));
-            dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2));
+            ori = Geom::Matrix(Geom::Translate (2*h * cos30 * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx,  (h + h * sin30) * pow(j, shifty_exp) + dy));
+            dia1 = Geom::Matrix (Geom::Translate (-w/2, -h/2) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (w/2 * cos60, w/2 * sin60));
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2 * cos60, w/2 * sin60));
+            dia3 = dia2 * Geom::Matrix (Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2, h/2));
             dia4 = dia3 * dia1.inverse();
             dia5 = dia3 * dia2.inverse();
         }
-        if (x % 6 == 0) {
+        if (i % 6 == 0) {
             return d_s_r * ori;
-        } else if (x % 6 == 1) {
+        } else if (i % 6 == 1) {
             return d_s_r * rotate_m60_c * dia1 * ori;
-        } else if (x % 6 == 2) {
+        } else if (i % 6 == 2) {
             return d_s_r * rotate_m120_c * dia2 * ori;
-        } else if (x % 6 == 3) {
+        } else if (i % 6 == 3) {
             return d_s_r * rotate_180_c * dia3 * ori;
-        } else if (x % 6 == 4) {
+        } else if (i % 6 == 4) {
             return d_s_r * rotate_120_c * dia4 * ori;
-        } else if (x % 6 == 5) {
+        } else if (i % 6 == 5) {
             return d_s_r * rotate_60_c * dia5 * ori;
         }
     }
@@ -762,57 +738,57 @@ clonetiler_get_transform (
     case TILE_P6M:
     {
 
-        NR::Matrix ori;
-        NR::Matrix dia1, dia2, dia3, dia4, dia5, dia6, dia7, dia8, dia9, dia10;
+        Geom::Matrix ori;
+        Geom::Matrix dia1, dia2, dia3, dia4, dia5, dia6, dia7, dia8, dia9, dia10;
         if (w > h) {
-            ori = NR::Matrix(NR::translate (w * pow((2*(i/12) + (j%2)), shiftx_exp) + dx,  (2*w * sin60) * pow(j, shifty_exp) + dy));
-            dia1 = NR::Matrix (NR::translate (w/2, h/2) * NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, h/2 * sin30));
-            dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30));
-            dia3 = dia2 * NR::Matrix (NR::translate (-h/2 * cos30, h/2 * sin30) * NR::translate (w * cos60, 0) * NR::translate (-h/2 * cos30, -h/2 * sin30));
-            dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30));
-            dia5 = dia4 * NR::Matrix (NR::translate (-h/2 * cos30, -h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60) * NR::translate (w/2, -h/2));
-            dia6 = dia5 * NR::Matrix (NR::translate (0, h));
+            ori = Geom::Matrix(Geom::Translate (w * pow((2*(i/12) + (j%2)), shiftx_exp) + dx,  (2*w * sin60) * pow(j, shifty_exp) + dy));
+            dia1 = Geom::Matrix (Geom::Translate (w/2, h/2) * Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, h/2 * sin30));
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, -h * sin30));
+            dia3 = dia2 * Geom::Matrix (Geom::Translate (-h/2 * cos30, h/2 * sin30) * Geom::Translate (w * cos60, 0) * Geom::Translate (-h/2 * cos30, -h/2 * sin30));
+            dia4 = dia3 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30));
+            dia5 = dia4 * Geom::Matrix (Geom::Translate (-h/2 * cos30, -h/2 * sin30) * Geom::Translate (-w/2 * cos60, w/2 * sin60) * Geom::Translate (w/2, -h/2));
+            dia6 = dia5 * Geom::Matrix (Geom::Translate (0, h));
             dia7 = dia6 * dia1.inverse();
             dia8 = dia6 * dia2.inverse();
             dia9 = dia6 * dia3.inverse();
             dia10 = dia6 * dia4.inverse();
         } else {
-            ori = NR::Matrix(NR::translate (4*h * cos30 * pow((i/12 + 0.5*(j%2)), shiftx_exp) + dx,  (2*h  + 2*h * sin30) * pow(y, shifty_exp) + dy));
-            dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60));
-            dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30));
-            dia3 = dia2 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h * cos30, 0) * NR::translate (-w/2 * cos60, w/2 * sin60));
-            dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30));
-            dia5 = dia4 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2));
-            dia6 = dia5 * NR::Matrix (NR::translate (0, h));
+            ori = Geom::Matrix(Geom::Translate (4*h * cos30 * pow((i/12 + 0.5*(j%2)), shiftx_exp) + dx,  (2*h  + 2*h * sin30) * pow(j, shifty_exp) + dy));
+            dia1 = Geom::Matrix (Geom::Translate (-w/2, -h/2) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (w/2 * cos60, w/2 * sin60));
+            dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, -h * sin30));
+            dia3 = dia2 * Geom::Matrix (Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (h * cos30, 0) * Geom::Translate (-w/2 * cos60, w/2 * sin60));
+            dia4 = dia3 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30));
+            dia5 = dia4 * Geom::Matrix (Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2, h/2));
+            dia6 = dia5 * Geom::Matrix (Geom::Translate (0, h));
             dia7 = dia6 * dia1.inverse();
             dia8 = dia6 * dia2.inverse();
             dia9 = dia6 * dia3.inverse();
             dia10 = dia6 * dia4.inverse();
         }
-        if (x % 12 == 0) {
+        if (i % 12 == 0) {
             return d_s_r * ori;
-        } else if (x % 12 == 1) {
+        } else if (i % 12 == 1) {
             return d_s_r * flip_y * rotate_m60_c * dia1 * ori;
-        } else if (x % 12 == 2) {
+        } else if (i % 12 == 2) {
             return d_s_r * rotate_m60_c * dia2 * ori;
-        } else if (x % 12 == 3) {
+        } else if (i % 12 == 3) {
             return d_s_r * flip_y * rotate_m120_c * dia3 * ori;
-        } else if (x % 12 == 4) {
+        } else if (i % 12 == 4) {
             return d_s_r * rotate_m120_c * dia4 * ori;
-        } else if (x % 12 == 5) {
+        } else if (i % 12 == 5) {
             return d_s_r * flip_x * dia5 * ori;
-        } else if (x % 12 == 6) {
+        } else if (i % 12 == 6) {
             return d_s_r * flip_x * flip_y * dia6 * ori;
-        } else if (x % 12 == 7) {
+        } else if (i % 12 == 7) {
             return d_s_r * flip_y * rotate_120_c * dia7 * ori;
-        } else if (x % 12 == 8) {
+        } else if (i % 12 == 8) {
             return d_s_r * rotate_120_c * dia8 * ori;
-        } else if (x % 12 == 9) {
+        } else if (i % 12 == 9) {
             return d_s_r * flip_y * rotate_60_c * dia9 * ori;
-        } else if (x % 12 == 10) {
+        } else if (i % 12 == 10) {
             return d_s_r * rotate_60_c * dia10 * ori;
-        } else if (x % 12 == 11) {
-            return d_s_r * flip_y * NR::translate (0, h) * ori;
+        } else if (i % 12 == 11) {
+            return d_s_r * flip_y * Geom::Translate (0, h) * ori;
         }
     }
     break;
@@ -821,7 +797,7 @@ clonetiler_get_transform (
         break;
     }
 
-    return NR::identity();
+    return Geom::identity();
 }
 
 static bool
@@ -854,6 +830,7 @@ static NRArena const *trace_arena = NULL;
 static unsigned trace_visionkey;
 static NRArenaItem *trace_root;
 static gdouble trace_zoom;
+static SPDocument *trace_doc;
 
 static void
 clonetiler_trace_hide_tiled_clones_recursively (SPObject *from)
@@ -861,9 +838,9 @@ clonetiler_trace_hide_tiled_clones_recursively (SPObject *from)
     if (!trace_arena)
         return;
 
-    for (SPObject *o = sp_object_first_child(from); o != NULL; o = SP_OBJECT_NEXT(o)) {
+    for (SPObject *o = from->firstChild(); o != NULL; o = o->next) {
         if (SP_IS_ITEM(o) && clonetiler_is_a_clone_of (o, NULL))
-            sp_item_invoke_hide(SP_ITEM(o), trace_visionkey); // FIXME: hide each tiled clone's original too!
+            SP_ITEM(o)->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too!
         clonetiler_trace_hide_tiled_clones_recursively (o);
     }
 }
@@ -873,41 +850,40 @@ clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original)
 {
     trace_arena = NRArena::create();
     /* Create ArenaItem and set transform */
-    trace_visionkey = sp_item_display_key_new(1);
-    trace_root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT (doc)),
-                                      (NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY);
+    trace_visionkey = SPItem::display_key_new(1);
+    trace_doc = doc;
+    trace_root = SP_ITEM(trace_doc->getRoot())->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY);
 
     // hide the (current) original and any tiled clones, we only want to pick the background
-    sp_item_invoke_hide(original, trace_visionkey);
-    clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (doc)));
+    original->invoke_hide(trace_visionkey);
+    clonetiler_trace_hide_tiled_clones_recursively(SP_OBJECT(trace_doc->getRoot()));
 
-    sp_document_root (doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
-    sp_document_ensure_up_to_date(doc);
+    trace_doc->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+    trace_doc->ensureUpToDate();
 
     trace_zoom = zoom;
 }
 
 static guint32
-clonetiler_trace_pick (NR::Rect box)
+clonetiler_trace_pick (Geom::Rect box)
 {
     if (!trace_arena)
         return 0;
 
-    NRMatrix t;
-    nr_matrix_set_scale(&t, trace_zoom, trace_zoom);
+    Geom::Matrix t(Geom::Scale(trace_zoom, trace_zoom));
     nr_arena_item_set_transform(trace_root, &t);
     NRGC gc(NULL);
-    nr_matrix_set_identity(&gc.transform);
+    gc.transform.setIdentity();
     nr_arena_item_invoke_update( trace_root, NULL, &gc,
                                  NR_ARENA_ITEM_STATE_ALL,
                                  NR_ARENA_ITEM_STATE_NONE );
 
     /* Item integer bbox in points */
     NRRectL ibox;
-    ibox.x0 = (int) floor(trace_zoom * box.min()[NR::X] + 0.5);
-    ibox.y0 = (int) floor(trace_zoom * box.min()[NR::Y] + 0.5);
-    ibox.x1 = (int) floor(trace_zoom * box.max()[NR::X] + 0.5);
-    ibox.y1 = (int) floor(trace_zoom * box.max()[NR::Y] + 0.5);
+    ibox.x0 = (int) floor(trace_zoom * box[Geom::X].min() + 0.5);
+    ibox.y0 = (int) floor(trace_zoom * box[Geom::Y].min() + 0.5);
+    ibox.x1 = (int) floor(trace_zoom * box[Geom::X].max() + 0.5);
+    ibox.y1 = (int) floor(trace_zoom * box[Geom::Y].max() + 0.5);
 
     /* Find visible area */
     int width = ibox.x1 - ibox.x0;
@@ -965,6 +941,9 @@ clonetiler_trace_pick (NR::Rect box)
 static void
 clonetiler_trace_finish ()
 {
+    if (trace_doc) {
+        SP_ITEM(trace_doc->getRoot())->invoke_hide(trace_visionkey);
+    }
     if (trace_arena) {
         ((NRObject *) trace_arena)->unreference();
         trace_arena = NULL;
@@ -991,20 +970,20 @@ clonetiler_unclump( GtkWidget */*widget*/, void * )
 
     GSList *to_unclump = NULL; // not including the original
 
-    for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
         if (clonetiler_is_a_clone_of (child, obj)) {
             to_unclump = g_slist_prepend (to_unclump, child);
         }
     }
 
-    sp_document_ensure_up_to_date(sp_desktop_document(desktop));
+    sp_desktop_document(desktop)->ensureUpToDate();
 
     unclump (to_unclump);
 
     g_slist_free (to_unclump);
 
-    sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER,
-                      _("Unclump tiled clones"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+                       _("Unclump tiled clones"));
 }
 
 static guint
@@ -1014,7 +993,7 @@ clonetiler_number_of_clones (SPObject *obj)
 
     guint n = 0;
 
-    for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
         if (clonetiler_is_a_clone_of (child, obj)) {
             n ++;
         }
@@ -1043,7 +1022,7 @@ clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true )
 
 // remove old tiling
     GSList *to_delete = NULL;
-    for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
         if (clonetiler_is_a_clone_of (child, obj)) {
             to_delete = g_slist_prepend (to_delete, child);
         }
@@ -1055,25 +1034,26 @@ clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true )
 
     clonetiler_change_selection (NULL, selection, dlg);
 
-    if (do_undo)
-        sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER,
-                          _("Delete tiled clones"));
+    if (do_undo) {
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+                           _("Delete tiled clones"));
+    }
 }
 
-static NR::Rect
-transform_rect(NR::Rect const &r, NR::Matrix const &m)
+static Geom::Rect
+transform_rect( Geom::Rect const &r, Geom::Matrix const &m)
 {
-    using NR::X;
-    using NR::Y;
-    NR::Point const p1 = r.corner(1) * m;
-    NR::Point const p2 = r.corner(2) * m;
-    NR::Point const p3 = r.corner(3) * m;
-    NR::Point const p4 = r.corner(4) * m;
-    return NR::Rect(
-        NR::Point(
+    using Geom::X;
+    using Geom::Y;
+    Geom::Point const p1 = r.corner(1) * m;
+    Geom::Point const p2 = r.corner(2) * m;
+    Geom::Point const p3 = r.corner(3) * m;
+    Geom::Point const p4 = r.corner(4) * m;
+    return Geom::Rect(
+        Geom::Point(
             std::min(std::min(p1[X], p2[X]), std::min(p3[X], p4[X])),
             std::min(std::min(p1[Y], p2[Y]), std::min(p3[Y], p4[Y]))),
-        NR::Point(
+        Geom::Point(
             std::max(std::max(p1[X], p2[X]), std::max(p3[X], p4[X])),
             std::max(std::max(p1[Y], p2[Y]), std::max(p3[Y], p4[Y]))));
 }
@@ -1098,7 +1078,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
     if (desktop == NULL)
         return;
-
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
     // check if something is selected
@@ -1113,6 +1093,15 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
         return;
     }
 
+    // set "busy" cursor
+    desktop->setWaitingCursor();
+
+    // set statusbar text
+    GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status");
+    gtk_label_set_markup (GTK_LABEL(status), _("<small>Creating tiled clones...</small>"));
+    gtk_widget_queue_draw(GTK_WIDGET(status));
+    gdk_window_process_all_updates();
+
     SPObject *obj = SP_OBJECT(selection->singleItem());
     Inkscape::XML::Node *obj_repr = SP_OBJECT_REPR(obj);
     const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id"));
@@ -1120,95 +1109,93 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
     clonetiler_remove (NULL, NULL, false);
 
-    double shiftx_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shiftx_per_i", 0, -100, 1000);
-    double shifty_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shifty_per_i", 0, -100, 1000);
-    double shiftx_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shiftx_per_j", 0, -100, 1000);
-    double shifty_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shifty_per_j", 0, -100, 1000);
-    double shiftx_rand  = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shiftx_rand", 0, 0, 1000);
-    double shifty_rand  = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shifty_rand", 0, 0, 1000);
-    double shiftx_exp   =        prefs_get_double_attribute_limited (prefs_path, "shiftx_exp",   1, 0, 10);
-    double shifty_exp   =        prefs_get_double_attribute_limited (prefs_path, "shifty_exp", 1, 0, 10);
-    int    shiftx_alternate =    prefs_get_int_attribute (prefs_path, "shiftx_alternate", 0);
-    int    shifty_alternate =    prefs_get_int_attribute (prefs_path, "shifty_alternate", 0);
-    int    shiftx_cumulate  =    prefs_get_int_attribute (prefs_path, "shiftx_cumulate", 0);
-    int    shifty_cumulate  =    prefs_get_int_attribute (prefs_path, "shifty_cumulate", 0);
-    int    shiftx_excludew  =    prefs_get_int_attribute (prefs_path, "shiftx_excludew", 0);
-    int    shifty_excludeh  =    prefs_get_int_attribute (prefs_path, "shifty_excludeh", 0);
-
-    double scalex_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scalex_per_i", 0, -100, 1000);
-    double scaley_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scaley_per_i", 0, -100, 1000);
-    double scalex_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scalex_per_j", 0, -100, 1000);
-    double scaley_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scaley_per_j", 0, -100, 1000);
-    double scalex_rand  = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scalex",  0, 0, 1000);
-    double scaley_rand  = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scaley",  0, 0, 1000);
-    double scalex_exp   =        prefs_get_double_attribute_limited (prefs_path, "scalex_exp",   1, 0, 10);
-    double scaley_exp   =        prefs_get_double_attribute_limited (prefs_path, "scaley_exp",   1, 0, 10);
-    double scalex_log       =    prefs_get_double_attribute_limited (prefs_path, "scalex_log",   0, 0, 10);
-    double scaley_log       =    prefs_get_double_attribute_limited (prefs_path, "scaley_log",   0, 0, 10);
-    int    scalex_alternate =    prefs_get_int_attribute (prefs_path, "scalex_alternate", 0);
-    int    scaley_alternate =    prefs_get_int_attribute (prefs_path, "scaley_alternate", 0);
-    int    scalex_cumulate  =    prefs_get_int_attribute (prefs_path, "scalex_cumulate", 0);
-    int    scaley_cumulate  =    prefs_get_int_attribute (prefs_path, "scaley_cumulate", 0);
-
-    double rotate_per_i =        prefs_get_double_attribute_limited (prefs_path, "rotate_per_i", 0, -180, 180);
-    double rotate_per_j =        prefs_get_double_attribute_limited (prefs_path, "rotate_per_j", 0, -180, 180);
-    double rotate_rand =  0.01 * prefs_get_double_attribute_limited (prefs_path, "rotate_rand", 0, 0, 100);
-    int    rotate_alternatei   = prefs_get_int_attribute (prefs_path, "rotate_alternatei", 0);
-    int    rotate_alternatej   = prefs_get_int_attribute (prefs_path, "rotate_alternatej", 0);
-    int    rotate_cumulatei    = prefs_get_int_attribute (prefs_path, "rotate_cumulatei", 0);
-    int    rotate_cumulatej    = prefs_get_int_attribute (prefs_path, "rotate_cumulatej", 0);
-
-    double blur_per_i =   0.01 * prefs_get_double_attribute_limited (prefs_path, "blur_per_i", 0, 0, 100);
-    double blur_per_j =   0.01 * prefs_get_double_attribute_limited (prefs_path, "blur_per_j", 0, 0, 100);
-    int    blur_alternatei =     prefs_get_int_attribute (prefs_path, "blur_alternatei", 0);
-    int    blur_alternatej =     prefs_get_int_attribute (prefs_path, "blur_alternatej", 0);
-    double blur_rand =    0.01 * prefs_get_double_attribute_limited (prefs_path, "blur_rand", 0, 0, 100);
-
-    double opacity_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "opacity_per_i", 0, 0, 100);
-    double opacity_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "opacity_per_j", 0, 0, 100);
-    int    opacity_alternatei =   prefs_get_int_attribute (prefs_path, "opacity_alternatei", 0);
-    int    opacity_alternatej =   prefs_get_int_attribute (prefs_path, "opacity_alternatej", 0);
-    double opacity_rand =  0.01 * prefs_get_double_attribute_limited (prefs_path, "opacity_rand", 0, 0, 100);
-
-    const gchar *initial_color =     prefs_get_string_attribute (prefs_path, "initial_color");
-    double hue_per_j =        0.01 * prefs_get_double_attribute_limited (prefs_path, "hue_per_j", 0, -100, 100);
-    double hue_per_i =        0.01 * prefs_get_double_attribute_limited (prefs_path, "hue_per_i", 0, -100, 100);
-    double hue_rand  =        0.01 * prefs_get_double_attribute_limited (prefs_path, "hue_rand", 0, 0, 100);
-    double saturation_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "saturation_per_j", 0, -100, 100);
-    double saturation_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "saturation_per_i", 0, -100, 100);
-    double saturation_rand =  0.01 * prefs_get_double_attribute_limited (prefs_path, "saturation_rand", 0, 0, 100);
-    double lightness_per_j =  0.01 * prefs_get_double_attribute_limited (prefs_path, "lightness_per_j", 0, -100, 100);
-    double lightness_per_i =  0.01 * prefs_get_double_attribute_limited (prefs_path, "lightness_per_i", 0, -100, 100);
-    double lightness_rand =   0.01 * prefs_get_double_attribute_limited (prefs_path, "lightness_rand", 0, 0, 100);
-    int    color_alternatej = prefs_get_int_attribute (prefs_path, "color_alternatej", 0);
-    int    color_alternatei = prefs_get_int_attribute (prefs_path, "color_alternatei", 0);
-
-    int type = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
-
-    int keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
-
-    int imax = prefs_get_int_attribute (prefs_path, "imax", 2);
-    int jmax = prefs_get_int_attribute (prefs_path, "jmax", 2);
-
-    int fillrect = prefs_get_int_attribute (prefs_path, "fillrect", 0);
-    double fillwidth = prefs_get_double_attribute_limited (prefs_path, "fillwidth", 50, 0, 1e6);
-    double fillheight = prefs_get_double_attribute_limited (prefs_path, "fillheight", 50, 0, 1e6);
-
-    int dotrace = prefs_get_int_attribute (prefs_path, "dotrace", 0);
-    int pick = prefs_get_int_attribute (prefs_path, "pick", 0);
-    int pick_to_presence = prefs_get_int_attribute (prefs_path, "pick_to_presence", 0);
-    int pick_to_size = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
-    int pick_to_color = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
-    int pick_to_opacity = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
-    double rand_picked = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_picked", 0, 0, 100);
-    int invert_picked = prefs_get_int_attribute (prefs_path, "invert_picked", 0);
-    double gamma_picked = prefs_get_double_attribute_limited (prefs_path, "gamma_picked", 0, -10, 10);
+    double shiftx_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_i", 0, -10000, 10000);
+    double shifty_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_i", 0, -10000, 10000);
+    double shiftx_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_j", 0, -10000, 10000);
+    double shifty_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_j", 0, -10000, 10000);
+    double shiftx_rand  = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_rand", 0, 0, 1000);
+    double shifty_rand  = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_rand", 0, 0, 1000);
+    double shiftx_exp   =        prefs->getDoubleLimited(prefs_path + "shiftx_exp",   1, 0, 10);
+    double shifty_exp   =        prefs->getDoubleLimited(prefs_path + "shifty_exp", 1, 0, 10);
+    bool   shiftx_alternate =    prefs->getBool(prefs_path + "shiftx_alternate");
+    bool   shifty_alternate =    prefs->getBool(prefs_path + "shifty_alternate");
+    bool   shiftx_cumulate  =    prefs->getBool(prefs_path + "shiftx_cumulate");
+    bool   shifty_cumulate  =    prefs->getBool(prefs_path + "shifty_cumulate");
+    bool   shiftx_excludew  =    prefs->getBool(prefs_path + "shiftx_excludew");
+    bool   shifty_excludeh  =    prefs->getBool(prefs_path + "shifty_excludeh");
+
+    double scalex_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_per_i", 0, -100, 1000);
+    double scaley_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_per_i", 0, -100, 1000);
+    double scalex_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_per_j", 0, -100, 1000);
+    double scaley_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_per_j", 0, -100, 1000);
+    double scalex_rand  = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_rand",  0, 0, 1000);
+    double scaley_rand  = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_rand",  0, 0, 1000);
+    double scalex_exp   =        prefs->getDoubleLimited(prefs_path + "scalex_exp",   1, 0, 10);
+    double scaley_exp   =        prefs->getDoubleLimited(prefs_path + "scaley_exp",   1, 0, 10);
+    double scalex_log       =    prefs->getDoubleLimited(prefs_path + "scalex_log",   0, 0, 10);
+    double scaley_log       =    prefs->getDoubleLimited(prefs_path + "scaley_log",   0, 0, 10);
+    bool   scalex_alternate =    prefs->getBool(prefs_path + "scalex_alternate");
+    bool   scaley_alternate =    prefs->getBool(prefs_path + "scaley_alternate");
+    bool   scalex_cumulate  =    prefs->getBool(prefs_path + "scalex_cumulate");
+    bool   scaley_cumulate  =    prefs->getBool(prefs_path + "scaley_cumulate");
+
+    double rotate_per_i =        prefs->getDoubleLimited(prefs_path + "rotate_per_i", 0, -180, 180);
+    double rotate_per_j =        prefs->getDoubleLimited(prefs_path + "rotate_per_j", 0, -180, 180);
+    double rotate_rand =  0.01 * prefs->getDoubleLimited(prefs_path + "rotate_rand", 0, 0, 100);
+    bool   rotate_alternatei   = prefs->getBool(prefs_path + "rotate_alternatei");
+    bool   rotate_alternatej   = prefs->getBool(prefs_path + "rotate_alternatej");
+    bool   rotate_cumulatei    = prefs->getBool(prefs_path + "rotate_cumulatei");
+    bool   rotate_cumulatej    = prefs->getBool(prefs_path + "rotate_cumulatej");
+
+    double blur_per_i =   0.01 * prefs->getDoubleLimited(prefs_path + "blur_per_i", 0, 0, 100);
+    double blur_per_j =   0.01 * prefs->getDoubleLimited(prefs_path + "blur_per_j", 0, 0, 100);
+    bool   blur_alternatei =     prefs->getBool(prefs_path + "blur_alternatei");
+    bool   blur_alternatej =     prefs->getBool(prefs_path + "blur_alternatej");
+    double blur_rand =    0.01 * prefs->getDoubleLimited(prefs_path + "blur_rand", 0, 0, 100);
+
+    double opacity_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "opacity_per_i", 0, 0, 100);
+    double opacity_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "opacity_per_j", 0, 0, 100);
+    bool   opacity_alternatei =   prefs->getBool(prefs_path + "opacity_alternatei");
+    bool   opacity_alternatej =   prefs->getBool(prefs_path + "opacity_alternatej");
+    double opacity_rand =  0.01 * prefs->getDoubleLimited(prefs_path + "opacity_rand", 0, 0, 100);
+
+    Glib::ustring initial_color =    prefs->getString(prefs_path + "initial_color");
+    double hue_per_j =        0.01 * prefs->getDoubleLimited(prefs_path + "hue_per_j", 0, -100, 100);
+    double hue_per_i =        0.01 * prefs->getDoubleLimited(prefs_path + "hue_per_i", 0, -100, 100);
+    double hue_rand  =        0.01 * prefs->getDoubleLimited(prefs_path + "hue_rand", 0, 0, 100);
+    double saturation_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "saturation_per_j", 0, -100, 100);
+    double saturation_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "saturation_per_i", 0, -100, 100);
+    double saturation_rand =  0.01 * prefs->getDoubleLimited(prefs_path + "saturation_rand", 0, 0, 100);
+    double lightness_per_j =  0.01 * prefs->getDoubleLimited(prefs_path + "lightness_per_j", 0, -100, 100);
+    double lightness_per_i =  0.01 * prefs->getDoubleLimited(prefs_path + "lightness_per_i", 0, -100, 100);
+    double lightness_rand =   0.01 * prefs->getDoubleLimited(prefs_path + "lightness_rand", 0, 0, 100);
+    bool   color_alternatej = prefs->getBool(prefs_path + "color_alternatej");
+    bool   color_alternatei = prefs->getBool(prefs_path + "color_alternatei");
+
+    int    type = prefs->getInt(prefs_path + "symmetrygroup", 0);
+    bool   keepbbox = prefs->getBool(prefs_path + "keepbbox", true);
+    int    imax = prefs->getInt(prefs_path + "imax", 2);
+    int    jmax = prefs->getInt(prefs_path + "jmax", 2);
+
+    bool   fillrect = prefs->getBool(prefs_path + "fillrect");
+    double fillwidth = prefs->getDoubleLimited(prefs_path + "fillwidth", 50, 0, 1e6);
+    double fillheight = prefs->getDoubleLimited(prefs_path + "fillheight", 50, 0, 1e6);
+
+    bool   dotrace = prefs->getBool(prefs_path + "dotrace");
+    int    pick = prefs->getInt(prefs_path + "pick");
+    bool   pick_to_presence = prefs->getBool(prefs_path + "pick_to_presence");
+    bool   pick_to_size = prefs->getBool(prefs_path + "pick_to_size");
+    bool   pick_to_color = prefs->getBool(prefs_path + "pick_to_color");
+    bool   pick_to_opacity = prefs->getBool(prefs_path + "pick_to_opacity");
+    double rand_picked = 0.01 * prefs->getDoubleLimited(prefs_path + "rand_picked", 0, 0, 100);
+    bool   invert_picked = prefs->getBool(prefs_path + "invert_picked");
+    double gamma_picked = prefs->getDoubleLimited(prefs_path + "gamma_picked", 0, -10, 10);
 
     if (dotrace) {
         clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, SP_ITEM (obj));
     }
 
-    NR::Point center;
+    Geom::Point center;
     double w;
     double h;
     double x0;
@@ -1224,83 +1211,81 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
         double cx = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cx", 0);
         double cy = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cy", 0);
-        center = NR::Point (cx, cy);
+        center = Geom::Point (cx, cy);
 
         w = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-w", 0);
         h = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-h", 0);
         x0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-x0", 0);
         y0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-y0", 0);
     } else {
-        NR::Maybe<NR::Rect> r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj)),
-                                                        SPItem::GEOMETRIC_BBOX);
-        /* impl: Use of GEOMETRIC_BBOX is so that the stroke of rectangles will be shared
-         * (overlapped) rather than effectively doubled in width.
-         *
-         * (If you wish to change this, then please consider discussing at bug #1722238.) */
-
+        bool prefs_bbox = prefs->getBool("/tools/bounding_box", false);
+        SPItem::BBoxType bbox_type = ( prefs_bbox ? 
+            SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX );
+        Geom::OptRect r = SP_ITEM(obj)->getBounds(SP_ITEM(obj)->i2doc_affine(),
+                                                        bbox_type);
         if (r) {
-            w = r->dimensions()[NR::X];
-            h = r->dimensions()[NR::Y];
-            x0 = r->min()[NR::X];
-            y0 = r->min()[NR::Y];
+            w = r->dimensions()[Geom::X];
+            h = r->dimensions()[Geom::Y];
+            x0 = r->min()[Geom::X];
+            y0 = r->min()[Geom::Y];
             center = desktop->dt2doc(SP_ITEM(obj)->getCenter());
 
-            sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", center[NR::X]);
-            sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", center[NR::Y]);
+            sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", center[Geom::X]);
+            sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", center[Geom::Y]);
             sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w);
             sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h);
             sp_repr_set_svg_double(obj_repr, "inkscape:tile-x0", x0);
             sp_repr_set_svg_double(obj_repr, "inkscape:tile-y0", y0);
         } else {
-            center = NR::Point(0, 0);
+            center = Geom::Point(0, 0);
             w = h = 0;
             x0 = y0 = 0;
         }
     }
 
-    NR::Point cur = NR::Point (0, 0);
-    NR::Rect bbox_original = NR::Rect (NR::Point (x0, y0), NR::Point (x0 + w, y0 + h));
+    Geom::Point cur(0, 0);
+    Geom::Rect bbox_original (Geom::Point (x0, y0), Geom::Point (x0 + w, y0 + h));
     double perimeter_original = (w + h)/4;
 
     // The integers i and j are reserved for tile column and row.
     // The doubles x and y are used for coordinates
     for (int i = 0;
          fillrect?
-             (fabs(cur[NR::X]) < fillwidth && i < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows
+             (fabs(cur[Geom::X]) < fillwidth && i < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows
              : (i < imax);
          i ++) {
         for (int j = 0;
              fillrect?
-                 (fabs(cur[NR::Y]) < fillheight && j < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols
+                 (fabs(cur[Geom::Y]) < fillheight && j < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols
                  : (j < jmax);
              j ++) {
 
             // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored
 
             // Get transform from symmetry, shift, scale, rotation
-            NR::Matrix t = clonetiler_get_transform (type, i, j, center[NR::X], center[NR::Y], w, h,
-                                                     shiftx_per_i,     shifty_per_i,
-                                                     shiftx_per_j,     shifty_per_j,
-                                                     shiftx_rand,      shifty_rand,
-                                                     shiftx_exp,       shifty_exp,
-                                                     shiftx_alternate, shifty_alternate,
-                                                     shiftx_cumulate,  shifty_cumulate,
-                                                     shiftx_excludew,  shifty_excludeh,
-                                                     scalex_per_i,     scaley_per_i,
-                                                     scalex_per_j,     scaley_per_j,
-                                                     scalex_rand,      scaley_rand,
-                                                     scalex_exp,       scaley_exp,
-                                                     scalex_log,       scaley_log,
-                                                     scalex_alternate, scaley_alternate,
-                                                     scalex_cumulate,  scaley_cumulate,
-                                                     rotate_per_i,     rotate_per_j,
-                                                     rotate_rand,
-                                                     rotate_alternatei, rotate_alternatej,
-                                                     rotate_cumulatei,  rotate_cumulatej      );
+            Geom::Matrix t = clonetiler_get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h,
+                                                       shiftx_per_i,     shifty_per_i,
+                                                       shiftx_per_j,     shifty_per_j,
+                                                       shiftx_rand,      shifty_rand,
+                                                       shiftx_exp,       shifty_exp,
+                                                       shiftx_alternate, shifty_alternate,
+                                                       shiftx_cumulate,  shifty_cumulate,
+                                                       shiftx_excludew,  shifty_excludeh,
+                                                       scalex_per_i,     scaley_per_i,
+                                                       scalex_per_j,     scaley_per_j,
+                                                       scalex_rand,      scaley_rand,
+                                                       scalex_exp,       scaley_exp,
+                                                       scalex_log,       scaley_log,
+                                                       scalex_alternate, scaley_alternate,
+                                                       scalex_cumulate,  scaley_cumulate,
+                                                       rotate_per_i,     rotate_per_j,
+                                                       rotate_rand,
+                                                       rotate_alternatei, rotate_alternatej,
+                                                       rotate_cumulatei,  rotate_cumulatej      );
 
             cur = center * t - center;
             if (fillrect) {
-                if ((cur[NR::X] > fillwidth) || (cur[NR::Y] > fillheight)) { // off limits
+                if ((cur[Geom::X] > fillwidth) || (cur[Geom::Y] > fillheight)) { // off limits
                     continue;
                 }
             }
@@ -1308,8 +1293,8 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
             gchar color_string[32]; *color_string = 0;
 
             // Color tab
-            if (initial_color) {
-                guint32 rgba = sp_svg_read_color (initial_color, 0x000000ff);
+            if (!initial_color.empty()) {
+                guint32 rgba = sp_svg_read_color (initial_color.data(), 0x000000ff);
                 float hsl[3];
                 sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba));
 
@@ -1349,7 +1334,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
             // Trace tab
             if (dotrace) {
-                NR::Rect bbox_t = transform_rect (bbox_original, t);
+                Geom::Rect bbox_t = transform_rect (bbox_original, t);
 
                 guint32 rgba = clonetiler_trace_pick (bbox_t);
                 float r = SP_RGBA32_R_F(rgba);
@@ -1399,10 +1384,10 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
                 if (gamma_picked != 0) {
                     double power;
-                    if (gamma_picked < 0)
+                    if (gamma_picked > 0)
                         power = 1/(1 + fabs(gamma_picked));
                     else
-                        power = 1 + gamma_picked;
+                        power = 1 + fabs(gamma_picked);
 
                     val = pow (val, power);
                     r = pow (r, power);
@@ -1431,7 +1416,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
                     }
                 }
                 if (pick_to_size) {
-                    t = NR::translate(-center[NR::X], -center[NR::Y]) * NR::scale (val, val) * NR::translate(center[NR::X], center[NR::Y]) * t;
+                    t = Geom::Translate(-center[Geom::X], -center[Geom::Y]) * Geom::Scale (val, val) * Geom::Translate(center[Geom::X], center[Geom::Y]) * t;
                 }
                 if (pick_to_opacity) {
                     opacity *= val;
@@ -1456,7 +1441,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
             clone->setAttribute("inkscape:tiled-clone-of", id_href);
             clone->setAttribute("xlink:href", id_href);
 
-            NR::Point new_center;
+            Geom::Point new_center;
             bool center_set = false;
             if (obj_repr->attribute("inkscape:transform-center-x") || obj_repr->attribute("inkscape:transform-center-y")) {
                 new_center = desktop->dt2doc(SP_ITEM(obj)->getCenter()) * t;
@@ -1481,12 +1466,15 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
             if (blur > 0.0) {
                 SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone);
-                double perimeter = perimeter_original * t.expansion();
+                double perimeter = perimeter_original * t.descrim();
                 double radius = blur * perimeter;
+                // this is necessary for all newly added clones to have correct bboxes,
+                // otherwise filters won't work:
+                sp_desktop_document(desktop)->ensureUpToDate();
                 // it's hard to figure out exact width/height of the tile without having an object
                 // that we can take bbox of; however here we only need a lower bound so that blur
                 // margins are not too small, and the perimeter should work
-                SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, t.expansion(), t.expansionX(), t.expansionY(), perimeter, perimeter);
+                SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, t.descrim(), t.expansionX(), t.expansionY(), perimeter, perimeter);
                 sp_style_set_property_url (clone_object, "filter", SP_OBJECT(constructed), false);
             }
 
@@ -1501,7 +1489,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
             Inkscape::GC::release(clone);
         }
-        cur[NR::Y] = 0;
+        cur[Geom::Y] = 0;
     }
 
     if (dotrace) {
@@ -1510,8 +1498,10 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
     clonetiler_change_selection (NULL, selection, dlg);
 
-    sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
-                     _("Create tiled clones"));
+    desktop->clearWaitingCursor();
+
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+                       _("Create tiled clones"));
 }
 
 static GtkWidget *
@@ -1528,7 +1518,8 @@ static void
 clonetiler_checkbox_toggled (GtkToggleButton *tb, gpointer *data)
 {
     const gchar *attr = (const gchar *) data;
-    prefs_set_int_attribute (prefs_path, attr, gtk_toggle_button_get_active (tb));
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb));
 }
 
 static GtkWidget *
@@ -1539,7 +1530,8 @@ clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr)
     GtkWidget *b = gtk_check_button_new ();
     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL);
 
-    int value = prefs_get_int_attribute (prefs_path, attr, 0);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    bool value = prefs->getBool(prefs_path + attr);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value);
 
     gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0);
@@ -1555,8 +1547,9 @@ clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr)
 static void
 clonetiler_value_changed (GtkAdjustment *adj, gpointer data)
 {
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     const gchar *pref = (const gchar *) data;
-    prefs_set_double_attribute (prefs_path, pref, adj->value);
+    prefs->setDouble(prefs_path + pref, adj->value);
 }
 
 static GtkWidget *
@@ -1581,7 +1574,8 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l
         gtk_entry_set_width_chars (GTK_ENTRY (sb), 4);
         gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, SB_MARGIN);
 
-        double value = prefs_get_double_attribute_limited (prefs_path, attr, exponent? 1 : 0, lower, upper);
+        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+        double value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper);
         gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
         gtk_signal_connect(GTK_OBJECT(a), "value_changed",
                            GTK_SIGNAL_FUNC(clonetiler_value_changed), (gpointer) attr);
@@ -1605,28 +1599,32 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l
 static void
 clonetiler_symgroup_changed( GtkMenuItem */*item*/, gpointer data )
 {
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     gint group_new = GPOINTER_TO_INT (data);
-    prefs_set_int_attribute ( prefs_path, "symmetrygroup", group_new );
+    prefs->setInt(prefs_path + "symmetrygroup", group_new);
 }
 
 static void
 clonetiler_xy_changed (GtkAdjustment *adj, gpointer data)
 {
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     const gchar *pref = (const gchar *) data;
-    prefs_set_int_attribute (prefs_path, pref, (int) floor(adj->value + 0.5));
+    prefs->setInt(prefs_path + pref, (int) floor(adj->value + 0.5));
 }
 
 static void
 clonetiler_keep_bbox_toggled( GtkToggleButton *tb, gpointer /*data*/ )
 {
-    prefs_set_int_attribute (prefs_path, "keepbbox", gtk_toggle_button_get_active (tb));
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb));
 }
 
 static void
 clonetiler_pick_to (GtkToggleButton *tb, gpointer data)
 {
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     const gchar *pref = (const gchar *) data;
-    prefs_set_int_attribute (prefs_path, pref, gtk_toggle_button_get_active (tb));
+    prefs->setBool(prefs_path + pref, gtk_toggle_button_get_active(tb));
 }
 
 
@@ -1690,7 +1688,7 @@ clonetiler_table_x_y_rand (int values)
     {
         GtkWidget *hb = gtk_hbox_new (FALSE, 0);
 
-        GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "clonetiler_per_row");
+        GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_OBJECT_ROWS);
         gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
 
         GtkWidget *l = gtk_label_new ("");
@@ -1703,7 +1701,7 @@ clonetiler_table_x_y_rand (int values)
     {
         GtkWidget *hb = gtk_hbox_new (FALSE, 0);
 
-        GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "clonetiler_per_column");
+        GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_OBJECT_COLUMNS);
         gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
 
         GtkWidget *l = gtk_label_new ("");
@@ -1725,8 +1723,9 @@ clonetiler_table_x_y_rand (int values)
 static void
 clonetiler_pick_switched( GtkToggleButton */*tb*/, gpointer data )
 {
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     guint v = GPOINTER_TO_INT (data);
-    prefs_set_int_attribute (prefs_path, "pick", v);
+    prefs->setInt(prefs_path + "pick", v);
 }
 
 
@@ -1743,7 +1742,8 @@ clonetiler_switch_to_create( GtkToggleButton */*tb*/, GtkWidget *dlg )
         gtk_widget_set_sensitive (widthheight, FALSE);
     }
 
-    prefs_set_int_attribute (prefs_path, "fillrect", 0);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setBool(prefs_path + "fillrect", false);
 }
 
 
@@ -1760,7 +1760,8 @@ clonetiler_switch_to_fill( GtkToggleButton */*tb*/, GtkWidget *dlg )
         gtk_widget_set_sensitive (widthheight, TRUE);
     }
 
-    prefs_set_int_attribute (prefs_path, "fillrect", 1);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setBool(prefs_path + "fillrect", true);
 }
 
 
@@ -1773,7 +1774,8 @@ clonetiler_fill_width_changed (GtkAdjustment *adj, GtkWidget *u)
     SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
     gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
 
-    prefs_set_double_attribute (prefs_path, "fillwidth", pixels);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setDouble(prefs_path + "fillwidth", pixels);
 }
 
 static void
@@ -1783,7 +1785,8 @@ clonetiler_fill_height_changed (GtkAdjustment *adj, GtkWidget *u)
     SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
     gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
 
-    prefs_set_double_attribute (prefs_path, "fillheight", pixels);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setDouble(prefs_path + "fillheight", pixels);
 }
 
 
@@ -1792,7 +1795,8 @@ clonetiler_do_pick_toggled( GtkToggleButton *tb, gpointer /*data*/ )
 {
     GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace");
 
-    prefs_set_int_attribute (prefs_path, "dotrace", gtk_toggle_button_get_active (tb));
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setBool(prefs_path + "dotrace", gtk_toggle_button_get_active (tb));
 
     if (vvb)
         gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb));
@@ -1804,6 +1808,7 @@ clonetiler_do_pick_toggled( GtkToggleButton *tb, gpointer /*data*/ )
 void
 clonetiler_dialog (void)
 {
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     if (!dlg)
     {
         gchar title[500];
@@ -1811,13 +1816,13 @@ clonetiler_dialog (void)
 
         dlg = sp_window_new (title, TRUE);
         if (x == -1000 || y == -1000) {
-            x = prefs_get_int_attribute (prefs_path, "x", -1000);
-            y = prefs_get_int_attribute (prefs_path, "y", -1000);
+            x = prefs->getInt(prefs_path + "x", -1000);
+            y = prefs->getInt(prefs_path + "y", -1000);
         }
 
         if (w ==0 || h == 0) {
-            w = prefs_get_int_attribute (prefs_path, "w", 0);
-            h = prefs_get_int_attribute (prefs_path, "h", 0);
+            w = prefs->getInt(prefs_path + "w", 0);
+            h = prefs->getInt(prefs_path + "h", 0);
         }
 
 //        if (x<0) x=0;
@@ -1844,18 +1849,10 @@ clonetiler_dialog (void)
         gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg);
         gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg);
 
-        if (Inkscape::NSApplication::Application::getNewGui())
-        {
-            _shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (&on_delete);
-            _dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::bind (&on_dialog_hide, dlg));
-            _dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::bind (&on_dialog_unhide, dlg));
-            _desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::bind (&on_transientize, &wd));
-        } else {
-            g_signal_connect   ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
-            g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
-            g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
-            g_signal_connect   ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
-        }
+        g_signal_connect   ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
+        g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
+        g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
+        g_signal_connect   ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
 
         GtkTooltips *tt = gtk_tooltips_new();
 
@@ -1881,7 +1878,7 @@ clonetiler_dialog (void)
             gtk_box_pack_start (GTK_BOX (vb), om, FALSE, FALSE, SB_MARGIN);
 
             GtkWidget *m = gtk_menu_new ();
-            int current = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
+            int current = prefs->getInt(prefs_path + "symmetrygroup", 0);
 
             struct SymGroups {
                 int group;
@@ -1953,7 +1950,7 @@ clonetiler_dialog (void)
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
                                                    _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j",
-                                                   -100, 1000, "%");
+                                                   -10000, 10000, "%");
                 clonetiler_table_attach (table, l, 0, 2, 2);
             }
 
@@ -1961,7 +1958,7 @@ clonetiler_dialog (void)
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
                                                    _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i",
-                                                   -100, 1000, "%");
+                                                   -10000, 10000, "%");
                 clonetiler_table_attach (table, l, 0, 2, 3);
             }
 
@@ -1986,7 +1983,7 @@ clonetiler_dialog (void)
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
                                                    _("Vertical shift per row (in % of tile height)"), "shifty_per_j",
-                                                   -100, 1000, "%");
+                                                   -10000, 10000, "%");
                 clonetiler_table_attach (table, l, 0, 3, 2);
             }
 
@@ -1994,7 +1991,7 @@ clonetiler_dialog (void)
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
                                                    _("Vertical shift per column (in % of tile height)"), "shifty_per_i",
-                                                   -100, 1000, "%");
+                                                   -10000, 10000, "%");
                 clonetiler_table_attach (table, l, 0, 3, 3);
             }
 
@@ -2429,7 +2426,7 @@ clonetiler_dialog (void)
             GtkWidget *l = gtk_label_new (_("Initial color: "));
             gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
 
-            guint32 rgba = 0x000000ff | sp_svg_read_color (prefs_get_string_attribute(prefs_path, "initial_color"), 0x000000ff);
+            guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff);
             color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke)")), rgba, false);
             _color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));
 
@@ -2561,8 +2558,8 @@ clonetiler_dialog (void)
 
             GtkWidget *b  = gtk_check_button_new_with_label (_("Trace the drawing under the tiles"));
             g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
-            gint old = prefs_get_int_attribute (prefs_path, "dotrace", 0);
-            gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+            bool old = prefs->getBool(prefs_path + "dotrace");
+            gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
             gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone"), NULL);
             gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
 
@@ -2593,7 +2590,7 @@ clonetiler_dialog (void)
                     clonetiler_table_attach (table, radio, 0.0, 1, 1);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                                         GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR));
-                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_COLOR);
+                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR);
                 }
                 {
                     radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity"));
@@ -2601,7 +2598,7 @@ clonetiler_dialog (void)
                     clonetiler_table_attach (table, radio, 0.0, 2, 1);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                                         GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY));
-                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_OPACITY);
+                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY);
                 }
                 {
                     radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R"));
@@ -2609,7 +2606,7 @@ clonetiler_dialog (void)
                     clonetiler_table_attach (table, radio, 0.0, 1, 2);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                                         GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R));
-                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_R);
+                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R);
                 }
                 {
                     radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G"));
@@ -2617,7 +2614,7 @@ clonetiler_dialog (void)
                     clonetiler_table_attach (table, radio, 0.0, 2, 2);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                                         GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G));
-                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_G);
+                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G);
                 }
                 {
                     radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B"));
@@ -2625,37 +2622,31 @@ clonetiler_dialog (void)
                     clonetiler_table_attach (table, radio, 0.0, 3, 2);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                                         GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B));
-                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_B);
+                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B);
                 }
                 {
-                    //TRANSLATORS: only translate "string" in "context|string".
-                    // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
-                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|H"));
+                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H"));
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the hue of the color"), NULL);
                     clonetiler_table_attach (table, radio, 0.0, 1, 3);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                                         GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H));
-                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_H);
+                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H);
                 }
                 {
-                    //TRANSLATORS: only translate "string" in "context|string".
-                    // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
-                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|S"));
+                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S"));
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the saturation of the color"), NULL);
                     clonetiler_table_attach (table, radio, 0.0, 2, 3);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                                         GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S));
-                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_S);
+                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S);
                 }
                 {
-                    //TRANSLATORS: only translate "string" in "context|string".
-                    // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
-                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|L"));
+                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L"));
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the lightness of the color"), NULL);
                     clonetiler_table_attach (table, radio, 0.0, 3, 3);
                     gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                                         GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L));
-                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_L);
+                    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L);
                 }
 
             }
@@ -2716,8 +2707,8 @@ clonetiler_dialog (void)
 
                 {
                     GtkWidget *b  = gtk_check_button_new_with_label (_("Presence"));
-                    gint old = prefs_get_int_attribute (prefs_path, "pick_to_presence", 1);
-                    gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+                    bool old = prefs->getBool(prefs_path + "pick_to_presence", true);
+                    gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is created with the probability determined by the picked value in that point"), NULL);
                     clonetiler_table_attach (table, b, 0.0, 1, 1);
                     gtk_signal_connect(GTK_OBJECT(b), "toggled",
@@ -2726,8 +2717,8 @@ clonetiler_dialog (void)
 
                 {
                     GtkWidget *b  = gtk_check_button_new_with_label (_("Size"));
-                    gint old = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
-                    gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+                    bool old = prefs->getBool(prefs_path + "pick_to_size");
+                    gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's size is determined by the picked value in that point"), NULL);
                     clonetiler_table_attach (table, b, 0.0, 2, 1);
                     gtk_signal_connect(GTK_OBJECT(b), "toggled",
@@ -2736,8 +2727,8 @@ clonetiler_dialog (void)
 
                 {
                     GtkWidget *b  = gtk_check_button_new_with_label (_("Color"));
-                    gint old = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
-                    gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+                    bool old = prefs->getBool(prefs_path + "pick_to_color", 0);
+                    gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)"), NULL);
                     clonetiler_table_attach (table, b, 0.0, 1, 2);
                     gtk_signal_connect(GTK_OBJECT(b), "toggled",
@@ -2746,15 +2737,15 @@ clonetiler_dialog (void)
 
                 {
                     GtkWidget *b  = gtk_check_button_new_with_label (_("Opacity"));
-                    gint old = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
-                    gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+                    bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0);
+                    gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's opacity is determined by the picked value in that point"), NULL);
                     clonetiler_table_attach (table, b, 0.0, 2, 2);
                     gtk_signal_connect(GTK_OBJECT(b), "toggled",
                                        GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_opacity");
                 }
             }
-           gtk_widget_set_sensitive (vvb, prefs_get_int_attribute (prefs_path, "dotrace", 0));
+           gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace"));
         }
         }
 
@@ -2772,7 +2763,7 @@ clonetiler_dialog (void)
 
                 {
                     GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
-                    int value = prefs_get_int_attribute (prefs_path, "jmax", 2);
+                    int value = prefs->getInt(prefs_path + "jmax", 2);
                     gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
                     GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many rows in the tiling"), NULL);
@@ -2792,7 +2783,7 @@ clonetiler_dialog (void)
 
                 {
                     GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
-                    int value = prefs_get_int_attribute (prefs_path, "imax", 2);
+                    int value = prefs->getInt(prefs_path + "imax", 2);
                     gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
                     GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
                     gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many columns in the tiling"), NULL);
@@ -2819,7 +2810,7 @@ clonetiler_dialog (void)
                     GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0);
                     sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
 
-                    double value = prefs_get_double_attribute (prefs_path, "fillwidth", 50);
+                    double value = prefs->getDouble(prefs_path + "fillwidth", 50.0);
                     SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
                     gdouble const units = sp_pixels_get_units (value, unit);
                     gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
@@ -2843,7 +2834,7 @@ clonetiler_dialog (void)
                     GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0);
                     sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
 
-                    double value = prefs_get_double_attribute (prefs_path, "fillheight", 50);
+                    double value = prefs->getDouble(prefs_path + "fillheight", 50.0);
                     SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
                     gdouble const units = sp_pixels_get_units (value, unit);
                     gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
@@ -2870,7 +2861,7 @@ clonetiler_dialog (void)
                 clonetiler_table_attach (table, radio, 0.0, 1, 1);
                 gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg);
             }
-            if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 0) {
+            if (!prefs->getBool(prefs_path + "fillrect")) {
                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
                 gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
             }
@@ -2880,7 +2871,7 @@ clonetiler_dialog (void)
                 clonetiler_table_attach (table, radio, 0.0, 2, 1);
                 gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg);
             }
-            if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 1) {
+            if (prefs->getBool(prefs_path + "fillrect")) {
                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
                 gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
             }
@@ -2893,8 +2884,8 @@ clonetiler_dialog (void)
             gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
 
             GtkWidget *b  = gtk_check_button_new_with_label (_("Use saved size and position of the tile"));
-            gint keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
-            gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox != 0);
+            bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true);
+            gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox);
             gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size"), NULL);
             gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
 
@@ -2985,4 +2976,4 @@ clonetiler_dialog (void)
   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 :