[oops, resending from the right account, sorry!] Here is a slightly improved version, v2 - space before ( for functions other than C_ and friends; - command context is "undo-type" not "command" (it was "command" before, but this change adds new strings anyway) - somewhat friendlier descriptions following Mitch's suggestions. I was tempted to do a separate patch to redesign the shear tool box slightly - right now if you enter numbers into both the x and y boxes some odd things happen. The right answer is a drop-down or radio button to say horizontal or vertical, but the transform tools are changing anyway I think. -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org www.advogato.org
diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c index 360e9c0..bc2e2ab 100644 --- a/app/tools/gimpfliptool.c +++ b/app/tools/gimpfliptool.c @@ -64,6 +64,7 @@ static TileManager * gimp_flip_tool_transform (GimpTransformTool *tool, gint *new_offset_x, gint *new_offset_y); +static gchar *gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool); G_DEFINE_TYPE (GimpFlipTool, gimp_flip_tool, GIMP_TYPE_TRANSFORM_TOOL) @@ -98,13 +99,33 @@ gimp_flip_tool_class_init (GimpFlipToolClass *klass) tool_class->cursor_update = gimp_flip_tool_cursor_update; trans_class->transform = gimp_flip_tool_transform; + trans_class->get_undo_desc = gimp_flip_tool_get_undo_desc; } +static gchar * +gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool) +{ + GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (tr_tool); + + switch (options->flip_type) + { + case GIMP_ORIENTATION_HORIZONTAL: + return g_strdup( C_("command", "Flip Horizontal")); + case GIMP_ORIENTATION_VERTICAL: + return g_strdup( C_("command", "Flip Vertical")); + default: + /* probably this is not actually reached today, but + * could be if someone defined FLIP_DIAGONAL, say... + */ + return g_strdup( C_("command", "Flip")); + } +} + + static void gimp_flip_tool_init (GimpFlipTool *flip_tool) { GimpTool *tool = GIMP_TOOL (flip_tool); - GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (flip_tool); gimp_tool_control_set_snap_to (tool->control, FALSE); gimp_tool_control_set_precision (tool->control, @@ -116,7 +137,6 @@ gimp_flip_tool_init (GimpFlipTool *flip_tool) gimp_tool_control_set_toggle_tool_cursor (tool->control, GIMP_TOOL_CURSOR_FLIP_VERTICAL); - tr_tool->undo_desc = C_("command", "Flip"); } static void diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c index 63220b4..3855465 100644 --- a/app/tools/gimpperspectivetool.c +++ b/app/tools/gimpperspectivetool.c @@ -63,6 +63,7 @@ static void gimp_perspective_tool_dialog_update (GimpTransformTool *tr_tool); static void gimp_perspective_tool_prepare (GimpTransformTool *tr_tool); static void gimp_perspective_tool_motion (GimpTransformTool *tr_tool); static void gimp_perspective_tool_recalc_matrix (GimpTransformTool *tr_tool); +static gchar *gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool); G_DEFINE_TYPE (GimpPerspectiveTool, gimp_perspective_tool, @@ -97,6 +98,7 @@ gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass) trans_class->prepare = gimp_perspective_tool_prepare; trans_class->motion = gimp_perspective_tool_motion; trans_class->recalc_matrix = gimp_perspective_tool_recalc_matrix; + trans_class->get_undo_desc = gimp_perspective_tool_get_undo_desc; } static void @@ -108,7 +110,6 @@ gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool) gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_PERSPECTIVE); - tr_tool->undo_desc = C_("command", "Perspective"); tr_tool->progress_text = _("Perspective transformation"); tr_tool->use_grid = TRUE; @@ -119,6 +120,10 @@ gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool) static void gimp_perspective_tool_dialog (GimpTransformTool *tr_tool) { +} + +static void unused(GimpTransformTool *tr_tool) +{ GimpPerspectiveTool *perspective = GIMP_PERSPECTIVE_TOOL (tr_tool); GtkWidget *content_area; GtkWidget *frame; @@ -171,6 +176,12 @@ gimp_perspective_tool_dialog_update (GimpTransformTool *tr_tool) } } +static gchar * +gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool) +{ + return g_strdup (C_("undo-type", "Perspective")); +} + static void gimp_perspective_tool_prepare (GimpTransformTool *tr_tool) { diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index f320541..4a570d9 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -71,6 +71,7 @@ static void rotate_angle_changed (GtkAdjustment *adj, GimpTransformTool *tr_tool); static void rotate_center_changed (GtkWidget *entry, GimpTransformTool *tr_tool); +static gchar *gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool); G_DEFINE_TYPE (GimpRotateTool, gimp_rotate_tool, GIMP_TYPE_TRANSFORM_TOOL) @@ -108,6 +109,17 @@ gimp_rotate_tool_class_init (GimpRotateToolClass *klass) trans_class->prepare = gimp_rotate_tool_prepare; trans_class->motion = gimp_rotate_tool_motion; trans_class->recalc_matrix = gimp_rotate_tool_recalc_matrix; + trans_class->get_undo_desc = gimp_rotate_tool_get_undo_desc; +} + +static gchar * +gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool) +{ + return g_strdup_printf( "%s by %-3.3g° around (%g, %g)", + C_("undo-command", "Rotate"), + gimp_rad_to_deg (tr_tool->trans_info[ANGLE]), + tr_tool->trans_info[CENTER_X], + tr_tool->trans_info[CENTER_Y]); } static void @@ -118,7 +130,6 @@ gimp_rotate_tool_init (GimpRotateTool *rotate_tool) gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_ROTATE); - tr_tool->undo_desc = C_("command", "Rotate"); tr_tool->progress_text = _("Rotating"); tr_tool->use_grid = TRUE; diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index f2812af..48adcae 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -70,6 +70,8 @@ static void gimp_scale_tool_size_notify (GtkWidget *box, GParamSpec *pspec, GimpTransformTool *tr_tool); +static gchar *gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool); + G_DEFINE_TYPE (GimpScaleTool, gimp_scale_tool, GIMP_TYPE_TRANSFORM_TOOL) @@ -103,6 +105,7 @@ gimp_scale_tool_class_init (GimpScaleToolClass *klass) trans_class->prepare = gimp_scale_tool_prepare; trans_class->motion = gimp_scale_tool_motion; trans_class->recalc_matrix = gimp_scale_tool_recalc_matrix; + trans_class->get_undo_desc = gimp_scale_tool_get_undo_desc; } static void @@ -113,7 +116,6 @@ gimp_scale_tool_init (GimpScaleTool *scale_tool) gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_RESIZE); - tr_tool->undo_desc = C_("command", "Scale"); tr_tool->progress_text = _("Scaling"); tr_tool->use_grid = TRUE; @@ -122,6 +124,16 @@ gimp_scale_tool_init (GimpScaleTool *scale_tool) tr_tool->use_mid_handles = TRUE; } +static gchar * +gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool) +{ + gint width = ROUND (tr_tool->trans_info[X1] - tr_tool->trans_info[X0]); + gint height = ROUND (tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]); + return g_strdup_printf ("%s to %d x %d", + C_("undo-type", "Scale"), width, height); +} + + static void gimp_scale_tool_dialog (GimpTransformTool *tr_tool) { diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c index f83d340..c6a0b10 100644 --- a/app/tools/gimpsheartool.c +++ b/app/tools/gimpsheartool.c @@ -66,6 +66,7 @@ static void shear_x_mag_changed (GtkAdjustment *adj, static void shear_y_mag_changed (GtkAdjustment *adj, GimpTransformTool *tr_tool); +static gchar *gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool); G_DEFINE_TYPE (GimpShearTool, gimp_shear_tool, GIMP_TYPE_TRANSFORM_TOOL) @@ -87,6 +88,23 @@ gimp_shear_tool_register (GimpToolRegisterCallback callback, data); } +static gchar * +gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool) +{ + gdouble x = tr_tool->trans_info[XSHEAR]; + gdouble y = tr_tool->trans_info[YSHEAR]; + if (tr_tool->trans_info[HORZ_OR_VERT] == GIMP_ORIENTATION_HORIZONTAL) + return g_strdup_printf ("%s horizontally %-3.3g", + C_("undo-type", "Shear"), x); + else if (tr_tool->trans_info[HORZ_OR_VERT] == GIMP_ORIENTATION_VERTICAL) + return g_strdup_printf ("%s vertically %-3.3g", + C_("undo-type", "Shear"), y); + else /* e.g. user entered numbers but no notification callback */ + return g_strdup_printf ("%s horizontally %-3.3g vertically %-3.3g", + C_("undo-type", "Shear"), x, y); +} + + static void gimp_shear_tool_class_init (GimpShearToolClass *klass) { @@ -97,6 +115,7 @@ gimp_shear_tool_class_init (GimpShearToolClass *klass) trans_class->prepare = gimp_shear_tool_prepare; trans_class->motion = gimp_shear_tool_motion; trans_class->recalc_matrix = gimp_shear_tool_recalc_matrix; + trans_class->get_undo_desc = gimp_shear_tool_get_undo_desc; } static void @@ -107,7 +126,6 @@ gimp_shear_tool_init (GimpShearTool *shear_tool) gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_SHEAR); - tr_tool->undo_desc = C_("command", "Shear"); tr_tool->progress_text = _("Shearing"); tr_tool->use_grid = TRUE; diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index 5b2a7cd..9864d92 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -184,6 +184,7 @@ gimp_transform_tool_class_init (GimpTransformToolClass *klass) klass->motion = NULL; klass->recalc_matrix = NULL; klass->transform = gimp_transform_tool_real_transform; + klass->get_undo_desc = NULL; } static void @@ -1050,6 +1051,7 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool, const gchar *null_message = NULL; const gchar *locked_message = NULL; gboolean new_layer; + gchar *undo_desc = NULL; switch (options->type) { @@ -1098,8 +1100,12 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool, /* We're going to dirty this image, but we want to keep the tool around */ gimp_tool_control_set_preserve (tool->control, TRUE); - gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM, - tr_tool->undo_desc); + undo_desc = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->get_undo_desc (tr_tool); + gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM, undo_desc); + if (undo_desc) + { + g_free(undo_desc); /* undo_group_start saves a copy */ + } switch (options->type) { diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h index 04e64e2..d3d8eed 100644 --- a/app/tools/gimptransformtool.h +++ b/app/tools/gimptransformtool.h @@ -89,7 +89,6 @@ struct _GimpTransformTool GimpCanvasItem *handles[TRANSFORM_HANDLE_CENTER + 1]; - const gchar *undo_desc; const gchar *progress_text; GtkWidget *dialog; @@ -112,6 +111,7 @@ struct _GimpTransformToolClass gint orig_offset_y, gint *new_offset_x, gint *new_offset_y); + gchar * (* get_undo_desc) (GimpTransformTool *tool); };
_______________________________________________ Gimp-developer mailing list Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer