Code

init matrix variable, removes compiler warnings
[inkscape.git] / src / widgets / toolbox.cpp
index ee96092824a67e2fecb17ecc6185f648e4a7acb4..146853c2258d10716a08fbe89703cc75757a9db4 100644 (file)
@@ -28,6 +28,7 @@
 # include "config.h"
 #endif
 
+#include <gtkmm.h>
 #include <gtk/gtk.h>
 
 #include "widgets/button.h"
@@ -35,6 +36,8 @@
 #include "widgets/spw-utilities.h"
 #include "widgets/spinbutton-events.h"
 
+#include "ui/widget/style-swatch.h"
+
 #include "prefs-utils.h"
 #include "verbs.h"
 #include "sp-namedview.h"
 #include "sp-star.h"
 #include "sp-spiral.h"
 #include "sp-ellipse.h"
+#include "sp-text.h"
+#include "sp-flowtext.h"
+#include "style.h"
 #include "selection.h"
 #include "document-private.h"
+#include "desktop-style.h"
+#include "../libnrtype/font-lister.h"
+#include "../connection-pool.h"
 
 #include "mod360.h"
 
@@ -75,12 +84,15 @@ static GtkWidget *sp_star_toolbox_new(SPDesktop *desktop);
 static GtkWidget *sp_arc_toolbox_new(SPDesktop *desktop);
 static GtkWidget *sp_rect_toolbox_new(SPDesktop *desktop);
 static GtkWidget *sp_spiral_toolbox_new(SPDesktop *desktop);
+static GtkWidget *sp_pencil_toolbox_new(SPDesktop *desktop);
+static GtkWidget *sp_pen_toolbox_new(SPDesktop *desktop);
 static GtkWidget *sp_calligraphy_toolbox_new(SPDesktop *desktop);
 static GtkWidget *sp_dropper_toolbox_new(SPDesktop *desktop);
 static GtkWidget *sp_empty_toolbox_new(SPDesktop *desktop);
-static GtkWidget *sp_text_toolbox_new(SPDesktop *desktop);
 static GtkWidget *sp_connector_toolbox_new(SPDesktop *desktop);
 
+namespace { GtkWidget *sp_text_toolbox_new (SPDesktop *desktop); }
+
 
 static struct {
     gchar const *type_name;
@@ -117,8 +129,8 @@ static struct {
     { "SPRectContext",   "rect_toolbox",   sp_rect_toolbox_new },
     { "SPArcContext",    "arc_toolbox",    sp_arc_toolbox_new },
     { "SPSpiralContext", "spiral_toolbox", sp_spiral_toolbox_new },
-    { "SPPencilContext", "pencil_toolbox", NULL },
-    { "SPPenContext", "pen_toolbox", NULL },
+    { "SPPencilContext", "pencil_toolbox", sp_pencil_toolbox_new },
+    { "SPPenContext", "pen_toolbox", sp_pen_toolbox_new },
     { "SPDynaDrawContext", "calligraphy_toolbox", sp_calligraphy_toolbox_new },
     { "SPTextContext",   "text_toolbox",   sp_text_toolbox_new },
     { "SPDropperContext", "dropper_toolbox", sp_dropper_toolbox_new },
@@ -127,14 +139,16 @@ static struct {
     { NULL, NULL, NULL }
 };
 
-static void toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop, SetupFunction setup_func, UpdateFunction update_func, sigc::connection*);
+static void toolbox_set_desktop (GtkWidget *toolbox, SPDesktop *desktop, SetupFunction setup_func, UpdateFunction update_func, sigc::connection*);
+
+static void setup_tool_toolbox (GtkWidget *toolbox, SPDesktop *desktop);
+static void update_tool_toolbox (SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
 
-static void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
-static void update_tool_toolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
-static void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
-static void update_aux_toolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
-static void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
-static void update_commands_toolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
+static void setup_aux_toolbox (GtkWidget *toolbox, SPDesktop *desktop);
+static void update_aux_toolbox (SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
+
+static void setup_commands_toolbox (GtkWidget *toolbox, SPDesktop *desktop);
+static void update_commands_toolbox (SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
 
 /* Global text entry widgets necessary for update */
 /* GtkWidget *dropper_rgb_entry, 
@@ -147,7 +161,7 @@ static void delete_connection(GObject *obj, sigc::connection *connection) {
 }
 
 static GtkWidget *
-sp_toolbox_button_new(GtkWidget *t, GtkIconSize size, gchar const *pxname, GtkSignalFunc handler,
+sp_toolbox_button_new(GtkWidget *t, Inkscape::IconSize size, gchar const *pxname, GtkSignalFunc handler,
                       GtkTooltips *tt, gchar const *tip)
 {
     GtkWidget *b = sp_button_new_from_data(size, SP_BUTTON_TYPE_NORMAL, NULL, pxname, tip, tt);
@@ -158,9 +172,8 @@ sp_toolbox_button_new(GtkWidget *t, GtkIconSize size, gchar const *pxname, GtkSi
     return b;
 }
 
-
 GtkWidget *
-sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, GtkIconSize size, SPButtonType type,
+sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
                                                  Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
                                                  Inkscape::UI::View::View *view, GtkTooltips *tt)
 {
@@ -182,13 +195,13 @@ sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, GtkIconSize size,
     return b;
 }
 
-GtkWidget *sp_toolbox_button_new_from_verb(GtkWidget *t, GtkIconSize size, SPButtonType type, Inkscape::Verb *verb,
+GtkWidget *sp_toolbox_button_new_from_verb(GtkWidget *t, Inkscape::IconSize size, SPButtonType type, Inkscape::Verb *verb,
                                            Inkscape::UI::View::View *view, GtkTooltips *tt)
 {
     return sp_toolbox_button_new_from_verb_with_doubleclick(t, size, type, verb, NULL, view, tt);
 }
 
-GtkWidget * sp_toolbox_button_normal_new_from_verb(GtkWidget *t, GtkIconSize size, Inkscape::Verb *verb,
+GtkWidget * sp_toolbox_button_normal_new_from_verb(GtkWidget *t, Inkscape::IconSize size, Inkscape::Verb *verb,
                                                    Inkscape::UI::View::View *view, GtkTooltips *tt)
 {
     return sp_toolbox_button_new_from_verb(t, size, SP_BUTTON_TYPE_NORMAL, verb, view, tt);
@@ -372,7 +385,11 @@ sp_node_path_edit_symmetrical(void)
     sp_node_selected_set_type(Inkscape::NodePath::NODE_SYMM);
 }
 
-
+static void toggle_show_handles (GtkWidget *button, gpointer data) {
+    bool show = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+    prefs_set_int_attribute ("tools.nodes", "show_handles",  show ? 1 : 0);
+    sp_nodepath_show_handles(show);
+}
 
 //################################
 //##    Node Editing Toolbox    ##
@@ -388,48 +405,68 @@ sp_node_toolbox_new(SPDesktop *desktop)
 
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_insert",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_insert",
         GTK_SIGNAL_FUNC(sp_node_path_edit_add), tt, _("Insert new nodes into selected segments"));
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_delete",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_delete",
         GTK_SIGNAL_FUNC(sp_node_path_edit_delete), tt, _("Delete selected nodes"));
 
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_join",
-        GTK_SIGNAL_FUNC(sp_node_path_edit_join), tt, _("Join paths at selected nodes"));
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_join_segment",
-        GTK_SIGNAL_FUNC(sp_node_path_edit_join_segment), tt, _("Join paths at selected nodes with new segment"));
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_join",
+        GTK_SIGNAL_FUNC(sp_node_path_edit_join), tt, _("Join selected endnodes"));
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_join_segment",
+        GTK_SIGNAL_FUNC(sp_node_path_edit_join_segment), tt, _("Join selected endnodes with a new segment"));
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_delete_segment",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_delete_segment",
         GTK_SIGNAL_FUNC(sp_node_path_edit_delete_segment), tt, _("Split path between two non-endpoint nodes"));
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_break",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_break",
         GTK_SIGNAL_FUNC(sp_node_path_edit_break), tt, _("Break path at selected nodes"));
 
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_cusp",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_cusp",
         GTK_SIGNAL_FUNC(sp_node_path_edit_cusp), tt, _("Make selected nodes corner"));
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_smooth",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_smooth",
         GTK_SIGNAL_FUNC(sp_node_path_edit_smooth), tt, _("Make selected nodes smooth"));
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_symmetric",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_symmetric",
         GTK_SIGNAL_FUNC(sp_node_path_edit_symmetrical), tt, _("Make selected nodes symmetric"));
 
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_line",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_line",
         GTK_SIGNAL_FUNC(sp_node_path_edit_toline), tt, _("Make selected segments lines"));
 
-    sp_toolbox_button_new(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, "node_curve",
+    sp_toolbox_button_new(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, "node_curve",
         GTK_SIGNAL_FUNC(sp_node_path_edit_tocurve), tt, _("Make selected segments curves"));
 
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_normal_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_TO_CURVE), view, tt);
+    sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_TO_CURVE), view, tt);
+
+    sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_OUTLINE), view, tt);
+
+    aux_toolbox_space(tb, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_normal_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_OUTLINE), view, tt);
+    GtkWidget *cvbox = gtk_vbox_new (FALSE, 0);
+    GtkWidget *cbox = gtk_hbox_new (FALSE, 0);
+
+    {
+    GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
+                                              SP_BUTTON_TYPE_TOGGLE,
+                                              NULL,
+                                              "nodes_show_handles",
+                                              _("Show the Bezier handles of selected nodes"),
+                                              tt);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("tools.nodes", "show_handles", 1));
+    g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_show_handles), desktop);
+    gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
+    }
+
+    gtk_box_pack_start(GTK_BOX(cvbox), cbox, TRUE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(tb), cvbox, FALSE, FALSE, 0);
 
     gtk_widget_show_all(tb);
 
@@ -453,33 +490,33 @@ sp_zoom_toolbox_new(SPDesktop *desktop)
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0),
                        FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_IN), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_IN), view, tt);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_OUT), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_OUT), view, tt);
 
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_SELECTION), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_SELECTION), view, tt);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_DRAWING), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_DRAWING), view, tt);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_PAGE), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_PAGE), view, tt);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_PAGE_WIDTH), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_PAGE_WIDTH), view, tt);
 
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_PREV), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_PREV), view, tt);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_NEXT), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_NEXT), view, tt);
 
     gtk_box_pack_start(GTK_BOX(tb), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_1_1), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_1_1), view, tt);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_1_2), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_1_2), view, tt);
 
-    sp_toolbox_button_new_from_verb(tb, GTK_ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_2_1), view, tt);
+    sp_toolbox_button_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_ZOOM_2_1), view, tt);
 
     gtk_widget_show_all(tb);
 
@@ -506,7 +543,6 @@ sp_commands_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop)
     toolbox_set_desktop(gtk_bin_get_child(GTK_BIN(toolbox)), desktop, setup_commands_toolbox, update_commands_toolbox, static_cast<sigc::connection*>(g_object_get_data(G_OBJECT(toolbox), "event_context_connection")));
 }
 
-
 static void
 toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop, SetupFunction setup_func, UpdateFunction update_func, sigc::connection *conn)
 {
@@ -543,7 +579,7 @@ setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
 {
     GtkTooltips *tooltips=GTK_TOOLTIPS(g_object_get_data(G_OBJECT(toolbox), "tooltips"));
     gint shrinkLeft = prefs_get_int_attribute_limited( "toolbox.left", "small", 0, 0, 1 );
-    GtkIconSize toolboxSize = shrinkLeft ? GTK_ICON_SIZE_SMALL_TOOLBAR : GTK_ICON_SIZE_LARGE_TOOLBAR;
+    Inkscape::IconSize toolboxSize = shrinkLeft ? Inkscape::ICON_SIZE_SMALL_TOOLBAR : Inkscape::ICON_SIZE_LARGE_TOOLBAR;
 
     for (int i = 0 ; tools[i].type_name ; i++ ) {
         GtkWidget *button =
@@ -618,7 +654,7 @@ setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
     GtkWidget *tb = gtk_hbox_new(FALSE, 0);
 
     gint shrinkTop = prefs_get_int_attribute_limited( "toolbox", "small", 1, 0, 1 );
-    GtkIconSize toolboxSize = shrinkTop ? GTK_ICON_SIZE_SMALL_TOOLBAR : GTK_ICON_SIZE_LARGE_TOOLBAR;
+    Inkscape::IconSize toolboxSize = shrinkTop ? Inkscape::ICON_SIZE_SMALL_TOOLBAR : Inkscape::ICON_SIZE_LARGE_TOOLBAR;
 
     sp_toolbox_button_new_from_verb(tb, toolboxSize, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_FILE_NEW), view, tt);
     sp_toolbox_button_new_from_verb(tb, toolboxSize, SP_BUTTON_TYPE_NORMAL, Inkscape::Verb::get(SP_VERB_FILE_OPEN), view, tt);
@@ -735,7 +771,7 @@ sp_tb_spinbutton(
     gboolean altx, gchar const *altx_mark,
     gdouble lower, gdouble upper, gdouble step, gdouble page,
     void (*callback)(GtkAdjustment *, GtkWidget *),
-    gdouble climb = 0.1, guint digits = 3)
+    gdouble climb = 0.1, guint digits = 3, double factor = 1.0)
 {
     GtkTooltips *tt = gtk_tooltips_new();
 
@@ -746,7 +782,7 @@ sp_tb_spinbutton(
     gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5);
     gtk_container_add(GTK_CONTAINER(hb), l);
 
-    GtkObject *a = gtk_adjustment_new(prefs_get_double_attribute(path, data, def),
+    GtkObject *a = gtk_adjustment_new(prefs_get_double_attribute(path, data, def) * factor,
                                       lower, upper, step, page, page);
     gtk_object_set_data(GTK_OBJECT(tbl), data, a);
     if (us)
@@ -756,7 +792,9 @@ sp_tb_spinbutton(
     gtk_tooltips_set_tip(tt, sb, tooltip, NULL);
     if (altx)
         gtk_object_set_data(GTK_OBJECT(sb), altx_mark, sb);
-    gtk_widget_set_size_request(sb, AUX_SPINBUTTON_WIDTH_SMALL, AUX_SPINBUTTON_HEIGHT);
+    gtk_widget_set_size_request(sb, 
+                                (upper <= 1.0 || digits == 0)? AUX_SPINBUTTON_WIDTH_SMALL - 10: AUX_SPINBUTTON_WIDTH_SMALL,
+                                AUX_SPINBUTTON_HEIGHT);
     gtk_widget_show(sb);
     gtk_signal_connect(GTK_OBJECT(sb), "focus-in-event", GTK_SIGNAL_FUNC(spinbutton_focus_in), tbl);
     gtk_signal_connect(GTK_OBJECT(sb), "key-press-event", GTK_SIGNAL_FUNC(spinbutton_keypress), tbl);
@@ -777,7 +815,7 @@ sp_stb_magnitude_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 {
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl), "desktop");
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         // do not remember prefs if this call is initiated by an undo change, because undoing object
         // creation sets bogus values to its attributes before it is deleted
         prefs_set_int_attribute("tools.shapes.star", "magnitude", (gint)adj->value);
@@ -793,7 +831,7 @@ sp_stb_magnitude_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 
     bool modmade = false;
 
-    Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+    Inkscape::Selection *selection = sp_desktop_selection(desktop);
     GSList const *items = selection->itemList();
     for (; items != NULL; items = items->next) {
         if (SP_IS_STAR((SPItem *) items->data)) {
@@ -806,7 +844,7 @@ sp_stb_magnitude_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
             modmade = true;
         }
     }
-    if (modmade)  sp_document_done(SP_DT_DOCUMENT(desktop));
+    if (modmade)  sp_document_done(sp_desktop_document(desktop));
 
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
 
@@ -818,7 +856,7 @@ sp_stb_proportion_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 {
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl), "desktop");
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         prefs_set_double_attribute("tools.shapes.star", "proportion", adj->value);
     }
 
@@ -831,7 +869,7 @@ sp_stb_proportion_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE));
 
     bool modmade = false;
-    Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+    Inkscape::Selection *selection = sp_desktop_selection(desktop);
     GSList const *items = selection->itemList();
     for (; items != NULL; items = items->next) {
         if (SP_IS_STAR((SPItem *) items->data)) {
@@ -850,7 +888,7 @@ sp_stb_proportion_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
         }
     }
 
-    if (modmade) sp_document_done(SP_DT_DOCUMENT(desktop));
+    if (modmade) sp_document_done(sp_desktop_document(desktop));
 
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
 
@@ -862,7 +900,7 @@ sp_stb_sides_flat_state_changed(GtkWidget *widget, GtkObject *tbl)
 {
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl), "desktop");
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
             prefs_set_string_attribute("tools.shapes.star", "isflatsided", "true");
         } else {
@@ -878,7 +916,7 @@ sp_stb_sides_flat_state_changed(GtkWidget *widget, GtkObject *tbl)
     // in turn, prevent listener from responding
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE));
 
-    Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+    Inkscape::Selection *selection = sp_desktop_selection(desktop);
     GSList const *items = selection->itemList();
     GtkWidget *prop_widget = (GtkWidget*) g_object_get_data(G_OBJECT(tbl), "prop_widget");
     bool modmade = false;
@@ -903,7 +941,7 @@ sp_stb_sides_flat_state_changed(GtkWidget *widget, GtkObject *tbl)
             }
         }
     }
-    if (modmade) sp_document_done(SP_DT_DOCUMENT(desktop));
+    if (modmade) sp_document_done(sp_desktop_document(desktop));
 
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
 
@@ -915,7 +953,7 @@ sp_stb_rounded_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 {
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl), "desktop");
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         prefs_set_double_attribute("tools.shapes.star", "rounded", (gdouble) adj->value);
     }
 
@@ -929,7 +967,7 @@ sp_stb_rounded_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 
     bool modmade = false;
 
-    Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+    Inkscape::Selection *selection = sp_desktop_selection(desktop);
     GSList const *items = selection->itemList();
     for (; items != NULL; items = items->next) {
         if (SP_IS_STAR((SPItem *) items->data)) {
@@ -939,7 +977,7 @@ sp_stb_rounded_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
             modmade = true;
         }
     }
-    if (modmade)  sp_document_done(SP_DT_DOCUMENT(desktop));
+    if (modmade)  sp_document_done(sp_desktop_document(desktop));
 
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
 
@@ -952,7 +990,7 @@ sp_stb_randomized_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 {
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl), "desktop");
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         prefs_set_double_attribute("tools.shapes.star", "randomized", (gdouble) adj->value);
     }
 
@@ -966,7 +1004,7 @@ sp_stb_randomized_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 
     bool modmade = false;
 
-    Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+    Inkscape::Selection *selection = sp_desktop_selection(desktop);
     GSList const *items = selection->itemList();
     for (; items != NULL; items = items->next) {
         if (SP_IS_STAR((SPItem *) items->data)) {
@@ -976,7 +1014,7 @@ sp_stb_randomized_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
             modmade = true;
         }
     }
-    if (modmade)  sp_document_done(SP_DT_DOCUMENT(desktop));
+    if (modmade)  sp_document_done(sp_desktop_document(desktop));
 
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
 
@@ -1242,11 +1280,16 @@ sp_star_toolbox_new(SPDesktop *desktop)
         gtk_box_pack_start(GTK_BOX(tbl),hb, FALSE, FALSE, AUX_SPACING);
     }
 
+    Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch(NULL);
+    swatch->setWatchedTool ("tools.shapes.star", true);
+    GtkWidget *swatch_ = GTK_WIDGET(swatch->gobj());
+    gtk_box_pack_end(GTK_BOX(tbl), swatch_, FALSE, FALSE, 0);
+
     gtk_widget_show_all(tbl);
     sp_set_font_size_smaller (tbl);
 
     sigc::connection *connection = new sigc::connection(
-        SP_DT_SELECTION(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), (GtkObject *)tbl))
+        sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), (GtkObject *)tbl))
         );
     g_signal_connect(G_OBJECT(tbl), "destroy", G_CALLBACK(delete_connection), connection);
 
@@ -1282,7 +1325,7 @@ sp_rtb_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const *value_name
     GtkWidget *us = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tbl), "units");
     SPUnit const *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(us));
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         prefs_set_double_attribute("tools.shapes.rect", value_name, sp_units_get_pixels(adj->value, *unit));
     }
 
@@ -1295,7 +1338,7 @@ sp_rtb_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const *value_name
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE));
 
     bool modmade = false;
-    Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+    Inkscape::Selection *selection = sp_desktop_selection(desktop);
     for (GSList const *items = selection->itemList(); items != NULL; items = items->next) {
         if (SP_IS_RECT(items->data)) {
             if (adj->value != 0) {
@@ -1310,7 +1353,7 @@ sp_rtb_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const *value_name
     sp_rtb_sensitivize (tbl);
 
     if (modmade) {
-        sp_document_done(SP_DT_DOCUMENT(desktop));
+        sp_document_done(sp_desktop_document(desktop));
     }
 
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
@@ -1568,6 +1611,11 @@ sp_rect_toolbox_new(SPDesktop *desktop)
         gtk_box_pack_start(GTK_BOX(tbl), hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
     }
 
+    Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch(NULL);
+    swatch->setWatchedTool ("tools.shapes.rect", true);
+    GtkWidget *swatch_ = GTK_WIDGET(swatch->gobj());
+    gtk_box_pack_end(GTK_BOX(tbl), swatch_, FALSE, FALSE, 0);
+
     g_object_set_data(G_OBJECT(tbl), "single", GINT_TO_POINTER(TRUE));
     sp_rtb_sensitivize (tbl);
 
@@ -1575,7 +1623,7 @@ sp_rect_toolbox_new(SPDesktop *desktop)
     sp_set_font_size_smaller (tbl);
 
     sigc::connection *connection = new sigc::connection(
-        SP_DT_SELECTION(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), (GtkObject *)tbl))
+        sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), (GtkObject *)tbl))
         );
     g_signal_connect(G_OBJECT(tbl), "destroy", G_CALLBACK(delete_connection), connection);
 
@@ -1591,7 +1639,7 @@ sp_spl_tb_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const *value_n
 {
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl), "desktop");
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         prefs_set_double_attribute("tools.shapes.spiral", value_name, adj->value);
     }
 
@@ -1606,7 +1654,7 @@ sp_spl_tb_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const *value_n
     gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL);
 
     bool modmade = false;
-    for (GSList const *items = SP_DT_SELECTION(desktop)->itemList();
+    for (GSList const *items = sp_desktop_selection(desktop)->itemList();
          items != NULL;
          items = items->next)
     {
@@ -1621,7 +1669,7 @@ sp_spl_tb_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const *value_n
     g_free(namespaced_name);
 
     if (modmade) {
-        sp_document_done(SP_DT_DOCUMENT(desktop));
+        sp_document_done(sp_desktop_document(desktop));
     }
 
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
@@ -1811,17 +1859,63 @@ sp_spiral_toolbox_new(SPDesktop *desktop)
         gtk_box_pack_start(GTK_BOX(tbl),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
     }
 
+    Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch(NULL);
+    swatch->setWatchedTool ("tools.shapes.spiral", true);
+    GtkWidget *swatch_ = GTK_WIDGET(swatch->gobj());
+    gtk_box_pack_end(GTK_BOX(tbl), swatch_, FALSE, FALSE, 0);
+
     gtk_widget_show_all(tbl);
     sp_set_font_size_smaller (tbl);
 
     sigc::connection *connection = new sigc::connection(
-        SP_DT_SELECTION(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_spiral_toolbox_selection_changed), (GtkObject *)tbl))
+        sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_spiral_toolbox_selection_changed), (GtkObject *)tbl))
         );
     g_signal_connect(G_OBJECT(tbl), "destroy", G_CALLBACK(delete_connection), connection);
 
     return tbl;
 }
 
+//########################
+//##     Pen/Pencil    ##
+//########################
+
+
+static GtkWidget *
+sp_pen_toolbox_new(SPDesktop *desktop)
+{
+    GtkWidget *tbl = gtk_hbox_new(FALSE, 0);
+    gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas);
+    gtk_object_set_data(GTK_OBJECT(tbl), "desktop", desktop);
+
+    Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch(NULL);
+    swatch->setWatchedTool ("tools.freehand.pen", true);
+    GtkWidget *swatch_ = GTK_WIDGET(swatch->gobj());
+    gtk_box_pack_end(GTK_BOX(tbl), swatch_, FALSE, FALSE, 0);
+
+    gtk_widget_show_all(tbl);
+    sp_set_font_size_smaller (tbl);
+
+    return tbl;
+}
+
+static GtkWidget *
+sp_pencil_toolbox_new(SPDesktop *desktop)
+{
+    GtkWidget *tbl = gtk_hbox_new(FALSE, 0);
+    gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas);
+    gtk_object_set_data(GTK_OBJECT(tbl), "desktop", desktop);
+
+    Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch(NULL);
+    swatch->setWatchedTool ("tools.freehand.pencil", true);
+    GtkWidget *swatch_ = GTK_WIDGET(swatch->gobj());
+    gtk_box_pack_end(GTK_BOX(tbl), swatch_, FALSE, FALSE, 0);
+
+    gtk_widget_show_all(tbl);
+    sp_set_font_size_smaller (tbl);
+
+    return tbl;
+}
+
 
 //########################
 //##     Calligraphy    ##
@@ -1851,7 +1945,7 @@ sp_ddc_angle_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 static void
 sp_ddc_width_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
 {
-    prefs_set_double_attribute("tools.calligraphic", "width", adj->value);
+    prefs_set_double_attribute("tools.calligraphic", "width", adj->value * 0.01);
     spinbutton_defocus(GTK_OBJECT(tbl));
 }
 
@@ -1869,6 +1963,13 @@ sp_ddc_flatness_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
     spinbutton_defocus(GTK_OBJECT(tbl));
 }
 
+static void
+sp_ddc_tremor_value_changed(GtkAdjustment *adj, GtkWidget *tbl)
+{
+    prefs_set_double_attribute("tools.calligraphic", "tremor", adj->value);
+    spinbutton_defocus(GTK_OBJECT(tbl));
+}
+
 static void
 sp_ddc_pressure_state_changed(GtkWidget *button, gpointer data)
 {
@@ -1893,8 +1994,9 @@ static void sp_ddc_defaults(GtkWidget *, GtkWidget *tbl)
         {"mass", 0.02},
         {"drag", 1.0},
         {"angle", 30.0},
-        {"width", 0.15},
+        {"width", 15},
         {"thinning", 0.1},
+        {"tremor", 0.0},
         {"flatness", 0.9}
     };
 
@@ -1923,10 +2025,10 @@ sp_calligraphy_toolbox_new(SPDesktop *desktop)
     /* Width */
     {
         GtkWidget *hb = sp_tb_spinbutton(_("Width:"), _("The width of the calligraphic pen (relative to the visible canvas area)"),
-                                         "tools.calligraphic", "width", 0.15,
+                                         "tools.calligraphic", "width", 15,
                                          NULL, tbl, TRUE, "altx-calligraphy",
-                                         0.01, 1.0, 0.01, 0.1,
-                                         sp_ddc_width_value_changed,  0.01, 2);
+                                         1, 100, 1.0, 10.0,
+                                         sp_ddc_width_value_changed,  0.01, 0, 100);
         gtk_box_pack_start(GTK_BOX(tbl), hb, FALSE, FALSE, AUX_SPACING);
     }
 
@@ -1966,6 +2068,15 @@ sp_calligraphy_toolbox_new(SPDesktop *desktop)
     //  interval
     gtk_box_pack_start(GTK_BOX(tbl), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
+    /* Tremor */
+    {
+        GtkWidget *hb = sp_tb_spinbutton(_("Tremor:"), _("How uneven or trembling is the pen stroke"),
+                                         "tools.calligraphic", "tremor", 0.0,
+                                         NULL, tbl, FALSE, NULL,
+                                         0.0, 1.0, 0.01, 0.1,
+                                         sp_ddc_tremor_value_changed, 0.01, 2);
+        gtk_box_pack_start(GTK_BOX(tbl), hb, FALSE, FALSE, AUX_SPACING);
+    }
     /* Mass */
     {
         GtkWidget *hb = sp_tb_spinbutton(_("Mass:"), _("How much inertia affects the movement of the pen"),
@@ -1995,7 +2106,7 @@ sp_calligraphy_toolbox_new(SPDesktop *desktop)
 
     /* Use Pressure button */
     {
-    GtkWidget *button = sp_button_new_from_data( GTK_ICON_SIZE_SMALL_TOOLBAR,
+    GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
                                                  SP_BUTTON_TYPE_TOGGLE,
                                                  NULL,
                                                  "use_pressure",
@@ -2008,7 +2119,7 @@ sp_calligraphy_toolbox_new(SPDesktop *desktop)
 
     /* Use Tilt button */
     {
-    GtkWidget *button = sp_button_new_from_data( GTK_ICON_SIZE_SMALL_TOOLBAR,
+    GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
                                                  SP_BUTTON_TYPE_TOGGLE,
                                                  NULL,
                                                  "use_tilt",
@@ -2034,24 +2145,11 @@ sp_calligraphy_toolbox_new(SPDesktop *desktop)
         gtk_box_pack_start(GTK_BOX(tbl),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
     }
 
-/*
-     // Tablet features
-    {
-        GtkWidget *hb = gtk_hbox_new(FALSE, 1);
-        GtkWidget *fscb = gtk_check_button_new_with_label(_("Tablet"));
-        gtk_widget_set_sensitive(GTK_WIDGET(fscb), TRUE);
-
-
-
 
-        gtk_tooltips_set_tip(tt, fscb, _("Enable/Disable drawing tablet features"), NULL);
-        gtk_widget_show(fscb);
-        gtk_object_set_data(GTK_OBJECT(tbl), "flat_checkbox", fscb);
-        gtk_container_add(GTK_CONTAINER(hb), fscb);
-
-        gtk_box_pack_start(GTK_BOX(tbl),hb, FALSE, FALSE, AUX_SPACING);
-    }
-*/
+    Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch(NULL);
+    swatch->setWatchedTool ("tools.calligraphic", true);
+    GtkWidget *swatch_ = GTK_WIDGET(swatch->gobj());
+    gtk_box_pack_end(GTK_BOX(tbl), swatch_, FALSE, FALSE, 0);
 
     gtk_widget_show_all(tbl);
     sp_set_font_size_smaller (tbl);
@@ -2086,7 +2184,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const
 {
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl), "desktop");
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         prefs_set_double_attribute("tools.shapes.arc", value_name, (adj->value * M_PI)/ 180);
     }
 
@@ -2101,7 +2199,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const
     gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL);
 
     bool modmade = false;
-    for (GSList const *items = SP_DT_SELECTION(desktop)->itemList();
+    for (GSList const *items = sp_desktop_selection(desktop)->itemList();
          items != NULL;
          items = items->next)
     {
@@ -2132,7 +2230,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GtkWidget *tbl, gchar const
     sp_arctb_sensitivize (tbl, adj->value, other->value);
 
     if (modmade) {
-        sp_document_maybe_done(SP_DT_DOCUMENT(desktop), value_name);
+        sp_document_maybe_done(sp_desktop_document(desktop), value_name);
     }
 
     // defocus spinbuttons by moving focus to the canvas, unless "stay" is on
@@ -2159,7 +2257,7 @@ sp_arctb_open_state_changed(GtkWidget *widget, GtkObject *tbl)
 {
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl), "desktop");
 
-    if (sp_document_get_undo_sensitive(SP_DT_DOCUMENT(desktop))) {
+    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
             prefs_set_string_attribute("tools.shapes.arc", "open", "true");
         } else {
@@ -2178,7 +2276,7 @@ sp_arctb_open_state_changed(GtkWidget *widget, GtkObject *tbl)
     bool modmade = false;
 
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
-        for (GSList const *items = SP_DT_SELECTION(desktop)->itemList();
+        for (GSList const *items = sp_desktop_selection(desktop)->itemList();
              items != NULL;
              items = items->next)
         {
@@ -2190,7 +2288,7 @@ sp_arctb_open_state_changed(GtkWidget *widget, GtkObject *tbl)
             }
         }
     } else {
-        for (GSList const *items = SP_DT_SELECTION(desktop)->itemList();
+        for (GSList const *items = sp_desktop_selection(desktop)->itemList();
              items != NULL;
              items = items->next)
         {
@@ -2204,7 +2302,7 @@ sp_arctb_open_state_changed(GtkWidget *widget, GtkObject *tbl)
     }
 
     if (modmade) {
-        sp_document_done(SP_DT_DOCUMENT(desktop));
+        sp_document_done(sp_desktop_document(desktop));
     }
 
     g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
@@ -2398,10 +2496,15 @@ sp_arc_toolbox_new(SPDesktop *desktop)
     }
 
     sigc::connection *connection = new sigc::connection(
-        SP_DT_SELECTION(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), (GtkObject *)tbl))
+        sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), (GtkObject *)tbl))
         );
     g_signal_connect(G_OBJECT(tbl), "destroy", G_CALLBACK(delete_connection), connection);
 
+    Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch(NULL);
+    swatch->setWatchedTool ("tools.shapes.arc", true);
+    GtkWidget *swatch_ = GTK_WIDGET(swatch->gobj());
+    gtk_box_pack_end(GTK_BOX(tbl), swatch_, FALSE, FALSE, 0);
+
     gtk_widget_show_all(tbl);
     sp_set_font_size_smaller (tbl);
 
@@ -2605,7 +2708,7 @@ sp_dropper_toolbox_new(SPDesktop *desktop)
         GtkWidget *hb = gtk_hbox_new(FALSE, 1);
         
         GtkWidget *button = 
-            sp_button_new_from_data( GTK_ICON_SIZE_SMALL_TOOLBAR,
+            sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
                                      SP_BUTTON_TYPE_TOGGLE,
                                      NULL,
                                      "pick_color",
@@ -2681,129 +2784,341 @@ sp_text_letter_rotation_changed(GtkAdjustment *adj, GtkWidget *tbl)
 {
     //Call back for letter rotation spinbutton
 }*/
-static GtkWidget *
-sp_text_toolbox_new(SPDesktop *desktop)
-{
-    GtkWidget *tbl = gtk_hbox_new(FALSE, 0);
-/*    GtkWidget *us = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tbl), "units");
-    GtkTooltips *tt = gtk_tooltips_new();
-    GtkWidget *group;
 
-        //Font Family
+namespace {
+
+    void
+    sp_text_toolbox_selection_changed (Inkscape::Selection *selection, GObject *tbl)
+    {
+        GtkComboBox *cbox = 0;
+    
+        SPStyle *query =
+            sp_style_new ();
+
+        int result_family =
+            sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY); 
+
+        int result_style =
+            sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE); 
+
+        int result_numbers =
+            sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS); 
+
+        // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
+        if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING)
         {
-        GtkWidget *c = gtk_combo_new ();
-        gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE);
-        gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE);
-        gtk_combo_set_use_arrows_always ((GtkCombo *) c, TRUE);
-        gtk_widget_set_size_request (c, 144, -1);
-        aux_toolbox_space(tbl, 1);
-        gtk_box_pack_start (GTK_BOX (tbl), c, FALSE, FALSE, 0);
+            Inkscape::XML::Node *repr = inkscape_get_repr (INKSCAPE, "tools.text");
+
+            if (repr)
+            {
+                sp_style_read_from_repr (query, repr);
+            }
+            else
+            {
+                return;
+            }
         }
 
-        //Font Style
+        if (result_numbers == QUERY_STYLE_MULTIPLE_DIFFERENT)
         {
-        GtkWidget *c = gtk_combo_new ();
-        gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE);
-        gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE);
-        gtk_combo_set_use_arrows_always ((GtkCombo *) c, TRUE);
-        gtk_widget_set_size_request (c, 88, -1);
-        aux_toolbox_space(tbl, 1);
-        gtk_box_pack_start (GTK_BOX (tbl), c, FALSE, FALSE, 0);
+            static char* cboxes[] = { "combo-box-family", "combo-box-style" };
+        
+            for (unsigned n = 0 ; n < G_N_ELEMENTS(cboxes); ++n)
+            {
+                cbox = GTK_COMBO_BOX(g_object_get_data (G_OBJECT(tbl), cboxes[n]));
+                g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(1));
+                gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), -1); 
+                g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(0));
+            }
+            gtk_widget_hide (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));        
+            return;
         }
 
-        //Font Size
+        if (query->text)
         {
-        GtkWidget *c = gtk_combo_new ();
-        gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE);
-        gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE);
-        gtk_combo_set_use_arrows_always ((GtkCombo *) c, TRUE);
-        gtk_widget_set_size_request (c, 64, -1);
-        aux_toolbox_space(tbl, 1);
-        gtk_box_pack_start (GTK_BOX (tbl), c, FALSE, FALSE, 0);
+            if (query->text->font_family.value) 
+            {
+                Gtk::TreePath path;
+                try {
+                    path = Inkscape::FontLister::get_instance()->get_row_for_font (query->text->font_family.value);
+                } catch (...) {
+                    return;
+                }
+
+                cbox = GTK_COMBO_BOX(g_object_get_data (G_OBJECT(tbl), "combo-box-family"));
+                g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(1));
+                gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), gtk_tree_path_get_indices (path.gobj())[0]);
+                g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(0));
+            }
+
+            //Style
+            cbox = GTK_COMBO_BOX(g_object_get_data (G_OBJECT(tbl), "combo-box-style"));
+            g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(1));
+            gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), gint(query->font_style.value));
+            g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(0));
+
+            gtk_widget_hide (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));        
         }
+    }
 
-        aux_toolbox_space(tbl, AUX_BETWEEN_BUTTON_GROUPS);
-        //Bold
-        {
-        GtkWidget *px = gtk_image_new_from_stock(GTK_STOCK_BOLD, GTK_ICON_SIZE_SMALL_TOOLBAR);
-        GtkWidget *button = gtk_toggle_button_new ();
-        gtk_container_add (GTK_CONTAINER (button), px);
-        gtk_widget_show(button);
-        gtk_tooltips_set_tip (tt, button, _("Bold"), NULL);
-        gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
-        gtk_widget_set_sensitive(button, TRUE);
-        gtk_box_pack_start (GTK_BOX (tbl), button, FALSE, FALSE, 0);
+    void
+    sp_text_toolbox_selection_modified (Inkscape::Selection *selection, guint flags, GObject *tbl) 
+    {
+        sp_text_toolbox_selection_changed (selection, tbl); 
+    }
+
+    void
+    sp_text_toolbox_subselection_changed (gpointer dragger, GObject *tbl)
+    {
+        sp_text_toolbox_selection_changed (NULL, tbl); 
+    }
+
+    void
+    sp_text_toolbox_family_changed (GtkComboBox *cbox,
+                                    GtkWidget   *tbl) 
+    {
+        SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+
+        if (GPOINTER_TO_INT(g_object_get_data (G_OBJECT (cbox), "block")) != 0) return;
+
+        if (gtk_combo_box_get_active (cbox) < 0) return;
+
+        SPCSSAttr *css = sp_repr_css_attr_new (); 
+        sp_repr_css_set_property (css, "font-family", gtk_combo_box_get_active_text (cbox));
+        sp_desktop_set_style (desktop, css, true, true);
+        sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP));
+        sp_repr_css_attr_unref (css);
+
+        gtk_widget_hide (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));        
+    }
+
+    void
+    sp_text_toolbox_family_entry_activate (GtkEntry     *entry,
+                                           GtkWidget    *tbl) 
+    {
+        const char* family = gtk_entry_get_text (entry);
+
+        try {    
+            Gtk::TreePath path = Inkscape::FontLister::get_instance()->get_row_for_font (family);
+            GtkComboBox *cbox = GTK_COMBO_BOX(g_object_get_data (G_OBJECT(tbl), "combo-box-family"));
+            gtk_combo_box_set_active (cbox, gtk_tree_path_get_indices (path.gobj())[0]);
+            gtk_widget_hide (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));        
+        } catch (...) {
+            //XXX: Accept it anyway and show the warning
+            if (family && strlen (family)) gtk_widget_show_all (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));        
         }
+    }
+
+    void
+    sp_text_toolbox_style_changed (GtkComboBox *cbox,
+                                   GtkWidget   *tbl) 
+    {
+        SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+
+        if (GPOINTER_TO_INT(g_object_get_data (G_OBJECT (cbox), "block")) != 0) return;
+    
+        static char* styles[] = { "normal", "italic" , "oblique" };
+
+        SPCSSAttr *css = sp_repr_css_attr_new (); 
+        sp_repr_css_set_property (css, "font-style", styles[gtk_combo_box_get_active (cbox)]);
+        sp_desktop_set_style (desktop, css, true, true);
+        sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP));
+        sp_repr_css_attr_unref (css);
+    }
+
+}//<unnamed> namespace
+
+#if 0
+static void  cell_data_func  (GtkCellLayout     *cell_layout,
+                              GtkCellRenderer   *cell,
+                              GtkTreeModel      *tree_model,
+                              GtkTreeIter       *iter,
+                              gpointer           data)
+{
+    char *text; 
+    gtk_tree_model_get (tree_model, iter, 0, &text, -1); 
+    g_object_set (G_OBJECT (cell), "family", text, NULL);
+}
+#endif
+
+namespace
+{
+    GtkWidget*
+    sp_text_toolbox_new (SPDesktop *desktop)
+    {
+        GtkWidget   *tbl = gtk_hbox_new (FALSE, 0);
+
+#if 0
+    GtkWidget   *us = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(tbl), "units"));
+    GtkTooltips *tt = gtk_tooltips_new();
+    GtkWidget   *group;
+#endif
+
+        //Font Family
+        GtkWidget *cbox = gtk_combo_box_entry_new_text ();
+        Glib::RefPtr<Gtk::ListStore> store = Inkscape::FontLister::get_instance()->get_font_list();
+        gtk_cell_layout_clear (GTK_CELL_LAYOUT (cbox));
+        GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
+        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cbox), cell, FALSE);
+        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (cbox), cell, "text", 0, NULL);
+        GtkEntryCompletion *completion = gtk_entry_completion_new ();
+        gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (Glib::unwrap(store)));
+        gtk_entry_completion_set_text_column (completion, 0);
+        gtk_entry_completion_set_minimum_key_length (completion, 3); //3 characters minimum sounds reasonable
+        g_object_set (G_OBJECT(completion), "inline-completion", TRUE, "popup-completion", TRUE, NULL);
+
+#if 0
+        gtk_cell_layout_set_cell_data_func
+            (GTK_CELL_LAYOUT (cbox),
+             cell, 
+             GtkCellLayoutDataFunc (cell_data_func),
+             tbl, 
+             NULL); 
+#endif
+
+        gtk_combo_box_set_model (GTK_COMBO_BOX (cbox), GTK_TREE_MODEL (Glib::unwrap(store)));
+        gtk_widget_set_size_request (cbox, 250, -1);
+        aux_toolbox_space (tbl, 1);
+        gtk_box_pack_start (GTK_BOX (tbl), cbox, FALSE, FALSE, 0);
+        g_object_set_data (G_OBJECT (tbl), "combo-box-family", cbox);
+        g_signal_connect (G_OBJECT (cbox), "changed", G_CALLBACK (sp_text_toolbox_family_changed), tbl);
+        g_signal_connect (G_OBJECT (GTK_BIN(cbox)->child), "activate", G_CALLBACK (sp_text_toolbox_family_entry_activate), tbl);
+        gtk_entry_set_completion (GTK_ENTRY(GTK_BIN(cbox)->child), completion);
+
+        GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
+        aux_toolbox_space (tbl, 1);
+        GtkWidget *box = gtk_event_box_new ();
+        gtk_container_add (GTK_CONTAINER (box), image);
+        gtk_box_pack_start (GTK_BOX (tbl), box, FALSE, FALSE, 4);
+        g_object_set_data (G_OBJECT (tbl), "warning-image", box);
+        GtkTooltips *tooltips = gtk_tooltips_new ();
+        gtk_tooltips_set_tip (tooltips, box, _("This font is currently not installed on your system. Inkscape will use the default font instead."), "");
+        gtk_widget_hide (GTK_WIDGET (box));
+
+        //Font Style
+        cbox = gtk_combo_box_new_text ();
+        gtk_combo_box_append_text (GTK_COMBO_BOX (cbox), _("Normal"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (cbox), _("Italic"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (cbox), _("Oblique"));
+        gtk_widget_set_size_request (cbox, 144, -1);
+        aux_toolbox_space (tbl, 1);
+        gtk_box_pack_start (GTK_BOX (tbl), cbox, FALSE, FALSE, 0);
+        g_object_set_data (G_OBJECT (tbl), "combo-box-style", cbox);
+        g_signal_connect (G_OBJECT (cbox), "changed", G_CALLBACK (sp_text_toolbox_style_changed), tbl);
+
+        Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISTextToolbox");
+
+        sigc::connection *c_selection_changed =
+            new sigc::connection (sp_desktop_selection (desktop)->connectChanged 
+                                (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), (GObject*)tbl)));
+        pool->add_connection ("selection-changed", c_selection_changed);
+
+        sigc::connection *c_selection_modified =
+            new sigc::connection (sp_desktop_selection (desktop)->connectModified 
+                                (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_modified), (GObject*)tbl)));
+        pool->add_connection ("selection-modified", c_selection_modified);
+
+        sigc::connection *c_subselection_changed =
+            new sigc::connection (desktop->connectToolSubselectionChanged
+                                (sigc::bind (sigc::ptr_fun (sp_text_toolbox_subselection_changed), (GObject*)tbl)));
+        pool->add_connection ("tool-subselection-changed", c_subselection_changed);
+
+        Inkscape::ConnectionPool::connect_destroy (G_OBJECT (tbl), pool);
+
+#if 0
+    //Font Size
+    {
+            GtkWidget *c = gtk_combo_new ();
+            gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE);
+            gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE);
+            gtk_combo_set_use_arrows_always ((GtkCombo *) c, TRUE);
+            gtk_widget_set_size_request (c, 64, -1);
+            aux_toolbox_space(tbl, 1);
+            gtk_box_pack_start (GTK_BOX (tbl), c, FALSE, FALSE, 0);
+    }
+
+    aux_toolbox_space(tbl, AUX_BETWEEN_BUTTON_GROUPS);
+    //Bold
+    {
+            GtkWidget *px = gtk_image_new_from_stock(GTK_STOCK_BOLD, Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+            GtkWidget *button = gtk_toggle_button_new ();
+            gtk_container_add (GTK_CONTAINER (button), px);
+            gtk_widget_show(button);
+            gtk_tooltips_set_tip (tt, button, _("Bold"), NULL);
+            gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+            gtk_widget_set_sensitive(button, TRUE);
+            gtk_box_pack_start (GTK_BOX (tbl), button, FALSE, FALSE, 0);
+    }
 
 
         //Italic
         {
-        GtkWidget *px = gtk_image_new_from_stock(GTK_STOCK_ITALIC, GTK_ICON_SIZE_SMALL_TOOLBAR);
-        GtkWidget *button = gtk_toggle_button_new ();
-        gtk_container_add (GTK_CONTAINER (button), px);
-        gtk_widget_show(button);
-        gtk_tooltips_set_tip (tt, button, _("Italics"), NULL);
-        gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
-        gtk_widget_set_sensitive(button, TRUE);
-        gtk_box_pack_start (GTK_BOX (tbl), button, FALSE, FALSE, 0);
+            GtkWidget *px = gtk_image_new_from_stock(GTK_STOCK_ITALIC, Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+            GtkWidget *button = gtk_toggle_button_new ();
+            gtk_container_add (GTK_CONTAINER (button), px);
+            gtk_widget_show(button);
+            gtk_tooltips_set_tip (tt, button, _("Italics"), NULL);
+            gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+            gtk_widget_set_sensitive(button, TRUE);
+            gtk_box_pack_start (GTK_BOX (tbl), button, FALSE, FALSE, 0);
         }
 
         //Underline
         {
-        GtkWidget *px = gtk_image_new_from_stock(GTK_STOCK_UNDERLINE, GTK_ICON_SIZE_SMALL_TOOLBAR);
-        GtkWidget *button = gtk_toggle_button_new ();
-        gtk_container_add (GTK_CONTAINER (button), px);
-        gtk_widget_show(button);
-        gtk_tooltips_set_tip (tt, button, _("Underline"), NULL);
-        gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
-        gtk_widget_set_sensitive(button, FALSE);
-        gtk_box_pack_start (GTK_BOX (tbl), button, FALSE, FALSE, 0);
+            GtkWidget *px = gtk_image_new_from_stock(GTK_STOCK_UNDERLINE, Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+            GtkWidget *button = gtk_toggle_button_new ();
+            gtk_container_add (GTK_CONTAINER (button), px);
+            gtk_widget_show(button);
+            gtk_tooltips_set_tip (tt, button, _("Underline"), NULL);
+            gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+            gtk_widget_set_sensitive(button, FALSE);
+            gtk_box_pack_start (GTK_BOX (tbl), button, FALSE, FALSE, 0);
         }
 
         aux_toolbox_space(tbl, AUX_BETWEEN_BUTTON_GROUPS);
         // align left
         {
-        GtkWidget *px = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_LEFT, GTK_ICON_SIZE_SMALL_TOOLBAR);
-        GtkWidget *b = group = gtk_radio_button_new (NULL);
+            GtkWidget *px = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_LEFT, Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+            GtkWidget *b = group = gtk_radio_button_new (NULL);
                gtk_container_add (GTK_CONTAINER (b), px);
-        gtk_tooltips_set_tip (tt, b, _("Align lines left"), NULL);
-        gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE);
-        gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE );
-        gtk_box_pack_start (GTK_BOX (tbl), b, FALSE, FALSE, 0);
+            gtk_tooltips_set_tip (tt, b, _("Align lines left"), NULL);
+            gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE);
+            gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE );
+            gtk_box_pack_start (GTK_BOX (tbl), b, FALSE, FALSE, 0);
         }
 
         // align center
         {
-        GtkWidget *px = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_CENTER, GTK_ICON_SIZE_SMALL_TOOLBAR);
-        GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
+            GtkWidget *px = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_CENTER, Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+            GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
                gtk_container_add (GTK_CONTAINER (b), px);
-        // TRANSLATORS: `Center' here is a verb.
-        gtk_tooltips_set_tip (tt, b, _("Center lines"), NULL);
+            // TRANSLATORS: `Center' here is a verb.
+            gtk_tooltips_set_tip (tt, b, _("Center lines"), NULL);
                gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE);
-        gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE );
-        gtk_box_pack_start (GTK_BOX (tbl), b, FALSE, FALSE, 0);
+            gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE );
+            gtk_box_pack_start (GTK_BOX (tbl), b, FALSE, FALSE, 0);
         }
 
         // align right
         {
-        GtkWidget *px = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT, GTK_ICON_SIZE_SMALL_TOOLBAR);
-        GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
+            GtkWidget *px = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT, Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+            GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
                gtk_container_add (GTK_CONTAINER (b), px);
-        gtk_tooltips_set_tip (tt, b, _("Align lines right"), NULL);
-        gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE);
-        gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE );
-        gtk_box_pack_start (GTK_BOX (tbl), b, FALSE, FALSE, 0);
+            gtk_tooltips_set_tip (tt, b, _("Align lines right"), NULL);
+            gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE);
+            gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE );
+            gtk_box_pack_start (GTK_BOX (tbl), b, FALSE, FALSE, 0);
         }
 
         // full justification
         {
-        GtkWidget *px = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_FILL, GTK_ICON_SIZE_SMALL_TOOLBAR);
-        GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
+            GtkWidget *px = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_FILL, Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+            GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
                gtk_container_add (GTK_CONTAINER (b), px);
-        gtk_tooltips_set_tip (tt, b, _("Full justification"), NULL);
-        gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE);
-        gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE );
-        gtk_box_pack_start (GTK_BOX (tbl), b, FALSE, FALSE, 0);
+            gtk_tooltips_set_tip (tt, b, _("Full justification"), NULL);
+            gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE);
+            gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE );
+            gtk_box_pack_start (GTK_BOX (tbl), b, FALSE, FALSE, 0);
         }
         
                
@@ -2811,7 +3126,7 @@ sp_text_toolbox_new(SPDesktop *desktop)
                
         // horizontal
         {
-        GtkWidget *px= sp_icon_new(GTK_ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_WRITING_MODE_LR);
+        GtkWidget *px= sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_WRITING_MODE_LR);
         GtkWidget *b = group = gtk_radio_button_new (NULL);
                gtk_container_add (GTK_CONTAINER (b), px);
         gtk_tooltips_set_tip (tt, b, _("Horizontal text"), NULL);
@@ -2822,7 +3137,7 @@ sp_text_toolbox_new(SPDesktop *desktop)
 
         // vertical
         {
-        GtkWidget *px = sp_icon_new (GTK_ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_WRITING_MODE_TB);
+        GtkWidget *px = sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_WRITING_MODE_TB);
         GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
                gtk_container_add (GTK_CONTAINER (b), px);
         gtk_tooltips_set_tip (tt, b, _("Vertical text"), NULL);
@@ -2836,7 +3151,7 @@ sp_text_toolbox_new(SPDesktop *desktop)
         // letter spacing
     {
         {
-        GtkWidget *image = sp_icon_new (GTK_ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_LETTER_SPACING);
+        GtkWidget *image = sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_LETTER_SPACING);
         GtkWidget *hb = gtk_hbox_new(FALSE, 1);
         gtk_container_add (GTK_CONTAINER (hb), image);
         gtk_widget_show(image);
@@ -2857,7 +3172,7 @@ sp_text_toolbox_new(SPDesktop *desktop)
         // line spacing
     {
         {
-        GtkWidget *image = sp_icon_new (GTK_ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_LINE_SPACING);
+        GtkWidget *image = sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_LINE_SPACING);
         GtkWidget *hb = gtk_hbox_new(FALSE, 1);
         gtk_container_add (GTK_CONTAINER (hb), image);
         gtk_widget_show(image);
@@ -2886,7 +3201,7 @@ sp_text_toolbox_new(SPDesktop *desktop)
     // horizontal kerning
     {
         {
-        GtkWidget *image = sp_icon_new (GTK_ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_HORZ_KERN);
+        GtkWidget *image = sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_HORZ_KERN);
         GtkWidget *hb = gtk_hbox_new(FALSE, 1);
         gtk_container_add (GTK_CONTAINER (hb), image);
         gtk_widget_show(image);
@@ -2907,7 +3222,7 @@ sp_text_toolbox_new(SPDesktop *desktop)
     // vertical kerning
     {
         {
-        GtkWidget *image = sp_icon_new (GTK_ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_VERT_KERN);
+        GtkWidget *image = sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_VERT_KERN);
         GtkWidget *hb = gtk_hbox_new(FALSE, 1);
         gtk_container_add (GTK_CONTAINER (hb), image);
         gtk_widget_show(image);
@@ -2935,7 +3250,7 @@ sp_text_toolbox_new(SPDesktop *desktop)
     aux_toolbox_space(tbl, AUX_BETWEEN_BUTTON_GROUPS);
     {
         {
-        GtkWidget *image = sp_icon_new (GTK_ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_ROTATION);
+        GtkWidget *image = sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_ROTATION);
         GtkWidget *hb = gtk_hbox_new(FALSE, 1);
         gtk_container_add (GTK_CONTAINER (hb), image);
         gtk_widget_show(image);
@@ -2959,7 +3274,7 @@ sp_text_toolbox_new(SPDesktop *desktop)
        
         // Remove Manual Kerns
         {
-        GtkWidget *px = sp_icon_new (GTK_ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_REMOVE_KERNS);
+        GtkWidget *px = sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_STOCK_TEXT_REMOVE_KERNS);
         GtkWidget *button = gtk_button_new ();
         gtk_container_add (GTK_CONTAINER (button), px);
         gtk_widget_show(button);
@@ -2968,13 +3283,19 @@ sp_text_toolbox_new(SPDesktop *desktop)
         gtk_widget_set_sensitive(button, TRUE);
         gtk_box_pack_start (GTK_BOX (tbl), button, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
         }
+#endif
 
-    gtk_widget_show_all(tbl);
-    sp_set_font_size_smaller (tbl);
+        Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch(NULL);
+        swatch->setWatchedTool ("tools.text", true);
+        GtkWidget *swatch_ = GTK_WIDGET(swatch->gobj());
+        gtk_box_pack_end (GTK_BOX(tbl), swatch_, FALSE, FALSE, 0);
+        gtk_widget_show_all (tbl);
+
+        return tbl;
 
-*/    return tbl;
+    } // end of sp_text_toolbox_new()
 
-} // end of sp_text_toolbox_new()
+}//<unnamed> namespace
 
 
 //#########################
@@ -3002,7 +3323,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GtkWidget *tbl)
         
     SPDesktop *desktop = (SPDesktop *) gtk_object_get_data(GTK_OBJECT(tbl),
             "desktop");
-    SPDocument *doc = SP_DT_DOCUMENT(desktop);
+    SPDocument *doc = sp_desktop_document(desktop);
 
     if (!sp_document_get_undo_sensitive(doc))
     {
@@ -3079,11 +3400,11 @@ sp_connector_toolbox_new(SPDesktop *desktop)
     gtk_box_pack_start(GTK_BOX(tbl), gtk_hbox_new(FALSE, 0), FALSE, FALSE,
             AUX_BETWEEN_BUTTON_GROUPS);
 
-    sp_toolbox_button_new(tbl, GTK_ICON_SIZE_SMALL_TOOLBAR,
+    sp_toolbox_button_new(tbl, Inkscape::ICON_SIZE_SMALL_TOOLBAR,
             "connector_avoid", GTK_SIGNAL_FUNC(sp_connector_path_set_avoid),
             tt, _("Make connectors avoid selected objects"));
 
-    sp_toolbox_button_new(tbl, GTK_ICON_SIZE_SMALL_TOOLBAR,
+    sp_toolbox_button_new(tbl, Inkscape::ICON_SIZE_SMALL_TOOLBAR,
             "connector_ignore", GTK_SIGNAL_FUNC(sp_connector_path_set_ignore),
             tt, _("Make connectors ignore selected objects"));