Re: [Gimp-developer] Improving undo strings (work in progress)

2011-08-24 Thread Liam R E Quin
[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
@@ 

[Gimp-developer] Improving undo strings (work in progress)

2011-08-23 Thread Liam R E Quin
Thanks to help from Mitch to get me started, I've had another go at
improving the gimp undo strings for the transform tools.

This patch changes the labels shown under Edit-Undo, Edit-Redo and
also the undo history.

If this goes down well I could do it for more cases. Right now it
affects the following strings in the undo history:

Old:  New:
==
FlipFlip Horizontal, or Flip Vertical
Rotate  Rotate 15 at (300, 206)
Shear   Shear x=10 y=0
 note: if you enter numbers into both fields in the shear dialogue,
 it accepts them both but only uses one. This is a bug somewhere in
 the shear tool _or_ in the dialogue.  If the latter, the dialogue
 should have just Amount:  and a horizontal/vertical choice.

Perspective unchanged, since you can't enter the numbers in the dialogue
 box and it would be an exercise in frustration for people to try
 and drag the handles to match the numbers.  I had a patch once that
 used entries there, but abandoned it because supposedly the
 transform tools were all being redone.

Scale   Scale x=300 y=200.
 note: The values in the dialogue box do not show the centre of the
 transform, so you can't always reuse the numbers and get the same
 result.  It's a UI bug. I've left off the centre coordinates here.


Comments?

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/

diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c
index 360e9c0..56e4f99 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..8f7c8c6 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;
@@ -171,6 +172,12 @@ gimp_perspective_tool_dialog_update (GimpTransformTool *tr_tool)
   }
 }
 
+static gchar *