Commit 2d56352b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed enum value GIMP_UNDO_GROUP_EDIT_COPY (I have no idea why we used

2003-12-09  Michael Natterer  <mitch@gimp.org>

	* app/core/core-enums.[ch]: removed enum value
	GIMP_UNDO_GROUP_EDIT_COPY (I have no idea why we used to push an
	undo group around "Copy"...).

	* app/core/gimp-edit.c (gimp_edit_extract): new utility function
	which does everything needed for cut and copy and does not push an
	undo group for copy.

	(gimp_edit_cut,copy): removed lots of duplicated code and call
	gimp_edit_extract().

	(gimp_edit_paste,paste_as_new): no need to call
	gimp_item_set_image() on newly created layers.
parent 62f48d3e
2003-12-09 Michael Natterer <mitch@gimp.org>
* app/core/core-enums.[ch]: removed enum value
GIMP_UNDO_GROUP_EDIT_COPY (I have no idea why we used to push an
undo group around "Copy"...).
* app/core/gimp-edit.c (gimp_edit_extract): new utility function
which does everything needed for cut and copy and does not push an
undo group for copy.
(gimp_edit_cut,copy): removed lots of duplicated code and call
gimp_edit_extract().
(gimp_edit_paste,paste_as_new): no need to call
gimp_item_set_image() on newly created layers.
2003-12-09 Michael Natterer <mitch@gimp.org>
* app/core/gimplayer-floating-sel.c (floating_sel_attach): changed
......@@ -576,7 +576,6 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_GROUP_FS_ANCHOR, N_("Anchor Floating Selection"), "group-fs-anchor" },
{ GIMP_UNDO_GROUP_EDIT_PASTE, N_("Paste"), "group-edit-paste" },
{ GIMP_UNDO_GROUP_EDIT_CUT, N_("Cut"), "group-edit-cut" },
{ GIMP_UNDO_GROUP_EDIT_COPY, N_("Copy"), "group-edit-copy" },
{ GIMP_UNDO_GROUP_TEXT, N_("Text"), "group-text" },
{ GIMP_UNDO_GROUP_TRANSFORM, N_("Transform"), "group-transform" },
{ GIMP_UNDO_GROUP_PAINT, N_("Paint"), "group-paint" },
......
......@@ -415,7 +415,6 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_GROUP_FS_ANCHOR, /*< desc="Anchor Floating Selection" >*/
GIMP_UNDO_GROUP_EDIT_PASTE, /*< desc="Paste" >*/
GIMP_UNDO_GROUP_EDIT_CUT, /*< desc="Cut" >*/
GIMP_UNDO_GROUP_EDIT_COPY, /*< desc="Copy" >*/
GIMP_UNDO_GROUP_TEXT, /*< desc="Text" >*/
GIMP_UNDO_GROUP_TRANSFORM, /*< desc="Transform" >*/
GIMP_UNDO_GROUP_PAINT, /*< desc="Paint" >*/
......
......@@ -47,10 +47,13 @@
/* local function protypes */
static gboolean gimp_edit_fill_internal (GimpImage *gimage,
GimpDrawable *drawable,
GimpFillType fill_type,
const gchar *undo_desc);
static const GimpBuffer * gimp_edit_extract (GimpImage *gimage,
GimpDrawable *drawable,
gboolean cut_pixels);
static gboolean gimp_edit_fill_internal (GimpImage *gimage,
GimpDrawable *drawable,
GimpFillType fill_type,
const gchar *undo_desc);
/* public functions */
......@@ -59,116 +62,20 @@ const GimpBuffer *
gimp_edit_cut (GimpImage *gimage,
GimpDrawable *drawable)
{
TileManager *tiles;
gboolean empty;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
/* Start a group undo */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_CUT,
_("Cut"));
/* See if the gimage mask is empty */
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
/* Next, cut the mask portion from the gimage */
tiles = gimp_selection_extract (gimp_image_get_mask (gimage),
drawable, TRUE, FALSE, TRUE);
if (tiles)
gimage->gimp->have_current_cut_buffer = TRUE;
/* Only crop if the gimage mask wasn't empty */
if (tiles && ! empty)
{
TileManager *crop;
crop = tile_manager_crop (tiles, 0);
if (crop != tiles)
{
tile_manager_unref (tiles);
tiles = crop;
}
}
/* end the group undo */
gimp_image_undo_group_end (gimage);
if (tiles)
{
/* Free the old global edit buffer */
if (gimage->gimp->global_buffer)
g_object_unref (gimage->gimp->global_buffer);
/* Set the global edit buffer */
gimage->gimp->global_buffer = gimp_buffer_new (tiles,
"Global Buffer",
FALSE);
return gimage->gimp->global_buffer;
}
return NULL;
return gimp_edit_extract (gimage, drawable, TRUE);
}
const GimpBuffer *
gimp_edit_copy (GimpImage *gimage,
GimpDrawable *drawable)
{
TileManager *tiles;
gboolean empty;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
/* Start a group undo */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_COPY,
_("Copy"));
/* See if the gimage mask is empty */
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
/* First, copy the masked portion of the gimage */
tiles = gimp_selection_extract (gimp_image_get_mask (gimage),
drawable, FALSE, FALSE, TRUE);
if (tiles)
gimage->gimp->have_current_cut_buffer = TRUE;
/* Only crop if the gimage mask wasn't empty */
if (tiles && ! empty)
{
TileManager *crop;
crop = tile_manager_crop (tiles, 0);
if (crop != tiles)
{
tile_manager_unref (tiles);
tiles = crop;
}
}
/* end the group undo */
gimp_image_undo_group_end (gimage);
if (tiles)
{
/* Free the old global edit buffer */
if (gimage->gimp->global_buffer)
g_object_unref (gimage->gimp->global_buffer);
/* Set the global edit buffer */
gimage->gimp->global_buffer = gimp_buffer_new (tiles,
"Global Buffer",
FALSE);
return gimage->gimp->global_buffer;
}
return NULL;
return gimp_edit_extract (gimage, drawable, FALSE);
}
GimpLayer *
......@@ -200,7 +107,6 @@ gimp_edit_paste (GimpImage *gimage,
_("Pasted Layer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer)
return NULL;
......@@ -233,15 +139,10 @@ gimp_edit_paste (GimpImage *gimage,
gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE);
/* if there's a drawable, add a new floating selection */
if (drawable != NULL)
{
floating_sel_attach (layer, drawable);
}
if (drawable)
floating_sel_attach (layer, drawable);
else
{
gimp_item_set_image (GIMP_ITEM (layer), gimage);
gimp_image_add_layer (gimage, layer, 0);
}
gimp_image_add_layer (gimage, layer, 0);
/* end the group undo */
gimp_image_undo_group_end (gimage);
......@@ -280,13 +181,11 @@ gimp_edit_paste_as_new (Gimp *gimp,
if (layer)
{
gimp_item_set_image (GIMP_ITEM (layer), gimage);
gimp_image_add_layer (gimage, layer, 0);
gimp_image_undo_enable (gimage);
gimp_create_display (gimp, gimage, 0x0101);
g_object_unref (gimage);
return gimage;
......@@ -351,6 +250,58 @@ gimp_edit_fill (GimpImage *gimage,
/* private functions */
const GimpBuffer *
gimp_edit_extract (GimpImage *gimage,
GimpDrawable *drawable,
gboolean cut_pixels)
{
TileManager *tiles;
gboolean empty;
/* See if the gimage mask is empty */
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
if (cut_pixels)
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_CUT, _("Cut"));
/* Cut/copy the mask portion from the gimage */
tiles = gimp_selection_extract (gimp_image_get_mask (gimage),
drawable, cut_pixels, FALSE, TRUE);
if (cut_pixels)
gimp_image_undo_group_end (gimage);
if (tiles)
{
/* Only crop if the gimage mask wasn't empty */
if (! empty)
{
TileManager *crop;
crop = tile_manager_crop (tiles, 0);
if (crop != tiles)
{
tile_manager_unref (tiles);
tiles = crop;
}
}
/* Set the global edit buffer */
if (gimage->gimp->global_buffer)
g_object_unref (gimage->gimp->global_buffer);
gimage->gimp->global_buffer = gimp_buffer_new (tiles, "Global Buffer",
FALSE);
gimage->gimp->have_current_cut_buffer = TRUE;
return gimage->gimp->global_buffer;
}
return NULL;
}
static gboolean
gimp_edit_fill_internal (GimpImage *gimage,
GimpDrawable *drawable,
......
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