Commit d5494406 authored by Ell's avatar Ell

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).
parent 44c8a1f2
......@@ -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);
}
}
......
......@@ -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)
{
......
......@@ -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");
}
......
......@@ -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)
{
......
......@@ -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");
}
......
......@@ -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");
}
......
......@@ -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");
}
......
......@@ -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,
......
......@@ -72,6 +72,7 @@ struct _GimpTransformToolClass
gint *new_offset_x,
gint *new_offset_y);
const gchar *undo_desc;
const gchar *progress_text;
};
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment