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

app/vectors/Makefile.am app/vectors/vectors-types.h new undo class which

2007-01-30  Michael Natterer  <mitch@gimp.org>

	* app/vectors/Makefile.am
	* app/vectors/vectors-types.h
	* app/vectors/gimpvectorspropundo.[ch]: new undo class which
	implements GIMP_UNDO_VECTORS_REPOSITION.

	* app/core/gimpimage-undo-push.c: use it here.

	* app/Makefile.am: another lame linker hack to make it build with
	the new file that is not used in app/vectors/ itself.


svn path=/trunk/; revision=21818
parent e5419559
2007-01-30 Michael Natterer <mitch@gimp.org>
* app/vectors/Makefile.am
* app/vectors/vectors-types.h
* app/vectors/gimpvectorspropundo.[ch]: new undo class which
implements GIMP_UNDO_VECTORS_REPOSITION.
* app/core/gimpimage-undo-push.c: use it here.
* app/Makefile.am: another lame linker hack to make it build with
the new file that is not used in app/vectors/ itself.
2007-01-30 Michael Natterer <mitch@gimp.org>
 
* app/core/gimpguideundo.c
......@@ -92,7 +92,7 @@ INCLUDES = \
$(DBUS_GLIB_CFLAGS) \
-I$(includedir)
gimp_2_3_LDFLAGS = $(mwindows) $(munix) -u $(SYMPREFIX)xcf_init -u $(SYMPREFIX)internal_procs_init
gimp_2_3_LDFLAGS = $(mwindows) $(munix) -u $(SYMPREFIX)xcf_init -u $(SYMPREFIX)internal_procs_init -u $(SYMPREFIX)gimp_coords_mix
gimp_2_3_LDADD = \
gui/libappgui.a \
......@@ -107,8 +107,8 @@ gimp_2_3_LDADD = \
file/libappfile.a \
plug-in/libappplug-in.a \
pdb/libapppdb.a \
vectors/libappvectors.a \
core/libappcore.a \
vectors/libappvectors.a \
paint/libapppaint.a \
text/libapptext.a \
config/libappconfig.a \
......@@ -143,7 +143,7 @@ gimp_console_2_3_CPPFLAGS = \
$(AM_CPPFLAGS) \
-DGIMP_CONSOLE_COMPILATION
gimp_console_2_3_LDFLAGS = $(mwindows) $(munix) -u $(SYMPREFIX)xcf_init -u $(SYMPREFIX)internal_procs_init
gimp_console_2_3_LDFLAGS = $(mwindows) $(munix) -u $(SYMPREFIX)xcf_init -u $(SYMPREFIX)internal_procs_init -u $(SYMPREFIX)gimp_coords_mix
gimp_console_2_3_LDADD = \
widgets/widgets-enums.o \
......@@ -154,8 +154,8 @@ gimp_console_2_3_LDADD = \
file/libappfile.a \
plug-in/libappplug-in.a \
pdb/libapppdb.a \
vectors/libappvectors.a \
core/libappcore.a \
vectors/libappvectors.a \
paint/libapppaint.a \
text/libapptext.a \
config/libappconfig.a \
......
......@@ -54,6 +54,7 @@
#include "text/gimptextundo.h"
#include "vectors/gimpvectors.h"
#include "vectors/gimpvectorspropundo.h"
#include "gimp-intl.h"
......@@ -1446,76 +1447,25 @@ undo_free_vectors_mod (GimpUndo *undo,
/******************************/
/* Vectors re-position Undo */
/* Vectors Properties Undos */
/******************************/
typedef struct _VectorsRepositionUndo VectorsRepositionUndo;
struct _VectorsRepositionUndo
{
gint old_position;
};
static gboolean undo_pop_vectors_reposition (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void undo_free_vectors_reposition (GimpUndo *undo,
GimpUndoMode undo_mode);
GimpUndo *
gimp_image_undo_push_vectors_reposition (GimpImage *image,
const gchar *undo_desc,
GimpVectors *vectors)
{
GimpUndo *new;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (vectors)), NULL);
if ((new = gimp_image_undo_push (image, GIMP_TYPE_ITEM_UNDO,
sizeof (VectorsRepositionUndo),
sizeof (VectorsRepositionUndo),
GIMP_UNDO_VECTORS_REPOSITION, undo_desc,
GIMP_DIRTY_IMAGE_STRUCTURE,
undo_pop_vectors_reposition,
undo_free_vectors_reposition,
"item", vectors,
NULL)))
{
VectorsRepositionUndo *vru = new->data;
vru->old_position = gimp_image_get_vectors_index (image, vectors);
return new;
}
return NULL;
}
static gboolean
undo_pop_vectors_reposition (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
VectorsRepositionUndo *vru = undo->data;
GimpVectors *vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (undo)->item);
gint pos;
/* what's the vectors's current index? */
pos = gimp_image_get_vectors_index (undo->image, vectors);
gimp_image_position_vectors (undo->image, vectors, vru->old_position,
FALSE, NULL);
vru->old_position = pos;
return TRUE;
}
static void
undo_free_vectors_reposition (GimpUndo *undo,
GimpUndoMode undo_mode)
{
g_free (undo->data);
return gimp_image_undo_push (image, GIMP_TYPE_VECTORS_PROP_UNDO,
0, 0,
GIMP_UNDO_VECTORS_REPOSITION, undo_desc,
GIMP_DIRTY_IMAGE_STRUCTURE,
NULL, NULL,
"item", vectors,
NULL);
}
......
......@@ -37,7 +37,8 @@ libappvectors_a_SOURCES = \
gimpvectors-preview.c \
gimpvectors-preview.h \
gimpvectors-warp.c \
gimpvectors-warp.h
gimpvectors-warp.h \
gimpvectorspropundo.c \
gimpvectorspropundo.h
EXTRA_DIST = makefile.msc
/* 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 <glib-object.h>
#include "vectors-types.h"
#include "core/gimpimage.h"
#include "gimpvectors.h"
#include "gimpvectorspropundo.h"
static GObject * gimp_vectors_prop_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_vectors_prop_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
G_DEFINE_TYPE (GimpVectorsPropUndo, gimp_vectors_prop_undo, GIMP_TYPE_ITEM_UNDO)
#define parent_class gimp_vectors_prop_undo_parent_class
static void
gimp_vectors_prop_undo_class_init (GimpVectorsPropUndoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
object_class->constructor = gimp_vectors_prop_undo_constructor;
undo_class->pop = gimp_vectors_prop_undo_pop;
}
static void
gimp_vectors_prop_undo_init (GimpVectorsPropUndo *undo)
{
}
static GObject *
gimp_vectors_prop_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpVectorsPropUndo *vectors_prop_undo;
GimpImage *image;
GimpVectors *vectors;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
vectors_prop_undo = GIMP_VECTORS_PROP_UNDO (object);
g_assert (GIMP_IS_VECTORS (GIMP_ITEM_UNDO (object)->item));
image = GIMP_UNDO (object)->image;
vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (object)->item);
switch (GIMP_UNDO (object)->undo_type)
{
case GIMP_UNDO_VECTORS_REPOSITION:
vectors_prop_undo->position = gimp_image_get_vectors_index (image, vectors);
break;
default:
g_assert_not_reached ();
}
return object;
}
static void
gimp_vectors_prop_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
GimpVectorsPropUndo *vectors_prop_undo = GIMP_VECTORS_PROP_UNDO (undo);
GimpVectors *vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (undo)->item);
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
switch (undo->undo_type)
{
case GIMP_UNDO_VECTORS_REPOSITION:
{
gint position;
position = gimp_image_get_vectors_index (undo->image, vectors);
gimp_image_position_vectors (undo->image, vectors,
vectors_prop_undo->position,
FALSE, NULL);
vectors_prop_undo->position = position;
}
break;
default:
g_assert_not_reached ();
}
}
/* 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.
*/
#ifndef __GIMP_VECTORS_PROP_UNDO_H__
#define __GIMP_VECTORS_PROP_UNDO_H__
#include "core/gimpitemundo.h"
#define GIMP_TYPE_VECTORS_PROP_UNDO (gimp_vectors_prop_undo_get_type ())
#define GIMP_VECTORS_PROP_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_VECTORS_PROP_UNDO, GimpVectorsPropUndo))
#define GIMP_VECTORS_PROP_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_VECTORS_PROP_UNDO, GimpVectorsPropUndoClass))
#define GIMP_IS_VECTORS_PROP_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_VECTORS_PROP_UNDO))
#define GIMP_IS_VECTORS_PROP_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_VECTORS_PROP_UNDO))
#define GIMP_VECTORS_PROP_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_VECTORS_PROP_UNDO, GimpVectorsPropUndoClass))
typedef struct _GimpVectorsPropUndoClass GimpVectorsPropUndoClass;
struct _GimpVectorsPropUndo
{
GimpItemUndo parent_instance;
gint position;
};
struct _GimpVectorsPropUndoClass
{
GimpItemUndoClass parent_class;
};
GType gimp_vectors_prop_undo_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_VECTORS_PROP_UNDO_H__ */
......@@ -26,11 +26,12 @@
#include "vectors/vectors-enums.h"
typedef struct _GimpAnchor GimpAnchor;
typedef struct _GimpAnchor GimpAnchor;
typedef struct _GimpVectors GimpVectors;
typedef struct _GimpStroke GimpStroke;
typedef struct _GimpBezierStroke GimpBezierStroke;
typedef struct _GimpVectors GimpVectors;
typedef struct _GimpVectorsPropUndo GimpVectorsPropUndo;
typedef struct _GimpStroke GimpStroke;
typedef struct _GimpBezierStroke GimpBezierStroke;
#endif /* __VECTORS_TYPES_H__ */
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