Commit 426020da authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/tools/gimpforegroundselecttool-undo.[ch] removed...

2007-02-03  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpforegroundselecttool-undo.[ch]
	* app/tools/gimptransformtool-undo.[ch]: removed...

	* app/tools/Makefile.am
	* app/tools/tools-types.h
	* app/tools/gimpforegroundselecttoolundo.[ch]
	* app/tools/gimptransformtoolundo.[ch]: ...and added a proper undo
	classes.

	* app/tools/gimptransformtool.c: push undos using the new class.


svn path=/trunk/; revision=21843
parent 792ba898
2007-02-03 Michael Natterer <mitch@gimp.org>
* app/tools/gimpforegroundselecttool-undo.[ch]
* app/tools/gimptransformtool-undo.[ch]: removed...
* app/tools/Makefile.am
* app/tools/tools-types.h
* app/tools/gimpforegroundselecttoolundo.[ch]
* app/tools/gimptransformtoolundo.[ch]: ...and added a proper undo
classes.
* app/tools/gimptransformtool.c: push undos using the new class.
2007-02-03 Michael Natterer <mitch@gimp.org>
* app/paint/gimppaintcore-undo.[ch]
......@@ -74,8 +74,8 @@ libapptools_a_sources = \
gimpforegroundselectoptions.h \
gimpforegroundselecttool.c \
gimpforegroundselecttool.h \
gimpforegroundselecttool-undo.c \
gimpforegroundselecttool-undo.h \
gimpforegroundselecttoolundo.c \
gimpforegroundselecttoolundo.h \
gimpfuzzyselecttool.c \
gimpfuzzyselecttool.h \
gimphealtool.c \
......@@ -162,8 +162,8 @@ libapptools_a_sources = \
gimptransformoptions.h \
gimptransformtool.c \
gimptransformtool.h \
gimptransformtool-undo.c \
gimptransformtool-undo.h \
gimptransformtoolundo.c \
gimptransformtoolundo.h \
gimpvectoroptions.c \
gimpvectoroptions.h \
gimpvectortool.c \
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "tools-types.h"
#include "base/tile-manager.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage.h"
#include "core/gimpundo.h"
#include "gimptoolcontrol.h"
#include "gimpforegroundselecttool.h"
#include "gimpforegroundselecttool-undo.h"
#include "tool_manager.h"
typedef struct
{
gint tool_ID;
} FgSelectUndo;
static gboolean undo_pop_foreground_select (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void undo_free_foreground_select (GimpUndo *undo,
GimpUndoMode undo_mode);
gboolean
gimp_foreground_select_tool_push_undo (GimpImage *image,
const gchar *undo_desc,
gint tool_ID)
{
GimpUndo *new;
if ((new = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
sizeof (FgSelectUndo),
sizeof (FgSelectUndo),
GIMP_UNDO_FOREGROUND_SELECT, undo_desc,
FALSE,
undo_pop_foreground_select,
undo_free_foreground_select,
NULL)))
{
FgSelectUndo *undo = new->data;
undo->tool_ID = tool_ID;
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_foreground_select (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (undo->image->gimp);
if (GIMP_IS_FOREGROUND_SELECT_TOOL (active_tool))
{
FgSelectUndo *fg_undo = undo->data;
/* only pop if the active tool is the tool that pushed this undo */
if (fg_undo->tool_ID == active_tool->ID)
{
}
}
return TRUE;
}
static void
undo_free_foreground_select (GimpUndo *undo,
GimpUndoMode undo_mode)
{
FgSelectUndo *fg_undo = undo->data;
g_free (fg_undo);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "tools-types.h"
#include "gimpforegroundselecttool.h"
#include "gimpforegroundselecttoolundo.h"
enum
{
PROP_0,
PROP_FOREGROUND_SELECT_TOOL
};
static GObject * gimp_foreground_select_tool_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_foreground_select_tool_undo_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_foreground_select_tool_undo_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_foreground_select_tool_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void gimp_foreground_select_tool_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode);
G_DEFINE_TYPE (GimpForegroundSelectToolUndo, gimp_foreground_select_tool_undo,
GIMP_TYPE_UNDO)
#define parent_class gimp_foreground_select_tool_undo_parent_class
static void
gimp_foreground_select_tool_undo_class_init (GimpForegroundSelectToolUndoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
object_class->constructor = gimp_foreground_select_tool_undo_constructor;
object_class->set_property = gimp_foreground_select_tool_undo_set_property;
object_class->get_property = gimp_foreground_select_tool_undo_get_property;
undo_class->pop = gimp_foreground_select_tool_undo_pop;
undo_class->free = gimp_foreground_select_tool_undo_free;
g_object_class_install_property (object_class, PROP_FOREGROUND_SELECT_TOOL,
g_param_spec_object ("foreground-select-tool",
NULL, NULL,
GIMP_TYPE_FOREGROUND_SELECT_TOOL,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_foreground_select_tool_undo_init (GimpForegroundSelectToolUndo *undo)
{
}
static GObject *
gimp_foreground_select_tool_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpForegroundSelectToolUndo *foreground_select_tool_undo;
GimpForegroundSelectTool *foreground_select_tool;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
foreground_select_tool_undo = GIMP_FOREGROUND_SELECT_TOOL_UNDO (object);
g_assert (GIMP_IS_FOREGROUND_SELECT_TOOL (foreground_select_tool_undo->foreground_select_tool));
foreground_select_tool = GIMP_FOREGROUND_SELECT_TOOL (foreground_select_tool_undo->foreground_select_tool);
g_object_add_weak_pointer (G_OBJECT (foreground_select_tool_undo->foreground_select_tool),
(gpointer) &foreground_select_tool_undo->foreground_select_tool);
return object;
}
static void
gimp_foreground_select_tool_undo_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpForegroundSelectToolUndo *foreground_select_tool_undo =
GIMP_FOREGROUND_SELECT_TOOL_UNDO (object);
switch (property_id)
{
case PROP_FOREGROUND_SELECT_TOOL:
foreground_select_tool_undo->foreground_select_tool =
g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_foreground_select_tool_undo_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpForegroundSelectToolUndo *foreground_select_tool_undo =
GIMP_FOREGROUND_SELECT_TOOL_UNDO (object);
switch (property_id)
{
case PROP_FOREGROUND_SELECT_TOOL:
g_value_set_object (value,
foreground_select_tool_undo->foreground_select_tool);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_foreground_select_tool_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
GimpForegroundSelectToolUndo *foreground_select_tool_undo =
GIMP_FOREGROUND_SELECT_TOOL_UNDO (undo);
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
}
static void
gimp_foreground_select_tool_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode)
{
GimpForegroundSelectToolUndo *foreground_select_tool_undo = GIMP_FOREGROUND_SELECT_TOOL_UNDO (undo);
if (foreground_select_tool_undo->foreground_select_tool)
{
g_object_remove_weak_pointer (G_OBJECT (foreground_select_tool_undo->foreground_select_tool),
(gpointer) &foreground_select_tool_undo->foreground_select_tool);
foreground_select_tool_undo->foreground_select_tool = NULL;
}
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
}
......@@ -20,9 +20,33 @@
#define __GIMP_FOREGROUND_SELECT_TOOL_UNDO_H__
gboolean gimp_foreground_select_tool_push_undo (GimpImage *image,
const gchar *undo_desc,
gint tool_ID);
#include "core/gimpundo.h"
#endif /* __GIMP_FOREGROUND_SELECT_TOOL_UNDO_H__ */
#define GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO (gimp_foreground_select_tool_undo_get_type ())
#define GIMP_FOREGROUND_SELECT_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO, GimpForegroundSelectToolUndo))
#define GIMP_FOREGROUND_SELECT_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO, GimpForegroundSelectToolUndoClass))
#define GIMP_IS_FOREGROUND_SELECT_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO))
#define GIMP_IS_FOREGROUND_SELECT_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO))
#define GIMP_FOREGROUND_SELECT_TOOL_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO, GimpForegroundSelectToolUndoClass))
typedef struct _GimpForegroundSelectToolUndoClass GimpForegroundSelectToolUndoClass;
struct _GimpForegroundSelectToolUndo
{
GimpUndo parent_instance;
GimpForegroundSelectTool *foreground_select_tool;
};
struct _GimpForegroundSelectToolUndoClass
{
GimpUndoClass parent_class;
};
GType gimp_foreground_select_tool_undo_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_FOREGROUND_SELECT_TOOL_UNDO_H__ */
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "tools-types.h"
#include "base/tile-manager.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage.h"
#include "core/gimpundo.h"
#include "gimptoolcontrol.h"
#include "gimptransformtool.h"
#include "gimptransformtool-undo.h"
#include "tool_manager.h"
#include "gimp-intl.h"
/********************/
/* Transform Undo */
/********************/
typedef struct _TransformUndo TransformUndo;
struct _TransformUndo
{
gint tool_ID;
GType tool_type;
TransInfo trans_info;
TileManager *original;
};
static gboolean undo_pop_transform (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void undo_free_transform (GimpUndo *undo,
GimpUndoMode undo_mode);
gboolean
gimp_transform_tool_push_undo (GimpImage *image,
const gchar *undo_desc,
gint tool_ID,
GType tool_type,
gdouble *trans_info,
TileManager *original)
{
GimpUndo *new;
if ((new = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
sizeof (TransformUndo),
sizeof (TransformUndo),
GIMP_UNDO_TRANSFORM, undo_desc,
FALSE,
undo_pop_transform,
undo_free_transform,
NULL)))
{
TransformUndo *tu = new->data;
gint i;
tu->tool_ID = tool_ID;
tu->tool_type = tool_type;
for (i = 0; i < TRANS_INFO_SIZE; i++)
tu->trans_info[i] = trans_info[i];
if (original)
tu->original = tile_manager_ref (original);
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_transform (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (undo->image->gimp);
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
{
GimpTransformTool *tt = GIMP_TRANSFORM_TOOL (active_tool);
TransformUndo *tu = undo->data;
/* only pop if the active tool is the tool that pushed this undo */
if (tu->tool_ID == active_tool->ID)
{
TileManager *temp;
gdouble d;
gint i;
/* swap the transformation information arrays */
for (i = 0; i < TRANS_INFO_SIZE; i++)
{
d = tu->trans_info[i];
tu->trans_info[i] = tt->trans_info[i];
tt->trans_info[i] = d;
}
/* swap the original buffer--the source buffer for repeated transforms
*/
temp = tu->original;
tu->original = tt->original;
tt->original = temp;
/* If we're re-implementing the first transform, reactivate tool */
if (undo_mode == GIMP_UNDO_MODE_REDO && tt->original)
{
gimp_tool_control_activate (active_tool->control);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tt));
}
}
}
return TRUE;
}
static void
undo_free_transform (GimpUndo *undo,
GimpUndoMode undo_mode)
{
TransformUndo * tu = undo->data;
if (tu->original)
tile_manager_unref (tu->original);
g_free (tu);
}
......@@ -61,7 +61,7 @@
#include "gimptoolcontrol.h"
#include "gimptransformoptions.h"
#include "gimptransformtool.h"
#include "gimptransformtool-undo.h"
#include "gimptransformtoolundo.h"
#include "gimp-intl.h"
......@@ -1280,11 +1280,13 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
*/
tool->drawable = gimp_image_active_drawable (display->image);
gimp_transform_tool_push_undo (display->image, NULL,
tool->ID,
G_TYPE_FROM_INSTANCE (tool),
tr_tool->old_trans_info,
NULL);
gimp_image_undo_push (display->image, GIMP_TYPE_TRANSFORM_TOOL_UNDO,
0, 0,
GIMP_UNDO_TRANSFORM, NULL,
0,
NULL, NULL,
"transform-tool", tr_tool,
NULL);
/* push the undo group end */
gimp_image_undo_group_end (display->image);
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "tools-types.h"
#include "base/tile-manager.h"
#include "gimptoolcontrol.h"
#include "gimptransformtool.h"
#include "gimptransformtoolundo.h"
enum
{
PROP_0,
PROP_TRANSFORM_TOOL
};
static GObject * gimp_transform_tool_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_transform_tool_undo_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_transform_tool_undo_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_transform_tool_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void gimp_transform_tool_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode);
G_DEFINE_TYPE (GimpTransformToolUndo, gimp_transform_tool_undo, GIMP_TYPE_UNDO)
#define parent_class gimp_transform_tool_undo_parent_class
static void
gimp_transform_tool_undo_class_init (GimpTransformToolUndoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
object_class->constructor = gimp_transform_tool_undo_constructor;
object_class->set_property = gimp_transform_tool_undo_set_property;
object_class->get_property = gimp_transform_tool_undo_get_property;