app/core/gimpchannel.c app/core/gimpdrawable.c app/core/gimplayer.c

2005-12-23  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpchannel.c
	* app/core/gimpdrawable.c
	* app/core/gimplayer.c
	* app/core/gimplayermask.c
	* app/text/gimptextlayer.c
	* app/vectors/gimpvectors.c: moved variables to local scopes in
	implementations of GimpItem::duplicate()
This commit is contained in:
Michael Natterer 2005-12-23 01:15:19 +00:00 committed by Michael Natterer
parent 14d43a50d2
commit 54c86f97f7
7 changed files with 111 additions and 112 deletions

View File

@ -1,3 +1,13 @@
2005-12-23 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c
* app/core/gimpdrawable.c
* app/core/gimplayer.c
* app/core/gimplayermask.c
* app/text/gimptextlayer.c
* app/vectors/gimpvectors.c: moved variables to local scopes in
implementations of GimpItem::duplicate()
2005-12-23 Simon Budig <simon@gimp.org>
* app/vectors/gimpbezierstroke.c

View File

@ -377,9 +377,7 @@ gimp_channel_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpChannel *channel;
GimpItem *new_item;
GimpChannel *new_channel;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
@ -389,11 +387,10 @@ gimp_channel_duplicate (GimpItem *item,
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha);
if (! GIMP_IS_CHANNEL (new_item))
return new_item;
channel = GIMP_CHANNEL (item);
new_channel = GIMP_CHANNEL (new_item);
if (GIMP_IS_CHANNEL (new_item))
{
GimpChannel *channel = GIMP_CHANNEL (item);
GimpChannel *new_channel = GIMP_CHANNEL (new_item);
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
@ -405,6 +402,7 @@ gimp_channel_duplicate (GimpItem *item,
new_channel->y1 = channel->y1;
new_channel->x2 = channel->x2;
new_channel->y2 = channel->y2;
}
return new_item;
}

View File

@ -302,23 +302,20 @@ gimp_drawable_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpDrawable *drawable;
GimpItem *new_item;
GimpDrawable *new_drawable;
GimpImageType new_image_type;
PixelRegion srcPR;
PixelRegion destPR;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha);
if (! GIMP_IS_DRAWABLE (new_item))
return new_item;
drawable = GIMP_DRAWABLE (item);
new_drawable = GIMP_DRAWABLE (new_item);
if (GIMP_IS_DRAWABLE (new_item))
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GimpDrawable *new_drawable = GIMP_DRAWABLE (new_item);
GimpImageType new_image_type;
PixelRegion srcPR;
PixelRegion destPR;
if (add_alpha)
new_image_type = gimp_drawable_type_with_alpha (drawable);
@ -326,7 +323,7 @@ gimp_drawable_duplicate (GimpItem *item,
new_image_type = gimp_drawable_type (drawable);
gimp_drawable_configure (new_drawable,
gimp_item_get_image (GIMP_ITEM (drawable)),
gimp_item_get_image (item),
item->offset_x,
item->offset_y,
item->width,
@ -349,6 +346,7 @@ gimp_drawable_duplicate (GimpItem *item,
copy_region (&srcPR, &destPR);
else
add_alpha_region (&srcPR, &destPR);
}
return new_item;
}

View File

@ -514,20 +514,17 @@ gimp_layer_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpLayer *layer;
GimpItem *new_item;
GimpLayer *new_layer;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha);
if (! GIMP_IS_LAYER (new_item))
return new_item;
layer = GIMP_LAYER (item);
new_layer = GIMP_LAYER (new_item);
if (GIMP_IS_LAYER (new_item))
{
GimpLayer *layer = GIMP_LAYER (item);;
GimpLayer *new_layer = GIMP_LAYER (new_item);
new_layer->mode = layer->mode;
new_layer->opacity = layer->opacity;
@ -536,10 +533,12 @@ gimp_layer_duplicate (GimpItem *item,
/* duplicate the layer mask if necessary */
if (layer->mask)
{
GimpItem *dup = gimp_item_duplicate (GIMP_ITEM (layer->mask),
GimpItem *new_mask =
gimp_item_duplicate (GIMP_ITEM (layer->mask),
G_TYPE_FROM_INSTANCE (layer->mask),
FALSE);
gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (dup), FALSE);
gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (new_mask), FALSE);
}
}
return new_item;

View File

@ -128,24 +128,22 @@ gimp_layer_mask_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpLayerMask *layer_mask;
GimpItem *new_item;
GimpLayerMask *new_layer_mask;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha);
if (! GIMP_IS_LAYER_MASK (new_item))
return new_item;
layer_mask = GIMP_LAYER_MASK (item);
new_layer_mask = GIMP_LAYER_MASK (new_item);
if (GIMP_IS_LAYER_MASK (new_item))
{
GimpLayerMask *layer_mask = GIMP_LAYER_MASK (item);
GimpLayerMask *new_layer_mask = GIMP_LAYER_MASK (new_item);
new_layer_mask->apply_mask = layer_mask->apply_mask;
new_layer_mask->edit_mask = layer_mask->edit_mask;
new_layer_mask->show_mask = layer_mask->show_mask;
}
return new_item;
}

View File

@ -244,8 +244,6 @@ gimp_text_layer_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpTextLayer *layer;
GimpTextLayer *new_layer;
GimpItem *new_item;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
@ -254,11 +252,10 @@ gimp_text_layer_duplicate (GimpItem *item,
new_type,
add_alpha);
if (! GIMP_IS_TEXT_LAYER (new_item))
return new_item;
layer = GIMP_TEXT_LAYER (item);
new_layer = GIMP_TEXT_LAYER (new_item);
if (GIMP_IS_TEXT_LAYER (new_item))
{
GimpTextLayer *layer = GIMP_TEXT_LAYER (item);
GimpTextLayer *new_layer = GIMP_TEXT_LAYER (new_item);
gimp_config_sync (G_OBJECT (layer), G_OBJECT (new_layer), 0);
@ -274,6 +271,7 @@ gimp_text_layer_duplicate (GimpItem *item,
/* this is just the parasite name, not a pointer to the parasite */
if (layer->text_parasite)
new_layer->text_parasite = layer->text_parasite;
}
return new_item;
}

View File

@ -274,22 +274,20 @@ gimp_vectors_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpVectors *vectors;
GimpItem *new_item;
GimpVectors *new_vectors;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_VECTORS), NULL);
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha);
if (! GIMP_IS_VECTORS (new_item))
return new_item;
vectors = GIMP_VECTORS (item);
new_vectors = GIMP_VECTORS (new_item);
if (GIMP_IS_VECTORS (new_item))
{
GimpVectors *vectors = GIMP_VECTORS (item);
GimpVectors *new_vectors = GIMP_VECTORS (new_item);
gimp_vectors_copy_strokes (vectors, new_vectors);
}
return new_item;
}