[gimp] app, libgimpwidgets: move gimp_prop_spin_scale_new() and…



commit 7056f1b96046f0aa33899c6f51b8161a280cbad7
Author: Jehan <jehan girinstud io>
Date:   Fri Feb 18 22:49:45 2022 +0100

    app, libgimpwidgets: move gimp_prop_spin_scale_new() and…
    
    … gimp_prop_widget_set_factor() to libgimpwidgets.
    
    Now that GimpSpinScale is in libgimpwidgets, it's time to move the
    associated prop too, to make it a prop widget with such a widget easily
    creatable by plug-ins.
    
    While doing so, I update both these functions logic, binding properties
    together with the g_object_bind_property*() APIs (as we do already in
    some other recent prop functions) rather than connecting to signals
    ourselves. It makes for much simpler code.

 app/propgui/gimppropgui-color-balance.c  |   5 +-
 app/propgui/gimppropgui-color-rotate.c   |   8 +-
 app/propgui/gimppropgui-hue-saturation.c |  23 +--
 app/propgui/gimppropgui.c                |   2 +-
 app/tools/gimpairbrushtool.c             |   4 +-
 app/tools/gimpbrightnesscontrasttool.c   |   6 +-
 app/tools/gimpbucketfilloptions.c        |  12 +-
 app/tools/gimpcoloroptions.c             |   2 +-
 app/tools/gimpconvolvetool.c             |   2 +-
 app/tools/gimpdodgeburntool.c            |   2 +-
 app/tools/gimpfiltertool.c               |   1 -
 app/tools/gimpforegroundselectoptions.c  |   8 +-
 app/tools/gimpgradientoptions.c          |   6 +-
 app/tools/gimpinkoptions-gui.c           |  10 +-
 app/tools/gimpmybrushoptions-gui.c       |   6 +-
 app/tools/gimpnpointdeformationoptions.c |   6 +-
 app/tools/gimppaintoptions-gui.c         |  15 +-
 app/tools/gimppaintselectoptions.c       |   2 +-
 app/tools/gimprectangleoptions.c         |   4 +-
 app/tools/gimprectangleselectoptions.c   |   2 +-
 app/tools/gimpregionselectoptions.c      |   2 +-
 app/tools/gimpseamlesscloneoptions.c     |   2 +-
 app/tools/gimpselectionoptions.c         |   2 +-
 app/tools/gimpsmudgetool.c               |   4 +-
 app/tools/gimptransformgridoptions.c     |   6 +-
 app/tools/gimpwarpoptions.c              |  12 +-
 app/widgets/gimppropwidgets.c            | 330 -------------------------------
 app/widgets/gimppropwidgets.h            |  13 --
 libgimpwidgets/gimppropwidgets.c         | 226 ++++++++++++++++++++-
 libgimpwidgets/gimppropwidgets.h         |  11 ++
 libgimpwidgets/gimpwidgets.def           |   2 +
 31 files changed, 309 insertions(+), 427 deletions(-)
---
diff --git a/app/propgui/gimppropgui-color-balance.c b/app/propgui/gimppropgui-color-balance.c
index 2793ca4df1..37c0da05c2 100644
--- a/app/propgui/gimppropgui-color-balance.c
+++ b/app/propgui/gimppropgui-color-balance.c
@@ -54,10 +54,9 @@ create_levels_scale (GObject     *config,
   gtk_grid_attach (GTK_GRID (grid), label, 0, col, 1, 1);
   gtk_widget_show (label);
 
-  scale = gimp_prop_spin_scale_new (config, property_name,
-                                    NULL, 0.01, 0.1, 0);
+  scale = gimp_prop_spin_scale_new (config, property_name, 0.01, 0.1, 0);
   gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), NULL);
-  gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
+  gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
   gtk_widget_set_hexpand (scale, TRUE);
   gtk_grid_attach (GTK_GRID (grid), scale, 1, col, 1, 1);
 
diff --git a/app/propgui/gimppropgui-color-rotate.c b/app/propgui/gimppropgui-color-rotate.c
index 6b8b26c634..cabd336337 100644
--- a/app/propgui/gimppropgui-color-rotate.c
+++ b/app/propgui/gimppropgui-color-rotate.c
@@ -105,12 +105,12 @@ gimp_prop_angle_range_box_new (GObject     *config,
   gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
   gtk_widget_show (vbox);
 
-  scale = gimp_prop_spin_scale_new (config, alpha_property_name, NULL,
+  scale = gimp_prop_spin_scale_new (config, alpha_property_name,
                                     1.0, 15.0, 2);
   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (scale), TRUE);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, beta_property_name, NULL,
+  scale = gimp_prop_spin_scale_new (config, beta_property_name,
                                     1.0, 15.0, 2);
   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (scale), TRUE);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
@@ -167,12 +167,12 @@ gimp_prop_polar_box_new (GObject     *config,
   gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
   gtk_widget_show (vbox);
 
-  scale = gimp_prop_spin_scale_new (config, angle_property_name, NULL,
+  scale = gimp_prop_spin_scale_new (config, angle_property_name,
                                     1.0, 15.0, 2);
   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (scale), TRUE);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, radius_property_name, NULL,
+  scale = gimp_prop_spin_scale_new (config, radius_property_name,
                                     1.0, 15.0, 2);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
diff --git a/app/propgui/gimppropgui-hue-saturation.c b/app/propgui/gimppropgui-hue-saturation.c
index 423ef83659..7104e5bbf3 100644
--- a/app/propgui/gimppropgui-hue-saturation.c
+++ b/app/propgui/gimppropgui-hue-saturation.c
@@ -222,9 +222,9 @@ _gimp_prop_gui_new_hue_saturation (GObject                  *config,
   gtk_widget_show (grid);
 
   /* Create the 'Overlap' option slider */
-  scale = gimp_prop_spin_scale_new (config, "overlap",
-                                    _("_Overlap"), 0.01, 0.1, 0);
-  gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
+  scale = gimp_prop_spin_scale_new (config, "overlap", 0.01, 0.1, 0);
+  gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
+  gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), _("_Overlap"));
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
   frame = gimp_frame_new (_("Adjust Selected Color"));
@@ -237,20 +237,21 @@ _gimp_prop_gui_new_hue_saturation (GObject                  *config,
 
   /*  Create the hue scale widget  */
   scale = gimp_prop_spin_scale_new (config, "hue",
-                                    _("_Hue"), 1.0 / 180.0, 15.0 / 180.0, 0);
-  gimp_prop_widget_set_factor (scale, 180.0, 0.0, 0.0, 1);
+                                    1.0 / 180.0, 15.0 / 180.0, 0);
+  gimp_prop_widget_set_factor (scale, 180.0, 1.0, 15.0, 1);
+  gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), _("_Hue"));
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
   /*  Create the lightness scale widget  */
-  scale = gimp_prop_spin_scale_new (config, "lightness",
-                                    _("_Lightness"), 0.01, 0.1, 0);
-  gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
+  scale = gimp_prop_spin_scale_new (config, "lightness", 0.01, 0.1, 0);
+  gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
+  gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), _("_Lightness"));
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
   /*  Create the saturation scale widget  */
-  scale = gimp_prop_spin_scale_new (config, "saturation",
-                                    _("_Saturation"), 0.01, 0.1, 0);
-  gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
+  scale = gimp_prop_spin_scale_new (config, "saturation", 0.01, 0.1, 0);
+  gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
+  gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), _("_Saturation"));
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
diff --git a/app/propgui/gimppropgui.c b/app/propgui/gimppropgui.c
index 331c8cb5c9..777ce87d60 100644
--- a/app/propgui/gimppropgui.c
+++ b/app/propgui/gimppropgui.c
@@ -199,7 +199,7 @@ gimp_prop_widget_new_from_pspec (GObject                  *config,
             }
         }
 
-      widget = gimp_prop_spin_scale_new (config, pspec->name, NULL,
+      widget = gimp_prop_spin_scale_new (config, pspec->name,
                                          step, page, digits);
 
       if (HAS_KEY (pspec, "unit", "degree") &&
diff --git a/app/tools/gimpairbrushtool.c b/app/tools/gimpairbrushtool.c
index 6aa0788cb1..6f0c8a6b33 100644
--- a/app/tools/gimpairbrushtool.c
+++ b/app/tools/gimpairbrushtool.c
@@ -135,11 +135,11 @@ gimp_airbrush_options_gui (GimpToolOptions *tool_options)
   button = gimp_prop_check_button_new (config, "motion-only", NULL);
   gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, "rate", NULL,
+  scale = gimp_prop_spin_scale_new (config, "rate",
                                     1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, "flow", NULL,
+  scale = gimp_prop_spin_scale_new (config, "flow",
                                     1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c
index 74d48da5aa..7134260b7d 100644
--- a/app/tools/gimpbrightnesscontrasttool.c
+++ b/app/tools/gimpbrightnesscontrasttool.c
@@ -279,14 +279,16 @@ gimp_brightness_contrast_tool_dialog (GimpFilterTool *filter_tool)
 
   /*  Create the brightness scale widget  */
   scale = gimp_prop_spin_scale_new (filter_tool->config, "brightness",
-                                    _("_Brightness"), 0.01, 0.1, 3);
+                                    0.01, 0.1, 3);
+  gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), _("_Brightness"));
   gtk_box_pack_start (GTK_BOX (main_vbox), scale, FALSE, FALSE, 0);
 
   bc_tool->brightness_scale = scale;
 
   /*  Create the contrast scale widget  */
   scale = gimp_prop_spin_scale_new (filter_tool->config, "contrast",
-                                    _("_Contrast"), 0.01, 0.1, 3);
+                                    0.01, 0.1, 3);
+  gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), _("_Contrast"));
   gtk_box_pack_start (GTK_BOX (main_vbox), scale, FALSE, FALSE, 0);
 
   bc_tool->contrast_scale = scale;
diff --git a/app/tools/gimpbucketfilloptions.c b/app/tools/gimpbucketfilloptions.c
index d89380712f..0328b59d5f 100644
--- a/app/tools/gimpbucketfilloptions.c
+++ b/app/tools/gimpbucketfilloptions.c
@@ -490,7 +490,7 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (box2), widget, FALSE, FALSE, 0);
 
   /*  the threshold scale  */
-  scale = gimp_prop_spin_scale_new (config, "threshold", NULL,
+  scale = gimp_prop_spin_scale_new (config, "threshold",
                                     1.0, 16.0, 1);
   gtk_box_pack_start (GTK_BOX (box2), scale, FALSE, FALSE, 0);
   options->priv->threshold_scale = scale;
@@ -535,7 +535,7 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (box2), combo, FALSE, FALSE, 0);
 
   /*  Line Art: fill as line art  */
-  scale = gimp_prop_spin_scale_new (config, "fill-color-as-line-art-threshold", NULL,
+  scale = gimp_prop_spin_scale_new (config, "fill-color-as-line-art-threshold",
                                     1.0, 16.0, 1);
 
   frame = gimp_prop_expanding_frame_new (config, "fill-color-as-line-art", NULL,
@@ -548,7 +548,7 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (box2), widget, FALSE, FALSE, 0);
 
   /*  Line Art: feather radius scale  */
-  scale = gimp_prop_spin_scale_new (config, "feather-radius", NULL,
+  scale = gimp_prop_spin_scale_new (config, "feather-radius",
                                     1.0, 10.0, 1);
 
   frame = gimp_prop_expanding_frame_new (config, "feather", NULL,
@@ -556,17 +556,17 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
 
   /*  Line Art: max growing size */
-  scale = gimp_prop_spin_scale_new (config, "line-art-max-grow", NULL,
+  scale = gimp_prop_spin_scale_new (config, "line-art-max-grow",
                                     1, 5, 0);
   gtk_box_pack_start (GTK_BOX (box2), scale, FALSE, FALSE, 0);
 
   /*  Line Art: stroke threshold */
-  scale = gimp_prop_spin_scale_new (config, "line-art-threshold", NULL,
+  scale = gimp_prop_spin_scale_new (config, "line-art-threshold",
                                     0.05, 0.1, 2);
   gtk_box_pack_start (GTK_BOX (box2), scale, FALSE, FALSE, 0);
 
   /*  Line Art: max gap length */
-  scale = gimp_prop_spin_scale_new (config, "line-art-max-gap-length", NULL,
+  scale = gimp_prop_spin_scale_new (config, "line-art-max-gap-length",
                                     1, 5, 0);
   gtk_box_pack_start (GTK_BOX (box2), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpcoloroptions.c b/app/tools/gimpcoloroptions.c
index f98829ff33..dd33934991 100644
--- a/app/tools/gimpcoloroptions.c
+++ b/app/tools/gimpcoloroptions.c
@@ -154,7 +154,7 @@ gimp_color_options_gui (GimpToolOptions *tool_options)
   GtkWidget *scale;
 
   /*  the sample average options  */
-  scale = gimp_prop_spin_scale_new (config, "average-radius", NULL,
+  scale = gimp_prop_spin_scale_new (config, "average-radius",
                                     1.0, 10.0, 0);
 
   frame = gimp_prop_expanding_frame_new (config, "sample-average", NULL,
diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c
index 4c03931d8d..47240374a2 100644
--- a/app/tools/gimpconvolvetool.c
+++ b/app/tools/gimpconvolvetool.c
@@ -220,7 +220,7 @@ gimp_convolve_options_gui (GimpToolOptions *tool_options)
   g_free (str);
 
   /*  the rate scale  */
-  scale = gimp_prop_spin_scale_new (config, "rate", NULL,
+  scale = gimp_prop_spin_scale_new (config, "rate",
                                     1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c
index 2e594d9e3a..b11d0c36cb 100644
--- a/app/tools/gimpdodgeburntool.c
+++ b/app/tools/gimpdodgeburntool.c
@@ -230,7 +230,7 @@ gimp_dodge_burn_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
   /*  the exposure scale  */
-  scale = gimp_prop_spin_scale_new (config, "exposure", NULL,
+  scale = gimp_prop_spin_scale_new (config, "exposure",
                                     1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 489661ed91..3fc294338d 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -1142,7 +1142,6 @@ gimp_filter_tool_update_dialog_operation_settings (GimpFilterTool *filter_tool)
           /*  The opacity scale  */
           scale = gimp_prop_spin_scale_new (filter_tool->config,
                                             "gimp-opacity",
-                                            NULL,
                                             1.0, 10.0, 1);
           gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
           gtk_box_pack_start (GTK_BOX (vbox2), scale,
diff --git a/app/tools/gimpforegroundselectoptions.c b/app/tools/gimpforegroundselectoptions.c
index 4fcbc78d0a..24339ece7d 100644
--- a/app/tools/gimpforegroundselectoptions.c
+++ b/app/tools/gimpforegroundselectoptions.c
@@ -298,7 +298,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
   gtk_widget_show (hbox);
 
   /* stroke width */
-  scale = gimp_prop_spin_scale_new (config, "stroke-width", NULL,
+  scale = gimp_prop_spin_scale_new (config, "stroke-width",
                                     1.0, 10.0, 2);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0);
   gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), 1.7);
@@ -351,7 +351,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
   gtk_widget_show (inner_vbox);
 
   /*  engine parameters  */
-  scale = gimp_prop_spin_scale_new (config, "levels", NULL,
+  scale = gimp_prop_spin_scale_new (config, "levels",
                                     1.0, 1.0, 0);
   gtk_box_pack_start (GTK_BOX (inner_vbox), scale, FALSE, FALSE, 0);
 
@@ -363,7 +363,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
                                GINT_TO_POINTER (GIMP_MATTING_ENGINE_LEVIN),
                                NULL);
 
-  scale = gimp_prop_spin_scale_new (config, "active-levels", NULL,
+  scale = gimp_prop_spin_scale_new (config, "active-levels",
                                     1.0, 1.0, 0);
   gtk_box_pack_start (GTK_BOX (inner_vbox), scale, FALSE, FALSE, 0);
 
@@ -375,7 +375,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
                                GINT_TO_POINTER (GIMP_MATTING_ENGINE_LEVIN),
                                NULL);
 
-  scale = gimp_prop_spin_scale_new (config, "iterations", NULL,
+  scale = gimp_prop_spin_scale_new (config, "iterations",
                                     1.0, 1.0, 0);
   gtk_box_pack_start (GTK_BOX (inner_vbox), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpgradientoptions.c b/app/tools/gimpgradientoptions.c
index d0b2f7e292..a1a24fe609 100644
--- a/app/tools/gimpgradientoptions.c
+++ b/app/tools/gimpgradientoptions.c
@@ -314,7 +314,7 @@ gimp_gradient_options_gui (GimpToolOptions *tool_options)
   gradient_options_repeat_gradient_type_notify (options, NULL, combo);
 
   /*  the offset scale  */
-  scale = gimp_prop_spin_scale_new (config, "offset", NULL,
+  scale = gimp_prop_spin_scale_new (config, "offset",
                                     1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
@@ -329,12 +329,12 @@ gimp_gradient_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
   /*  max depth scale  */
-  scale = gimp_prop_spin_scale_new (config, "supersample-depth", NULL,
+  scale = gimp_prop_spin_scale_new (config, "supersample-depth",
                                     1.0, 1.0, 0);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
 
   /*  threshold scale  */
-  scale = gimp_prop_spin_scale_new (config, "supersample-threshold", NULL,
+  scale = gimp_prop_spin_scale_new (config, "supersample-threshold",
                                     0.01, 0.1, 2);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpinkoptions-gui.c b/app/tools/gimpinkoptions-gui.c
index 0c1f1f27cb..98422c7bcd 100644
--- a/app/tools/gimpinkoptions-gui.c
+++ b/app/tools/gimpinkoptions-gui.c
@@ -61,12 +61,12 @@ gimp_ink_options_gui (GimpToolOptions *tool_options)
   gtk_widget_show (vbox2);
 
   /*  size slider  */
-  scale = gimp_prop_spin_scale_new (config, "size", NULL,
+  scale = gimp_prop_spin_scale_new (config, "size",
                                     1.0, 2.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
 
   /* angle adjust slider */
-  scale = gimp_prop_spin_scale_new (config, "tilt-angle", NULL,
+  scale = gimp_prop_spin_scale_new (config, "tilt-angle",
                                     1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
 
@@ -80,17 +80,17 @@ gimp_ink_options_gui (GimpToolOptions *tool_options)
   gtk_widget_show (vbox2);
 
   /* size sens slider */
-  scale = gimp_prop_spin_scale_new (config, "size-sensitivity", NULL,
+  scale = gimp_prop_spin_scale_new (config, "size-sensitivity",
                                     0.01, 0.1, 2);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
 
   /* tilt sens slider */
-  scale = gimp_prop_spin_scale_new (config, "tilt-sensitivity", NULL,
+  scale = gimp_prop_spin_scale_new (config, "tilt-sensitivity",
                                     0.01, 0.1, 2);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
 
   /* velocity sens slider */
-  scale = gimp_prop_spin_scale_new (config, "vel-sensitivity", NULL,
+  scale = gimp_prop_spin_scale_new (config, "vel-sensitivity",
                                     0.01, 0.1, 2);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpmybrushoptions-gui.c b/app/tools/gimpmybrushoptions-gui.c
index 1d396077fb..a2f927f920 100644
--- a/app/tools/gimpmybrushoptions-gui.c
+++ b/app/tools/gimpmybrushoptions-gui.c
@@ -64,17 +64,17 @@ gimp_mybrush_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
   /* radius */
-  scale = gimp_prop_spin_scale_new (config, "radius", NULL,
+  scale = gimp_prop_spin_scale_new (config, "radius",
                                     0.1, 1.0, 2);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
   /* opaque */
-  scale = gimp_prop_spin_scale_new (config, "opaque", NULL,
+  scale = gimp_prop_spin_scale_new (config, "opaque",
                                     0.1, 1.0, 2);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
   /* hardness */
-  scale = gimp_prop_spin_scale_new (config, "hardness", NULL,
+  scale = gimp_prop_spin_scale_new (config, "hardness",
                                     0.1, 1.0, 2);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpnpointdeformationoptions.c b/app/tools/gimpnpointdeformationoptions.c
index 8fdc8a14ff..7f3e8c4c9b 100644
--- a/app/tools/gimpnpointdeformationoptions.c
+++ b/app/tools/gimpnpointdeformationoptions.c
@@ -209,14 +209,14 @@ gimp_n_point_deformation_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
   gtk_widget_set_can_focus (widget, FALSE);
 
-  widget = gimp_prop_spin_scale_new (config, "square-size", NULL,
+  widget = gimp_prop_spin_scale_new (config, "square-size",
                                      1.0, 10.0, 0);
   npd_options->scale_square_size = widget;
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget), 10.0, 100.0);
   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
   gtk_widget_set_can_focus (widget, FALSE);
 
-  widget = gimp_prop_spin_scale_new (config, "rigidity", NULL,
+  widget = gimp_prop_spin_scale_new (config, "rigidity",
                                      1.0, 10.0, 0);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget), 1.0, 2000.0);
   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
@@ -233,7 +233,7 @@ gimp_n_point_deformation_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
   gtk_widget_set_can_focus (widget, FALSE);
 
-  widget = gimp_prop_spin_scale_new (config, "mls-weights-alpha", NULL,
+  widget = gimp_prop_spin_scale_new (config, "mls-weights-alpha",
                                      0.1, 0.1, 1);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget), 0.1, 2.0);
   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c
index 04b4ff5403..4c6bc7cde3 100644
--- a/app/tools/gimppaintoptions-gui.c
+++ b/app/tools/gimppaintoptions-gui.c
@@ -126,10 +126,9 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
     }
 
   /*  the opacity scale  */
-  scale = gimp_prop_spin_scale_new (config, "opacity", NULL,
-                                    0.01, 0.1, 0);
+  scale = gimp_prop_spin_scale_new (config, "opacity", 0.01, 0.1, 0);
   gimp_spin_scale_set_constrain_drag (GIMP_SPIN_SCALE (scale), TRUE);
-  gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
+  gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
   /*  temp debug foo, disabled in stable  */
@@ -327,7 +326,7 @@ dynamics_options_gui (GimpPaintOptions *paint_options,
   gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, FALSE, FALSE, 0);
   gtk_widget_show (hbox);
 
-  scale = gimp_prop_spin_scale_new (config, "fade-length", NULL,
+  scale = gimp_prop_spin_scale_new (config, "fade-length",
                                     1.0, 50.0, 0);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0);
   gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
@@ -392,7 +391,7 @@ jitter_options_gui (GimpPaintOptions *paint_options,
   GtkWidget *frame;
   GtkWidget *scale;
 
-  scale = gimp_prop_spin_scale_new (config, "jitter-amount", NULL,
+  scale = gimp_prop_spin_scale_new (config, "jitter-amount",
                                     0.01, 1.0, 2);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 0.0, 5.0);
 
@@ -416,11 +415,11 @@ smoothing_options_gui (GimpPaintOptions *paint_options,
   frame = gimp_prop_expanding_frame_new (config, "use-smoothing", NULL,
                                          vbox, NULL);
 
-  scale = gimp_prop_spin_scale_new (config, "smoothing-quality", NULL,
+  scale = gimp_prop_spin_scale_new (config, "smoothing-quality",
                                     1, 10, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, "smoothing-factor", NULL,
+  scale = gimp_prop_spin_scale_new (config, "smoothing-factor",
                                     1, 10, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
@@ -507,7 +506,7 @@ gimp_paint_options_gui_scale_with_buttons (GObject      *config,
 
   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 
-  scale = gimp_prop_spin_scale_new (config, prop_name, NULL,
+  scale = gimp_prop_spin_scale_new (config, prop_name,
                                     step_increment, page_increment, digits);
   gimp_spin_scale_set_constrain_drag (GIMP_SPIN_SCALE (scale), TRUE);
 
diff --git a/app/tools/gimppaintselectoptions.c b/app/tools/gimppaintselectoptions.c
index 00d892f99b..a56287dd88 100644
--- a/app/tools/gimppaintselectoptions.c
+++ b/app/tools/gimppaintselectoptions.c
@@ -179,7 +179,7 @@ gimp_paint_select_options_gui (GimpToolOptions *tool_options)
   gtk_widget_show (hbox);
 
   /* stroke width */
-  scale = gimp_prop_spin_scale_new (config, "stroke-width", NULL,
+  scale = gimp_prop_spin_scale_new (config, "stroke-width",
                                     1.0, 10.0, 2);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0);
   gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), 1.7);
diff --git a/app/tools/gimprectangleoptions.c b/app/tools/gimprectangleoptions.c
index 29b9704584..42a674a5bf 100644
--- a/app/tools/gimprectangleoptions.c
+++ b/app/tools/gimprectangleoptions.c
@@ -1019,9 +1019,9 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
   {
     GtkWidget *scale;
 
-    scale = gimp_prop_spin_scale_new (config, "highlight-opacity", NULL,
+    scale = gimp_prop_spin_scale_new (config, "highlight-opacity",
                                       0.01, 0.1, 0);
-    gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
+    gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
 
     frame = gimp_prop_expanding_frame_new (config, "highlight", NULL,
                                            scale, NULL);
diff --git a/app/tools/gimprectangleselectoptions.c b/app/tools/gimprectangleselectoptions.c
index 1a9b8636cf..26bc62f3e6 100644
--- a/app/tools/gimprectangleselectoptions.c
+++ b/app/tools/gimprectangleselectoptions.c
@@ -172,7 +172,7 @@ gimp_rectangle_select_options_gui (GimpToolOptions *tool_options)
       GtkWidget *scale;
       GtkWidget *toggle;
 
-      scale = gimp_prop_spin_scale_new (config, "corner-radius", NULL,
+      scale = gimp_prop_spin_scale_new (config, "corner-radius",
                                         1.0, 10.0, 1);
       gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale),
                                         0.0, 1000.0);
diff --git a/app/tools/gimpregionselectoptions.c b/app/tools/gimpregionselectoptions.c
index 9809b22e11..c37ef6d3cc 100644
--- a/app/tools/gimpregionselectoptions.c
+++ b/app/tools/gimpregionselectoptions.c
@@ -268,7 +268,7 @@ gimp_region_select_options_gui (GimpToolOptions *tool_options)
     }
 
   /*  the threshold scale  */
-  scale = gimp_prop_spin_scale_new (config, "threshold", NULL,
+  scale = gimp_prop_spin_scale_new (config, "threshold",
                                     1.0, 16.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimpseamlesscloneoptions.c b/app/tools/gimpseamlesscloneoptions.c
index 269c4cdea1..569dfc8414 100644
--- a/app/tools/gimpseamlesscloneoptions.c
+++ b/app/tools/gimpseamlesscloneoptions.c
@@ -128,7 +128,7 @@ gimp_seamless_clone_options_gui (GimpToolOptions *tool_options)
   GtkWidget *vbox   = gimp_tool_options_gui (tool_options);
   GtkWidget *scale;
 
-  scale = gimp_prop_spin_scale_new (config, "max-refine-scale", NULL,
+  scale = gimp_prop_spin_scale_new (config, "max-refine-scale",
                                     1.0, 10.0, 0);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 0.0, 50.0);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
diff --git a/app/tools/gimpselectionoptions.c b/app/tools/gimpselectionoptions.c
index d2b06c4ce1..5d8e279c6f 100644
--- a/app/tools/gimpselectionoptions.c
+++ b/app/tools/gimpselectionoptions.c
@@ -278,7 +278,7 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
     GtkWidget *scale;
 
     /*  the feather radius scale  */
-    scale = gimp_prop_spin_scale_new (config, "feather-radius", NULL,
+    scale = gimp_prop_spin_scale_new (config, "feather-radius",
                                       1.0, 10.0, 1);
 
     frame = gimp_prop_expanding_frame_new (config, "feather", NULL,
diff --git a/app/tools/gimpsmudgetool.c b/app/tools/gimpsmudgetool.c
index 46b6c48f55..c361966519 100644
--- a/app/tools/gimpsmudgetool.c
+++ b/app/tools/gimpsmudgetool.c
@@ -99,11 +99,11 @@ gimp_smudge_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
   /*  the rate scale  */
-  scale = gimp_prop_spin_scale_new (config, "rate", NULL,
+  scale = gimp_prop_spin_scale_new (config, "rate",
                                     1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, "flow", NULL,
+  scale = gimp_prop_spin_scale_new (config, "flow",
                                     1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
diff --git a/app/tools/gimptransformgridoptions.c b/app/tools/gimptransformgridoptions.c
index da70bac25f..377088aa42 100644
--- a/app/tools/gimptransformgridoptions.c
+++ b/app/tools/gimptransformgridoptions.c
@@ -443,9 +443,9 @@ gimp_transform_grid_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
   gtk_widget_show (frame);
 
-  scale = gimp_prop_spin_scale_new (config, "preview-opacity", NULL,
+  scale = gimp_prop_spin_scale_new (config, "preview-opacity",
                                     0.01, 0.1, 0);
-  gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
+  gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
   gtk_widget_show (scale);
 
@@ -470,7 +470,7 @@ gimp_transform_grid_options_gui (GimpToolOptions *tool_options)
   gtk_frame_set_label_widget (GTK_FRAME (frame), combo);
 
   /*  the grid density scale  */
-  scale = gimp_prop_spin_scale_new (config, "grid-size", NULL,
+  scale = gimp_prop_spin_scale_new (config, "grid-size",
                                     1.8, 8.0, 0);
   gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), NULL);
   gtk_container_add (GTK_CONTAINER (frame), scale);
diff --git a/app/tools/gimpwarpoptions.c b/app/tools/gimpwarpoptions.c
index 74786dd0ca..4279c9eb36 100644
--- a/app/tools/gimpwarpoptions.c
+++ b/app/tools/gimpwarpoptions.c
@@ -309,22 +309,22 @@ gimp_warp_options_gui (GimpToolOptions *tool_options)
 
   options->behavior_combo = combo;
 
-  scale = gimp_prop_spin_scale_new (config, "effect-size", NULL,
+  scale = gimp_prop_spin_scale_new (config, "effect-size",
                                     0.01, 1.0, 2);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, "effect-hardness", NULL,
+  scale = gimp_prop_spin_scale_new (config, "effect-hardness",
                                     1, 10, 1);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 0.0, 100.0);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, "effect-strength", NULL,
+  scale = gimp_prop_spin_scale_new (config, "effect-strength",
                                     1, 10, 1);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 100.0);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, "stroke-spacing", NULL,
+  scale = gimp_prop_spin_scale_new (config, "stroke-spacing",
                                     1, 10, 1);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 100.0);
   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
@@ -360,7 +360,7 @@ gimp_warp_options_gui (GimpToolOptions *tool_options)
   button = gimp_prop_check_button_new (config, "stroke-during-motion", NULL);
   gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
 
-  scale = gimp_prop_spin_scale_new (config, "stroke-periodically-rate", NULL,
+  scale = gimp_prop_spin_scale_new (config, "stroke-periodically-rate",
                                     1, 10, 1);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 0.0, 100.0);
 
@@ -377,7 +377,7 @@ gimp_warp_options_gui (GimpToolOptions *tool_options)
   gtk_container_add (GTK_CONTAINER (frame), vbox2);
   gtk_widget_show (vbox2);
 
-  scale = gimp_prop_spin_scale_new (config, "n-animation-frames", NULL,
+  scale = gimp_prop_spin_scale_new (config, "n-animation-frames",
                                     1.0, 10.0, 0);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 3.0, 100.0);
   gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c
index dbd58bece8..976af2d54e 100644
--- a/app/widgets/gimppropwidgets.c
+++ b/app/widgets/gimppropwidgets.c
@@ -450,336 +450,6 @@ gimp_prop_color_button_notify (GObject    *config,
 }
 
 
-/*****************/
-/*  adjustments  */
-/*****************/
-
-static void   gimp_prop_adjustment_callback (GtkAdjustment *adjustment,
-                                             GObject       *config);
-static void   gimp_prop_adjustment_notify   (GObject       *config,
-                                             GParamSpec    *param_spec,
-                                             GtkAdjustment *adjustment);
-
-/**
- * gimp_prop_spin_scale_new:
- * @config:        #GimpConfig object to which property is attached.
- * @property_name: Name of gdouble property
- * @label:         Label of the created #GimpSpinScale.
- * @step_increment:
- * @page_increment:
- * @digits:
- *
- * Creates a #GimpSpinScale to set and display the value of a
- * gdouble property in a very space-efficient way.
- * If @label is %NULL, the @property_name's nick will be used as label
- * of the returned widget.
- * The property's lower and upper values will be used as min/max of the
- * #GimpSpinScale.
- *
- * Returns:  A new #GimpSpinScale widget.
- *
- * Since GIMP 2.8
- */
-GtkWidget *
-gimp_prop_spin_scale_new (GObject     *config,
-                          const gchar *property_name,
-                          const gchar *label,
-                          gdouble      step_increment,
-                          gdouble      page_increment,
-                          gint         digits)
-{
-  GParamSpec    *param_spec;
-  GtkAdjustment *adjustment;
-  GtkWidget     *scale;
-  gdouble        value;
-  gdouble        lower;
-  gdouble        upper;
-
-  param_spec = find_param_spec (config, property_name, G_STRFUNC);
-  if (! param_spec)
-    return NULL;
-
-  /* The generic min and max for the property. */
-  if (! _gimp_prop_widgets_get_numeric_values (config, param_spec,
-                                               &value, &lower, &upper,
-                                               G_STRFUNC))
-    return NULL;
-
-  /* Get label. */
-  if (! label)
-    label = g_param_spec_get_nick (param_spec);
-
-  /* Also usable on int properties. */
-  if (! G_IS_PARAM_SPEC_DOUBLE (param_spec))
-    digits = 0;
-
-  adjustment = gtk_adjustment_new (value, lower, upper,
-                                   step_increment, page_increment, 0.0);
-
-  scale = gimp_spin_scale_new (adjustment, label, digits);
-
-  set_param_spec (G_OBJECT (adjustment), scale, param_spec);
-
-  if (GEGL_IS_PARAM_SPEC_DOUBLE (param_spec))
-    {
-      GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (param_spec);
-
-      gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale),
-                                        gspec->ui_minimum, gspec->ui_maximum);
-      gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), gspec->ui_gamma);
-    }
-  else if (GEGL_IS_PARAM_SPEC_INT (param_spec))
-    {
-      GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (param_spec);
-
-      gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale),
-                                        gspec->ui_minimum, gspec->ui_maximum);
-      gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), gspec->ui_gamma);
-    }
-
-  g_signal_connect (adjustment, "value-changed",
-                    G_CALLBACK (gimp_prop_adjustment_callback),
-                    config);
-
-  connect_notify (config, property_name,
-                  G_CALLBACK (gimp_prop_adjustment_notify),
-                  adjustment);
-
-  gtk_widget_show (scale);
-
-  return scale;
-}
-
-void
-gimp_prop_widget_set_factor (GtkWidget *widget,
-                             gdouble    factor,
-                             gdouble    step_increment,
-                             gdouble    page_increment,
-                             gint       digits)
-{
-  GtkAdjustment *adjustment;
-  gdouble       *factor_store;
-  gdouble        old_factor = 1.0;
-  gdouble        f;
-
-  g_return_if_fail (GTK_IS_SPIN_BUTTON (widget));
-  g_return_if_fail (factor != 0.0);
-  g_return_if_fail (digits >= 0);
-
-  adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
-
-  g_return_if_fail (get_param_spec (G_OBJECT (adjustment)) != NULL);
-
-  factor_store = g_object_get_data (G_OBJECT (adjustment),
-                                    "gimp-prop-adjustment-factor");
-  if (factor_store)
-    {
-      old_factor = *factor_store;
-    }
-  else
-    {
-      factor_store = g_new (gdouble, 1);
-      g_object_set_data_full (G_OBJECT (adjustment),
-                              "gimp-prop-adjustment-factor",
-                              factor_store, (GDestroyNotify) g_free);
-    }
-
-  *factor_store = factor;
-
-  f = factor / old_factor;
-
-  if (step_increment <= 0)
-    step_increment = f * gtk_adjustment_get_step_increment (adjustment);
-
-  if (page_increment <= 0)
-    page_increment = f * gtk_adjustment_get_page_increment (adjustment);
-
-  gtk_adjustment_configure (adjustment,
-                            f * gtk_adjustment_get_value (adjustment),
-                            f * gtk_adjustment_get_lower (adjustment),
-                            f * gtk_adjustment_get_upper (adjustment),
-                            step_increment,
-                            page_increment,
-                            f * gtk_adjustment_get_page_size (adjustment));
-
-  gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), digits);
-}
-
-static void
-gimp_prop_adjustment_callback (GtkAdjustment *adjustment,
-                               GObject       *config)
-{
-  GParamSpec *param_spec;
-  gdouble     value;
-  gdouble    *factor;
-
-  param_spec = get_param_spec (G_OBJECT (adjustment));
-  if (! param_spec)
-    return;
-
-  value = gtk_adjustment_get_value (adjustment);
-
-  factor = g_object_get_data (G_OBJECT (adjustment),
-                              "gimp-prop-adjustment-factor");
-  if (factor)
-    value /= *factor;
-
-  if (G_IS_PARAM_SPEC_INT (param_spec))
-    {
-      gint v;
-
-      g_object_get (config, param_spec->name, &v, NULL);
-
-      if (v != (gint) value)
-        g_object_set (config, param_spec->name, (gint) value, NULL);
-    }
-  else if (G_IS_PARAM_SPEC_UINT (param_spec))
-    {
-      guint v;
-
-      g_object_get (config, param_spec->name, &v, NULL);
-
-      if (v != (guint) value)
-        g_object_set (config, param_spec->name, (guint) value, NULL);
-    }
-  else if (G_IS_PARAM_SPEC_LONG (param_spec))
-    {
-      glong v;
-
-      g_object_get (config, param_spec->name, &v, NULL);
-
-      if (v != (glong) value)
-        g_object_set (config, param_spec->name, (glong) value, NULL);
-    }
-  else if (G_IS_PARAM_SPEC_ULONG (param_spec))
-    {
-      gulong v;
-
-      g_object_get (config, param_spec->name, &v, NULL);
-
-      if (v != (gulong) value)
-        g_object_set (config, param_spec->name, (gulong) value, NULL);
-    }
-  else if (G_IS_PARAM_SPEC_INT64 (param_spec))
-    {
-      gint64 v;
-
-      g_object_get (config, param_spec->name, &v, NULL);
-
-      if (v != (gint64) value)
-        g_object_set (config, param_spec->name, (gint64) value, NULL);
-    }
-  else if (G_IS_PARAM_SPEC_UINT64 (param_spec))
-    {
-      guint64 v;
-
-      g_object_get (config, param_spec->name, &v, NULL);
-
-      if (v != (guint64) value)
-        g_object_set (config, param_spec->name, (guint64) value, NULL);
-    }
-  else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
-    {
-      gdouble v;
-
-      g_object_get (config, param_spec->name, &v, NULL);
-
-      if (v != value)
-        g_object_set (config, param_spec->name, value, NULL);
-    }
-}
-
-static void
-gimp_prop_adjustment_notify (GObject       *config,
-                             GParamSpec    *param_spec,
-                             GtkAdjustment *adjustment)
-{
-  gdouble  value;
-  gdouble *factor;
-
-  if (G_IS_PARAM_SPEC_INT (param_spec))
-    {
-      gint int_value;
-
-      g_object_get (config, param_spec->name, &int_value, NULL);
-
-      value = int_value;
-    }
-  else if (G_IS_PARAM_SPEC_UINT (param_spec))
-    {
-      guint uint_value;
-
-      g_object_get (config, param_spec->name, &uint_value, NULL);
-
-      value = uint_value;
-    }
-  else if (G_IS_PARAM_SPEC_LONG (param_spec))
-    {
-      glong long_value;
-
-      g_object_get (config, param_spec->name, &long_value, NULL);
-
-      value = long_value;
-    }
-  else if (G_IS_PARAM_SPEC_ULONG (param_spec))
-    {
-      gulong ulong_value;
-
-      g_object_get (config, param_spec->name, &ulong_value, NULL);
-
-      value = ulong_value;
-    }
-  else if (G_IS_PARAM_SPEC_INT64 (param_spec))
-    {
-      gint64 int64_value;
-
-      g_object_get (config, param_spec->name, &int64_value, NULL);
-
-      value = int64_value;
-    }
-  else if (G_IS_PARAM_SPEC_UINT64 (param_spec))
-    {
-      guint64 uint64_value;
-
-      g_object_get (config, param_spec->name, &uint64_value, NULL);
-
-#if defined _MSC_VER && (_MSC_VER < 1300)
-      value = (gint64) uint64_value;
-#else
-      value = uint64_value;
-#endif
-    }
-  else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
-    {
-      g_object_get (config, param_spec->name, &value, NULL);
-    }
-  else
-    {
-      g_warning ("%s: unhandled param spec of type %s",
-                 G_STRFUNC, G_PARAM_SPEC_TYPE_NAME (param_spec));
-      return;
-    }
-
-  factor = g_object_get_data (G_OBJECT (adjustment),
-                              "gimp-prop-adjustment-factor");
-  if (factor)
-    value *= *factor;
-
-  if (gtk_adjustment_get_value (adjustment) != value)
-    {
-      g_signal_handlers_block_by_func (adjustment,
-                                       gimp_prop_adjustment_callback,
-                                       config);
-
-      gtk_adjustment_set_value (adjustment, value);
-
-      g_signal_handlers_unblock_by_func (adjustment,
-                                         gimp_prop_adjustment_callback,
-                                         config);
-    }
-}
-
-
 /************/
 /*  angles  */
 /************/
diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h
index 7b89aa0830..20c8cc6e3a 100644
--- a/app/widgets/gimppropwidgets.h
+++ b/app/widgets/gimppropwidgets.h
@@ -57,19 +57,6 @@ GtkWidget * gimp_prop_color_button_new      (GObject       *config,
 
 /*  GParamDouble  */
 
-GtkWidget * gimp_prop_spin_scale_new        (GObject       *config,
-                                             const gchar   *property_name,
-                                             const gchar   *label,
-                                             gdouble        step_increment,
-                                             gdouble        page_increment,
-                                             gint           digits);
-
-void        gimp_prop_widget_set_factor     (GtkWidget     *widget,
-                                             gdouble        factor,
-                                             gdouble        step_increment,
-                                             gdouble        page_increment,
-                                             gint           digits);
-
 GtkWidget * gimp_prop_angle_dial_new        (GObject       *config,
                                              const gchar   *property_name);
 GtkWidget * gimp_prop_angle_range_dial_new  (GObject       *config,
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index 473c48170b..42afa20250 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -1355,6 +1355,9 @@ static void   gimp_prop_adjustment_notify   (GObject       *config,
  * Creates a spin button to set and display the value of the
  * specified double property.
  *
+ * If you wish to change the widget's range relatively to the
+ * @property_name's range, use gimp_prop_widget_set_factor().
+ *
  * Returns: (transfer full): A new #libgimpwidgets-gimpspinbutton.
  *
  * Since: 2.4
@@ -1369,6 +1372,7 @@ gimp_prop_spin_button_new (GObject     *config,
   GParamSpec    *param_spec;
   GtkWidget     *spinbutton;
   GtkAdjustment *adjustment;
+  GBinding      *binding;
   gdouble        value;
   gdouble        lower;
   gdouble        upper;
@@ -1392,13 +1396,12 @@ gimp_prop_spin_button_new (GObject     *config,
 
   set_param_spec (G_OBJECT (adjustment), spinbutton, param_spec);
 
-  g_signal_connect (adjustment, "value-changed",
-                    G_CALLBACK (gimp_prop_adjustment_callback),
-                    config);
-
-  connect_notify (config, property_name,
-                  G_CALLBACK (gimp_prop_adjustment_notify),
-                  adjustment);
+  binding = g_object_bind_property (config,     property_name,
+                                    spinbutton, "value",
+                                    G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+  g_object_set_data (G_OBJECT (adjustment),
+                     "gimp-prop-adjustment-binding",
+                     binding);
 
   gtk_widget_show (spinbutton);
 
@@ -1450,6 +1453,215 @@ gimp_prop_label_spin_new (GObject     *config,
   return widget;
 }
 
+/**
+ * gimp_prop_spin_scale_new:
+ * @config:         Object to which property is attached.
+ * @property_name:  Name of double or int property controlled by the
+ *                  spin button.
+ * @step_increment: Step size.
+ * @page_increment: Page size.
+ * @digits:         Number of digits after decimal point to display.
+ *                  This is only used for double properties. In case of
+ *                  int properties, `digits = 0` is implied.
+ *
+ * Creates a spin scale to set and display the value of the specified
+ * int or double property.
+ *
+ * By default, the @property_name's nick will be used as label of the
+ * returned widget. Use gimp_spin_scale_set_label() to change this.
+ *
+ * If you wish to change the widget's range relatively to the
+ * @property_name's range, use gimp_prop_widget_set_factor().
+ *
+ * Returns: (transfer full): A new #libgimpwidgets-gimpspinbutton.
+ *
+ * Since: 3.0
+ */
+GtkWidget *
+gimp_prop_spin_scale_new (GObject     *config,
+                          const gchar *property_name,
+                          gdouble      step_increment,
+                          gdouble      page_increment,
+                          gint         digits)
+{
+  GParamSpec    *param_spec;
+  GtkWidget     *spinscale;
+  GtkAdjustment *adjustment;
+  const gchar   *label;
+  const gchar   *tooltip;
+  GBinding      *binding;
+  gdouble        value;
+  gdouble        lower;
+  gdouble        upper;
+
+  param_spec = find_param_spec (config, property_name, G_STRFUNC);
+  if (! param_spec)
+    return NULL;
+
+  if (! get_numeric_values (config,
+                            param_spec, &value, &lower, &upper, G_STRFUNC))
+    return NULL;
+
+  if (! G_IS_PARAM_SPEC_DOUBLE (param_spec))
+    digits = 0;
+
+  adjustment = gtk_adjustment_new (value, lower, upper,
+                                   step_increment, page_increment, 0);
+  label = g_param_spec_get_nick (param_spec);
+
+  spinscale = gimp_spin_scale_new (adjustment, label, digits);
+
+  set_param_spec (G_OBJECT (adjustment), spinscale, param_spec);
+
+  tooltip = g_param_spec_get_blurb (param_spec);
+  gimp_help_set_help_data (spinscale, tooltip, NULL);
+
+  binding = g_object_bind_property (config, property_name,
+                                    spinscale, "value",
+                                    G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+  g_object_set_data (G_OBJECT (adjustment),
+                     "gimp-prop-adjustment-binding",
+                     binding);
+
+  gtk_widget_show (spinscale);
+
+  return spinscale;
+}
+
+/**
+ * gimp_prop_widget_set_factor:
+ * @widget:         Property widget.
+ * @factor:         Multiplier to convert the @widget's range and
+ *                  map appropriately to the property's range it is
+ *                  associated to.
+ * @step_increment: Step size.
+ * @page_increment: Page size.
+ * @digits:         Number of digits after decimal point to display.
+ *
+ * Change the display factor of the property @widget relatively to the
+ * property it was bound to. Currently the only types of widget accepted
+ * as input are those created by gimp_prop_spin_scale_new() and
+ * gimp_prop_spin_button_new().
+ *
+ * If @factor is 1.0, then the config property and the widget display
+ * map exactly.
+ *
+ * If @factor is not 1.0, the widget's range will be computed based of
+ * @property_name's range multiplied by @factor. A typical usage would
+ * be to display a [0.0, 1.0] range as [0.0, 100.0] by setting 100.0 as
+ * @factor. This function can only be used with double properties.
+ *
+ * The @step_increment and @page_increment can be set to new increments
+ * you want to get for this new range. If you set them to 0.0 or
+ * negative values, new increments will be computed based on the new
+ * @factor and previous factor.
+ *
+ * Since: 3.0
+ */
+void
+gimp_prop_widget_set_factor (GtkWidget *widget,
+                             gdouble    factor,
+                             gdouble    step_increment,
+                             gdouble    page_increment,
+                             gint       digits)
+{
+  GtkAdjustment *adjustment;
+  GParamSpec    *param_spec;
+  GBinding      *binding;
+  GObject       *config;
+  gchar         *property_name;
+  gdouble       *factor_store;
+  gdouble        old_factor = 1.0;
+  gdouble        f;
+
+  g_return_if_fail (GTK_IS_SPIN_BUTTON (widget));
+  g_return_if_fail (factor != 0.0);
+  g_return_if_fail (digits >= 0);
+
+  adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
+
+  param_spec = get_param_spec (G_OBJECT (adjustment));
+  g_return_if_fail (param_spec != NULL && G_IS_PARAM_SPEC_DOUBLE (param_spec));
+
+  /* Get the old factor and recompute new values. */
+  factor_store = g_object_get_data (G_OBJECT (adjustment),
+                                    "gimp-prop-adjustment-factor");
+  if (factor_store)
+    {
+      old_factor = *factor_store;
+    }
+  else
+    {
+      factor_store = g_new (gdouble, 1);
+      g_object_set_data_full (G_OBJECT (adjustment),
+                              "gimp-prop-adjustment-factor",
+                              factor_store, (GDestroyNotify) g_free);
+    }
+
+  *factor_store = factor;
+
+  f = factor / old_factor;
+
+  if (step_increment <= 0)
+    step_increment = f * gtk_adjustment_get_step_increment (adjustment);
+
+  if (page_increment <= 0)
+    page_increment = f * gtk_adjustment_get_page_increment (adjustment);
+
+  /* Remove the old binding. */
+  binding = g_object_get_data (G_OBJECT (adjustment),
+                               "gimp-prop-adjustment-binding");
+  g_return_if_fail (binding != NULL);
+  config = g_binding_dup_source (binding);
+
+  /* This binding should not have outlived the config object. */
+  g_return_if_fail (config != NULL);
+
+  property_name = g_strdup (g_binding_get_source_property (binding));
+  g_binding_unbind (binding);
+
+  /* Reconfigure the scale object. */
+  gtk_adjustment_configure (adjustment,
+                            f * gtk_adjustment_get_value (adjustment),
+                            f * gtk_adjustment_get_lower (adjustment),
+                            f * gtk_adjustment_get_upper (adjustment),
+                            step_increment,
+                            page_increment,
+                            f * gtk_adjustment_get_page_size (adjustment));
+
+  gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), digits);
+
+  /* Finally create a new binding. */
+  if (factor != 1.0)
+    {
+      gdouble *user_data;
+
+      user_data = g_new0 (gdouble, 1);
+      *user_data = factor;
+      /* With @factor == 1.0, this is equivalent to a
+       * g_object_bind_property().
+       */
+      binding = g_object_bind_property_full (config, property_name,
+                                             widget, "value",
+                                             G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
+                                             gimp_prop_widget_double_to_factor,
+                                             gimp_prop_widget_double_from_factor,
+                                             user_data, (GDestroyNotify) g_free);
+    }
+  else
+    {
+      binding = g_object_bind_property (config, property_name,
+                                        widget, "value",
+                                        G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+    }
+  g_object_set_data (G_OBJECT (adjustment),
+                     "gimp-prop-adjustment-binding",
+                     binding);
+  g_object_unref (config);
+  g_free (property_name);
+}
+
 /**
  * gimp_prop_hscale_new:
  * @config:         Object to which property is attached.
diff --git a/libgimpwidgets/gimppropwidgets.h b/libgimpwidgets/gimppropwidgets.h
index be214473e6..f84f200b89 100644
--- a/libgimpwidgets/gimppropwidgets.h
+++ b/libgimpwidgets/gimppropwidgets.h
@@ -118,6 +118,17 @@ GtkWidget     * gimp_prop_label_spin_new          (GObject      *config,
                                                    const gchar  *property_name,
                                                    gint          digits);
 
+GtkWidget     * gimp_prop_spin_scale_new          (GObject      *config,
+                                                   const gchar  *property_name,
+                                                   gdouble       step_increment,
+                                                   gdouble       page_increment,
+                                                   gint          digits);
+
+void            gimp_prop_widget_set_factor       (GtkWidget    *widget,
+                                                   gdouble       factor,
+                                                   gdouble       step_increment,
+                                                   gdouble       page_increment,
+                                                   gint          digits);
 
 GtkWidget     * gimp_prop_hscale_new              (GObject      *config,
                                                    const gchar  *property_name,
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index ebbb1cc4c0..6e85834228 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -374,10 +374,12 @@ EXPORTS
        gimp_prop_scale_entry_new
        gimp_prop_size_entry_new
        gimp_prop_spin_button_new
+       gimp_prop_spin_scale_new
        gimp_prop_string_combo_box_new
        gimp_prop_switch_new
        gimp_prop_text_buffer_new
        gimp_prop_unit_combo_box_new
+       gimp_prop_widget_set_factor
        gimp_query_boolean_box
        gimp_query_double_box
        gimp_query_int_box


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]