app: also manage all contrain and frompivot properties centrally

using g_object_bind_property().
This commit is contained in:
Michael Natterer 2017-06-19 23:29:01 +02:00
parent 0411801765
commit 9f59657fef
6 changed files with 48 additions and 90 deletions

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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);
}
}

View File

@ -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",