[gimp] app: also manage all contrain and frompivot properties centrally



commit 9f59657fef60e071e61a08b44c74e693956cbeba
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 19 23:29:01 2017 +0200

    app: also manage all contrain and frompivot properties centrally
    
    using g_object_bind_property().

 app/tools/gimpperspectivetool.c      |   17 +++--------------
 app/tools/gimprotatetool.c           |   23 ++++++-----------------
 app/tools/gimpscaletool.c            |   27 ++++++++-------------------
 app/tools/gimpsheartool.c            |   22 ++++++----------------
 app/tools/gimptransformtool.c        |   32 ++++++++++++++++++++++----------
 app/tools/gimpunifiedtransformtool.c |   17 +++--------------
 6 files changed, 48 insertions(+), 90 deletions(-)
---
diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c
index 6cf7b6c..5b7a55d 100644
--- a/app/tools/gimpperspectivetool.c
+++ b/app/tools/gimpperspectivetool.c
@@ -185,10 +185,9 @@ gimp_perspective_tool_prepare (GimpTransformTool  *tr_tool)
 static GimpToolWidget *
 gimp_perspective_tool_get_widget (GimpTransformTool *tr_tool)
 {
-  GimpTool             *tool    = GIMP_TOOL (tr_tool);
-  GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
-  GimpDisplayShell     *shell   = gimp_display_get_shell (tool->display);
-  GimpToolWidget       *widget;
+  GimpTool         *tool  = GIMP_TOOL (tr_tool);
+  GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
+  GimpToolWidget   *widget;
 
   widget = gimp_tool_transform_grid_new (shell,
                                          &tr_tool->transform,
@@ -202,16 +201,6 @@ gimp_perspective_tool_get_widget (GimpTransformTool *tr_tool)
                 "outside-function",        GIMP_TRANSFORM_FUNCTION_PERSPECTIVE,
                 "use-perspective-handles", TRUE,
                 "use-center-handle",       TRUE,
-                "constrain-move",          options->constrain_move,
-                "constrain-scale",         options->constrain_scale,
-                "constrain-rotate",        options->constrain_rotate,
-                "constrain-shear",         options->constrain_shear,
-                "constrain-perspective",   options->constrain_perspective,
-                "frompivot-scale",         options->frompivot_scale,
-                "frompivot-shear",         options->frompivot_shear,
-                "frompivot-perspective",   options->frompivot_perspective,
-                "cornersnap",              options->cornersnap,
-                "fixedpivot",              options->fixedpivot,
                 NULL);
 
   g_signal_connect (widget, "changed",
diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c
index a17eab8..f60d794 100644
--- a/app/tools/gimprotatetool.c
+++ b/app/tools/gimprotatetool.c
@@ -296,10 +296,9 @@ gimp_rotate_tool_prepare (GimpTransformTool *tr_tool)
 static GimpToolWidget *
 gimp_rotate_tool_get_widget (GimpTransformTool *tr_tool)
 {
-  GimpTool             *tool    = GIMP_TOOL (tr_tool);
-  GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
-  GimpDisplayShell     *shell   = gimp_display_get_shell (tool->display);
-  GimpToolWidget       *widget;
+  GimpTool         *tool  = GIMP_TOOL (tr_tool);
+  GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
+  GimpToolWidget   *widget;
 
   widget = gimp_tool_rotate_grid_new (shell,
                                       tr_tool->x1,
@@ -311,19 +310,9 @@ gimp_rotate_tool_get_widget (GimpTransformTool *tr_tool)
                                       tr_tool->trans_info[ANGLE]);
 
   g_object_set (widget,
-                "inside-function",         GIMP_TRANSFORM_FUNCTION_ROTATE,
-                "outside-function",        GIMP_TRANSFORM_FUNCTION_ROTATE,
-                "use-pivot-handle",        TRUE,
-                "constrain-move",          options->constrain_move,
-                "constrain-scale",         options->constrain_scale,
-                "constrain-rotate",        options->constrain_rotate,
-                "constrain-shear",         options->constrain_shear,
-                "constrain-perspective",   options->constrain_perspective,
-                "frompivot-scale",         options->frompivot_scale,
-                "frompivot-shear",         options->frompivot_shear,
-                "frompivot-perspective",   options->frompivot_perspective,
-                "cornersnap",              options->cornersnap,
-                "fixedpivot",              options->fixedpivot,
+                "inside-function",  GIMP_TRANSFORM_FUNCTION_ROTATE,
+                "outside-function", GIMP_TRANSFORM_FUNCTION_ROTATE,
+                "use-pivot-handle", TRUE,
                 NULL);
 
   g_signal_connect (widget, "changed",
diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c
index e922851..34ca377 100644
--- a/app/tools/gimpscaletool.c
+++ b/app/tools/gimpscaletool.c
@@ -193,10 +193,9 @@ gimp_scale_tool_prepare (GimpTransformTool *tr_tool)
 static GimpToolWidget *
 gimp_scale_tool_get_widget (GimpTransformTool *tr_tool)
 {
-  GimpTool             *tool    = GIMP_TOOL (tr_tool);
-  GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
-  GimpDisplayShell     *shell   = gimp_display_get_shell (tool->display);
-  GimpToolWidget       *widget;
+  GimpTool         *tool  = GIMP_TOOL (tr_tool);
+  GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
+  GimpToolWidget   *widget;
 
   widget = gimp_tool_transform_grid_new (shell,
                                          &tr_tool->transform,
@@ -206,21 +205,11 @@ gimp_scale_tool_get_widget (GimpTransformTool *tr_tool)
                                          tr_tool->y2);
 
   g_object_set (widget,
-                "inside-function",         GIMP_TRANSFORM_FUNCTION_SCALE,
-                "outside-function",        GIMP_TRANSFORM_FUNCTION_SCALE,
-                "use-corner-handles",      TRUE,
-                "use-side-handles",        TRUE,
-                "use-center-handle",       TRUE,
-                "constrain-move",          options->constrain_move,
-                "constrain-scale",         options->constrain_scale,
-                "constrain-rotate",        options->constrain_rotate,
-                "constrain-shear",         options->constrain_shear,
-                "constrain-perspective",   options->constrain_perspective,
-                "frompivot-scale",         options->frompivot_scale,
-                "frompivot-shear",         options->frompivot_shear,
-                "frompivot-perspective",   options->frompivot_perspective,
-                "cornersnap",              options->cornersnap,
-                "fixedpivot",              options->fixedpivot,
+                "inside-function",    GIMP_TRANSFORM_FUNCTION_SCALE,
+                "outside-function",   GIMP_TRANSFORM_FUNCTION_SCALE,
+                "use-corner-handles", TRUE,
+                "use-side-handles",   TRUE,
+                "use-center-handle",  TRUE,
                 NULL);
 
   g_signal_connect (widget, "changed",
diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c
index 134aed4..8eccaaa 100644
--- a/app/tools/gimpsheartool.c
+++ b/app/tools/gimpsheartool.c
@@ -174,10 +174,9 @@ gimp_shear_tool_prepare (GimpTransformTool *tr_tool)
 static GimpToolWidget *
 gimp_shear_tool_get_widget (GimpTransformTool *tr_tool)
 {
-  GimpTool             *tool    = GIMP_TOOL (tr_tool);
-  GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
-  GimpDisplayShell     *shell   = gimp_display_get_shell (tool->display);
-  GimpToolWidget       *widget;
+  GimpTool         *tool  = GIMP_TOOL (tr_tool);
+  GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
+  GimpToolWidget   *widget;
 
   widget = gimp_tool_shear_grid_new (shell,
                                      tr_tool->x1,
@@ -189,18 +188,9 @@ gimp_shear_tool_get_widget (GimpTransformTool *tr_tool)
                                      tr_tool->trans_info[SHEAR_Y]);
 
   g_object_set (widget,
-                "inside-function",         GIMP_TRANSFORM_FUNCTION_SHEAR,
-                "outside-function",        GIMP_TRANSFORM_FUNCTION_SHEAR,
-                "constrain-move",          options->constrain_move,
-                "constrain-scale",         options->constrain_scale,
-                "constrain-rotate",        options->constrain_rotate,
-                "constrain-shear",         options->constrain_shear,
-                "constrain-perspective",   options->constrain_perspective,
-                "frompivot-scale",         options->frompivot_scale,
-                "frompivot-shear",         TRUE,
-                "frompivot-perspective",   options->frompivot_perspective,
-                "cornersnap",              options->cornersnap,
-                "fixedpivot",              options->fixedpivot,
+                "inside-function",  GIMP_TRANSFORM_FUNCTION_SHEAR,
+                "outside-function", GIMP_TRANSFORM_FUNCTION_SHEAR,
+                "frompivot-shear",  TRUE,
                 NULL);
 
   g_signal_connect (widget, "changed",
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 6d95237..72b3751 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -310,6 +310,22 @@ gimp_transform_tool_initialize (GimpTool     *tool,
       /*  Get the on-canvas gui  */
       if (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->get_widget)
         {
+          static const gchar *properties[] =
+          {
+            "constrain-move",
+            "constrain-scale",
+            "constrain-rotate",
+            "constrain-shear",
+            "constrain-perspective",
+            "frompivot-scale",
+            "frompivot-shear",
+            "frompivot-perspective",
+            "cornersnap",
+            "fixedpivot"
+          };
+
+          gint i;
+
           tr_tool->widget =
             GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->get_widget (tr_tool);
 
@@ -322,6 +338,12 @@ gimp_transform_tool_initialize (GimpTool     *tool,
                                   G_BINDING_SYNC_CREATE |
                                   G_BINDING_BIDIRECTIONAL);
 
+          for (i = 0; i < G_N_ELEMENTS (properties); i++)
+            g_object_bind_property (G_OBJECT (options),         properties[i],
+                                    G_OBJECT (tr_tool->widget), properties[i],
+                                    G_BINDING_SYNC_CREATE |
+                                    G_BINDING_BIDIRECTIONAL);
+
           g_signal_connect (tr_tool->widget, "changed",
                             G_CALLBACK (gimp_transform_tool_widget_changed),
                             tr_tool);
@@ -772,16 +794,6 @@ gimp_transform_tool_options_notify (GimpTool         *tool,
            ! strcmp (pspec->name, "fixedpivot") ||
            ! strcmp (pspec->name, "cornersnap"))
     {
-      gboolean value;
-
-      g_object_get (options,
-                    pspec->name, &value,
-                    NULL);
-
-      g_object_set (tr_tool->widget,
-                    pspec->name, value,
-                    NULL);
-
       gimp_transform_tool_dialog_update (tr_tool);
     }
 }
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index 6282b6b..2d1a58d 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -185,10 +185,9 @@ gimp_unified_transform_tool_prepare (GimpTransformTool *tr_tool)
 static GimpToolWidget *
 gimp_unified_transform_tool_get_widget (GimpTransformTool *tr_tool)
 {
-  GimpTool             *tool    = GIMP_TOOL (tr_tool);
-  GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
-  GimpDisplayShell     *shell   = gimp_display_get_shell (tool->display);
-  GimpToolWidget       *widget;
+  GimpTool         *tool  = GIMP_TOOL (tr_tool);
+  GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
+  GimpToolWidget   *widget;
 
   widget = gimp_tool_transform_grid_new (shell,
                                          &tr_tool->transform,
@@ -207,16 +206,6 @@ gimp_unified_transform_tool_get_widget (GimpTransformTool *tr_tool)
                 "use-side-handles",        TRUE,
                 "use-shear-handles",       TRUE,
                 "use-pivot-handle",        TRUE,
-                "constrain-move",          options->constrain_move,
-                "constrain-scale",         options->constrain_scale,
-                "constrain-rotate",        options->constrain_rotate,
-                "constrain-shear",         options->constrain_shear,
-                "constrain-perspective",   options->constrain_perspective,
-                "frompivot-scale",         options->frompivot_scale,
-                "frompivot-shear",         options->frompivot_shear,
-                "frompivot-perspective",   options->frompivot_perspective,
-                "cornersnap",              options->cornersnap,
-                "fixedpivot",              options->fixedpivot,
                 NULL);
 
   g_signal_connect (widget, "changed",


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