Code

Add units selector to offset and remove offset range limits
authorjohncoswell <johncoswell@users.sourceforge.net>
Thu, 8 Mar 2007 02:35:11 +0000 (02:35 +0000)
committerjohncoswell <johncoswell@users.sourceforge.net>
Thu, 8 Mar 2007 02:35:11 +0000 (02:35 +0000)
src/flood-context.cpp
src/flood-context.h
src/widgets/toolbox.cpp

index 6ee1f9a683de014f194a348e916d024b6fca05f5..5d106a795ecf2a1a38555c80d50a3876fd270470 100644 (file)
@@ -302,7 +302,7 @@ static void do_trace(GdkPixbuf *px, SPDesktop *desktop, NR::Matrix transform) {
 
     long totalNodeCount = 0L;
 
-    double offset = prefs_get_double_attribute_limited("tools.paintbucket", "offset", 1.5, 0.0, 2.0);
+    double offset = prefs_get_double_attribute("tools.paintbucket", "offset", 2.0);
 
     for (unsigned int i=0 ; i<results.size() ; i++) {
         Inkscape::Trace::TracingEngineResult result = results[i];
@@ -747,6 +747,7 @@ void flood_channels_changed(GtkComboBox *cbox, GtkWidget *tbl)
 {
     prefs_set_int_attribute("tools.paintbucket", "channels", (gint)gtk_combo_box_get_active(cbox));
 }
+
 /*
   Local Variables:
   mode:c++
index 63cabdd5b96ee17a4f067c5cb98c96e1f714b4a4..269d2856ac7a311bdbaa14ab55675e11af4354b6 100644 (file)
@@ -14,6 +14,9 @@
 #include <sigc++/sigc++.h>
 #include <gtk/gtk.h>
 #include "event-context.h"
+#include "helper/unit-menu.h"
+#include "helper/units.h"
+
 struct SPKnotHolder;
 
 #define SP_TYPE_FLOOD_CONTEXT            (sp_flood_context_get_type ())
index fe6e6f67608fd2ac4c36e891aa37452e8b86dc7f..975a8cbdac708ec55c3fc3e3739336030eb615a6 100644 (file)
@@ -4442,7 +4442,10 @@ static void paintbucket_tolerance_changed(GtkAdjustment *adj, GtkWidget *tbl)
 
 static void paintbucket_offset_changed(GtkAdjustment *adj, GtkWidget *tbl)
 {
-    prefs_set_double_attribute("tools.paintbucket", "offset", (gint)adj->value);
+    GtkWidget *us = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tbl), "units");
+    SPUnit const *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(us));
+    
+    prefs_set_double_attribute("tools.paintbucket", "offset", (gdouble)sp_units_get_pixels(adj->value, *unit));
     spinbutton_defocus(GTK_OBJECT(tbl));
 }
 
@@ -4466,16 +4469,24 @@ sp_paintbucket_toolbox_new(SPDesktop *desktop)
     //  interval
     gtk_box_pack_start(GTK_BOX(tbl), gtk_hbox_new(FALSE, 0), FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
 
+    // Create the units menu.
+    GtkWidget *us = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
+    sp_unit_selector_setsize(us, AUX_OPTION_MENU_WIDTH, AUX_OPTION_MENU_HEIGHT);
+    sp_unit_selector_set_unit (SP_UNIT_SELECTOR(us), sp_desktop_namedview(desktop)->doc_units);
+    
     // Offset spinbox
     {
         GtkWidget *offset = sp_tb_spinbutton(_("Offset:"),
                 _("The amount to grow the path after it has been traced"),
-                "tools.paintbucket", "offset", 5, NULL, tbl, TRUE,
-                "inkscape:paintbucket-offset", 0.0, 2.0, 0.1, 0.5,
+                "tools.paintbucket", "offset", 5, us, tbl, TRUE,
+                "inkscape:paintbucket-offset", -1e6, 1e6, 0.1, 0.5,
                 paintbucket_offset_changed, 1, 2);
 
         gtk_box_pack_start(GTK_BOX(tbl), offset, FALSE, FALSE,
                 AUX_SPACING);
+    
+        gtk_box_pack_start(GTK_BOX(tbl), us, FALSE, FALSE, AUX_SPACING);
+        gtk_object_set_data(GTK_OBJECT(tbl), "units", us);
     }
     
     //  interval