a whole lotta guide fixes

--Sven
This commit is contained in:
Sven Neumann 1999-10-13 23:07:45 +00:00
parent 08529ff5e7
commit fce4ad6327
28 changed files with 751 additions and 434 deletions

View File

@ -1,3 +1,23 @@
Thu Oct 14 01:00:03 MEST 1999 Sven Neumann <sven@gimp.org>
* app/gdisplay.c
* app/gimage.c
* app/gimpimage.c
* app/guides_cmds.c
* app/move.c
* app/undo.c
* app/undo_types.h
* app/xcf.c
* tools/pdbgen/pdb/guides.pdb: a whole lotta guide fixes:
Guides are now freed on image close; undo should work in all
cases; resize and scale use undo_groups so all operations are
undoable in one step; some display probs fixed.
* plug-ins/common/rotate.c: when rotating an image, rotate
the guides too.
This should fix bug #2608.
Wed Oct 13 21:37:51 BST 1999 Andy Thomas <alt@gimp.org>
* app/crop.c

View File

@ -1259,7 +1259,9 @@ image_scale_callback (GtkWidget *widget,
{
ImageResize * image_scale;
GImage * gimage;
gboolean flush = FALSE;
gboolean flush = FALSE; /* this is a bit ugly:
we hijack the flush variable to check if
an undo_group was already started */
image_scale = (ImageResize *) client_data;
@ -1268,6 +1270,8 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
@ -1276,8 +1280,13 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->unit != gimage->unit)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
@ -1286,6 +1295,9 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
@ -1300,7 +1312,10 @@ image_scale_callback (GtkWidget *widget,
}
if (flush)
gdisplays_flush ();
{
undo_push_group_end (gimage);
gdisplays_flush ();
}
}
resize_widget_free (image_scale->resize);

View File

@ -1259,7 +1259,9 @@ image_scale_callback (GtkWidget *widget,
{
ImageResize * image_scale;
GImage * gimage;
gboolean flush = FALSE;
gboolean flush = FALSE; /* this is a bit ugly:
we hijack the flush variable to check if
an undo_group was already started */
image_scale = (ImageResize *) client_data;
@ -1268,6 +1270,8 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
@ -1276,8 +1280,13 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->unit != gimage->unit)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
@ -1286,6 +1295,9 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
@ -1300,7 +1312,10 @@ image_scale_callback (GtkWidget *widget,
}
if (flush)
gdisplays_flush ();
{
undo_push_group_end (gimage);
gdisplays_flush ();
}
}
resize_widget_free (image_scale->resize);

View File

@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)

View File

@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)

View File

@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)

View File

@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)

View File

@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)

View File

@ -130,12 +130,12 @@ static void undo_free_cantundo (UndoState, UndoType, void *);
/* Sizing functions */
static int layer_size (Layer *);
static int channel_size (Channel *);
static int layer_size (Layer *);
static int channel_size (Channel *);
static const char *undo_type_to_name (UndoType);
static const char * undo_type_to_name (UndoType);
static Undo * undo_new (UndoType, long, gboolean);
static Undo * undo_new (UndoType, long, gboolean);
static int shrink_wrap = FALSE;
@ -170,7 +170,7 @@ channel_size (Channel *channel)
static void
undo_free_list (GImage *gimage,
UndoState state,
UndoState state,
GSList *list)
{
GSList * orig;
@ -248,7 +248,9 @@ remove_stack_bottom (GImage *gimage)
/* Allocate and initialise a new Undo. Leaves data and function
* pointers zeroed ready to be filled in by caller. */
static Undo *
undo_new (UndoType type, long size, gboolean dirties_image)
undo_new (UndoType type,
long size,
gboolean dirties_image)
{
Undo *new;
@ -283,7 +285,7 @@ undo_free_up_space (GImage *gimage)
static Undo *
undo_push (GImage *gimage,
long size,
UndoType type,
UndoType type,
gboolean dirties_image)
{
Undo * new;
@ -340,7 +342,7 @@ static int
pop_stack (GImage *gimage,
GSList **stack_ptr,
GSList **unstack_ptr,
UndoState state)
UndoState state)
{
Undo * object;
GSList *stack;
@ -520,7 +522,9 @@ undo_get_redo_name (GImage *gimage)
static void
undo_map_over_stack (GSList *stack, undo_map_fn fn, void *data)
undo_map_over_stack (GSList *stack,
undo_map_fn fn,
void *data)
{
int in_group = 0;
int count = 0;
@ -552,7 +556,9 @@ undo_map_over_stack (GSList *stack, undo_map_fn fn, void *data)
}
void
undo_map_over_undo_stack (GImage *gimage, undo_map_fn fn, void *data)
undo_map_over_undo_stack (GImage *gimage,
undo_map_fn fn,
void *data)
{
/* shouldn't have group open */
g_return_if_fail (gimage->pushing_undo_group == 0);
@ -560,7 +566,9 @@ undo_map_over_undo_stack (GImage *gimage, undo_map_fn fn, void *data)
}
void
undo_map_over_redo_stack (GImage *gimage, undo_map_fn fn, void *data)
undo_map_over_redo_stack (GImage *gimage,
undo_map_fn fn,
void *data)
{
/* shouldn't have group open */
g_return_if_fail (gimage->pushing_undo_group == 0);
@ -569,7 +577,6 @@ undo_map_over_redo_stack (GImage *gimage, undo_map_fn fn, void *data)
void
undo_free (GImage *gimage)
{
@ -601,7 +608,7 @@ undo_free (GImage *gimage)
int
undo_push_group_start (GImage *gimage,
UndoType type)
UndoType type)
{
Undo *boundary_marker;
@ -803,8 +810,8 @@ undo_push_image_mod (GImage *gimage,
static int
undo_pop_image (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *image_undo_ptr)
{
ImageUndo *image_undo;
@ -876,7 +883,7 @@ undo_pop_image (GImage *gimage,
static void
undo_free_image (UndoState state,
UndoType type,
void *image_undo_ptr)
void *image_undo_ptr)
{
ImageUndo *image_undo;
@ -924,8 +931,8 @@ undo_push_mask (GImage *gimage,
static int
undo_pop_mask (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *mask_ptr)
{
MaskUndo *mask_undo;
@ -1009,8 +1016,8 @@ undo_pop_mask (GImage *gimage,
static void
undo_free_mask (UndoState state,
UndoType type,
undo_free_mask (UndoState state,
UndoType type,
void *mask_ptr)
{
MaskUndo *mask_undo;
@ -1052,8 +1059,8 @@ undo_push_layer_displace (GImage *gimage,
static int
undo_pop_layer_displace (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *info_ptr)
{
Layer * layer;
@ -1100,8 +1107,8 @@ undo_pop_layer_displace (GImage *gimage,
static void
undo_free_layer_displace (UndoState state,
UndoType type,
undo_free_layer_displace (UndoState state,
UndoType type,
void *info_ptr)
{
g_free (info_ptr);
@ -1138,8 +1145,8 @@ undo_push_transform (GImage *gimage,
static int
undo_pop_transform (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *tu_ptr)
{
TransformCore * tc;
@ -1187,8 +1194,8 @@ undo_pop_transform (GImage *gimage,
static void
undo_free_transform (UndoState state,
UndoType type,
undo_free_transform (UndoState state,
UndoType type,
void *tu_ptr)
{
TransformUndo * tu;
@ -1231,8 +1238,8 @@ undo_push_paint (GImage *gimage,
static int
undo_pop_paint (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *pu_ptr)
{
PaintCore * pc;
@ -1276,8 +1283,8 @@ undo_pop_paint (GImage *gimage,
static void
undo_free_paint (UndoState state,
UndoType type,
undo_free_paint (UndoState state,
UndoType type,
void *pu_ptr)
{
PaintUndo * pu;
@ -1291,9 +1298,9 @@ undo_free_paint (UndoState state,
/* New Layer Undo */
int
undo_push_layer (GImage *gimage,
UndoType type,
void *lu_ptr)
undo_push_layer (GImage *gimage,
UndoType type,
void *lu_ptr)
{
LayerUndo *lu;
Undo *new;
@ -1328,8 +1335,8 @@ undo_push_layer (GImage *gimage,
static int
undo_pop_layer (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *lu_ptr)
{
LayerUndo *lu;
@ -1391,8 +1398,8 @@ undo_pop_layer (GImage *gimage,
static void
undo_free_layer (UndoState state,
UndoType type,
undo_free_layer (UndoState state,
UndoType type,
void *lu_ptr)
{
LayerUndo *lu;
@ -1456,8 +1463,8 @@ undo_push_layer_mod (GImage *gimage,
static int
undo_pop_layer_mod (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
void **data;
@ -1515,8 +1522,8 @@ undo_pop_layer_mod (GImage *gimage,
static void
undo_free_layer_mod (UndoState state,
UndoType type,
undo_free_layer_mod (UndoState state,
UndoType type,
void *data_ptr)
{
void ** data;
@ -1531,9 +1538,9 @@ undo_free_layer_mod (UndoState state,
/* Layer Mask Undo */
int
undo_push_layer_mask (GImage *gimage,
UndoType type,
void *lmu_ptr)
undo_push_layer_mask (GImage *gimage,
UndoType type,
void *lmu_ptr)
{
LayerMaskUndo *lmu;
Undo *new;
@ -1567,8 +1574,8 @@ undo_push_layer_mask (GImage *gimage,
static int
undo_pop_layer_mask (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *lmu_ptr)
{
LayerMaskUndo *lmu;
@ -1617,8 +1624,8 @@ undo_pop_layer_mask (GImage *gimage,
static void
undo_free_layer_mask (UndoState state,
UndoType type,
undo_free_layer_mask (UndoState state,
UndoType type,
void *lmu_ptr)
{
LayerMaskUndo *lmu;
@ -1641,9 +1648,9 @@ undo_free_layer_mask (UndoState state,
/* New Channel Undo */
int
undo_push_channel (GImage *gimage,
UndoType type,
void *cu_ptr)
undo_push_channel (GImage *gimage,
UndoType type,
void *cu_ptr)
{
ChannelUndo *cu;
Undo *new;
@ -1677,8 +1684,8 @@ undo_push_channel (GImage *gimage,
static int
undo_pop_channel (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *cu_ptr)
{
ChannelUndo *cu;
@ -1724,8 +1731,8 @@ undo_pop_channel (GImage *gimage,
static void
undo_free_channel (UndoState state,
UndoType type,
undo_free_channel (UndoState state,
UndoType type,
void *cu_ptr)
{
ChannelUndo *cu;
@ -1785,8 +1792,8 @@ undo_push_channel_mod (GImage *gimage,
static int
undo_pop_channel_mod (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
void **data;
@ -1820,8 +1827,8 @@ undo_pop_channel_mod (GImage *gimage,
static void
undo_free_channel_mod (UndoState state,
UndoType type,
undo_free_channel_mod (UndoState state,
UndoType type,
void *data_ptr)
{
void ** data;
@ -1866,8 +1873,8 @@ undo_push_fs_to_layer (GImage *gimage,
static int
undo_pop_fs_to_layer (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *fsu_ptr)
{
FStoLayerUndo *fsu;
@ -1927,8 +1934,8 @@ undo_pop_fs_to_layer (GImage *gimage,
static void
undo_free_fs_to_layer (UndoState state,
UndoType type,
undo_free_fs_to_layer (UndoState state,
UndoType type,
void *fsu_ptr)
{
FStoLayerUndo *fsu;
@ -1970,8 +1977,8 @@ undo_push_fs_rigor (GImage *gimage,
static int
undo_pop_fs_rigor (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *layer_ptr)
{
int layer_id;
@ -2012,8 +2019,8 @@ undo_pop_fs_rigor (GImage *gimage,
static void
undo_free_fs_rigor (UndoState state,
UndoType type,
undo_free_fs_rigor (UndoState state,
UndoType type,
void *layer_ptr)
{
g_free (layer_ptr);
@ -2049,8 +2056,8 @@ undo_push_fs_relax (GImage *gimage,
static int
undo_pop_fs_relax (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *layer_ptr)
{
int layer_id;
@ -2091,9 +2098,9 @@ undo_pop_fs_relax (GImage *gimage,
static void
undo_free_fs_relax (UndoState state,
UndoType type,
void *layer_ptr)
undo_free_fs_relax (UndoState state,
UndoType type,
void *layer_ptr)
{
g_free (layer_ptr);
}
@ -2131,9 +2138,9 @@ undo_push_gimage_mod (GImage *gimage)
static int
undo_pop_gimage_mod (GImage *gimage,
UndoState state,
UndoType type,
void *data_ptr)
UndoState state,
UndoType type,
void *data_ptr)
{
int *data;
int tmp;
@ -2168,9 +2175,9 @@ undo_pop_gimage_mod (GImage *gimage,
static void
undo_free_gimage_mod (UndoState state,
UndoType type,
void *data_ptr)
undo_free_gimage_mod (UndoState state,
UndoType type,
void *data_ptr)
{
g_free (data_ptr);
}
@ -2214,8 +2221,8 @@ undo_push_qmask (GImage *gimage)
static int
undo_pop_qmask (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
QmaskUndo *data;
@ -2232,9 +2239,9 @@ undo_pop_qmask (GImage *gimage,
static void
undo_free_qmask (UndoState state,
UndoType type,
void *data_ptr)
undo_free_qmask (UndoState state,
UndoType type,
void *data_ptr)
{
g_free (data_ptr);
}
@ -2247,8 +2254,8 @@ typedef struct _GuideUndo GuideUndo;
struct _GuideUndo
{
GImage *gimage;
Guide *guide;
Guide orig;
Guide *guide;
Guide orig;
};
int
@ -2264,14 +2271,15 @@ undo_push_guide (GImage *gimage,
if ((new = undo_push (gimage, size, GUIDE_UNDO, TRUE)))
{
((Guide *)(guide))->ref_count++;
data = g_new (GuideUndo, 1);
new->data = data;
new->pop_func = undo_pop_guide;
new->free_func = undo_free_guide;
data = g_new (GuideUndo, 1);
new->data = data;
new->pop_func = undo_pop_guide;
new->free_func = undo_free_guide;
data->gimage = gimage;
data->guide = guide;
data->orig = *(data->guide);
data->guide = guide;
data->orig = *(data->guide);
return TRUE;
}
@ -2282,8 +2290,8 @@ undo_push_guide (GImage *gimage,
static int
undo_pop_guide (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
GuideUndo *data;
@ -2293,7 +2301,6 @@ undo_pop_guide (GImage *gimage,
data = data_ptr;
gdisplays_expose_guide (gimage, data->guide);
gdisplays_expose_guide (gimage, &data->orig);
tmp_ref = data->guide->ref_count;
tmp = *(data->guide);
@ -2301,13 +2308,15 @@ undo_pop_guide (GImage *gimage,
data->guide->ref_count = tmp_ref;
data->orig = tmp;
gdisplays_expose_guide (gimage, data->guide);
return TRUE;
}
static void
undo_free_guide (UndoState state,
UndoType type,
undo_free_guide (UndoState state,
UndoType type,
void *data_ptr)
{
GuideUndo *data;
@ -2316,9 +2325,11 @@ undo_free_guide (UndoState state,
data->guide->ref_count--;
if (data->guide->position < 0 && data->guide->ref_count <= 0)
gimage_delete_guide (data->gimage, data->guide);
g_free (data_ptr);
{
gimp_image_remove_guide (data->gimage, data->guide);
g_free (data->guide);
}
g_free (data);
}
/****************/
@ -2361,8 +2372,8 @@ undo_push_resolution (GImage *gimage)
static int
undo_pop_resolution (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
ResolutionUndo *data;
@ -2394,8 +2405,8 @@ undo_pop_resolution (GImage *gimage,
}
static void
undo_free_resolution (UndoState state,
UndoType type,
undo_free_resolution (UndoState state,
UndoType type,
void *data_ptr)
{
g_free (data_ptr);
@ -2416,8 +2427,8 @@ struct _ParasiteUndo
};
int
undo_push_image_parasite (GImage *gimage,
void *parasite)
undo_push_image_parasite (GImage *gimage,
void *parasite)
{
Undo *new;
ParasiteUndo *data;
@ -2530,8 +2541,8 @@ undo_push_drawable_parasite_remove (GImage *gimage,
static int
undo_pop_parasite (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
ParasiteUndo *data;
@ -2576,8 +2587,8 @@ undo_pop_parasite (GImage *gimage,
static void
undo_free_parasite (UndoState state,
UndoType type,
undo_free_parasite (UndoState state,
UndoType type,
void *data_ptr)
{
ParasiteUndo *data;
@ -2603,7 +2614,8 @@ typedef struct {
} LayerRepositionUndo;
int
undo_push_layer_reposition (GImage *gimage, GimpLayer *layer)
undo_push_layer_reposition (GImage *gimage,
GimpLayer *layer)
{
Undo *new;
LayerRepositionUndo *data;
@ -2629,8 +2641,8 @@ undo_push_layer_reposition (GImage *gimage, GimpLayer *layer)
static int
undo_pop_layer_reposition (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
LayerRepositionUndo *data = data_ptr;
@ -2647,8 +2659,8 @@ undo_pop_layer_reposition (GImage *gimage,
}
static void
undo_free_layer_reposition (UndoState state,
UndoType type,
undo_free_layer_reposition (UndoState state,
UndoType type,
void *data_ptr)
{
g_free (data_ptr);
@ -2667,7 +2679,8 @@ typedef struct {
} LayerRenameUndo;
int
undo_push_layer_rename (GImage *gimage, GimpLayer *layer)
undo_push_layer_rename (GImage *gimage,
GimpLayer *layer)
{
Undo *new;
LayerRenameUndo *data;
@ -2693,8 +2706,8 @@ undo_push_layer_rename (GImage *gimage, GimpLayer *layer)
static int
undo_pop_layer_rename (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
LayerRenameUndo *data = data_ptr;
@ -2709,8 +2722,8 @@ undo_pop_layer_rename (GImage *gimage,
}
static void
undo_free_layer_rename (UndoState state,
UndoType type,
undo_free_layer_rename (UndoState state,
UndoType type,
void *data_ptr)
{
LayerRenameUndo *data = data_ptr;
@ -2749,8 +2762,8 @@ undo_push_cantundo (GImage *gimage,
static int
undo_pop_cantundo (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
char *action = data_ptr;
@ -2769,9 +2782,9 @@ undo_pop_cantundo (GImage *gimage,
static void
undo_free_cantundo (UndoState state,
UndoType type,
void *data_ptr)
undo_free_cantundo (UndoState state,
UndoType type,
void *data_ptr)
{
/* nothing to free */
}
@ -2825,6 +2838,8 @@ static struct undo_name_t {
{PARASITE_ATTACH_UNDO, N_("attach parasite")},
{PARASITE_REMOVE_UNDO, N_("remove parasite")},
{RESOLUTION_UNDO, N_("resolution change")},
{IMAGE_SCALE_UNDO, N_("image scale")},
{IMAGE_RESIZE_UNDO, N_("image resize")},
{MISC_UNDO, N_("misc")}
};
#define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t))

View File

@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)

View File

@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)

View File

@ -363,10 +363,10 @@ gdisplay_delete (GDisplay *gdisp)
info_window_free (gdisp->window_info_dialog);
/* Remove navigation dialog if we have one */
if(gdisp->window_nav_dialog)
nav_window_free(gdisp->window_nav_dialog);
if (gdisp->window_nav_dialog)
nav_window_free(gdisp->window_nav_dialog);
if(gdisp->nav_popup)
if (gdisp->nav_popup)
nav_popup_free(gdisp->nav_popup);
/* set the active display to NULL if it was this display */
@ -737,7 +737,6 @@ gdisplay_draw_guides (GDisplay *gdisp)
{
guide = tmp_list->data;
tmp_list = tmp_list->next;
gdisplay_draw_guide (gdisp, guide, FALSE);
}
}
@ -1887,11 +1886,11 @@ gdisplays_resize_cursor_label (GimpImage *gimage)
}
void
gdisplays_update_area (GimpImage* gimage,
int x,
int y,
int w,
int h)
gdisplays_update_area (GimpImage *gimage,
int x,
int y,
int w,
int h)
{
GDisplay *gdisp;
GSList *list = display_list;
@ -1938,7 +1937,7 @@ gdisplays_update_area (GimpImage* gimage,
void
gdisplays_expose_guides (GimpImage* gimage)
gdisplays_expose_guides (GimpImage *gimage)
{
GDisplay *gdisp;
GList *tmp_list;
@ -1965,8 +1964,8 @@ gdisplays_expose_guides (GimpImage* gimage)
void
gdisplays_expose_guide (GimpImage* gimage,
Guide *guide)
gdisplays_expose_guide (GimpImage *gimage,
Guide *guide)
{
GDisplay *gdisp;
GSList *list;
@ -1977,8 +1976,10 @@ gdisplays_expose_guide (GimpImage* gimage,
{
gdisp = (GDisplay *) list->data;
if (gdisp->gimage == gimage)
gdisplay_expose_guide (gdisp, guide);
{
gdisplay_expose_guide (gdisp, guide);
}
list = g_slist_next (list);
}
}
@ -2015,7 +2016,7 @@ gdisplays_update_full (GimpImage* gimage)
void
gdisplays_shrink_wrap (GimpImage* gimage)
gdisplays_shrink_wrap (GimpImage *gimage)
{
GDisplay *gdisp;
GSList *list = display_list;

View File

@ -363,10 +363,10 @@ gdisplay_delete (GDisplay *gdisp)
info_window_free (gdisp->window_info_dialog);
/* Remove navigation dialog if we have one */
if(gdisp->window_nav_dialog)
nav_window_free(gdisp->window_nav_dialog);
if (gdisp->window_nav_dialog)
nav_window_free(gdisp->window_nav_dialog);
if(gdisp->nav_popup)
if (gdisp->nav_popup)
nav_popup_free(gdisp->nav_popup);
/* set the active display to NULL if it was this display */
@ -737,7 +737,6 @@ gdisplay_draw_guides (GDisplay *gdisp)
{
guide = tmp_list->data;
tmp_list = tmp_list->next;
gdisplay_draw_guide (gdisp, guide, FALSE);
}
}
@ -1887,11 +1886,11 @@ gdisplays_resize_cursor_label (GimpImage *gimage)
}
void
gdisplays_update_area (GimpImage* gimage,
int x,
int y,
int w,
int h)
gdisplays_update_area (GimpImage *gimage,
int x,
int y,
int w,
int h)
{
GDisplay *gdisp;
GSList *list = display_list;
@ -1938,7 +1937,7 @@ gdisplays_update_area (GimpImage* gimage,
void
gdisplays_expose_guides (GimpImage* gimage)
gdisplays_expose_guides (GimpImage *gimage)
{
GDisplay *gdisp;
GList *tmp_list;
@ -1965,8 +1964,8 @@ gdisplays_expose_guides (GimpImage* gimage)
void
gdisplays_expose_guide (GimpImage* gimage,
Guide *guide)
gdisplays_expose_guide (GimpImage *gimage,
Guide *guide)
{
GDisplay *gdisp;
GSList *list;
@ -1977,8 +1976,10 @@ gdisplays_expose_guide (GimpImage* gimage,
{
gdisp = (GDisplay *) list->data;
if (gdisp->gimage == gimage)
gdisplay_expose_guide (gdisp, guide);
{
gdisplay_expose_guide (gdisp, guide);
}
list = g_slist_next (list);
}
}
@ -2015,7 +2016,7 @@ gdisplays_update_full (GimpImage* gimage)
void
gdisplays_shrink_wrap (GimpImage* gimage)
gdisplays_shrink_wrap (GimpImage *gimage)
{
GDisplay *gdisp;
GSList *list = display_list;

View File

@ -363,10 +363,10 @@ gdisplay_delete (GDisplay *gdisp)
info_window_free (gdisp->window_info_dialog);
/* Remove navigation dialog if we have one */
if(gdisp->window_nav_dialog)
nav_window_free(gdisp->window_nav_dialog);
if (gdisp->window_nav_dialog)
nav_window_free(gdisp->window_nav_dialog);
if(gdisp->nav_popup)
if (gdisp->nav_popup)
nav_popup_free(gdisp->nav_popup);
/* set the active display to NULL if it was this display */
@ -737,7 +737,6 @@ gdisplay_draw_guides (GDisplay *gdisp)
{
guide = tmp_list->data;
tmp_list = tmp_list->next;
gdisplay_draw_guide (gdisp, guide, FALSE);
}
}
@ -1887,11 +1886,11 @@ gdisplays_resize_cursor_label (GimpImage *gimage)
}
void
gdisplays_update_area (GimpImage* gimage,
int x,
int y,
int w,
int h)
gdisplays_update_area (GimpImage *gimage,
int x,
int y,
int w,
int h)
{
GDisplay *gdisp;
GSList *list = display_list;
@ -1938,7 +1937,7 @@ gdisplays_update_area (GimpImage* gimage,
void
gdisplays_expose_guides (GimpImage* gimage)
gdisplays_expose_guides (GimpImage *gimage)
{
GDisplay *gdisp;
GList *tmp_list;
@ -1965,8 +1964,8 @@ gdisplays_expose_guides (GimpImage* gimage)
void
gdisplays_expose_guide (GimpImage* gimage,
Guide *guide)
gdisplays_expose_guide (GimpImage *gimage,
Guide *guide)
{
GDisplay *gdisp;
GSList *list;
@ -1977,8 +1976,10 @@ gdisplays_expose_guide (GimpImage* gimage,
{
gdisp = (GDisplay *) list->data;
if (gdisp->gimage == gimage)
gdisplay_expose_guide (gdisp, guide);
{
gdisplay_expose_guide (gdisp, guide);
}
list = g_slist_next (list);
}
}
@ -2015,7 +2016,7 @@ gdisplays_update_full (GimpImage* gimage)
void
gdisplays_shrink_wrap (GimpImage* gimage)
gdisplays_shrink_wrap (GimpImage *gimage)
{
GDisplay *gdisp;
GSList *list = display_list;

View File

@ -33,9 +33,9 @@ static void gimage_repaint_handler (GimpImage* gimage, gint, gint, gint, gi
GImage*
gimage_new(int width,
int height,
GimpImageBaseType base_type)
gimage_new (int width,
int height,
GimpImageBaseType base_type)
{
GimpImage* gimage = gimp_image_new (width, height, base_type);
@ -93,7 +93,7 @@ gimage_invalidate_previews (void)
}
static void
gimage_dirty_handler (GimpImage* gimage)
gimage_dirty_handler (GimpImage *gimage)
{
if (active_tool && !active_tool->preserve)
{
@ -132,11 +132,22 @@ gimage_image_count (void)
}
static void
gimage_destroy_handler (GimpImage* gimage)
gimage_destroy_handler (GimpImage *gimage)
{
GList *list;
/* free the undo list */
undo_free (gimage);
/* free all guides */
list = gimage->guides;
while (list)
{
g_free ((Guide*) list->data);
list = g_list_next (list);
}
g_list_free (gimage->guides);
palette_import_image_destroyed (gimage);
if (gimage_image_count () == 1) /* This is the last image */
@ -155,7 +166,7 @@ gimage_cmap_change_handler (GimpImage *gimage,
static void
gimage_rename_handler (GimpImage* gimage)
gimage_rename_handler (GimpImage *gimage)
{
gdisplays_update_title (gimage);
lc_dialog_update_image_list ();
@ -164,7 +175,7 @@ gimage_rename_handler (GimpImage* gimage)
}
static void
gimage_resize_handler (GimpImage* gimage)
gimage_resize_handler (GimpImage *gimage)
{
undo_push_group_end (gimage);
@ -184,11 +195,11 @@ gimage_restructure_handler (GimpImage* gimage)
}
static void
gimage_repaint_handler (GimpImage* gimage,
gint x,
gint y,
gint w,
gint h)
gimage_repaint_handler (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h)
{
gdisplays_update_area (gimage, x, y, w, h);
}

View File

@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)

View File

@ -1259,7 +1259,9 @@ image_scale_callback (GtkWidget *widget,
{
ImageResize * image_scale;
GImage * gimage;
gboolean flush = FALSE;
gboolean flush = FALSE; /* this is a bit ugly:
we hijack the flush variable to check if
an undo_group was already started */
image_scale = (ImageResize *) client_data;
@ -1268,6 +1270,8 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
@ -1276,8 +1280,13 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->unit != gimage->unit)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
@ -1286,6 +1295,9 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
@ -1300,7 +1312,10 @@ image_scale_callback (GtkWidget *widget,
}
if (flush)
gdisplays_flush ();
{
undo_push_group_end (gimage);
gdisplays_flush ();
}
}
resize_widget_free (image_scale->resize);

View File

@ -1259,7 +1259,9 @@ image_scale_callback (GtkWidget *widget,
{
ImageResize * image_scale;
GImage * gimage;
gboolean flush = FALSE;
gboolean flush = FALSE; /* this is a bit ugly:
we hijack the flush variable to check if
an undo_group was already started */
image_scale = (ImageResize *) client_data;
@ -1268,6 +1270,8 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
@ -1276,8 +1280,13 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->unit != gimage->unit)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
@ -1286,6 +1295,9 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
@ -1300,7 +1312,10 @@ image_scale_callback (GtkWidget *widget,
}
if (flush)
gdisplays_flush ();
{
undo_push_group_end (gimage);
gdisplays_flush ();
}
}
resize_widget_free (image_scale->resize);

View File

@ -65,6 +65,7 @@ image_add_hguide_invoker (Argument *args)
if (offset < gimage->height)
{
guide = gimp_image_add_hguide (gimage);
undo_push_guide (gimage, guide);
guide->position = offset;
guide_id = guide->guide_ID;
}
@ -142,6 +143,7 @@ image_add_vguide_invoker (Argument *args)
if (offset < gimage->width)
{
guide = gimp_image_add_vguide (gimage);
undo_push_guide (gimage, guide);
guide->position = offset;
guide_id = guide->guide_ID;
}
@ -227,10 +229,8 @@ image_delete_guide_invoker (Argument *args)
tmp_next = guides->next;
((Guide *) guides->data)->position = -1;
undo_push_guide (gimage, ((Guide *) guides->data));
/* gimp_image_remove_guide (gimage, ((Guide *) guides->data)); */
gimp_image_delete_guide (gimage, (Guide *) guides->data);
guides = tmp_next;
}
else

View File

@ -76,7 +76,7 @@ move_tool_button_press (Tool *tool,
tool->gdisp_ptr = gdisp_ptr;
move->layer = NULL;
move->guide = NULL;
move->disp = NULL;
move->disp = NULL;
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
@ -96,8 +96,6 @@ move_tool_button_press (Tool *tool,
{
undo_push_guide (gdisp->gimage, guide);
move->guide = NULL;
gdisplays_expose_guide (gdisp->gimage, guide);
gimage_remove_guide (gdisp->gimage, guide);
gdisplay_flush (gdisp);
@ -136,7 +134,8 @@ move_tool_button_press (Tool *tool,
}
static void
move_draw_guide (GDisplay *gdisp, Guide *guide)
move_draw_guide (GDisplay *gdisp,
Guide *guide)
{
int x1, y1;
int x2, y2;
@ -181,7 +180,7 @@ move_tool_button_release (Tool *tool,
{
MoveTool * move;
GDisplay * gdisp;
int remove_guide;
int delete_guide;
int x1, y1;
int x2, y2;
@ -197,7 +196,7 @@ move_tool_button_release (Tool *tool,
{
tool->scroll_lock = FALSE;
remove_guide = FALSE;
delete_guide = FALSE;
gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE);
gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE, FALSE);
@ -210,20 +209,20 @@ move_tool_button_release (Tool *tool,
{
case ORIENTATION_HORIZONTAL:
if ((move->guide->position < y1) || (move->guide->position > y2))
remove_guide = TRUE;
delete_guide = TRUE;
break;
case ORIENTATION_VERTICAL:
if ((move->guide->position < x1) || (move->guide->position > x2))
remove_guide = TRUE;
delete_guide = TRUE;
break;
}
gdisplays_expose_guide (gdisp->gimage, move->guide);
if (remove_guide)
if (delete_guide)
{
move_draw_guide (gdisp, move->guide);
move->guide->position = -1;
gimp_image_delete_guide (gdisp->gimage, move->guide);
move->guide = NULL;
move->disp = NULL;
}
@ -240,7 +239,7 @@ move_tool_button_release (Tool *tool,
}
else
{
/* First take care of the case where the user "cancels" the action */
/* Take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK))
{
if (move->layer)
@ -320,7 +319,7 @@ move_tool_cursor_update (Tool *tool,
{
if (move->guide)
{
gdisp = move->disp;
gdisp = gdisplays_check_valid (move->disp, move->disp->gimage);
if (gdisp)
gdisplay_draw_guide (gdisp, move->guide, FALSE);
}
@ -403,7 +402,12 @@ move_tool_start_hguide (Tool *tool,
tool->scroll_lock = TRUE;
private = tool->private;
if (private->guide && private->disp && private->disp->gimage)
gdisplay_draw_guide (private->disp, private->guide, FALSE);
private->guide = gimage_add_hguide (gdisp->gimage);
private->disp = gdisp;
tool->state = ACTIVE;
@ -425,7 +429,12 @@ move_tool_start_vguide (Tool *tool,
tool->scroll_lock = TRUE;
private = tool->private;
if (private->guide && private->disp && private->disp->gimage)
gdisplay_draw_guide (private->disp, private->guide, FALSE);
private->guide = gimage_add_vguide (gdisp->gimage);
private->disp = gdisp;
tool->state = ACTIVE;

View File

@ -76,7 +76,7 @@ move_tool_button_press (Tool *tool,
tool->gdisp_ptr = gdisp_ptr;
move->layer = NULL;
move->guide = NULL;
move->disp = NULL;
move->disp = NULL;
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
@ -96,8 +96,6 @@ move_tool_button_press (Tool *tool,
{
undo_push_guide (gdisp->gimage, guide);
move->guide = NULL;
gdisplays_expose_guide (gdisp->gimage, guide);
gimage_remove_guide (gdisp->gimage, guide);
gdisplay_flush (gdisp);
@ -136,7 +134,8 @@ move_tool_button_press (Tool *tool,
}
static void
move_draw_guide (GDisplay *gdisp, Guide *guide)
move_draw_guide (GDisplay *gdisp,
Guide *guide)
{
int x1, y1;
int x2, y2;
@ -181,7 +180,7 @@ move_tool_button_release (Tool *tool,
{
MoveTool * move;
GDisplay * gdisp;
int remove_guide;
int delete_guide;
int x1, y1;
int x2, y2;
@ -197,7 +196,7 @@ move_tool_button_release (Tool *tool,
{
tool->scroll_lock = FALSE;
remove_guide = FALSE;
delete_guide = FALSE;
gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE);
gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE, FALSE);
@ -210,20 +209,20 @@ move_tool_button_release (Tool *tool,
{
case ORIENTATION_HORIZONTAL:
if ((move->guide->position < y1) || (move->guide->position > y2))
remove_guide = TRUE;
delete_guide = TRUE;
break;
case ORIENTATION_VERTICAL:
if ((move->guide->position < x1) || (move->guide->position > x2))
remove_guide = TRUE;
delete_guide = TRUE;
break;
}
gdisplays_expose_guide (gdisp->gimage, move->guide);
if (remove_guide)
if (delete_guide)
{
move_draw_guide (gdisp, move->guide);
move->guide->position = -1;
gimp_image_delete_guide (gdisp->gimage, move->guide);
move->guide = NULL;
move->disp = NULL;
}
@ -240,7 +239,7 @@ move_tool_button_release (Tool *tool,
}
else
{
/* First take care of the case where the user "cancels" the action */
/* Take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK))
{
if (move->layer)
@ -320,7 +319,7 @@ move_tool_cursor_update (Tool *tool,
{
if (move->guide)
{
gdisp = move->disp;
gdisp = gdisplays_check_valid (move->disp, move->disp->gimage);
if (gdisp)
gdisplay_draw_guide (gdisp, move->guide, FALSE);
}
@ -403,7 +402,12 @@ move_tool_start_hguide (Tool *tool,
tool->scroll_lock = TRUE;
private = tool->private;
if (private->guide && private->disp && private->disp->gimage)
gdisplay_draw_guide (private->disp, private->guide, FALSE);
private->guide = gimage_add_hguide (gdisp->gimage);
private->disp = gdisp;
tool->state = ACTIVE;
@ -425,7 +429,12 @@ move_tool_start_vguide (Tool *tool,
tool->scroll_lock = TRUE;
private = tool->private;
if (private->guide && private->disp && private->disp->gimage)
gdisplay_draw_guide (private->disp, private->guide, FALSE);
private->guide = gimage_add_vguide (gdisp->gimage);
private->disp = gdisp;
tool->state = ACTIVE;

View File

@ -76,7 +76,7 @@ move_tool_button_press (Tool *tool,
tool->gdisp_ptr = gdisp_ptr;
move->layer = NULL;
move->guide = NULL;
move->disp = NULL;
move->disp = NULL;
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
@ -96,8 +96,6 @@ move_tool_button_press (Tool *tool,
{
undo_push_guide (gdisp->gimage, guide);
move->guide = NULL;
gdisplays_expose_guide (gdisp->gimage, guide);
gimage_remove_guide (gdisp->gimage, guide);
gdisplay_flush (gdisp);
@ -136,7 +134,8 @@ move_tool_button_press (Tool *tool,
}
static void
move_draw_guide (GDisplay *gdisp, Guide *guide)
move_draw_guide (GDisplay *gdisp,
Guide *guide)
{
int x1, y1;
int x2, y2;
@ -181,7 +180,7 @@ move_tool_button_release (Tool *tool,
{
MoveTool * move;
GDisplay * gdisp;
int remove_guide;
int delete_guide;
int x1, y1;
int x2, y2;
@ -197,7 +196,7 @@ move_tool_button_release (Tool *tool,
{
tool->scroll_lock = FALSE;
remove_guide = FALSE;
delete_guide = FALSE;
gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE);
gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE, FALSE);
@ -210,20 +209,20 @@ move_tool_button_release (Tool *tool,
{
case ORIENTATION_HORIZONTAL:
if ((move->guide->position < y1) || (move->guide->position > y2))
remove_guide = TRUE;
delete_guide = TRUE;
break;
case ORIENTATION_VERTICAL:
if ((move->guide->position < x1) || (move->guide->position > x2))
remove_guide = TRUE;
delete_guide = TRUE;
break;
}
gdisplays_expose_guide (gdisp->gimage, move->guide);
if (remove_guide)
if (delete_guide)
{
move_draw_guide (gdisp, move->guide);
move->guide->position = -1;
gimp_image_delete_guide (gdisp->gimage, move->guide);
move->guide = NULL;
move->disp = NULL;
}
@ -240,7 +239,7 @@ move_tool_button_release (Tool *tool,
}
else
{
/* First take care of the case where the user "cancels" the action */
/* Take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK))
{
if (move->layer)
@ -320,7 +319,7 @@ move_tool_cursor_update (Tool *tool,
{
if (move->guide)
{
gdisp = move->disp;
gdisp = gdisplays_check_valid (move->disp, move->disp->gimage);
if (gdisp)
gdisplay_draw_guide (gdisp, move->guide, FALSE);
}
@ -403,7 +402,12 @@ move_tool_start_hguide (Tool *tool,
tool->scroll_lock = TRUE;
private = tool->private;
if (private->guide && private->disp && private->disp->gimage)
gdisplay_draw_guide (private->disp, private->guide, FALSE);
private->guide = gimage_add_hguide (gdisp->gimage);
private->disp = gdisp;
tool->state = ACTIVE;
@ -425,7 +429,12 @@ move_tool_start_vguide (Tool *tool,
tool->scroll_lock = TRUE;
private = tool->private;
if (private->guide && private->disp && private->disp->gimage)
gdisplay_draw_guide (private->disp, private->guide, FALSE);
private->guide = gimage_add_vguide (gdisp->gimage);
private->disp = gdisp;
tool->state = ACTIVE;

View File

@ -130,12 +130,12 @@ static void undo_free_cantundo (UndoState, UndoType, void *);
/* Sizing functions */
static int layer_size (Layer *);
static int channel_size (Channel *);
static int layer_size (Layer *);
static int channel_size (Channel *);
static const char *undo_type_to_name (UndoType);
static const char * undo_type_to_name (UndoType);
static Undo * undo_new (UndoType, long, gboolean);
static Undo * undo_new (UndoType, long, gboolean);
static int shrink_wrap = FALSE;
@ -170,7 +170,7 @@ channel_size (Channel *channel)
static void
undo_free_list (GImage *gimage,
UndoState state,
UndoState state,
GSList *list)
{
GSList * orig;
@ -248,7 +248,9 @@ remove_stack_bottom (GImage *gimage)
/* Allocate and initialise a new Undo. Leaves data and function
* pointers zeroed ready to be filled in by caller. */
static Undo *
undo_new (UndoType type, long size, gboolean dirties_image)
undo_new (UndoType type,
long size,
gboolean dirties_image)
{
Undo *new;
@ -283,7 +285,7 @@ undo_free_up_space (GImage *gimage)
static Undo *
undo_push (GImage *gimage,
long size,
UndoType type,
UndoType type,
gboolean dirties_image)
{
Undo * new;
@ -340,7 +342,7 @@ static int
pop_stack (GImage *gimage,
GSList **stack_ptr,
GSList **unstack_ptr,
UndoState state)
UndoState state)
{
Undo * object;
GSList *stack;
@ -520,7 +522,9 @@ undo_get_redo_name (GImage *gimage)
static void
undo_map_over_stack (GSList *stack, undo_map_fn fn, void *data)
undo_map_over_stack (GSList *stack,
undo_map_fn fn,
void *data)
{
int in_group = 0;
int count = 0;
@ -552,7 +556,9 @@ undo_map_over_stack (GSList *stack, undo_map_fn fn, void *data)
}
void
undo_map_over_undo_stack (GImage *gimage, undo_map_fn fn, void *data)
undo_map_over_undo_stack (GImage *gimage,
undo_map_fn fn,
void *data)
{
/* shouldn't have group open */
g_return_if_fail (gimage->pushing_undo_group == 0);
@ -560,7 +566,9 @@ undo_map_over_undo_stack (GImage *gimage, undo_map_fn fn, void *data)
}
void
undo_map_over_redo_stack (GImage *gimage, undo_map_fn fn, void *data)
undo_map_over_redo_stack (GImage *gimage,
undo_map_fn fn,
void *data)
{
/* shouldn't have group open */
g_return_if_fail (gimage->pushing_undo_group == 0);
@ -569,7 +577,6 @@ undo_map_over_redo_stack (GImage *gimage, undo_map_fn fn, void *data)
void
undo_free (GImage *gimage)
{
@ -601,7 +608,7 @@ undo_free (GImage *gimage)
int
undo_push_group_start (GImage *gimage,
UndoType type)
UndoType type)
{
Undo *boundary_marker;
@ -803,8 +810,8 @@ undo_push_image_mod (GImage *gimage,
static int
undo_pop_image (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *image_undo_ptr)
{
ImageUndo *image_undo;
@ -876,7 +883,7 @@ undo_pop_image (GImage *gimage,
static void
undo_free_image (UndoState state,
UndoType type,
void *image_undo_ptr)
void *image_undo_ptr)
{
ImageUndo *image_undo;
@ -924,8 +931,8 @@ undo_push_mask (GImage *gimage,
static int
undo_pop_mask (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *mask_ptr)
{
MaskUndo *mask_undo;
@ -1009,8 +1016,8 @@ undo_pop_mask (GImage *gimage,
static void
undo_free_mask (UndoState state,
UndoType type,
undo_free_mask (UndoState state,
UndoType type,
void *mask_ptr)
{
MaskUndo *mask_undo;
@ -1052,8 +1059,8 @@ undo_push_layer_displace (GImage *gimage,
static int
undo_pop_layer_displace (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *info_ptr)
{
Layer * layer;
@ -1100,8 +1107,8 @@ undo_pop_layer_displace (GImage *gimage,
static void
undo_free_layer_displace (UndoState state,
UndoType type,
undo_free_layer_displace (UndoState state,
UndoType type,
void *info_ptr)
{
g_free (info_ptr);
@ -1138,8 +1145,8 @@ undo_push_transform (GImage *gimage,
static int
undo_pop_transform (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *tu_ptr)
{
TransformCore * tc;
@ -1187,8 +1194,8 @@ undo_pop_transform (GImage *gimage,
static void
undo_free_transform (UndoState state,
UndoType type,
undo_free_transform (UndoState state,
UndoType type,
void *tu_ptr)
{
TransformUndo * tu;
@ -1231,8 +1238,8 @@ undo_push_paint (GImage *gimage,
static int
undo_pop_paint (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *pu_ptr)
{
PaintCore * pc;
@ -1276,8 +1283,8 @@ undo_pop_paint (GImage *gimage,
static void
undo_free_paint (UndoState state,
UndoType type,
undo_free_paint (UndoState state,
UndoType type,
void *pu_ptr)
{
PaintUndo * pu;
@ -1291,9 +1298,9 @@ undo_free_paint (UndoState state,
/* New Layer Undo */
int
undo_push_layer (GImage *gimage,
UndoType type,
void *lu_ptr)
undo_push_layer (GImage *gimage,
UndoType type,
void *lu_ptr)
{
LayerUndo *lu;
Undo *new;
@ -1328,8 +1335,8 @@ undo_push_layer (GImage *gimage,
static int
undo_pop_layer (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *lu_ptr)
{
LayerUndo *lu;
@ -1391,8 +1398,8 @@ undo_pop_layer (GImage *gimage,
static void
undo_free_layer (UndoState state,
UndoType type,
undo_free_layer (UndoState state,
UndoType type,
void *lu_ptr)
{
LayerUndo *lu;
@ -1456,8 +1463,8 @@ undo_push_layer_mod (GImage *gimage,
static int
undo_pop_layer_mod (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
void **data;
@ -1515,8 +1522,8 @@ undo_pop_layer_mod (GImage *gimage,
static void
undo_free_layer_mod (UndoState state,
UndoType type,
undo_free_layer_mod (UndoState state,
UndoType type,
void *data_ptr)
{
void ** data;
@ -1531,9 +1538,9 @@ undo_free_layer_mod (UndoState state,
/* Layer Mask Undo */
int
undo_push_layer_mask (GImage *gimage,
UndoType type,
void *lmu_ptr)
undo_push_layer_mask (GImage *gimage,
UndoType type,
void *lmu_ptr)
{
LayerMaskUndo *lmu;
Undo *new;
@ -1567,8 +1574,8 @@ undo_push_layer_mask (GImage *gimage,
static int
undo_pop_layer_mask (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *lmu_ptr)
{
LayerMaskUndo *lmu;
@ -1617,8 +1624,8 @@ undo_pop_layer_mask (GImage *gimage,
static void
undo_free_layer_mask (UndoState state,
UndoType type,
undo_free_layer_mask (UndoState state,
UndoType type,
void *lmu_ptr)
{
LayerMaskUndo *lmu;
@ -1641,9 +1648,9 @@ undo_free_layer_mask (UndoState state,
/* New Channel Undo */
int
undo_push_channel (GImage *gimage,
UndoType type,
void *cu_ptr)
undo_push_channel (GImage *gimage,
UndoType type,
void *cu_ptr)
{
ChannelUndo *cu;
Undo *new;
@ -1677,8 +1684,8 @@ undo_push_channel (GImage *gimage,
static int
undo_pop_channel (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *cu_ptr)
{
ChannelUndo *cu;
@ -1724,8 +1731,8 @@ undo_pop_channel (GImage *gimage,
static void
undo_free_channel (UndoState state,
UndoType type,
undo_free_channel (UndoState state,
UndoType type,
void *cu_ptr)
{
ChannelUndo *cu;
@ -1785,8 +1792,8 @@ undo_push_channel_mod (GImage *gimage,
static int
undo_pop_channel_mod (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
void **data;
@ -1820,8 +1827,8 @@ undo_pop_channel_mod (GImage *gimage,
static void
undo_free_channel_mod (UndoState state,
UndoType type,
undo_free_channel_mod (UndoState state,
UndoType type,
void *data_ptr)
{
void ** data;
@ -1866,8 +1873,8 @@ undo_push_fs_to_layer (GImage *gimage,
static int
undo_pop_fs_to_layer (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *fsu_ptr)
{
FStoLayerUndo *fsu;
@ -1927,8 +1934,8 @@ undo_pop_fs_to_layer (GImage *gimage,
static void
undo_free_fs_to_layer (UndoState state,
UndoType type,
undo_free_fs_to_layer (UndoState state,
UndoType type,
void *fsu_ptr)
{
FStoLayerUndo *fsu;
@ -1970,8 +1977,8 @@ undo_push_fs_rigor (GImage *gimage,
static int
undo_pop_fs_rigor (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *layer_ptr)
{
int layer_id;
@ -2012,8 +2019,8 @@ undo_pop_fs_rigor (GImage *gimage,
static void
undo_free_fs_rigor (UndoState state,
UndoType type,
undo_free_fs_rigor (UndoState state,
UndoType type,
void *layer_ptr)
{
g_free (layer_ptr);
@ -2049,8 +2056,8 @@ undo_push_fs_relax (GImage *gimage,
static int
undo_pop_fs_relax (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *layer_ptr)
{
int layer_id;
@ -2091,9 +2098,9 @@ undo_pop_fs_relax (GImage *gimage,
static void
undo_free_fs_relax (UndoState state,
UndoType type,
void *layer_ptr)
undo_free_fs_relax (UndoState state,
UndoType type,
void *layer_ptr)
{
g_free (layer_ptr);
}
@ -2131,9 +2138,9 @@ undo_push_gimage_mod (GImage *gimage)
static int
undo_pop_gimage_mod (GImage *gimage,
UndoState state,
UndoType type,
void *data_ptr)
UndoState state,
UndoType type,
void *data_ptr)
{
int *data;
int tmp;
@ -2168,9 +2175,9 @@ undo_pop_gimage_mod (GImage *gimage,
static void
undo_free_gimage_mod (UndoState state,
UndoType type,
void *data_ptr)
undo_free_gimage_mod (UndoState state,
UndoType type,
void *data_ptr)
{
g_free (data_ptr);
}
@ -2214,8 +2221,8 @@ undo_push_qmask (GImage *gimage)
static int
undo_pop_qmask (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
QmaskUndo *data;
@ -2232,9 +2239,9 @@ undo_pop_qmask (GImage *gimage,
static void
undo_free_qmask (UndoState state,
UndoType type,
void *data_ptr)
undo_free_qmask (UndoState state,
UndoType type,
void *data_ptr)
{
g_free (data_ptr);
}
@ -2247,8 +2254,8 @@ typedef struct _GuideUndo GuideUndo;
struct _GuideUndo
{
GImage *gimage;
Guide *guide;
Guide orig;
Guide *guide;
Guide orig;
};
int
@ -2264,14 +2271,15 @@ undo_push_guide (GImage *gimage,
if ((new = undo_push (gimage, size, GUIDE_UNDO, TRUE)))
{
((Guide *)(guide))->ref_count++;
data = g_new (GuideUndo, 1);
new->data = data;
new->pop_func = undo_pop_guide;
new->free_func = undo_free_guide;
data = g_new (GuideUndo, 1);
new->data = data;
new->pop_func = undo_pop_guide;
new->free_func = undo_free_guide;
data->gimage = gimage;
data->guide = guide;
data->orig = *(data->guide);
data->guide = guide;
data->orig = *(data->guide);
return TRUE;
}
@ -2282,8 +2290,8 @@ undo_push_guide (GImage *gimage,
static int
undo_pop_guide (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
GuideUndo *data;
@ -2293,7 +2301,6 @@ undo_pop_guide (GImage *gimage,
data = data_ptr;
gdisplays_expose_guide (gimage, data->guide);
gdisplays_expose_guide (gimage, &data->orig);
tmp_ref = data->guide->ref_count;
tmp = *(data->guide);
@ -2301,13 +2308,15 @@ undo_pop_guide (GImage *gimage,
data->guide->ref_count = tmp_ref;
data->orig = tmp;
gdisplays_expose_guide (gimage, data->guide);
return TRUE;
}
static void
undo_free_guide (UndoState state,
UndoType type,
undo_free_guide (UndoState state,
UndoType type,
void *data_ptr)
{
GuideUndo *data;
@ -2316,9 +2325,11 @@ undo_free_guide (UndoState state,
data->guide->ref_count--;
if (data->guide->position < 0 && data->guide->ref_count <= 0)
gimage_delete_guide (data->gimage, data->guide);
g_free (data_ptr);
{
gimp_image_remove_guide (data->gimage, data->guide);
g_free (data->guide);
}
g_free (data);
}
/****************/
@ -2361,8 +2372,8 @@ undo_push_resolution (GImage *gimage)
static int
undo_pop_resolution (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
ResolutionUndo *data;
@ -2394,8 +2405,8 @@ undo_pop_resolution (GImage *gimage,
}
static void
undo_free_resolution (UndoState state,
UndoType type,
undo_free_resolution (UndoState state,
UndoType type,
void *data_ptr)
{
g_free (data_ptr);
@ -2416,8 +2427,8 @@ struct _ParasiteUndo
};
int
undo_push_image_parasite (GImage *gimage,
void *parasite)
undo_push_image_parasite (GImage *gimage,
void *parasite)
{
Undo *new;
ParasiteUndo *data;
@ -2530,8 +2541,8 @@ undo_push_drawable_parasite_remove (GImage *gimage,
static int
undo_pop_parasite (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
ParasiteUndo *data;
@ -2576,8 +2587,8 @@ undo_pop_parasite (GImage *gimage,
static void
undo_free_parasite (UndoState state,
UndoType type,
undo_free_parasite (UndoState state,
UndoType type,
void *data_ptr)
{
ParasiteUndo *data;
@ -2603,7 +2614,8 @@ typedef struct {
} LayerRepositionUndo;
int
undo_push_layer_reposition (GImage *gimage, GimpLayer *layer)
undo_push_layer_reposition (GImage *gimage,
GimpLayer *layer)
{
Undo *new;
LayerRepositionUndo *data;
@ -2629,8 +2641,8 @@ undo_push_layer_reposition (GImage *gimage, GimpLayer *layer)
static int
undo_pop_layer_reposition (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
LayerRepositionUndo *data = data_ptr;
@ -2647,8 +2659,8 @@ undo_pop_layer_reposition (GImage *gimage,
}
static void
undo_free_layer_reposition (UndoState state,
UndoType type,
undo_free_layer_reposition (UndoState state,
UndoType type,
void *data_ptr)
{
g_free (data_ptr);
@ -2667,7 +2679,8 @@ typedef struct {
} LayerRenameUndo;
int
undo_push_layer_rename (GImage *gimage, GimpLayer *layer)
undo_push_layer_rename (GImage *gimage,
GimpLayer *layer)
{
Undo *new;
LayerRenameUndo *data;
@ -2693,8 +2706,8 @@ undo_push_layer_rename (GImage *gimage, GimpLayer *layer)
static int
undo_pop_layer_rename (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
LayerRenameUndo *data = data_ptr;
@ -2709,8 +2722,8 @@ undo_pop_layer_rename (GImage *gimage,
}
static void
undo_free_layer_rename (UndoState state,
UndoType type,
undo_free_layer_rename (UndoState state,
UndoType type,
void *data_ptr)
{
LayerRenameUndo *data = data_ptr;
@ -2749,8 +2762,8 @@ undo_push_cantundo (GImage *gimage,
static int
undo_pop_cantundo (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *data_ptr)
{
char *action = data_ptr;
@ -2769,9 +2782,9 @@ undo_pop_cantundo (GImage *gimage,
static void
undo_free_cantundo (UndoState state,
UndoType type,
void *data_ptr)
undo_free_cantundo (UndoState state,
UndoType type,
void *data_ptr)
{
/* nothing to free */
}
@ -2825,6 +2838,8 @@ static struct undo_name_t {
{PARASITE_ATTACH_UNDO, N_("attach parasite")},
{PARASITE_REMOVE_UNDO, N_("remove parasite")},
{RESOLUTION_UNDO, N_("resolution change")},
{IMAGE_SCALE_UNDO, N_("image scale")},
{IMAGE_RESIZE_UNDO, N_("image resize")},
{MISC_UNDO, N_("misc")}
};
#define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t))

View File

@ -71,6 +71,8 @@ typedef enum
PARASITE_ATTACH_UNDO,
PARASITE_REMOVE_UNDO,
RESOLUTION_UNDO,
IMAGE_SCALE_UNDO,
IMAGE_RESIZE_UNDO,
MISC_UNDO = 100
} UndoType;

View File

@ -1811,6 +1811,7 @@ xcf_load_image_props (XcfInfo *info,
info->cp += xcf_read_int8 (info->fp, (guint8*) &orientation, 1);
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = position;
guide->orientation = orientation;
guide->guide_ID = next_guide_id++;

View File

@ -1811,6 +1811,7 @@ xcf_load_image_props (XcfInfo *info,
info->cp += xcf_read_int8 (info->fp, (guint8*) &orientation, 1);
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = position;
guide->orientation = orientation;
guide->guide_ID = next_guide_id++;

View File

@ -1,6 +1,6 @@
/*
* Rotate plug-in v0.7 by Sven Neumann, neumanns@uni-duesseldorf.de
* 1998/05/28
* Rotate plug-in v0.8 by Sven Neumann <sven@gimp.org>
* 1999/10/09
*
* Any suggestions, bug-reports or patches are very welcome.
*
@ -41,6 +41,7 @@
* (01/15/98) v0.6 fixed a line that caused rotate to crash on some
* systems
* (05/28/98) v0.7 use the new gimp_message function for error output
* (10/09/99) v0.8 rotate guides too
*/
/* TODO List
@ -58,16 +59,16 @@
/* Defines */
#define PLUG_IN_NAME "plug_in_rotate"
#define PLUG_IN_VERSION "v0.6 (01/15/98)"
#define PLUG_IN_VERSION "v0.8 (1999/10/09)"
#define PLUG_IN_IMAGE_TYPES "RGB*, INDEXED*, GRAY*"
#define PLUG_IN_AUTHOR "Sven Neumann (neumanns@uni-duesseldorf.de)"
#define PLUG_IN_AUTHOR "Sven Neumann <sven@gimp.org>"
#define PLUG_IN_COPYRIGHT "Sven Neumann"
#define NUMBER_IN_ARGS 5
#define IN_ARGS { PARAM_INT32, "run_mode", "Interactive, non-interactive"},\
{ PARAM_IMAGE, "image", "Input image" },\
{ PARAM_DRAWABLE, "drawable", "Input drawable"},\
{ PARAM_INT32, "angle", "Angle { 90 (1), 180 (2), 270 (3) } degrees"},\
#define IN_ARGS { PARAM_INT32, "run_mode", "Interactive, non-interactive"},\
{ PARAM_IMAGE, "image", "Input image" },\
{ PARAM_DRAWABLE, "drawable", "Input drawable"},\
{ PARAM_INT32, "angle", "Angle { 90 (1), 180 (2), 270 (3) } degrees"},\
{ PARAM_INT32, "everything", "Rotate the whole image? { TRUE, FALSE }"}
#define NUMBER_OUT_ARGS 0
@ -86,6 +87,13 @@ typedef struct {
gint run;
} RotateInterface;
typedef struct
{
gint32 ID;
gint32 orientation;
gint32 position;
} GuideInfo;
static RotateValues rotvals =
{
1, /* default to 90 degrees */
@ -98,27 +106,32 @@ static RotateInterface rotint =
};
static void query (void);
static void run (gchar *name,
gint nparams, /* number of parameters passed in */
GParam * param, /* parameters passed in */
gint *nreturn_vals, /* number of parameters returned */
GParam ** return_vals); /* parameters to be returned */
static void rotate (void);
static void rotate_drawable (GDrawable *drawable);
static void rotate_compute_offsets (gint *offsetx,
gint *offsety,
gint image_width, gint image_height,
gint width, gint height);
static gint rotate_dialog (void);
static void rotate_close_callback (GtkWidget *widget,
gpointer data);
static void rotate_ok_callback (GtkWidget *widget,
gpointer data);
static void rotate_toggle_update (GtkWidget *widget,
gpointer data);
gint32 my_gimp_selection_float (gint32 image_ID, gint32 drawable_ID);
gint32 my_gimp_selection_is_empty (gint32 image_ID);
static void query (void);
static void run (gchar *name,
gint nparams,
GParam *param,
gint *nreturn_vals,
GParam **return_vals);
static void rotate (void);
static void rotate_drawable (GDrawable *drawable);
static void rotate_compute_offsets (gint *offsetx,
gint *offsety,
gint image_width,
gint image_height,
gint width,
gint height);
static gint rotate_dialog (void);
static void rotate_close_callback (GtkWidget *widget,
gpointer data);
static void rotate_ok_callback (GtkWidget *widget,
gpointer data);
static void rotate_toggle_update (GtkWidget *widget,
gpointer data);
static gint32 my_gimp_selection_float (gint32 image_ID,
gint32 drawable_ID);
static gint32 my_gimp_selection_is_empty (gint32 image_ID);
/* Global Variables */
GPlugInInfo PLUG_IN_INFO =
@ -255,7 +268,7 @@ run (gchar *name, /* name of plugin */
/* Some helper functions */
gint32
static gint32
my_gimp_selection_is_empty (gint32 image_ID)
{
GParam *return_vals;
@ -279,8 +292,9 @@ my_gimp_selection_is_empty (gint32 image_ID)
return is_empty;
}
gint32
my_gimp_selection_float (gint32 image_ID, gint32 drawable_ID)
static gint32
my_gimp_selection_float (gint32 image_ID,
gint32 drawable_ID)
{
GParam *return_vals;
gint nreturn_vals;
@ -304,10 +318,12 @@ my_gimp_selection_float (gint32 image_ID, gint32 drawable_ID)
}
static void
rotate_compute_offsets (gint* offsetx,
gint* offsety,
gint image_width, gint image_height,
gint width, gint height)
rotate_compute_offsets (gint *offsetx,
gint *offsety,
gint image_width,
gint image_height,
gint width,
gint height)
{
gint buffer;
@ -493,7 +509,12 @@ rotate (void)
gint nreturn_vals;
GDrawable *drawable;
gint32 *layers;
gint i, nlayers;
gint i;
gint nlayers;
gint32 guide_ID;
GuideInfo *guide;
GList *guides = NULL;
GList *list;
if (rotvals.angle == 0) return;
@ -521,7 +542,10 @@ rotate (void)
PARAM_IMAGE, image_ID, PARAM_END);
if (rotvals.everything) /* rotate the whole image */
{
{
gint32 width = gimp_image_width (image_ID);
gint32 height = gimp_image_height (image_ID);
gimp_drawable_detach (active_drawable);
layers = gimp_image_get_layers (image_ID, &nlayers);
for ( i=0; i<nlayers; i++ )
@ -531,12 +555,71 @@ rotate (void)
gimp_drawable_detach (drawable);
}
g_free(layers);
if (rotvals.angle != 2)
/* build a list of all guides and remove them */
guide_ID = 0;
while ((guide_ID = gimp_image_find_next_guide (image_ID, guide_ID)) != 0)
{
gimp_image_resize (image_ID,
gimp_image_height(image_ID),
gimp_image_width(image_ID),
0, 0);
guide = g_new (GuideInfo, 1);
guide->ID = guide_ID;
guide->orientation = gimp_image_get_guide_orientation (image_ID, guide_ID);
guide->position = gimp_image_get_guide_position (image_ID, guide_ID);
guides = g_list_prepend (guides, guide);
}
for (list = guides; list; list = list->next)
{
guide = (GuideInfo *)list->data;
gimp_image_delete_guide (image_ID, guide->ID);
}
/* if rotation is not 180 degrees, resize the image */
/* Do it now after the guides are removed, since */
/* gimp_image_resize() moves the guides. */
if (rotvals.angle != 2)
gimp_image_resize (image_ID, height, width, 0, 0);
/* add the guides back to the image */
if (guides)
{
switch (rotvals.angle)
{
case 1:
for (list = guides; list; list = list->next)
{
guide = (GuideInfo *)list->data;
if (guide->orientation == ORIENTATION_HORIZONTAL)
gimp_image_add_vguide (image_ID, height - guide->position);
else
gimp_image_add_hguide (image_ID, guide->position);
g_free (guide);
}
break;
case 2:
for (list = guides; list; list = list->next)
{
guide = (GuideInfo *)list->data;
if (guide->orientation == ORIENTATION_HORIZONTAL)
gimp_image_add_hguide (image_ID, height - guide->position);
else
gimp_image_add_vguide (image_ID, width - guide->position);
g_free (guide);
}
break;
case 3:
for (list = guides; list; list = list->next)
{
guide = (GuideInfo *)list->data;
if (guide->orientation == ORIENTATION_HORIZONTAL)
gimp_image_add_vguide (image_ID, guide->position);
else
gimp_image_add_hguide (image_ID, width - guide->position);
g_free (guide);
}
break;
default:
break;
}
g_list_free (guides);
}
}
else /* rotate only the active layer */

View File

@ -55,6 +55,7 @@ HELP
if (offset < gimage->$max)
{
guide = gimp_image_add_${func}guide (gimage);
undo_push_guide (gimage, guide);
guide->position = offset;
guide_id = guide->guide_ID;
}
@ -111,10 +112,8 @@ HELP
tmp_next = guides->next;
((Guide *) guides->data)->position = -1;
undo_push_guide (gimage, ((Guide *) guides->data));
/* gimp_image_remove_guide (gimage, ((Guide *) guides->data)); */
gimp_image_delete_guide (gimage, (Guide *) guides->data);
guides = tmp_next;
}
else