Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / dialogs / clonetiler.cpp
index c10c8e28c7d8c0a2750465cc2f193ef72e25443b..8045675b4022ac097f522747e6523d2f60774551 100644 (file)
@@ -1,14 +1,14 @@
-#define __SP_CLONE_TILER_C__
-
-/*
+/** @file
  * Clone tiling dialog
- *
- * Authors:
- *   bulia byak <buliabyak@users.sf.net> 
+ */
+/* 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
@@ -95,28 +83,20 @@ static sigc::connection _color_changed_connection;
 static Inkscape::UI::Widget::ColorPicker *color_picker;
 
 static void
-clonetiler_dialog_destroy (GtkObject *object, gpointer data)
+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;
-    
+
     wd.win = dlg = NULL;
     wd.stop = 0;
 
 }
 
 static gboolean
-clonetiler_dialog_delete (GtkObject *object, GdkEvent * /*event*/, gpointer data)
+clonetiler_dialog_delete (GtkObject */*object*/, GdkEvent * /*event*/, gpointer /*data*/)
 {
     gtk_window_get_position ((GtkWindow *) dlg, &x, &y);
     gtk_window_get_size ((GtkWindow *) dlg, &w, &h);
@@ -124,20 +104,16 @@ clonetiler_dialog_delete (GtkObject *object, GdkEvent * /*event*/, gpointer data
     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, 32, rgba);
-    repr->setAttribute("initial_color", c);
+    sp_svg_write_color(c, sizeof(c), rgba);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setString(prefs_path + "initial_color", c);
 
     is_updating = false;
 }
@@ -220,78 +196,206 @@ enum {
 };
 
 
-static NR::Matrix
-clonetiler_get_transform ( 
+static Geom::Matrix
+clonetiler_get_transform (
+
     // symmetry group
     int type,
+
     // row, column
-    int x, int y,
+    int i, int j,
+
     // center, width, height of the tile
     double cx, double cy,
-    double w, double h,
+    double w,  double h,
 
     // values from the dialog:
-    double d_x_per_x, double d_y_per_x, double d_x_per_y, double d_y_per_y,
-    int alternate_x, int alternate_y, double rand_x, double rand_y,
-    double d_per_x_exp, double d_per_y_exp,
-    double d_rot_per_x, double d_rot_per_y, int alternate_rotx, int alternate_roty, double rand_rot,
-    double d_scalex_per_x, double d_scaley_per_x, double d_scalex_per_y, double d_scaley_per_y,
-    int alternate_scalex, int alternate_scaley, double rand_scalex, double rand_scaley
+    // Shift
+    double shiftx_per_i,      double shifty_per_i,
+    double shiftx_per_j,      double shifty_per_j,
+    double shiftx_rand,       double shifty_rand,
+    double shiftx_exp,        double shifty_exp,
+    int    shiftx_alternate,  int    shifty_alternate,
+    int    shiftx_cumulate,   int    shifty_cumulate,
+    int    shiftx_excludew,   int    shifty_excludeh,
+
+    // Scale
+    double scalex_per_i,      double scaley_per_i,
+    double scalex_per_j,      double scaley_per_j,
+    double scalex_rand,       double scaley_rand,
+    double scalex_exp,        double scaley_exp,
+    double scalex_log,        double scaley_log,
+    int    scalex_alternate,  int    scaley_alternate,
+    int    scalex_cumulate,   int    scaley_cumulate,
+
+    // Rotation
+    double rotate_per_i,      double rotate_per_j,
+    double rotate_rand,
+    int    rotate_alternatei, int    rotate_alternatej,
+    int    rotate_cumulatei,  int    rotate_cumulatej
     )
 {
-    // in abs units
-    double eff_x = (alternate_x? (x%2) : pow ((double) x, d_per_x_exp));
-    double eff_y = (alternate_y? (y%2) : pow ((double) y, d_per_y_exp));
-    double dx = d_x_per_x * w * eff_x + d_x_per_y  * w * eff_y + rand_x * w * g_random_double_range (-1, 1);
-    double dy = d_y_per_x * h * eff_x + d_y_per_y  * h * eff_y + rand_y * h * g_random_double_range (-1, 1);
-
-    NR::Matrix rect_translate (NR::translate (w * pow ((double) x, d_per_x_exp) + dx, h * pow ((double) y, d_per_y_exp) + dy));
-
-    // in deg
-    double eff_x_rot = (alternate_rotx? (x%2) : (x));
-    double eff_y_rot = (alternate_roty? (y%2) : (y));
-    double drot = d_rot_per_x * eff_x_rot + d_rot_per_y * eff_y_rot + rand_rot * 180 * g_random_double_range (-1, 1);
-
-    // times the original
-    double eff_x_s = (alternate_scalex? (x%2) : (x));
-    double eff_y_s = (alternate_scaley? (y%2) : (y));
-    double rand_scale_x, rand_scale_y;
-    if (rand_scaley == rand_scalex) {
-        // if rands are equal, scale proportionally
-        rand_scale_x = rand_scale_y = rand_scalex * 1 * g_random_double_range (-1, 1);
+
+    // Shift (in units of tile width or height) -------------
+    double delta_shifti = 0.0;
+    double delta_shiftj = 0.0;
+
+    if( shiftx_alternate ) {
+        delta_shifti = (double)(i%2);
     } else {
-        rand_scale_x = rand_scalex * 1 * g_random_double_range (-1, 1);
-        rand_scale_y = rand_scaley * 1 * g_random_double_range (-1, 1);
+        if( shiftx_cumulate ) {  // Should the delta shifts be cumulative (i.e. 1, 1+2, 1+2+3, ...)
+            delta_shifti = (double)(i*i);
+        } else {
+            delta_shifti = (double)i;
+        }
+    }
+
+    if( shifty_alternate ) {
+        delta_shiftj = (double)(j%2);
+    } else {
+        if( shifty_cumulate ) {
+            delta_shiftj = (double)(j*j);
+        } else {
+            delta_shiftj = (double)j;
+        }
     }
-    double dscalex = 1 + d_scalex_per_x * eff_x_s + d_scalex_per_y * eff_y_s + rand_scale_x;
-    if (dscalex < 0) dscalex = 0;
-    double dscaley = 1 + d_scaley_per_x * eff_x_s + d_scaley_per_y * eff_y_s + rand_scale_y;
-    if (dscaley < 0) dscaley = 0;
 
-    NR::Matrix drot_c = NR::translate(-cx, -cy) * NR::rotate (M_PI*drot/180) * NR::translate(cx, cy);
+    // Random shift, only calculate if non-zero.
+    double delta_shiftx_rand = 0.0;
+    double delta_shifty_rand = 0.0;
+    if( shiftx_rand != 0.0 ) delta_shiftx_rand = shiftx_rand * g_random_double_range (-1, 1);
+    if( shifty_rand != 0.0 ) delta_shifty_rand = shifty_rand * g_random_double_range (-1, 1);
 
-    NR::Matrix dscale_c = NR::translate(-cx, -cy) * NR::scale (dscalex, dscaley) * NR::translate(cx, cy);
 
-    NR::Matrix d_s_r = dscale_c * drot_c;
+    // Delta shift (units of tile width/height)
+    double di = shiftx_per_i * delta_shifti  + shiftx_per_j * delta_shiftj + delta_shiftx_rand;
+    double dj = shifty_per_i * delta_shifti  + shifty_per_j * delta_shiftj + delta_shifty_rand;
 
-    NR::Matrix rotate_180_c = NR::translate(-cx, -cy) * NR::rotate (M_PI) * NR::translate(cx, cy);
+    // Shift in actual x and y, used below
+    double dx = w * di;
+    double dy = h * dj;
+
+    double shifti = di;
+    double shiftj = dj;
+
+    // Include tile width and height in shift if required
+    if( !shiftx_excludew ) shifti += i;
+    if( !shifty_excludeh ) shiftj += j;
+
+    // Add exponential shift if necessary
+    if ( shiftx_exp != 1.0 ) shifti = pow( shifti, shiftx_exp );
+    if ( shifty_exp != 1.0 ) shiftj = pow( shiftj, shifty_exp );
+
+    // Final shift
+    Geom::Matrix rect_translate (Geom::Translate (w * shifti, h * shiftj));
+
+    // Rotation (in degrees) ------------
+    double delta_rotationi = 0.0;
+    double delta_rotationj = 0.0;
+
+    if( rotate_alternatei ) {
+        delta_rotationi = (double)(i%2);
+    } else {
+        if( rotate_cumulatei ) {
+            delta_rotationi = (double)(i*i + i)/2.0;
+        } else {
+            delta_rotationi = (double)i;
+        }
+    }
 
-    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);
+    if( rotate_alternatej ) {
+        delta_rotationj = (double)(j%2);
+    } else {
+        if( rotate_cumulatej ) {
+            delta_rotationj = (double)(j*j + j)/2.0;
+        } else {
+            delta_rotationj = (double)j;
+        }
+    }
 
-    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);
+    double delta_rotate_rand = 0.0;
+    if( rotate_rand != 0.0 ) delta_rotate_rand = rotate_rand * 180.0 * g_random_double_range (-1, 1);
 
-    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);
+    double dr = rotate_per_i * delta_rotationi + rotate_per_j * delta_rotationj + delta_rotate_rand;
 
-    double cos60 = cos(M_PI/3);
-    double sin60 = sin(M_PI/3);
-    double cos30 = cos(M_PI/6);
-    double sin30 = sin(M_PI/6);
+    // Scale (times the original) -----------
+    double delta_scalei = 0.0;
+    double delta_scalej = 0.0;
 
-    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);
+    if( scalex_alternate ) {
+        delta_scalei = (double)(i%2);
+    } else {
+        if( scalex_cumulate ) {  // Should the delta scales be cumulative (i.e. 1, 1+2, 1+2+3, ...)
+            delta_scalei = (double)(i*i + i)/2.0;
+        } else {
+            delta_scalei = (double)i;
+        }
+    }
+
+    if( scaley_alternate ) {
+        delta_scalej = (double)(j%2);
+    } else {
+        if( scaley_cumulate ) {
+            delta_scalej = (double)(j*j + j)/2.0;
+        } else {
+            delta_scalej = (double)j;
+        }
+    }
+
+    // Random scale, only calculate if non-zero.
+    double delta_scalex_rand = 0.0;
+    double delta_scaley_rand = 0.0;
+    if( scalex_rand != 0.0 ) delta_scalex_rand = scalex_rand * g_random_double_range (-1, 1);
+    if( scaley_rand != 0.0 ) delta_scaley_rand = scaley_rand * g_random_double_range (-1, 1);
+    // But if random factors are same, scale x and y proportionally
+    if( scalex_rand == scaley_rand ) delta_scalex_rand = delta_scaley_rand;
+
+    // Total delta scale
+    double scalex = 1.0 + scalex_per_i * delta_scalei  + scalex_per_j * delta_scalej + delta_scalex_rand;
+    double scaley = 1.0 + scaley_per_i * delta_scalei  + scaley_per_j * delta_scalej + delta_scaley_rand;
+
+    if( scalex < 0.0 ) scalex = 0.0;
+    if( scaley < 0.0 ) scaley = 0.0;
+
+    // Add exponential scale if necessary
+    if ( scalex_exp != 1.0 ) scalex = pow( scalex, scalex_exp );
+    if ( scaley_exp != 1.0 ) scaley = pow( scaley, scaley_exp );
+
+    // Add logarithmic factor if necessary
+    if ( scalex_log  > 0.0 ) scalex = pow( scalex_log, scalex - 1.0 );
+    if ( scaley_log  > 0.0 ) scaley = pow( scaley_log, scaley - 1.0 );
+    // Alternative using rotation angle
+    //if ( scalex_log  != 1.0 ) scalex *= pow( scalex_log, M_PI*dr/180 );
+    //if ( scaley_log  != 1.0 ) scaley *= pow( scaley_log, M_PI*dr/180 );
+
+
+    // Calculate transformation matrices, translating back to "center of tile" (rotation center) before transforming
+    Geom::Matrix drot_c   = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI*dr/180)    * Geom::Translate(cx, cy);
+
+    Geom::Matrix dscale_c = Geom::Translate(-cx, -cy) * Geom::Scale (scalex, scaley)  * Geom::Translate(cx, cy);
+
+    Geom::Matrix d_s_r = dscale_c * drot_c;
+
+    Geom::Matrix rotate_180_c  = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI)      * Geom::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);
+
+    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);
+
+    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);
+
+    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
+    const double cos60 = cos(M_PI/3);
+    const double sin60 = sin(M_PI/3);
+    const double cos30 = cos(M_PI/6);
+    const double sin30 = sin(M_PI/6);
 
     switch (type) {
 
@@ -300,7 +404,7 @@ clonetiler_get_transform (
         break;
 
     case TILE_P2:
-        if (x % 2 == 0) {
+        if (i % 2 == 0) {
             return d_s_r * rect_translate;
         } else {
             return d_s_r * rotate_180_c * rect_translate;
@@ -308,7 +412,7 @@ clonetiler_get_transform (
         break;
 
     case TILE_PM:
-        if (x % 2 == 0) {
+        if (i % 2 == 0) {
             return d_s_r * rect_translate;
         } else {
             return d_s_r * flip_x * rect_translate;
@@ -316,7 +420,7 @@ clonetiler_get_transform (
         break;
 
     case TILE_PG:
-        if (y % 2 == 0) {
+        if (j % 2 == 0) {
             return d_s_r * rect_translate;
         } else {
             return d_s_r * flip_x * rect_translate;
@@ -324,7 +428,7 @@ clonetiler_get_transform (
         break;
 
     case TILE_CM:
-        if ((x + y) % 2 == 0) {
+        if ((i + j) % 2 == 0) {
             return d_s_r * rect_translate;
         } else {
             return d_s_r * flip_x * rect_translate;
@@ -332,14 +436,14 @@ clonetiler_get_transform (
         break;
 
     case TILE_PMM:
-        if (y % 2 == 0) {
-            if (x % 2 == 0) {
+        if (j % 2 == 0) {
+            if (i % 2 == 0) {
                 return d_s_r * rect_translate;
             } else {
                 return d_s_r * flip_x * rect_translate;
             }
         } else {
-            if (x % 2 == 0) {
+            if (i % 2 == 0) {
                 return d_s_r * flip_y * rect_translate;
             } else {
                 return d_s_r * flip_x * flip_y * rect_translate;
@@ -348,26 +452,30 @@ clonetiler_get_transform (
         break;
 
     case TILE_PMG:
-        if (y % 4 == 0) {
-            return d_s_r * rect_translate;
-        } else if (y % 4 == 1) {
-            return d_s_r * flip_y * rect_translate;
-        } else if (y % 4 == 2) {
-            return d_s_r * flip_x * rect_translate;
-        } else if (y % 4 == 3) {
-            return d_s_r * flip_x * flip_y * rect_translate;
+        if (j % 2 == 0) {
+            if (i % 2 == 0) {
+                return d_s_r * rect_translate;
+            } else {
+                return d_s_r * rotate_180_c * rect_translate;
+            }
+        } else {
+            if (i % 2 == 0) {
+                return d_s_r * flip_y * rect_translate;
+            } else {
+                return d_s_r * rotate_180_c * flip_y * rect_translate;
+            }
         }
         break;
 
     case TILE_PGG:
-        if (y % 2 == 0) {
-            if (x % 2 == 0) {
+        if (j % 2 == 0) {
+            if (i % 2 == 0) {
                 return d_s_r * rect_translate;
             } else {
                 return d_s_r * flip_y * rect_translate;
             }
         } else {
-            if (x % 2 == 0) {
+            if (i % 2 == 0) {
                 return d_s_r * rotate_180_c * rect_translate;
             } else {
                 return d_s_r * rotate_180_c * flip_y * rect_translate;
@@ -376,26 +484,26 @@ clonetiler_get_transform (
         break;
 
     case TILE_CMM:
-        if (y % 4 == 0) {
-            if (x % 2 == 0) {
+        if (j % 4 == 0) {
+            if (i % 2 == 0) {
                 return d_s_r * rect_translate;
             } else {
                 return d_s_r * flip_x * rect_translate;
             }
-        } else if (y % 4 == 1) {
-            if (x % 2 == 0) {
+        } else if (j % 4 == 1) {
+            if (i % 2 == 0) {
                 return d_s_r * flip_y * rect_translate;
             } else {
                 return d_s_r * flip_x * flip_y * rect_translate;
             }
-        } else if (y % 4 == 2) {
-            if (x % 2 == 1) {
+        } else if (j % 4 == 2) {
+            if (i % 2 == 1) {
                 return d_s_r * rect_translate;
             } else {
                 return d_s_r * flip_x * rect_translate;
             }
         } else {
-            if (x % 2 == 1) {
+            if (i % 2 == 1) {
                 return d_s_r * flip_y * rect_translate;
             } else {
                 return d_s_r * flip_x * flip_y * rect_translate;
@@ -405,17 +513,17 @@ clonetiler_get_transform (
 
     case TILE_P4:
     {
-        NR::Matrix ori (NR::translate ((w + h) * pow((x/2), d_per_x_exp) + dx,  (h + w) * pow((y/2), d_per_y_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));
-        if (y % 2 == 0) {
-            if (x % 2 == 0) {
+        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;
             } else {
                 return d_s_r * rotate_m90_c * dia1 * ori;
             }
         } else {
-            if (x % 2 == 0) {
+            if (i % 2 == 0) {
                 return d_s_r * rotate_90_c * dia2 * ori;
             } else {
                 return d_s_r * rotate_180_c * dia1 * dia2 * ori;
@@ -427,28 +535,28 @@ clonetiler_get_transform (
     case TILE_P4M:
     {
         double max = MAX(w, h);
-        NR::Matrix ori (NR::translate ((max + max) * pow((x/4), d_per_x_exp) + dx,  (max + max) * pow((y/2), d_per_y_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));
-        if (y % 2 == 0) {
-            if (x % 4 == 0) {
+        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 (x % 4 == 1) {
+            } else if (i % 4 == 1) {
                 return d_s_r * flip_y * rotate_m90_c * dia1 * ori;
-            } else if (x % 4 == 2) {
-                return d_s_r * rotate_m90_c * dia1 * NR::translate (h, 0) * ori;
-            } else if (x % 4 == 3) {
-                return d_s_r * flip_x * NR::translate (w, 0) * ori;
+            } else if (i % 4 == 2) {
+                return d_s_r * rotate_m90_c * dia1 * Geom::Translate (h, 0) * ori;
+            } else if (i % 4 == 3) {
+                return d_s_r * flip_x * Geom::Translate (w, 0) * ori;
             }
         } else {
-            if (x % 4 == 0) {
-                return d_s_r * flip_y * NR::translate(0, h) * ori;
-            } else if (x % 4 == 1) {
-                return d_s_r * rotate_90_c * dia2 * NR::translate(0, h) * ori;
-            } else if (x % 4 == 2) {
-                return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate(h, 0) * NR::translate(0, h) * ori;
-            } else if (x % 4 == 3) {
-                return d_s_r * flip_y * flip_x * NR::translate(w, 0) * NR::translate(0, h) * ori;
+            if (i % 4 == 0) {
+                return d_s_r * flip_y * Geom::Translate(0, h) * ori;
+            } else if (i % 4 == 1) {
+                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 * Geom::Translate(h, 0) * Geom::Translate(0, h) * ori;
+            } else if (i % 4 == 3) {
+                return d_s_r * flip_y * flip_x * Geom::Translate(w, 0) * Geom::Translate(0, h) * ori;
             }
         }
     }
@@ -457,28 +565,28 @@ clonetiler_get_transform (
     case TILE_P4G:
     {
         double max = MAX(w, h);
-        NR::Matrix ori (NR::translate ((max + max) * pow((x/4), d_per_x_exp) + dx,  (max + max) * pow(y, d_per_y_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));
-        if (((x/4) + y) % 2 == 0) {
-            if (x % 4 == 0) {
+        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;
-            } else if (x % 4 == 1) {
+            } else if (i % 4 == 1) {
                 return d_s_r * rotate_m90_c * dia1 * ori;
-            } else if (x % 4 == 2) {
+            } else if (i % 4 == 2) {
                 return d_s_r * rotate_90_c * dia2 * ori;
-            } else if (x % 4 == 3) {
+            } else if (i % 4 == 3) {
                 return d_s_r * rotate_180_c * dia1 * dia2 * ori;
             }
         } else {
-            if (x % 4 == 0) {
-                return d_s_r * flip_y * NR::translate (0, h) * ori;
-            } else if (x % 4 == 1) {
-                return d_s_r * flip_y * rotate_m90_c * dia1 * NR::translate (-h, 0) * ori;
-            } else if (x % 4 == 2) {
-                return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate (h, 0) * ori;
-            } else if (x % 4 == 3) {
-                return d_s_r * flip_x * NR::translate (w, 0) * ori;
+            if (i % 4 == 0) {
+                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 * Geom::Translate (-h, 0) * ori;
+            } else if (i % 4 == 2) {
+                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 * Geom::Translate (w, 0) * ori;
             }
         }
     }
@@ -488,25 +596,25 @@ 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;
+            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*(x/3) + y%2), d_per_x_exp) + dx,  (height/2) * pow(y, d_per_y_exp) + dy));
-        if (x % 3 == 0) {
+        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 (x % 3 == 1) {
+        } else if (i % 3 == 1) {
             return d_s_r * rotate_m120_c * dia1 * ori;
-        } else if (x % 3 == 2) {
+        } else if (i % 3 == 2) {
             return d_s_r * rotate_120_c * dia2 * ori;
         }
     }
@@ -514,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((x/6) + 1/2 * (y%2), d_per_x_exp) + dx,  (w * cos30) * pow(y, d_per_y_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((x/6 + 0.5*(y%2)), d_per_x_exp) + dx,  (2*h - h * sin30) * pow(y, d_per_y_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;
@@ -552,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*(x/6) + y%2), d_per_x_exp) + dx,  (height/2) * pow(y, d_per_y_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*(x/6) + (y%2)), d_per_x_exp) + dx,  (2*w * sin60) * pow(y, d_per_y_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((x/6 + 0.5*(y%2)), d_per_x_exp) + dx,  (h + h * sin30) * pow(y, d_per_y_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;
         }
     }
@@ -630,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*(x/12) + (y%2)), d_per_x_exp) + dx,  (2*w * sin60) * pow(y, d_per_y_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((x/12 + 0.5*(y%2)), d_per_x_exp) + dx,  (2*h  + 2*h * sin30) * pow(y, d_per_y_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;
@@ -689,7 +797,7 @@ clonetiler_get_transform (
         break;
     }
 
-    return NR::identity();
+    return Geom::identity();
 }
 
 static bool
@@ -722,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)
@@ -729,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);
     }
 }
@@ -741,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;
@@ -833,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;
@@ -840,7 +951,7 @@ clonetiler_trace_finish ()
 }
 
 static void
-clonetiler_unclump (GtkWidget *widget, void *)
+clonetiler_unclump( GtkWidget */*widget*/, void * )
 {
     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
     if (desktop == NULL)
@@ -859,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
@@ -882,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 ++;
         }
@@ -892,7 +1003,7 @@ clonetiler_number_of_clones (SPObject *obj)
 }
 
 static void
-clonetiler_remove (GtkWidget *widget, void *, bool do_undo = true)
+clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true )
 {
     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
     if (desktop == NULL)
@@ -911,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);
         }
@@ -923,26 +1034,27 @@ 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(
-            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(
-            std::max(std::max(p1[X], p2[X]), std::max(p3[X], p4[X])), 
+    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]))),
+        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]))));
 }
 
@@ -961,12 +1073,12 @@ randomize01 (double val, double rand)
 
 
 static void
-clonetiler_apply (GtkWidget *widget, void *)
+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
@@ -981,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"));
@@ -988,144 +1109,183 @@ clonetiler_apply (GtkWidget *widget, void *)
 
     clonetiler_remove (NULL, NULL, false);
 
-    double d_x_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_x_per_x", 0, -100, 1000);
-    double d_y_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_y_per_x", 0, -100, 1000);
-    double d_per_x_exp = prefs_get_double_attribute_limited (prefs_path, "d_per_x_exp", 1, 0, 10);
-    double d_x_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_x_per_y", 0, -100, 1000);
-    double d_y_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_y_per_y", 0, -100, 1000);
-    double d_per_y_exp = prefs_get_double_attribute_limited (prefs_path, "d_per_y_exp", 1, 0, 10);
-    int alternate_x = prefs_get_int_attribute (prefs_path, "alternate_x", 0);
-    int alternate_y = prefs_get_int_attribute (prefs_path, "alternate_y", 0);
-    double rand_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_x", 0, 0, 1000);
-    double rand_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_y", 0, 0, 1000);
-
-    double d_scalex_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scalex_per_x", 0, -100, 1000);
-    double d_scaley_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scaley_per_x", 0, -100, 1000);
-    double d_scalex_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scalex_per_y", 0, -100, 1000);
-    double d_scaley_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scaley_per_y", 0, -100, 1000);
-    int alternate_scalex = prefs_get_int_attribute (prefs_path, "alternate_scalex", 0);
-    int alternate_scaley = prefs_get_int_attribute (prefs_path, "alternate_scaley", 0);
-    double rand_scalex = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scalex", 0, 0, 1000);
-    double rand_scaley = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scaley", 0, 0, 1000);
-
-    double d_rot_per_x = prefs_get_double_attribute_limited (prefs_path, "d_rot_per_x", 0, -180, 180);
-    double d_rot_per_y = prefs_get_double_attribute_limited (prefs_path, "d_rot_per_y", 0, -180, 180);
-    int alternate_rotx = prefs_get_int_attribute (prefs_path, "alternate_rotx", 0);
-    int alternate_roty = prefs_get_int_attribute (prefs_path, "alternate_roty", 0);
-    double rand_rot = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_rot", 0, 0, 100);
-
-    double d_blur_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_blur_per_y", 0, 0, 100);
-    double d_blur_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_blur_per_x", 0, 0, 100);
-    int alternate_blury = prefs_get_int_attribute (prefs_path, "alternate_blury", 0);
-    int alternate_blurx = prefs_get_int_attribute (prefs_path, "alternate_blurx", 0);
-    double rand_blur = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_blur", 0, 0, 100);
-
-    double d_opacity_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_y", 0, 0, 100);
-    double d_opacity_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_x", 0, 0, 100);
-    int alternate_opacityy = prefs_get_int_attribute (prefs_path, "alternate_opacityy", 0);
-    int alternate_opacityx = prefs_get_int_attribute (prefs_path, "alternate_opacityx", 0);
-    double rand_opacity = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_opacity", 0, 0, 100);
-
-    const gchar *initial_color = prefs_get_string_attribute (prefs_path, "initial_color");
-    double d_hue_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_hue_per_y", 0, -100, 100);
-    double d_hue_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_hue_per_x", 0, -100, 100);
-    double rand_hue = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_hue", 0, 0, 100);
-    double d_saturation_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_saturation_per_y", 0, -100, 100);
-    double d_saturation_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_saturation_per_x", 0, -100, 100);
-    double rand_saturation = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_saturation", 0, 0, 100);
-    double d_lightness_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_lightness_per_y", 0, -100, 100);
-    double d_lightness_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_lightness_per_x", 0, -100, 100);
-    double rand_lightness = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_lightness", 0, 0, 100);
-    int alternate_color_y = prefs_get_int_attribute (prefs_path, "alternate_color_y", 0);
-    int alternate_color_x = prefs_get_int_attribute (prefs_path, "alternate_color_x", 0);
-
-    int type = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
-
-    int keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
-
-    int xmax = prefs_get_int_attribute (prefs_path, "xmax", 2);
-    int ymax = prefs_get_int_attribute (prefs_path, "ymax", 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 c;
+    Geom::Point center;
     double w;
     double h;
+    double x0;
+    double y0;
 
     if (keepbbox &&
         obj_repr->attribute("inkscape:tile-w") &&
         obj_repr->attribute("inkscape:tile-h") &&
+        obj_repr->attribute("inkscape:tile-x0") &&
+        obj_repr->attribute("inkscape:tile-y0") &&
         obj_repr->attribute("inkscape:tile-cx") &&
         obj_repr->attribute("inkscape:tile-cy")) {
 
         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);
-
-        c = 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)));
+        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) {
-            c = r->midpoint();
-            w = r->dimensions()[NR::X];
-            h = r->dimensions()[NR::Y];
-
-            sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", c[NR::X]);
-            sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", c[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[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 {
-            c = 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 (c[NR::X] - w/2, c[NR::Y] - h/2), NR::Point (c[NR::X] + w/2, c[NR::Y] + h/2));
+    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;
 
-    for (int x = 0;
+    // 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 && x < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows
-             : (x < xmax);
-         x ++) {
-        for (int y = 0;
+             (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 && y < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols
-                 : (y < ymax);
-             y ++) {
+                 (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, x, y, c[NR::X], c[NR::Y], w, h,
-                                                     d_x_per_x, d_y_per_x, d_x_per_y, d_y_per_y, alternate_x, alternate_y, rand_x, rand_y,
-                                                     d_per_x_exp, d_per_y_exp,
-                                                     d_rot_per_x, d_rot_per_y, alternate_rotx, alternate_roty, rand_rot,
-                                                     d_scalex_per_x, d_scaley_per_x, d_scalex_per_y, d_scaley_per_y,
-                                                     alternate_scalex, alternate_scaley, rand_scalex, rand_scaley);
-
-            cur = c * t - c;
+            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;
                 }
             }
@@ -1133,48 +1293,48 @@ 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));
 
-                double eff_x = (alternate_color_x? (x%2) : (x));
-                double eff_y = (alternate_color_y? (y%2) : (y));
+                double eff_i = (color_alternatei? (i%2) : (i));
+                double eff_j = (color_alternatej? (j%2) : (j));
 
-                hsl[0] += d_hue_per_x * eff_x + d_hue_per_y * eff_y + rand_hue * g_random_double_range (-1, 1);
-                if (hsl[0] < 0) hsl[0] += 1;
-                if (hsl[0] > 1) hsl[0] -= 1;
-                hsl[1] += d_saturation_per_x * eff_x + d_saturation_per_y * eff_y + rand_saturation * g_random_double_range (-1, 1);
+                hsl[0] += hue_per_i * eff_i + hue_per_j * eff_j + hue_rand * g_random_double_range (-1, 1);
+                double notused;
+                hsl[0] = modf( hsl[0], &notused ); // Restrict to 0-1
+                hsl[1] += saturation_per_i * eff_i + saturation_per_j * eff_j + saturation_rand * g_random_double_range (-1, 1);
                 hsl[1] = CLAMP (hsl[1], 0, 1);
-                hsl[2] += d_lightness_per_x * eff_x + d_lightness_per_y * eff_y + rand_lightness * g_random_double_range (-1, 1);
+                hsl[2] += lightness_per_i * eff_i + lightness_per_j * eff_j + lightness_rand * g_random_double_range (-1, 1);
                 hsl[2] = CLAMP (hsl[2], 0, 1);
 
                 float rgb[3];
                 sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]);
-                sp_svg_write_color(color_string, 32, SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0));
+                sp_svg_write_color(color_string, sizeof(color_string), SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0));
             }
 
             // Blur
             double blur = 0.0;
             {
-            int eff_x = (alternate_blurx? (x%2) : (x));
-            int eff_y = (alternate_blury? (y%2) : (y));
-            blur =  (d_blur_per_x * eff_x + d_blur_per_y * eff_y + rand_blur * g_random_double_range (-1, 1));
+            int eff_i = (blur_alternatei? (i%2) : (i));
+            int eff_j = (blur_alternatej? (j%2) : (j));
+            blur =  (blur_per_i * eff_i + blur_per_j * eff_j + blur_rand * g_random_double_range (-1, 1));
             blur = CLAMP (blur, 0, 1);
             }
 
             // Opacity
             double opacity = 1.0;
             {
-            int eff_x = (alternate_opacityx? (x%2) : (x));
-            int eff_y = (alternate_opacityy? (y%2) : (y));
-            opacity = 1 - (d_opacity_per_x * eff_x + d_opacity_per_y * eff_y + rand_opacity * g_random_double_range (-1, 1));
+            int eff_i = (opacity_alternatei? (i%2) : (i));
+            int eff_j = (opacity_alternatej? (j%2) : (j));
+            opacity = 1 - (opacity_per_i * eff_i + opacity_per_j * eff_j + opacity_rand * g_random_double_range (-1, 1));
             opacity = CLAMP (opacity, 0, 1);
             }
 
             // 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);
@@ -1224,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);
@@ -1256,13 +1416,13 @@ clonetiler_apply (GtkWidget *widget, void *)
                     }
                 }
                 if (pick_to_size) {
-                    t = NR::translate(-c[NR::X], -c[NR::Y]) * NR::scale (val, val) * NR::translate(c[NR::X], c[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;
                 }
                 if (pick_to_color) {
-                    sp_svg_write_color(color_string, 32, rgba);
+                    sp_svg_write_color(color_string, sizeof(color_string), rgba);
                 }
             }
 
@@ -1281,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;
@@ -1306,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);
             }
 
@@ -1326,7 +1489,7 @@ clonetiler_apply (GtkWidget *widget, void *)
 
             Inkscape::GC::release(clone);
         }
-        cur[NR::Y] = 0;
+        cur[Geom::Y] = 0;
     }
 
     if (dotrace) {
@@ -1335,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 *
@@ -1353,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 *
@@ -1364,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);
@@ -1380,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 *
@@ -1406,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);
@@ -1428,30 +1597,34 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l
 }
 
 static void
-clonetiler_symgroup_changed (GtkMenuItem *item, gpointer data)
+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)
+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));
 }
 
 
@@ -1491,7 +1664,7 @@ clonetiler_reset_recursive (GtkWidget *w)
 }
 
 static void
-clonetiler_reset (GtkWidget *widget, void *)
+clonetiler_reset( GtkWidget */*widget*/, void * )
 {
     clonetiler_reset_recursive (dlg);
 }
@@ -1515,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 ("");
@@ -1528,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 ("");
@@ -1548,15 +1721,16 @@ clonetiler_table_x_y_rand (int values)
 }
 
 static void
-clonetiler_pick_switched (GtkToggleButton *tb, gpointer data)
+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);
 }
 
 
 static void
-clonetiler_switch_to_create (GtkToggleButton *tb, GtkWidget *dlg)
+clonetiler_switch_to_create( GtkToggleButton */*tb*/, GtkWidget *dlg )
 {
     GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
     GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
@@ -1568,12 +1742,13 @@ 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);
 }
 
 
 static void
-clonetiler_switch_to_fill (GtkToggleButton *tb, GtkWidget *dlg)
+clonetiler_switch_to_fill( GtkToggleButton */*tb*/, GtkWidget *dlg )
 {
     GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
     GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
@@ -1585,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);
 }
 
 
@@ -1598,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
@@ -1608,16 +1785,18 @@ 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);
 }
 
 
 static void
-clonetiler_do_pick_toggled (GtkToggleButton *tb, gpointer data)
+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));
@@ -1629,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];
@@ -1636,15 +1816,15 @@ 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;
 //        if (y<0) y=0;
 
@@ -1653,34 +1833,26 @@ clonetiler_dialog (void)
         }
         if (x >= 0 && y >= 0 && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE))) {
             gtk_window_move ((GtkWindow *) dlg, x, y);
-        
+
         } else {
             gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
         }
-        
-        
+
+
         sp_transientize (dlg);
         wd.win = dlg;
         wd.stop = 0;
-        
-                             
+
+
         gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg);
-        
+
         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();
 
@@ -1706,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;
@@ -1777,22 +1949,22 @@ clonetiler_dialog (void)
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Horizontal shift per row (in % of tile width)"), "d_x_per_y",
-                                                   -100, 1000, "%");
+                                                   _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j",
+                                                   -10000, 10000, "%");
                 clonetiler_table_attach (table, l, 0, 2, 2);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Horizontal shift per column (in % of tile width)"), "d_x_per_x",
-                                                   -100, 1000, "%");
+                                                   _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i",
+                                                   -10000, 10000, "%");
                 clonetiler_table_attach (table, l, 0, 2, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the horizontal shift by this percentage"), "rand_x",
+                                                   _("Randomize the horizontal shift by this percentage"), "shiftx_rand",
                                                    0, 1000, "%");
                 clonetiler_table_attach (table, l, 0, 2, 4);
             }
@@ -1810,22 +1982,22 @@ clonetiler_dialog (void)
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Vertical shift per row (in % of tile height)"), "d_y_per_y",
-                                                   -100, 1000, "%");
+                                                   _("Vertical shift per row (in % of tile height)"), "shifty_per_j",
+                                                   -10000, 10000, "%");
                 clonetiler_table_attach (table, l, 0, 3, 2);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Vertical shift per column (in % of tile height)"), "d_y_per_x",
-                                                   -100, 1000, "%");
+                                                   _("Vertical shift per column (in % of tile height)"), "shifty_per_i",
+                                                   -10000, 10000, "%");
                 clonetiler_table_attach (table, l, 0, 3, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the vertical shift by this percentage"), "rand_y",
+                                                   _("Randomize the vertical shift by this percentage"), "shifty_rand",
                                                    0, 1000, "%");
                 clonetiler_table_attach (table, l, 0, 3, 4);
             }
@@ -1840,14 +2012,14 @@ clonetiler_dialog (void)
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_y_exp",
+                                                   _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp",
                                                    0, 10, "", true);
                 clonetiler_table_attach (table, l, 0, 4, 2);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_x_exp",
+                                                   _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp",
                                                    0, 10, "", true);
                 clonetiler_table_attach (table, l, 0, 4, 3);
             }
@@ -1861,15 +2033,51 @@ clonetiler_dialog (void)
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each row"), "alternate_y");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each row"), "shifty_alternate");
                 clonetiler_table_attach (table, l, 0, 5, 2);
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each column"), "alternate_x");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each column"), "shiftx_alternate");
                 clonetiler_table_attach (table, l, 0, 5, 3);
             }
 
+            { // Cumulate
+                GtkWidget *l = gtk_label_new ("");
+                // TRANSLATORS: "Cumulate" is a verb here
+                gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));
+                gtk_size_group_add_widget(table_row_labels, l);
+                clonetiler_table_attach (table, l, 1, 6, 1);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the shifts for each row"), "shifty_cumulate");
+                clonetiler_table_attach (table, l, 0, 6, 2);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the shifts for each column"), "shiftx_cumulate");
+                clonetiler_table_attach (table, l, 0, 6, 3);
+            }
+
+            { // Exclude tile width and height in shift
+                GtkWidget *l = gtk_label_new ("");
+                // TRANSLATORS: "Cumulate" is a verb here
+                gtk_label_set_markup (GTK_LABEL(l), _("<small>Exclude tile:</small>"));
+                gtk_size_group_add_widget(table_row_labels, l);
+                clonetiler_table_attach (table, l, 1, 7, 1);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Exclude tile height in shift"), "shifty_excludeh");
+                clonetiler_table_attach (table, l, 0, 7, 2);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Exclude tile width in shift"), "shiftx_excludew");
+                clonetiler_table_attach (table, l, 0, 7, 3);
+            }
+
         }
 
 
@@ -1891,7 +2099,7 @@ clonetiler_dialog (void)
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Horizontal scale per row (in % of tile width)"), "d_scalex_per_y",
+                                                   _("Horizontal scale per row (in % of tile width)"), "scalex_per_j",
                                                    -100, 1000, "%");
                 clonetiler_table_attach (table, l, 0, 2, 2);
             }
@@ -1899,14 +2107,14 @@ clonetiler_dialog (void)
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Horizontal scale per column (in % of tile width)"), "d_scalex_per_x",
+                                                   _("Horizontal scale per column (in % of tile width)"), "scalex_per_i",
                                                    -100, 1000, "%");
                 clonetiler_table_attach (table, l, 0, 2, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the horizontal scale by this percentage"), "rand_scalex",
+                                                   _("Randomize the horizontal scale by this percentage"), "scalex_rand",
                                                    0, 1000, "%");
                 clonetiler_table_attach (table, l, 0, 2, 4);
             }
@@ -1922,7 +2130,7 @@ clonetiler_dialog (void)
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Vertical scale per row (in % of tile height)"), "d_scaley_per_y",
+                                                   _("Vertical scale per row (in % of tile height)"), "scaley_per_j",
                                                    -100, 1000, "%");
                 clonetiler_table_attach (table, l, 0, 3, 2);
             }
@@ -1930,36 +2138,98 @@ clonetiler_dialog (void)
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Vertical scale per column (in % of tile height)"), "d_scaley_per_x",
+                                                   _("Vertical scale per column (in % of tile height)"), "scaley_per_i",
                                                    -100, 1000, "%");
                 clonetiler_table_attach (table, l, 0, 3, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the vertical scale by this percentage"), "rand_scaley",
+                                                   _("Randomize the vertical scale by this percentage"), "scaley_rand",
                                                    0, 1000, "%");
                 clonetiler_table_attach (table, l, 0, 3, 4);
             }
 
-            { // alternates
+            // Exponent
+            {
                 GtkWidget *l = gtk_label_new ("");
-                // TRANSLATORS: "Alternate" is a verb here
-                gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
+                gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));
                 gtk_size_group_add_widget(table_row_labels, l);
                 clonetiler_table_attach (table, l, 1, 4, 1);
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each row"), "alternate_scaley");
+                GtkWidget *l = clonetiler_spinbox (tt,
+                                                   _("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp",
+                                                   0, 10, "", true);
                 clonetiler_table_attach (table, l, 0, 4, 2);
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each column"), "alternate_scalex");
+                GtkWidget *l = clonetiler_spinbox (tt,
+                                                   _("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp",
+                                                   0, 10, "", true);
                 clonetiler_table_attach (table, l, 0, 4, 3);
             }
 
+            // Logarithmic (as in logarithmic spiral)
+            {
+                GtkWidget *l = gtk_label_new ("");
+                gtk_label_set_markup (GTK_LABEL(l), _("<b>Base:</b>"));
+                gtk_size_group_add_widget(table_row_labels, l);
+                clonetiler_table_attach (table, l, 1, 5, 1);
+            }
+
+            {
+                GtkWidget *l = clonetiler_spinbox (tt,
+                                                   _("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log",
+                                                   0, 10, "", false);
+                clonetiler_table_attach (table, l, 0, 5, 2);
+            }
+
+            {
+                GtkWidget *l = clonetiler_spinbox (tt,
+                                                   _("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log",
+                                                   0, 10, "", false);
+                clonetiler_table_attach (table, l, 0, 5, 3);
+            }
+
+            { // alternates
+                GtkWidget *l = gtk_label_new ("");
+                // TRANSLATORS: "Alternate" is a verb here
+                gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
+                gtk_size_group_add_widget(table_row_labels, l);
+                clonetiler_table_attach (table, l, 1, 6, 1);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each row"), "scaley_alternate");
+                clonetiler_table_attach (table, l, 0, 6, 2);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each column"), "scalex_alternate");
+                clonetiler_table_attach (table, l, 0, 6, 3);
+            }
+
+            { // Cumulate
+                GtkWidget *l = gtk_label_new ("");
+                // TRANSLATORS: "Cumulate" is a verb here
+                gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));
+                gtk_size_group_add_widget(table_row_labels, l);
+                clonetiler_table_attach (table, l, 1, 7, 1);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the scales for each row"), "scaley_cumulate");
+                clonetiler_table_attach (table, l, 0, 7, 2);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the scales for each column"), "scalex_cumulate");
+                clonetiler_table_attach (table, l, 0, 7, 3);
+            }
+
         }
 
 
@@ -1981,7 +2251,7 @@ clonetiler_dialog (void)
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Rotate tiles by this angle for each row"), "d_rot_per_y",
+                                                   _("Rotate tiles by this angle for each row"), "rotate_per_j",
                                                    -180, 180, "&#176;");
                 clonetiler_table_attach (table, l, 0, 2, 2);
             }
@@ -1989,14 +2259,14 @@ clonetiler_dialog (void)
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
                     // xgettext:no-c-format
-                                                   _("Rotate tiles by this angle for each column"), "d_rot_per_x",
+                                                   _("Rotate tiles by this angle for each column"), "rotate_per_i",
                                                    -180, 180, "&#176;");
                 clonetiler_table_attach (table, l, 0, 2, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the rotation angle by this percentage"), "rand_rot",
+                                                   _("Randomize the rotation angle by this percentage"), "rotate_rand",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 2, 4);
             }
@@ -2010,14 +2280,33 @@ clonetiler_dialog (void)
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each row"), "alternate_roty");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each row"), "rotate_alternatej");
                 clonetiler_table_attach (table, l, 0, 3, 2);
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each column"), "alternate_rotx");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each column"), "rotate_alternatei");
                 clonetiler_table_attach (table, l, 0, 3, 3);
             }
+
+            { // Cumulate
+                GtkWidget *l = gtk_label_new ("");
+                // TRANSLATORS: "Cumulate" is a verb here
+                gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));
+                gtk_size_group_add_widget(table_row_labels, l);
+                clonetiler_table_attach (table, l, 1, 4, 1);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the rotation for each row"), "rotate_cumulatej");
+                clonetiler_table_attach (table, l, 0, 4, 2);
+            }
+
+            {
+                GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the rotation for each column"), "rotate_cumulatei");
+                clonetiler_table_attach (table, l, 0, 4, 3);
+            }
+
         }
 
 
@@ -2039,21 +2328,21 @@ clonetiler_dialog (void)
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Blur tiles by this percentage for each row"), "d_blur_per_y",
+                                                   _("Blur tiles by this percentage for each row"), "blur_per_j",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 2, 2);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Blur tiles by this percentage for each column"), "d_blur_per_x",
+                                                   _("Blur tiles by this percentage for each column"), "blur_per_i",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 2, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the tile blur by this percentage"), "rand_blur",
+                                                   _("Randomize the tile blur by this percentage"), "blur_rand",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 2, 4);
             }
@@ -2067,12 +2356,12 @@ clonetiler_dialog (void)
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each row"), "alternate_blury");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each row"), "blur_alternatej");
                 clonetiler_table_attach (table, l, 0, 3, 2);
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each column"), "alternate_blurx");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each column"), "blur_alternatei");
                 clonetiler_table_attach (table, l, 0, 3, 3);
             }
 
@@ -2088,21 +2377,21 @@ clonetiler_dialog (void)
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Decrease tile opacity by this percentage for each row"), "d_opacity_per_y",
+                                                   _("Decrease tile opacity by this percentage for each row"), "opacity_per_j",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 4, 2);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Decrease tile opacity by this percentage for each column"), "d_opacity_per_x",
+                                                   _("Decrease tile opacity by this percentage for each column"), "opacity_per_i",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 4, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the tile opacity by this percentage"), "rand_opacity",
+                                                   _("Randomize the tile opacity by this percentage"), "opacity_rand",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 4, 4);
             }
@@ -2116,12 +2405,12 @@ clonetiler_dialog (void)
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "alternate_opacityy");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "opacity_alternatej");
                 clonetiler_table_attach (table, l, 0, 5, 2);
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each column"), "alternate_opacityx");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each column"), "opacity_alternatei");
                 clonetiler_table_attach (table, l, 0, 5, 3);
             }
         }
@@ -2137,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));
 
@@ -2160,21 +2449,21 @@ clonetiler_dialog (void)
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Change the tile hue by this percentage for each row"), "d_hue_per_y",
+                                                   _("Change the tile hue by this percentage for each row"), "hue_per_j",
                                                    -100, 100, "%");
                 clonetiler_table_attach (table, l, 0, 2, 2);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Change the tile hue by this percentage for each column"), "d_hue_per_x",
+                                                   _("Change the tile hue by this percentage for each column"), "hue_per_i",
                                                    -100, 100, "%");
                 clonetiler_table_attach (table, l, 0, 2, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the tile hue by this percentage"), "rand_hue",
+                                                   _("Randomize the tile hue by this percentage"), "hue_rand",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 2, 4);
             }
@@ -2190,21 +2479,21 @@ clonetiler_dialog (void)
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Change the color saturation by this percentage for each row"), "d_saturation_per_y",
+                                                   _("Change the color saturation by this percentage for each row"), "saturation_per_j",
                                                    -100, 100, "%");
                 clonetiler_table_attach (table, l, 0, 3, 2);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Change the color saturation by this percentage for each column"), "d_saturation_per_x",
+                                                   _("Change the color saturation by this percentage for each column"), "saturation_per_i",
                                                    -100, 100, "%");
                 clonetiler_table_attach (table, l, 0, 3, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the color saturation by this percentage"), "rand_saturation",
+                                                   _("Randomize the color saturation by this percentage"), "saturation_rand",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 3, 4);
             }
@@ -2219,21 +2508,21 @@ clonetiler_dialog (void)
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Change the color lightness by this percentage for each row"), "d_lightness_per_y",
+                                                   _("Change the color lightness by this percentage for each row"), "lightness_per_j",
                                                    -100, 100, "%");
                 clonetiler_table_attach (table, l, 0, 4, 2);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Change the color lightness by this percentage for each column"), "d_lightness_per_x",
+                                                   _("Change the color lightness by this percentage for each column"), "lightness_per_i",
                                                    -100, 100, "%");
                 clonetiler_table_attach (table, l, 0, 4, 3);
             }
 
             {
                 GtkWidget *l = clonetiler_spinbox (tt,
-                                                   _("Randomize the color lightness by this percentage"), "rand_lightness",
+                                                   _("Randomize the color lightness by this percentage"), "lightness_rand",
                                                    0, 100, "%");
                 clonetiler_table_attach (table, l, 0, 4, 4);
             }
@@ -2247,12 +2536,12 @@ clonetiler_dialog (void)
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each row"), "alternate_color_y");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each row"), "color_alternatej");
                 clonetiler_table_attach (table, l, 0, 5, 2);
             }
 
             {
-                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each column"), "alternate_color_x");
+                GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each column"), "color_alternatei");
                 clonetiler_table_attach (table, l, 0, 5, 3);
             }
 
@@ -2269,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);
 
@@ -2301,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"));
@@ -2309,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"));
@@ -2317,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"));
@@ -2325,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"));
@@ -2333,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);
                 }
 
             }
@@ -2424,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",
@@ -2434,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",
@@ -2444,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",
@@ -2454,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"));
         }
         }
 
@@ -2480,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, "ymax", 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);
@@ -2488,7 +2771,7 @@ clonetiler_dialog (void)
                     gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0);
 
                     gtk_signal_connect(GTK_OBJECT(a), "value_changed",
-                                       GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "ymax");
+                                       GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "jmax");
                 }
 
                 {
@@ -2500,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, "xmax", 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);
@@ -2508,7 +2791,7 @@ clonetiler_dialog (void)
                     gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0);
 
                     gtk_signal_connect(GTK_OBJECT(a), "value_changed",
-                                       GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "xmax");
+                                       GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "imax");
                 }
 
                 clonetiler_table_attach (table, hb, 0.0, 1, 2);
@@ -2521,13 +2804,13 @@ clonetiler_dialog (void)
                 // unitmenu
                 GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
                 sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units);
-    
+
                 {
-                    // Width spinbutton 
+                    // Width spinbutton
                     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);
@@ -2551,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);
@@ -2578,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));
             }
@@ -2588,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));
             }
@@ -2601,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);
 
@@ -2693,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 :