[gimp] app: manage the transform tools' grid properties in GimpTransformTool



commit 0411801765e05699e100601c6231e1c1d688c329
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 19 23:06:39 2017 +0200

    app: manage the transform tools' grid properties in GimpTransformTool
    
    Simply use g_object_bind_property() to connect the grid properties of
    GimpTransformOoptions and GimpToolTransformGrid and remove all other
    grid property setting code.

 app/display/gimptooltransformgrid.c  |    6 +-----
 app/display/gimptooltransformgrid.h  |    4 +---
 app/tools/gimphandletransformtool.c  |   10 +++-------
 app/tools/gimpperspectiveclonetool.c |    3 +--
 app/tools/gimpperspectivetool.c      |    4 +---
 app/tools/gimprotatetool.c           |    2 --
 app/tools/gimpscaletool.c            |    4 +---
 app/tools/gimpsheartool.c            |    2 --
 app/tools/gimptransformtool.c        |   30 ++++++++++++++----------------
 app/tools/gimpunifiedtransformtool.c |    4 +---
 10 files changed, 23 insertions(+), 46 deletions(-)
---
diff --git a/app/display/gimptooltransformgrid.c b/app/display/gimptooltransformgrid.c
index c6de7c4..5c7c201 100644
--- a/app/display/gimptooltransformgrid.c
+++ b/app/display/gimptooltransformgrid.c
@@ -2225,9 +2225,7 @@ gimp_tool_transform_grid_new (GimpDisplayShell  *shell,
                               gdouble            x1,
                               gdouble            y1,
                               gdouble            x2,
-                              gdouble            y2,
-                              GimpGuidesType     guide_type,
-                              gint               n_guides)
+                              gdouble            y2)
 {
   g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
 
@@ -2238,7 +2236,5 @@ gimp_tool_transform_grid_new (GimpDisplayShell  *shell,
                        "y1",         y1,
                        "x2",         x2,
                        "y2",         y2,
-                       "guide-type", guide_type,
-                       "n-guides",   n_guides,
                        NULL);
 }
diff --git a/app/display/gimptooltransformgrid.h b/app/display/gimptooltransformgrid.h
index 81d7f39..32a5563 100644
--- a/app/display/gimptooltransformgrid.h
+++ b/app/display/gimptooltransformgrid.h
@@ -84,9 +84,7 @@ GimpToolWidget * gimp_tool_transform_grid_new      (GimpDisplayShell  *shell,
                                                     gdouble            x1,
                                                     gdouble            y1,
                                                     gdouble            x2,
-                                                    gdouble            y2,
-                                                    GimpGuidesType     guide_type,
-                                                    gint               n_guides);
+                                                    gdouble            y2);
 
 
 #endif /* __GIMP_TOOL_TRANSFORM_GRID_H__ */
diff --git a/app/tools/gimphandletransformtool.c b/app/tools/gimphandletransformtool.c
index 2a2cc4a..74210b9 100644
--- a/app/tools/gimphandletransformtool.c
+++ b/app/tools/gimphandletransformtool.c
@@ -306,13 +306,11 @@ static GimpToolWidget *
 gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool)
 {
   GimpTool                   *tool  = GIMP_TOOL (tr_tool);
-  GimpTransformOptions       *options;
-  GimpHandleTransformOptions *ht_options;
+  GimpHandleTransformOptions *options;
   GimpDisplayShell           *shell = gimp_display_get_shell (tool->display);
   GimpToolWidget             *widget;
 
-  options    = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
-  ht_options = GIMP_HANDLE_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
+  options = GIMP_HANDLE_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
 
   widget = gimp_tool_handle_grid_new (shell,
                                       tr_tool->x1,
@@ -341,9 +339,7 @@ gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool)
                 NULL);
 
   g_object_set (widget,
-                "guide-type",  options->grid_type,
-                "n-guides",    options->grid_size,
-                "handle-mode", ht_options->handle_mode,
+                "handle-mode", options->handle_mode,
                 NULL);
 
   g_signal_connect (widget, "changed",
diff --git a/app/tools/gimpperspectiveclonetool.c b/app/tools/gimpperspectiveclonetool.c
index 19e0d2f..39886e4 100644
--- a/app/tools/gimpperspectiveclonetool.c
+++ b/app/tools/gimpperspectiveclonetool.c
@@ -221,8 +221,7 @@ gimp_perspective_clone_tool_initialize (GimpTool     *tool,
                                       clone_tool->x1,
                                       clone_tool->y1,
                                       clone_tool->x2,
-                                      clone_tool->y2,
-                                      GIMP_GUIDES_NONE, 1);
+                                      clone_tool->y2);
 
       g_object_set (clone_tool->widget,
                     "pivot-x",                 (clone_tool->x1 + clone_tool->x2) / 2.0,
diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c
index dc1fc00..6cf7b6c 100644
--- a/app/tools/gimpperspectivetool.c
+++ b/app/tools/gimpperspectivetool.c
@@ -195,9 +195,7 @@ gimp_perspective_tool_get_widget (GimpTransformTool *tr_tool)
                                          tr_tool->x1,
                                          tr_tool->y1,
                                          tr_tool->x2,
-                                         tr_tool->y2,
-                                         options->grid_type,
-                                         options->grid_size);
+                                         tr_tool->y2);
 
   g_object_set (widget,
                 "inside-function",         GIMP_TRANSFORM_FUNCTION_PERSPECTIVE,
diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c
index 0d6eb8a..a17eab8 100644
--- a/app/tools/gimprotatetool.c
+++ b/app/tools/gimprotatetool.c
@@ -311,8 +311,6 @@ gimp_rotate_tool_get_widget (GimpTransformTool *tr_tool)
                                       tr_tool->trans_info[ANGLE]);
 
   g_object_set (widget,
-                "guide-type",              options->grid_type,
-                "n-guides",                options->grid_size,
                 "inside-function",         GIMP_TRANSFORM_FUNCTION_ROTATE,
                 "outside-function",        GIMP_TRANSFORM_FUNCTION_ROTATE,
                 "use-pivot-handle",        TRUE,
diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c
index 34415fc..e922851 100644
--- a/app/tools/gimpscaletool.c
+++ b/app/tools/gimpscaletool.c
@@ -203,9 +203,7 @@ gimp_scale_tool_get_widget (GimpTransformTool *tr_tool)
                                          tr_tool->x1,
                                          tr_tool->y1,
                                          tr_tool->x2,
-                                         tr_tool->y2,
-                                         options->grid_type,
-                                         options->grid_size);
+                                         tr_tool->y2);
 
   g_object_set (widget,
                 "inside-function",         GIMP_TRANSFORM_FUNCTION_SCALE,
diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c
index 6737553..134aed4 100644
--- a/app/tools/gimpsheartool.c
+++ b/app/tools/gimpsheartool.c
@@ -189,8 +189,6 @@ gimp_shear_tool_get_widget (GimpTransformTool *tr_tool)
                                      tr_tool->trans_info[SHEAR_Y]);
 
   g_object_set (widget,
-                "guide-type",              options->grid_type,
-                "n-guides",                options->grid_size,
                 "inside-function",         GIMP_TRANSFORM_FUNCTION_SHEAR,
                 "outside-function",        GIMP_TRANSFORM_FUNCTION_SHEAR,
                 "constrain-move",          options->constrain_move,
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 8dc7d24..6d95237 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -261,10 +261,11 @@ gimp_transform_tool_initialize (GimpTool     *tool,
                                 GimpDisplay  *display,
                                 GError      **error)
 {
-  GimpTransformTool *tr_tool  = GIMP_TRANSFORM_TOOL (tool);
-  GimpImage         *image    = gimp_display_get_image (display);
-  GimpDrawable      *drawable = gimp_image_get_active_drawable (image);
-  GimpItem          *item;
+  GimpTransformTool    *tr_tool  = GIMP_TRANSFORM_TOOL (tool);
+  GimpTransformOptions *options  = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
+  GimpImage            *image    = gimp_display_get_image (display);
+  GimpDrawable         *drawable = gimp_image_get_active_drawable (image);
+  GimpItem             *item;
 
   if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
     {
@@ -312,6 +313,15 @@ gimp_transform_tool_initialize (GimpTool     *tool,
           tr_tool->widget =
             GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->get_widget (tr_tool);
 
+          g_object_bind_property (G_OBJECT (options),         "grid-type",
+                                  G_OBJECT (tr_tool->widget), "guide-type",
+                                  G_BINDING_SYNC_CREATE |
+                                  G_BINDING_BIDIRECTIONAL);
+          g_object_bind_property (G_OBJECT (options),         "grid-size",
+                                  G_OBJECT (tr_tool->widget), "n-guides",
+                                  G_BINDING_SYNC_CREATE |
+                                  G_BINDING_BIDIRECTIONAL);
+
           g_signal_connect (tr_tool->widget, "changed",
                             G_CALLBACK (gimp_transform_tool_widget_changed),
                             tr_tool);
@@ -757,18 +767,6 @@ gimp_transform_tool_options_notify (GimpTool         *tool,
                       "opacity", tr_options->preview_opacity,
                       NULL);
     }
-  else if (! strcmp (pspec->name, "grid-type"))
-    {
-      g_object_set (tr_tool->widget,
-                    "guide-type", tr_options->grid_type,
-                    NULL);
-    }
-  else if (! strcmp (pspec->name, "grid-size"))
-    {
-      g_object_set (tr_tool->widget,
-                    "n-guides", tr_options->grid_size,
-                    NULL);
-    }
   else if (g_str_has_prefix (pspec->name, "constrain-") ||
            g_str_has_prefix (pspec->name, "frompivot-") ||
            ! strcmp (pspec->name, "fixedpivot") ||
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index a6afe7c..6282b6b 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -195,9 +195,7 @@ gimp_unified_transform_tool_get_widget (GimpTransformTool *tr_tool)
                                          tr_tool->x1,
                                          tr_tool->y1,
                                          tr_tool->x2,
-                                         tr_tool->y2,
-                                         options->grid_type,
-                                         options->grid_size);
+                                         tr_tool->y2);
 
   g_object_set (widget,
                 "pivot-x",                 (tr_tool->x1 + tr_tool->x2) / 2.0,


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