[gimp] app: add GimpTransformToolClass::undo_desc field



commit d54944065031d3f0850d13bb9e1e38978f1a3981
Author: Ell <ell_se yahoo com>
Date:   Mon Feb 4 10:21:31 2019 -0500

    app: add GimpTransformToolClass::undo_desc field
    
    Add an undo_desc field to GimpTransformToolClass, which subclasses
    should set to the tool's default undo description.  Provide a
    default implementation for the get_undo_desc() vfunc, which returns
    (a copy of) undo_desc.  This simplifies transform tools that have a
    static undo descrption, as well as provides a fallback when a
    detailed undo description can't be generated (not currently
    relevant, but will be used in the next commit).

 app/tools/gimpfliptool.c             |  3 ++-
 app/tools/gimphandletransformtool.c  | 11 +----------
 app/tools/gimpmeasuretool.c          |  1 +
 app/tools/gimpperspectivetool.c      | 11 +----------
 app/tools/gimprotatetool.c           |  1 +
 app/tools/gimpscaletool.c            |  1 +
 app/tools/gimpsheartool.c            |  1 +
 app/tools/gimptransformtool.c        | 26 +++++++++++++++++---------
 app/tools/gimptransformtool.h        |  1 +
 app/tools/gimpunifiedtransformtool.c | 11 +----------
 10 files changed, 27 insertions(+), 40 deletions(-)
---
diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c
index 1470ef73d8..49cc9a1247 100644
--- a/app/tools/gimpfliptool.c
+++ b/app/tools/gimpfliptool.c
@@ -130,6 +130,7 @@ gimp_flip_tool_class_init (GimpFlipToolClass *klass)
   tr_class->get_undo_desc   = gimp_flip_tool_get_undo_desc;
   tr_class->transform       = gimp_flip_tool_transform;
 
+  tr_class->undo_desc       = C_("undo-type", "Flip");
   tr_class->progress_text   = _("Flipping");
 }
 
@@ -305,7 +306,7 @@ gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool)
       /* probably this is not actually reached today, but
        * could be if someone defined FLIP_DIAGONAL, say...
        */
-      return g_strdup (C_("undo-desc", "Flip"));
+      return GIMP_TRANSFORM_TOOL_CLASS (parent_class)->get_undo_desc (tr_tool);
     }
 }
 
diff --git a/app/tools/gimphandletransformtool.c b/app/tools/gimphandletransformtool.c
index fb3d874034..2d330a8538 100644
--- a/app/tools/gimphandletransformtool.c
+++ b/app/tools/gimphandletransformtool.c
@@ -83,8 +83,6 @@ static void             gimp_handle_transform_tool_modifier_key   (GimpTool
                                                                    GdkModifierType           state,
                                                                    GimpDisplay              *display);
 
-static gchar          * gimp_handle_transform_tool_get_undo_desc  (GimpTransformTool        *tr_tool);
-
 static void             gimp_handle_transform_tool_prepare        (GimpTransformGridTool    *tg_tool);
 static GimpToolWidget * gimp_handle_transform_tool_get_widget     (GimpTransformGridTool    *tg_tool);
 static void             gimp_handle_transform_tool_update_widget  (GimpTransformGridTool    *tg_tool);
@@ -127,8 +125,6 @@ gimp_handle_transform_tool_class_init (GimpHandleTransformToolClass *klass)
 
   tool_class->modifier_key     = gimp_handle_transform_tool_modifier_key;
 
-  tr_class->get_undo_desc      = gimp_handle_transform_tool_get_undo_desc;
-
   tg_class->prepare            = gimp_handle_transform_tool_prepare;
   tg_class->get_widget         = gimp_handle_transform_tool_get_widget;
   tg_class->update_widget      = gimp_handle_transform_tool_update_widget;
@@ -136,6 +132,7 @@ gimp_handle_transform_tool_class_init (GimpHandleTransformToolClass *klass)
 
   generic_class->recalc_points = gimp_handle_transform_tool_recalc_points;
 
+  tr_class->undo_desc          = C_("undo-type", "Handle transform");
   tr_class->progress_text      = _("Handle transformation");
 }
 
@@ -199,12 +196,6 @@ gimp_handle_transform_tool_modifier_key (GimpTool        *tool,
                                                 state, display);
 }
 
-static gchar *
-gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool)
-{
-  return g_strdup (C_("undo-type", "Handle transform"));
-}
-
 static void
 gimp_handle_transform_tool_prepare (GimpTransformGridTool *tg_tool)
 {
diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c
index ad718c8d5f..0fdd0e228c 100644
--- a/app/tools/gimpmeasuretool.c
+++ b/app/tools/gimpmeasuretool.c
@@ -150,6 +150,7 @@ gimp_measure_tool_class_init (GimpMeasureToolClass *klass)
   tr_class->recalc_matrix    = gimp_measure_tool_recalc_matrix;
   tr_class->get_undo_desc    = gimp_measure_tool_get_undo_desc;
 
+  tr_class->undo_desc        = C_("undo-type", "Straighten");
   tr_class->progress_text    = _("Straightening");
 }
 
diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c
index f3bb64f6d4..2cdf89be98 100644
--- a/app/tools/gimpperspectivetool.c
+++ b/app/tools/gimpperspectivetool.c
@@ -54,8 +54,6 @@ enum
 
 /*  local function prototypes  */
 
-static gchar          * gimp_perspective_tool_get_undo_desc  (GimpTransformTool        *tr_tool);
-
 static void             gimp_perspective_tool_prepare        (GimpTransformGridTool    *tg_tool);
 static GimpToolWidget * gimp_perspective_tool_get_widget     (GimpTransformGridTool    *tg_tool);
 static void             gimp_perspective_tool_update_widget  (GimpTransformGridTool    *tg_tool);
@@ -95,8 +93,6 @@ gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
   GimpTransformGridToolClass    *tg_class      = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
   GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
 
-  tr_class->get_undo_desc      = gimp_perspective_tool_get_undo_desc;
-
   tg_class->prepare            = gimp_perspective_tool_prepare;
   tg_class->get_widget         = gimp_perspective_tool_get_widget;
   tg_class->update_widget      = gimp_perspective_tool_update_widget;
@@ -104,6 +100,7 @@ gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
 
   generic_class->recalc_points = gimp_perspective_tool_recalc_points;
 
+  tr_class->undo_desc          = C_("undo-type", "Perspective");
   tr_class->progress_text      = _("Perspective transformation");
 }
 
@@ -116,12 +113,6 @@ gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
                                      GIMP_TOOL_CURSOR_PERSPECTIVE);
 }
 
-static gchar *
-gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool)
-{
-  return g_strdup (C_("undo-type", "Perspective"));
-}
-
 static void
 gimp_perspective_tool_prepare (GimpTransformGridTool *tg_tool)
 {
diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c
index 0b16ddea2c..dbdd927294 100644
--- a/app/tools/gimprotatetool.c
+++ b/app/tools/gimprotatetool.c
@@ -118,6 +118,7 @@ gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
   tg_class->update_widget   = gimp_rotate_tool_update_widget;
   tg_class->widget_changed  = gimp_rotate_tool_widget_changed;
 
+  tr_class->undo_desc       = C_("undo-type", "Rotate");
   tr_class->progress_text   = _("Rotating");
   tg_class->ok_button_label = _("R_otate");
 }
diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c
index d555e02750..f9a1b31645 100644
--- a/app/tools/gimpscaletool.c
+++ b/app/tools/gimpscaletool.c
@@ -113,6 +113,7 @@ gimp_scale_tool_class_init (GimpScaleToolClass *klass)
   tg_class->update_widget   = gimp_scale_tool_update_widget;
   tg_class->widget_changed  = gimp_scale_tool_widget_changed;
 
+  tr_class->undo_desc       = C_("undo-type", "Scale");
   tr_class->progress_text   = _("Scaling");
   tg_class->ok_button_label = _("_Scale");
 }
diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c
index 26fe978df0..e03887d8ff 100644
--- a/app/tools/gimpsheartool.c
+++ b/app/tools/gimpsheartool.c
@@ -109,6 +109,7 @@ gimp_shear_tool_class_init (GimpShearToolClass *klass)
   tg_class->update_widget   = gimp_shear_tool_update_widget;
   tg_class->widget_changed  = gimp_shear_tool_widget_changed;
 
+  tr_class->progress_text   = C_("undo-type", "Shear");
   tr_class->progress_text   = _("Shearing");
   tg_class->ok_button_label = _("_Shear");
 }
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 1f1744a6aa..2f3968487d 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -61,14 +61,15 @@
 
 /*  local function prototypes  */
 
-static GeglBuffer * gimp_transform_tool_real_transform (GimpTransformTool  *tr_tool,
-                                                        GimpItem           *item,
-                                                        GeglBuffer         *orig_buffer,
-                                                        gint                orig_offset_x,
-                                                        gint                orig_offset_y,
-                                                        GimpColorProfile  **buffer_profile,
-                                                        gint               *new_offset_x,
-                                                        gint               *new_offset_y);
+static gchar      * gimp_transform_tool_real_get_undo_desc (GimpTransformTool  *tr_tool);
+static GeglBuffer * gimp_transform_tool_real_transform     (GimpTransformTool  *tr_tool,
+                                                            GimpItem           *item,
+                                                            GeglBuffer         *orig_buffer,
+                                                            gint                orig_offset_x,
+                                                            gint                orig_offset_y,
+                                                            GimpColorProfile  **buffer_profile,
+                                                            gint               *new_offset_x,
+                                                            gint               *new_offset_y);
 
 static gboolean     gimp_transform_tool_confirm        (GimpTransformTool  *tr_tool,
                                                         GimpDisplay        *display);
@@ -86,9 +87,10 @@ static void
 gimp_transform_tool_class_init (GimpTransformToolClass *klass)
 {
   klass->recalc_matrix = NULL;
-  klass->get_undo_desc = NULL;
+  klass->get_undo_desc = gimp_transform_tool_real_get_undo_desc;
   klass->transform     = gimp_transform_tool_real_transform;
 
+  klass->undo_desc     = _("Transform");
   klass->progress_text = _("Transforming");
 }
 
@@ -99,6 +101,12 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
   tr_tool->transform_valid = TRUE;
 }
 
+static gchar *
+gimp_transform_tool_real_get_undo_desc (GimpTransformTool *tr_tool)
+{
+  return g_strdup (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->undo_desc);
+}
+
 static GeglBuffer *
 gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
                                     GimpItem          *active_item,
diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h
index fb6899a860..2c9e0624b2 100644
--- a/app/tools/gimptransformtool.h
+++ b/app/tools/gimptransformtool.h
@@ -72,6 +72,7 @@ struct _GimpTransformToolClass
                                   gint               *new_offset_x,
                                   gint               *new_offset_y);
 
+  const gchar *undo_desc;
   const gchar *progress_text;
 };
 
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index a261b2145c..8e91298ca6 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -56,8 +56,6 @@ enum
 
 /*  local function prototypes  */
 
-static gchar          * gimp_unified_transform_tool_get_undo_desc  (GimpTransformTool        *tr_tool);
-
 static void             gimp_unified_transform_tool_prepare        (GimpTransformGridTool    *tg_tool);
 static GimpToolWidget * gimp_unified_transform_tool_get_widget     (GimpTransformGridTool    *tg_tool);
 static void             gimp_unified_transform_tool_update_widget  (GimpTransformGridTool    *tg_tool);
@@ -97,8 +95,6 @@ gimp_unified_transform_tool_class_init (GimpUnifiedTransformToolClass *klass)
   GimpTransformGridToolClass    *tg_class      = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
   GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
 
-  tr_class->get_undo_desc      = gimp_unified_transform_tool_get_undo_desc;
-
   tg_class->prepare            = gimp_unified_transform_tool_prepare;
   tg_class->get_widget         = gimp_unified_transform_tool_get_widget;
   tg_class->update_widget      = gimp_unified_transform_tool_update_widget;
@@ -106,6 +102,7 @@ gimp_unified_transform_tool_class_init (GimpUnifiedTransformToolClass *klass)
 
   generic_class->recalc_points = gimp_unified_transform_tool_recalc_points;
 
+  tr_class->undo_desc          = C_("undo-type", "Unified Transform");
   tr_class->progress_text      = _("Unified transform");
 }
 
@@ -114,12 +111,6 @@ gimp_unified_transform_tool_init (GimpUnifiedTransformTool *unified_tool)
 {
 }
 
-static gchar *
-gimp_unified_transform_tool_get_undo_desc (GimpTransformTool *tr_tool)
-{
-  return g_strdup (C_("undo-type", "Unified Transform"));
-}
-
 static void
 gimp_unified_transform_tool_prepare (GimpTransformGridTool *tg_tool)
 {


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