added new virtual function duplicate() as replacement for all

2003-02-11  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpitem.[ch]: added new virtual function duplicate()
	as replacement for all gimp_*_copy() functions.

	* app/core/gimpchannel.[ch]
	* app/core/gimpdrawable.[ch]
	* app/core/gimplayer.[ch]
	* app/core/gimplayermask.[ch]
	* app/vectors/gimpvectors.[ch]: replaced public copy() functions
	by duplicate() implementations.

	* app/text/gimptextlayer.c: added a duplicate() implementation.

	* app/widgets/gimpitemlistview.[ch]: removed the "copy_item_func"
	and simply call gimp_item_duplicate().

	* app/undo.c
	* app/core/gimpimage-duplicate.c
	* app/core/gimpimage-mask.c
	* app/core/gimpimage-qmask.c
	* app/gui/channels-commands.c
	* app/gui/dialogs-constructors.c
	* app/gui/layers-commands.c
	* app/gui/vectors-commands.c
	* app/widgets/gimptoolbox.c
	* tools/pdbgen/pdb/channel.pdb
	* tools/pdbgen/pdb/layer.pdb
	* tools/pdbgen/pdb/selection.pdb: changed accordingly.

	* app/pdb/channel_cmds.c
	* app/pdb/layer_cmds.c
	* app/pdb/selection_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2003-02-11 13:52:47 +00:00 committed by Michael Natterer
parent b0223ce4f9
commit 436ed648e8
41 changed files with 563 additions and 421 deletions

View File

@ -1,3 +1,37 @@
2003-02-11 Michael Natterer <mitch@gimp.org>
* app/core/gimpitem.[ch]: added new virtual function duplicate()
as replacement for all gimp_*_copy() functions.
* app/core/gimpchannel.[ch]
* app/core/gimpdrawable.[ch]
* app/core/gimplayer.[ch]
* app/core/gimplayermask.[ch]
* app/vectors/gimpvectors.[ch]: replaced public copy() functions
by duplicate() implementations.
* app/text/gimptextlayer.c: added a duplicate() implementation.
* app/widgets/gimpitemlistview.[ch]: removed the "copy_item_func"
and simply call gimp_item_duplicate().
* app/undo.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.c
* app/core/gimpimage-qmask.c
* app/gui/channels-commands.c
* app/gui/dialogs-constructors.c
* app/gui/layers-commands.c
* app/gui/vectors-commands.c
* app/widgets/gimptoolbox.c
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c
* app/pdb/selection_cmds.c: regenerated.
2003-02-11 Sven Neumann <sven@gimp.org> 2003-02-11 Sven Neumann <sven@gimp.org>
* plug-ins/common/uniteditor.c: argh, the "cell-background-gdk" * plug-ins/common/uniteditor.c: argh, the "cell-background-gdk"

View File

@ -120,9 +120,9 @@ channels_duplicate_channel_cmd_callback (GtkWidget *widget,
GimpChannel *new_channel; GimpChannel *new_channel;
return_if_no_channel (gimage, active_channel, data); return_if_no_channel (gimage, active_channel, data);
new_channel = gimp_channel_copy (active_channel, new_channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (active_channel),
G_TYPE_FROM_INSTANCE (active_channel), G_TYPE_FROM_INSTANCE (active_channel),
TRUE); TRUE));
gimp_image_add_channel (gimage, new_channel, -1); gimp_image_add_channel (gimage, new_channel, -1);
gimp_image_flush (gimage); gimp_image_flush (gimage);
} }

View File

@ -200,9 +200,9 @@ layers_duplicate_cmd_callback (GtkWidget *widget,
GimpLayer *new_layer; GimpLayer *new_layer;
return_if_no_layer (gimage, active_layer, data); return_if_no_layer (gimage, active_layer, data);
new_layer = gimp_layer_copy (active_layer, new_layer = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (active_layer),
G_TYPE_FROM_INSTANCE (active_layer), G_TYPE_FROM_INSTANCE (active_layer),
TRUE); TRUE));
gimp_image_add_layer (gimage, new_layer, -1); gimp_image_add_layer (gimage, new_layer, -1);
gimp_image_flush (gimage); gimp_image_flush (gimage);

View File

@ -122,9 +122,9 @@ vectors_duplicate_vectors_cmd_callback (GtkWidget *widget,
GimpVectors *new_vectors; GimpVectors *new_vectors;
return_if_no_vectors (gimage, active_vectors, data); return_if_no_vectors (gimage, active_vectors, data);
new_vectors = gimp_vectors_copy (active_vectors, new_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (active_vectors),
G_TYPE_FROM_INSTANCE (active_vectors), G_TYPE_FROM_INSTANCE (active_vectors),
TRUE); TRUE));
gimp_image_add_vectors (gimage, new_vectors, -1); gimp_image_add_vectors (gimage, new_vectors, -1);
gimp_image_flush (gimage); gimp_image_flush (gimage);
} }

View File

@ -48,16 +48,20 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
static void gimp_channel_class_init (GimpChannelClass *klass); static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel); static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_finalize (GObject *object); static void gimp_channel_finalize (GObject *object);
static gsize gimp_channel_get_memsize (GimpObject *object); static gsize gimp_channel_get_memsize (GimpObject *object);
static void gimp_channel_push_undo (GimpChannel *mask); static GimpItem * gimp_channel_duplicate (GimpItem *item,
static void gimp_channel_validate (TileManager *tm, GType new_type,
Tile *tile); gboolean add_alpha);
static void gimp_channel_push_undo (GimpChannel *mask);
static void gimp_channel_validate (TileManager *tm,
Tile *tile);
static GimpDrawableClass * parent_class = NULL; static GimpDrawableClass * parent_class = NULL;
@ -96,15 +100,19 @@ gimp_channel_class_init (GimpChannelClass *klass)
{ {
GObjectClass *object_class; GObjectClass *object_class;
GimpObjectClass *gimp_object_class; GimpObjectClass *gimp_object_class;
GimpItemClass *item_class;
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass); gimp_object_class = GIMP_OBJECT_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_channel_finalize; object_class->finalize = gimp_channel_finalize;
gimp_object_class->get_memsize = gimp_channel_get_memsize; gimp_object_class->get_memsize = gimp_channel_get_memsize;
item_class->duplicate = gimp_channel_duplicate;
} }
static void static void
@ -164,6 +172,45 @@ gimp_channel_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
} }
static GimpItem *
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);
if (g_type_is_a (new_type, GIMP_TYPE_CHANNEL))
add_alpha = FALSE;
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);
/* set the channel color and opacity */
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
new_channel->bounds_known = channel->bounds_known;
new_channel->empty = channel->empty;
new_channel->x1 = channel->x1;
new_channel->y1 = channel->y1;
new_channel->x2 = channel->x2;
new_channel->y2 = channel->y2;
return new_item;
}
static void static void
gimp_channel_push_undo (GimpChannel *mask) gimp_channel_push_undo (GimpChannel *mask)
{ {
@ -224,41 +271,6 @@ gimp_channel_new (GimpImage *gimage,
return channel; return channel;
} }
GimpChannel *
gimp_channel_copy (const GimpChannel *channel,
GType new_type,
gboolean dummy) /* the dummy is for symmetry with
* gimp_layer_copy() because
* both functions are used as
* function pointers in
* GimpDrawableListView --Mitch
*/
{
GimpChannel *new_channel;
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_CHANNEL), NULL);
new_channel = GIMP_CHANNEL (gimp_drawable_copy (GIMP_DRAWABLE (channel),
new_type,
FALSE));
/* set the channel color and opacity */
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
new_channel->bounds_known = channel->bounds_known;
new_channel->empty = channel->empty;
new_channel->x1 = channel->x1;
new_channel->y1 = channel->y1;
new_channel->x2 = channel->x2;
new_channel->y2 = channel->y2;
return new_channel;
}
void void
gimp_channel_set_color (GimpChannel *channel, gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color) const GimpRGB *color)

View File

@ -77,9 +77,6 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
gint height, gint height,
const gchar *name, const gchar *name,
const GimpRGB *color); const GimpRGB *color);
GimpChannel * gimp_channel_copy (const GimpChannel *channel,
GType new_type,
gboolean dummy);
gdouble gimp_channel_get_opacity (const GimpChannel *channel); gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel, void gimp_channel_set_opacity (GimpChannel *channel,

View File

@ -48,16 +48,20 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
static void gimp_channel_class_init (GimpChannelClass *klass); static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel); static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_finalize (GObject *object); static void gimp_channel_finalize (GObject *object);
static gsize gimp_channel_get_memsize (GimpObject *object); static gsize gimp_channel_get_memsize (GimpObject *object);
static void gimp_channel_push_undo (GimpChannel *mask); static GimpItem * gimp_channel_duplicate (GimpItem *item,
static void gimp_channel_validate (TileManager *tm, GType new_type,
Tile *tile); gboolean add_alpha);
static void gimp_channel_push_undo (GimpChannel *mask);
static void gimp_channel_validate (TileManager *tm,
Tile *tile);
static GimpDrawableClass * parent_class = NULL; static GimpDrawableClass * parent_class = NULL;
@ -96,15 +100,19 @@ gimp_channel_class_init (GimpChannelClass *klass)
{ {
GObjectClass *object_class; GObjectClass *object_class;
GimpObjectClass *gimp_object_class; GimpObjectClass *gimp_object_class;
GimpItemClass *item_class;
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass); gimp_object_class = GIMP_OBJECT_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_channel_finalize; object_class->finalize = gimp_channel_finalize;
gimp_object_class->get_memsize = gimp_channel_get_memsize; gimp_object_class->get_memsize = gimp_channel_get_memsize;
item_class->duplicate = gimp_channel_duplicate;
} }
static void static void
@ -164,6 +172,45 @@ gimp_channel_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
} }
static GimpItem *
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);
if (g_type_is_a (new_type, GIMP_TYPE_CHANNEL))
add_alpha = FALSE;
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);
/* set the channel color and opacity */
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
new_channel->bounds_known = channel->bounds_known;
new_channel->empty = channel->empty;
new_channel->x1 = channel->x1;
new_channel->y1 = channel->y1;
new_channel->x2 = channel->x2;
new_channel->y2 = channel->y2;
return new_item;
}
static void static void
gimp_channel_push_undo (GimpChannel *mask) gimp_channel_push_undo (GimpChannel *mask)
{ {
@ -224,41 +271,6 @@ gimp_channel_new (GimpImage *gimage,
return channel; return channel;
} }
GimpChannel *
gimp_channel_copy (const GimpChannel *channel,
GType new_type,
gboolean dummy) /* the dummy is for symmetry with
* gimp_layer_copy() because
* both functions are used as
* function pointers in
* GimpDrawableListView --Mitch
*/
{
GimpChannel *new_channel;
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_CHANNEL), NULL);
new_channel = GIMP_CHANNEL (gimp_drawable_copy (GIMP_DRAWABLE (channel),
new_type,
FALSE));
/* set the channel color and opacity */
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
new_channel->bounds_known = channel->bounds_known;
new_channel->empty = channel->empty;
new_channel->x1 = channel->x1;
new_channel->y1 = channel->y1;
new_channel->x2 = channel->x2;
new_channel->y2 = channel->y2;
return new_channel;
}
void void
gimp_channel_set_color (GimpChannel *channel, gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color) const GimpRGB *color)

View File

@ -77,9 +77,6 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
gint height, gint height,
const gchar *name, const gchar *name,
const GimpRGB *color); const GimpRGB *color);
GimpChannel * gimp_channel_copy (const GimpChannel *channel,
GType new_type,
gboolean dummy);
gdouble gimp_channel_get_opacity (const GimpChannel *channel); gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel, void gimp_channel_set_opacity (GimpChannel *channel,

View File

@ -63,14 +63,18 @@ enum
/* local function prototypes */ /* local function prototypes */
static void gimp_drawable_class_init (GimpDrawableClass *klass); static void gimp_drawable_class_init (GimpDrawableClass *klass);
static void gimp_drawable_init (GimpDrawable *drawable); static void gimp_drawable_init (GimpDrawable *drawable);
static void gimp_drawable_finalize (GObject *object); static void gimp_drawable_finalize (GObject *object);
static gsize gimp_drawable_get_memsize (GimpObject *object); static gsize gimp_drawable_get_memsize (GimpObject *object);
static void gimp_drawable_invalidate_preview (GimpViewable *viewable); static void gimp_drawable_invalidate_preview (GimpViewable *viewable);
static GimpItem * gimp_drawable_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
/* private variables */ /* private variables */
@ -114,10 +118,12 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
GObjectClass *object_class; GObjectClass *object_class;
GimpObjectClass *gimp_object_class; GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class; GimpViewableClass *viewable_class;
GimpItemClass *item_class;
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass); gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass); viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
@ -137,6 +143,8 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
viewable_class->invalidate_preview = gimp_drawable_invalidate_preview; viewable_class->invalidate_preview = gimp_drawable_invalidate_preview;
viewable_class->get_preview = gimp_drawable_get_preview; viewable_class->get_preview = gimp_drawable_get_preview;
item_class->duplicate = gimp_drawable_duplicate;
klass->visibility_changed = NULL; klass->visibility_changed = NULL;
} }
@ -213,6 +221,64 @@ gimp_drawable_invalidate_preview (GimpViewable *viewable)
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage)); gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
} }
static GimpItem *
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 (add_alpha)
new_image_type = gimp_drawable_type_with_alpha (drawable);
else
new_image_type = gimp_drawable_type (drawable);
gimp_drawable_configure (new_drawable,
gimp_item_get_image (GIMP_ITEM (drawable)),
drawable->offset_x,
drawable->offset_y,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
new_image_type,
GIMP_OBJECT (new_drawable)->name);
new_drawable->visible = drawable->visible;
pixel_region_init (&srcPR, drawable->tiles,
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
FALSE);
pixel_region_init (&destPR, new_drawable->tiles,
0, 0,
gimp_drawable_width (new_drawable),
gimp_drawable_height (new_drawable),
TRUE);
if (new_image_type == drawable->type)
copy_region (&srcPR, &destPR);
else
add_alpha_region (&srcPR, &destPR);
return new_item;
}
void void
gimp_drawable_configure (GimpDrawable *drawable, gimp_drawable_configure (GimpDrawable *drawable,
GimpImage *gimage, GimpImage *gimage,
@ -251,58 +317,6 @@ gimp_drawable_configure (GimpDrawable *drawable,
drawable->preview_valid = FALSE; drawable->preview_valid = FALSE;
} }
GimpDrawable *
gimp_drawable_copy (GimpDrawable *drawable,
GType new_type,
gboolean add_alpha)
{
GimpDrawable *new_drawable;
GimpImageType new_image_type;
PixelRegion srcPR;
PixelRegion destPR;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
new_drawable = GIMP_DRAWABLE (gimp_item_copy (GIMP_ITEM (drawable),
new_type,
add_alpha));
if (add_alpha)
new_image_type = gimp_drawable_type_with_alpha (drawable);
else
new_image_type = gimp_drawable_type (drawable);
gimp_drawable_configure (new_drawable,
gimp_item_get_image (GIMP_ITEM (drawable)),
drawable->offset_x,
drawable->offset_y,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
new_image_type,
GIMP_OBJECT (new_drawable)->name);
new_drawable->visible = drawable->visible;
pixel_region_init (&srcPR, drawable->tiles,
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
FALSE);
pixel_region_init (&destPR, new_drawable->tiles,
0, 0,
gimp_drawable_width (new_drawable),
gimp_drawable_height (new_drawable),
TRUE);
if (new_image_type == drawable->type)
copy_region (&srcPR, &destPR);
else
add_alpha_region (&srcPR, &destPR);
return new_drawable;
}
void void
gimp_drawable_update (GimpDrawable *drawable, gimp_drawable_update (GimpDrawable *drawable,
gint x, gint x,

View File

@ -71,9 +71,6 @@ void gimp_drawable_configure (GimpDrawable *drawable,
gint height, gint height,
GimpImageType type, GimpImageType type,
const gchar *name); const gchar *name);
GimpDrawable * gimp_drawable_copy (GimpDrawable *drawable,
GType new_type,
gboolean add_alpha);
void gimp_drawable_update (GimpDrawable *drawable, void gimp_drawable_update (GimpDrawable *drawable,
gint x, gint x,

View File

@ -100,7 +100,9 @@ gimp_image_duplicate (GimpImage *gimage)
{ {
layer = (GimpLayer *) list->data; layer = (GimpLayer *) list->data;
new_layer = gimp_layer_copy (layer, G_TYPE_FROM_INSTANCE (layer), FALSE); new_layer = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer),
G_TYPE_FROM_INSTANCE (layer),
FALSE));
gimp_item_set_image (GIMP_ITEM (new_layer), new_gimage); gimp_item_set_image (GIMP_ITEM (new_layer), new_gimage);
@ -135,8 +137,10 @@ gimp_image_duplicate (GimpImage *gimage)
{ {
channel = (GimpChannel *) list->data; channel = (GimpChannel *) list->data;
new_channel = gimp_channel_copy (channel, G_TYPE_FROM_INSTANCE (channel), new_channel =
TRUE); GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
G_TYPE_FROM_INSTANCE (channel),
FALSE));
gimp_item_set_image (GIMP_ITEM (new_channel), new_gimage); gimp_item_set_image (GIMP_ITEM (new_channel), new_gimage);

View File

@ -632,7 +632,9 @@ gimp_image_mask_save (GimpImage *gimage)
mask = gimp_image_get_mask (gimage); mask = gimp_image_get_mask (gimage);
new_channel = gimp_channel_copy (mask, G_TYPE_FROM_INSTANCE (mask), FALSE); new_channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (mask),
G_TYPE_FROM_INSTANCE (mask),
FALSE));
/* saved selections are not visible by default */ /* saved selections are not visible by default */
gimp_drawable_set_visible (GIMP_DRAWABLE (new_channel), FALSE); gimp_drawable_set_visible (GIMP_DRAWABLE (new_channel), FALSE);

View File

@ -93,9 +93,9 @@ gimp_image_set_qmask_state (GimpImage *gimage,
} }
else /* if selection */ else /* if selection */
{ {
mask = gimp_channel_copy (gimp_image_get_mask (gimage), mask = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (gimp_image_get_mask (gimage)),
G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)), G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)),
TRUE); FALSE));
gimp_image_mask_clear (gimage); /* Clear the selection */ gimp_image_mask_clear (gimage); /* Clear the selection */
gimp_image_add_channel (gimage, mask, 0); gimp_image_add_channel (gimage, mask, 0);

View File

@ -93,9 +93,9 @@ gimp_image_set_qmask_state (GimpImage *gimage,
} }
else /* if selection */ else /* if selection */
{ {
mask = gimp_channel_copy (gimp_image_get_mask (gimage), mask = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (gimp_image_get_mask (gimage)),
G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)), G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)),
TRUE); FALSE));
gimp_image_mask_clear (gimage); /* Clear the selection */ gimp_image_mask_clear (gimage); /* Clear the selection */
gimp_image_add_channel (gimage, mask, 0); gimp_image_add_channel (gimage, mask, 0);

View File

@ -2706,9 +2706,9 @@ undo_push_vectors_mod (GimpImage *gimage,
new->free_func = undo_free_vectors_mod; new->free_func = undo_free_vectors_mod;
vmu->vectors = vectors; vmu->vectors = vectors;
vmu->undo_vectors = gimp_vectors_copy (vectors, vmu->undo_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
G_TYPE_FROM_INSTANCE (vectors), G_TYPE_FROM_INSTANCE (vectors),
FALSE); FALSE));
return TRUE; return TRUE;
} }
@ -2729,9 +2729,9 @@ undo_pop_vectors_mod (GimpImage *gimage,
temp = vmu->undo_vectors; temp = vmu->undo_vectors;
vmu->undo_vectors = gimp_vectors_copy (vmu->vectors, vmu->undo_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vmu->vectors),
G_TYPE_FROM_INSTANCE (vmu->vectors), G_TYPE_FROM_INSTANCE (vmu->vectors),
FALSE); FALSE));
gimp_vectors_copy_strokes (temp, vmu->vectors); gimp_vectors_copy_strokes (temp, vmu->vectors);

View File

@ -54,13 +54,17 @@ enum
/* local function prototypes */ /* local function prototypes */
static void gimp_item_class_init (GimpItemClass *klass); static void gimp_item_class_init (GimpItemClass *klass);
static void gimp_item_init (GimpItem *item); static void gimp_item_init (GimpItem *item);
static void gimp_item_finalize (GObject *object); static void gimp_item_finalize (GObject *object);
static void gimp_item_name_changed (GimpObject *object); static void gimp_item_name_changed (GimpObject *object);
static gsize gimp_item_get_memsize (GimpObject *object); static gsize gimp_item_get_memsize (GimpObject *object);
static GimpItem * gimp_item_real_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
/* private variables */ /* private variables */
@ -124,6 +128,7 @@ gimp_item_class_init (GimpItemClass *klass)
gimp_object_class->get_memsize = gimp_item_get_memsize; gimp_object_class->get_memsize = gimp_item_get_memsize;
klass->removed = NULL; klass->removed = NULL;
klass->duplicate = gimp_item_real_duplicate;
} }
static void static void
@ -271,39 +276,10 @@ gimp_item_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
} }
void static GimpItem *
gimp_item_removed (GimpItem *item) gimp_item_real_duplicate (GimpItem *item,
{ GType new_type,
g_return_if_fail (GIMP_IS_ITEM (item)); gboolean add_alpha)
g_signal_emit (item, gimp_item_signals[REMOVED], 0);
}
void
gimp_item_configure (GimpItem *item,
GimpImage *gimage,
const gchar *name)
{
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (item->ID == 0);
g_return_if_fail (item->gimage == 0);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
item->ID = gimage->gimp->next_item_ID++;
g_hash_table_insert (gimage->gimp->item_table,
GINT_TO_POINTER (item->ID),
item);
gimp_item_set_image (item, gimage);
gimp_object_set_name (GIMP_OBJECT (item), name ? name : _("Unnamed"));
}
GimpItem *
gimp_item_copy (GimpItem *item,
GType new_type,
gboolean add_alpha)
{ {
GimpItem *new_item; GimpItem *new_item;
gchar *new_name; gchar *new_name;
@ -352,6 +328,47 @@ gimp_item_copy (GimpItem *item,
return new_item; return new_item;
} }
void
gimp_item_removed (GimpItem *item)
{
g_return_if_fail (GIMP_IS_ITEM (item));
g_signal_emit (item, gimp_item_signals[REMOVED], 0);
}
void
gimp_item_configure (GimpItem *item,
GimpImage *gimage,
const gchar *name)
{
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (item->ID == 0);
g_return_if_fail (item->gimage == 0);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
item->ID = gimage->gimp->next_item_ID++;
g_hash_table_insert (gimage->gimp->item_table,
GINT_TO_POINTER (item->ID),
item);
gimp_item_set_image (item, gimage);
gimp_object_set_name (GIMP_OBJECT (item), name ? name : _("Unnamed"));
}
GimpItem *
gimp_item_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (item->gimage), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_ITEM), NULL);
return GIMP_ITEM_GET_CLASS (item)->duplicate (item, new_type, add_alpha);
}
gint gint
gimp_item_get_ID (GimpItem *item) gimp_item_get_ID (GimpItem *item)
{ {

View File

@ -49,7 +49,13 @@ struct _GimpItemClass
{ {
GimpViewableClass parent_class; GimpViewableClass parent_class;
void (* removed) (GimpItem *item); /* signals */
void (* removed) (GimpItem *item);
/* virtual functions */
GimpItem * (* duplicate) (GimpItem *item,
GType new_type,
gboolean add_alpha);
}; };
@ -60,7 +66,7 @@ void gimp_item_removed (GimpItem *item);
void gimp_item_configure (GimpItem *item, void gimp_item_configure (GimpItem *item,
GimpImage *gimage, GimpImage *gimage,
const gchar *name); const gchar *name);
GimpItem * gimp_item_copy (GimpItem *item, GimpItem * gimp_item_duplicate (GimpItem *item,
GType new_type, GType new_type,
gboolean add_alpha); gboolean add_alpha);

View File

@ -60,20 +60,24 @@ enum
}; };
static void gimp_layer_class_init (GimpLayerClass *klass); static void gimp_layer_class_init (GimpLayerClass *klass);
static void gimp_layer_init (GimpLayer *layer); static void gimp_layer_init (GimpLayer *layer);
static void gimp_layer_finalize (GObject *object); static void gimp_layer_finalize (GObject *object);
static gsize gimp_layer_get_memsize (GimpObject *object); static gsize gimp_layer_get_memsize (GimpObject *object);
static void gimp_layer_invalidate_preview (GimpViewable *viewable); static void gimp_layer_invalidate_preview (GimpViewable *viewable);
static void gimp_layer_transform_color (GimpImage *gimage, static GimpItem * gimp_layer_duplicate (GimpItem *item,
PixelRegion *layerPR, GType new_type,
PixelRegion *bufPR, gboolean add_alpha);
GimpDrawable *drawable,
GimpImageBaseType type); static void gimp_layer_transform_color (GimpImage *gimage,
PixelRegion *layerPR,
PixelRegion *bufPR,
GimpDrawable *drawable,
GimpImageBaseType type);
static guint layer_signals[LAST_SIGNAL] = { 0 }; static guint layer_signals[LAST_SIGNAL] = { 0 };
@ -115,10 +119,12 @@ gimp_layer_class_init (GimpLayerClass *klass)
GObjectClass *object_class; GObjectClass *object_class;
GimpObjectClass *gimp_object_class; GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class; GimpViewableClass *viewable_class;
GimpItemClass *item_class;
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass); gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass); viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
@ -173,6 +179,8 @@ gimp_layer_class_init (GimpLayerClass *klass)
viewable_class->invalidate_preview = gimp_layer_invalidate_preview; viewable_class->invalidate_preview = gimp_layer_invalidate_preview;
item_class->duplicate = gimp_layer_duplicate;
klass->opacity_changed = NULL; klass->opacity_changed = NULL;
klass->mode_changed = NULL; klass->mode_changed = NULL;
klass->preserve_trans_changed = NULL; klass->preserve_trans_changed = NULL;
@ -263,6 +271,46 @@ gimp_layer_invalidate_preview (GimpViewable *viewable)
floating_sel_invalidate (layer); floating_sel_invalidate (layer);
} }
static GimpItem *
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);
new_layer->linked = layer->linked;
new_layer->preserve_trans = layer->preserve_trans;
new_layer->mode = layer->mode;
new_layer->opacity = layer->opacity;
/* duplicate the layer mask if necessary */
if (layer->mask)
{
new_layer->mask =
GIMP_LAYER_MASK (gimp_item_duplicate (GIMP_ITEM (layer->mask),
G_TYPE_FROM_INSTANCE (layer->mask),
FALSE));
gimp_layer_mask_set_layer (new_layer->mask, new_layer);
}
return new_item;
}
static void static void
gimp_layer_transform_color (GimpImage *gimage, gimp_layer_transform_color (GimpImage *gimage,
PixelRegion *layerPR, PixelRegion *layerPR,
@ -336,37 +384,6 @@ gimp_layer_new (GimpImage *gimage,
return layer; return layer;
} }
GimpLayer *
gimp_layer_copy (const GimpLayer *layer,
GType new_type,
gboolean add_alpha)
{
GimpLayer *new_layer;
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_LAYER), NULL);
new_layer = GIMP_LAYER (gimp_drawable_copy (GIMP_DRAWABLE (layer),
new_type,
add_alpha));
new_layer->linked = layer->linked;
new_layer->preserve_trans = layer->preserve_trans;
new_layer->mode = layer->mode;
new_layer->opacity = layer->opacity;
/* duplicate the layer mask if necessary */
if (layer->mask)
{
new_layer->mask = gimp_layer_mask_copy (layer->mask);
gimp_layer_mask_set_layer (new_layer->mask, new_layer);
}
return new_layer;
}
/** /**
* gimp_layer_new_from_tiles: * gimp_layer_new_from_tiles:
* @tiles: The buffer to make the new layer from. * @tiles: The buffer to make the new layer from.
@ -460,18 +477,9 @@ gimp_layer_new_from_drawable (GimpDrawable *drawable,
src_base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)); src_base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
new_base_type = gimp_image_base_type (dest_image); new_base_type = gimp_image_base_type (dest_image);
if (GIMP_IS_LAYER (drawable)) new_drawable = GIMP_DRAWABLE (gimp_item_duplicate (GIMP_ITEM (drawable),
{ GIMP_TYPE_LAYER,
new_drawable = GIMP_DRAWABLE (gimp_layer_copy (GIMP_LAYER (drawable),
G_TYPE_FROM_INSTANCE (drawable),
TRUE)); TRUE));
}
else
{
new_drawable = gimp_drawable_copy (drawable,
GIMP_TYPE_LAYER,
TRUE);
}
if (src_base_type != new_base_type) if (src_base_type != new_base_type)
{ {

View File

@ -81,9 +81,6 @@ GimpLayer * gimp_layer_new (GimpImage *gimage,
const gchar *name, const gchar *name,
gdouble opacity, gdouble opacity,
GimpLayerModeEffects mode); GimpLayerModeEffects mode);
GimpLayer * gimp_layer_copy (const GimpLayer *layer,
GType new_type,
gboolean add_alpha);
GimpLayer * gimp_layer_new_from_tiles (TileManager *tiles, GimpLayer * gimp_layer_new_from_tiles (TileManager *tiles,
GimpImage *dest_gimage, GimpImage *dest_gimage,

View File

@ -45,8 +45,12 @@ enum
}; };
static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass); static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layer_mask); static void gimp_layer_mask_init (GimpLayerMask *layer_mask);
static GimpItem * gimp_layer_mask_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
static guint layer_mask_signals[LAST_SIGNAL] = { 0 }; static guint layer_mask_signals[LAST_SIGNAL] = { 0 };
@ -85,6 +89,10 @@ gimp_layer_mask_get_type (void)
static void static void
gimp_layer_mask_class_init (GimpLayerMaskClass *klass) gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
{ {
GimpItemClass *item_class;
item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
layer_mask_signals[APPLY_CHANGED] = layer_mask_signals[APPLY_CHANGED] =
@ -113,6 +121,8 @@ gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
NULL, NULL, NULL, NULL,
gimp_marshal_VOID__VOID, gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
item_class->duplicate = gimp_layer_mask_duplicate;
} }
static void static void
@ -124,6 +134,33 @@ gimp_layer_mask_init (GimpLayerMask *layer_mask)
layer_mask->show_mask = FALSE; layer_mask->show_mask = FALSE;
} }
static GimpItem *
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);
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 item;
}
GimpLayerMask * GimpLayerMask *
gimp_layer_mask_new (GimpImage *gimage, gimp_layer_mask_new (GimpImage *gimage,
gint width, gint width,
@ -152,25 +189,6 @@ gimp_layer_mask_new (GimpImage *gimage,
return layer_mask; return layer_mask;
} }
GimpLayerMask *
gimp_layer_mask_copy (const GimpLayerMask *layer_mask)
{
GimpLayerMask *new_layer_mask;
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), NULL);
new_layer_mask =
GIMP_LAYER_MASK (gimp_channel_copy (GIMP_CHANNEL (layer_mask),
GIMP_TYPE_LAYER_MASK,
FALSE));
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_layer_mask;
}
void void
gimp_layer_mask_set_layer (GimpLayerMask *layer_mask, gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer) GimpLayer *layer)

View File

@ -63,7 +63,6 @@ GimpLayerMask * gimp_layer_mask_new (GimpImage *gimage,
gint height, gint height,
const gchar *name, const gchar *name,
const GimpRGB *color); const GimpRGB *color);
GimpLayerMask * gimp_layer_mask_copy (const GimpLayerMask *layer_mask);
void gimp_layer_mask_set_layer (GimpLayerMask *layer_mask, void gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer); GimpLayer *layer);

View File

@ -643,7 +643,6 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
(GimpReorderItemFunc) gimp_image_position_layer, (GimpReorderItemFunc) gimp_image_position_layer,
(GimpAddItemFunc) gimp_image_add_layer, (GimpAddItemFunc) gimp_image_add_layer,
(GimpRemoveItemFunc) layers_remove_layer, (GimpRemoveItemFunc) layers_remove_layer,
(GimpCopyItemFunc) gimp_layer_copy,
(GimpConvertItemFunc) gimp_layer_new_from_drawable, (GimpConvertItemFunc) gimp_layer_new_from_drawable,
(GimpNewItemFunc) layers_new_layer_query, (GimpNewItemFunc) layers_new_layer_query,
(GimpEditItemFunc) layers_edit_layer_query, (GimpEditItemFunc) layers_edit_layer_query,
@ -686,7 +685,6 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
(GimpReorderItemFunc) gimp_image_position_channel, (GimpReorderItemFunc) gimp_image_position_channel,
(GimpAddItemFunc) gimp_image_add_channel, (GimpAddItemFunc) gimp_image_add_channel,
(GimpRemoveItemFunc) gimp_image_remove_channel, (GimpRemoveItemFunc) gimp_image_remove_channel,
(GimpCopyItemFunc) gimp_channel_copy,
(GimpConvertItemFunc) NULL, (GimpConvertItemFunc) NULL,
(GimpNewItemFunc) channels_new_channel_query, (GimpNewItemFunc) channels_new_channel_query,
(GimpEditItemFunc) channels_edit_channel_query, (GimpEditItemFunc) channels_edit_channel_query,
@ -726,7 +724,6 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
(GimpReorderItemFunc) gimp_image_position_vectors, (GimpReorderItemFunc) gimp_image_position_vectors,
(GimpAddItemFunc) gimp_image_add_vectors, (GimpAddItemFunc) gimp_image_add_vectors,
(GimpRemoveItemFunc) gimp_image_remove_vectors, (GimpRemoveItemFunc) gimp_image_remove_vectors,
(GimpCopyItemFunc) gimp_vectors_copy,
(GimpConvertItemFunc) NULL, (GimpConvertItemFunc) NULL,
(GimpNewItemFunc) vectors_new_vectors_query, (GimpNewItemFunc) vectors_new_vectors_query,
(GimpEditItemFunc) vectors_edit_vectors_query, (GimpEditItemFunc) vectors_edit_vectors_query,

View File

@ -120,9 +120,9 @@ channels_duplicate_channel_cmd_callback (GtkWidget *widget,
GimpChannel *new_channel; GimpChannel *new_channel;
return_if_no_channel (gimage, active_channel, data); return_if_no_channel (gimage, active_channel, data);
new_channel = gimp_channel_copy (active_channel, new_channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (active_channel),
G_TYPE_FROM_INSTANCE (active_channel), G_TYPE_FROM_INSTANCE (active_channel),
TRUE); TRUE));
gimp_image_add_channel (gimage, new_channel, -1); gimp_image_add_channel (gimage, new_channel, -1);
gimp_image_flush (gimage); gimp_image_flush (gimage);
} }

View File

@ -643,7 +643,6 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
(GimpReorderItemFunc) gimp_image_position_layer, (GimpReorderItemFunc) gimp_image_position_layer,
(GimpAddItemFunc) gimp_image_add_layer, (GimpAddItemFunc) gimp_image_add_layer,
(GimpRemoveItemFunc) layers_remove_layer, (GimpRemoveItemFunc) layers_remove_layer,
(GimpCopyItemFunc) gimp_layer_copy,
(GimpConvertItemFunc) gimp_layer_new_from_drawable, (GimpConvertItemFunc) gimp_layer_new_from_drawable,
(GimpNewItemFunc) layers_new_layer_query, (GimpNewItemFunc) layers_new_layer_query,
(GimpEditItemFunc) layers_edit_layer_query, (GimpEditItemFunc) layers_edit_layer_query,
@ -686,7 +685,6 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
(GimpReorderItemFunc) gimp_image_position_channel, (GimpReorderItemFunc) gimp_image_position_channel,
(GimpAddItemFunc) gimp_image_add_channel, (GimpAddItemFunc) gimp_image_add_channel,
(GimpRemoveItemFunc) gimp_image_remove_channel, (GimpRemoveItemFunc) gimp_image_remove_channel,
(GimpCopyItemFunc) gimp_channel_copy,
(GimpConvertItemFunc) NULL, (GimpConvertItemFunc) NULL,
(GimpNewItemFunc) channels_new_channel_query, (GimpNewItemFunc) channels_new_channel_query,
(GimpEditItemFunc) channels_edit_channel_query, (GimpEditItemFunc) channels_edit_channel_query,
@ -726,7 +724,6 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
(GimpReorderItemFunc) gimp_image_position_vectors, (GimpReorderItemFunc) gimp_image_position_vectors,
(GimpAddItemFunc) gimp_image_add_vectors, (GimpAddItemFunc) gimp_image_add_vectors,
(GimpRemoveItemFunc) gimp_image_remove_vectors, (GimpRemoveItemFunc) gimp_image_remove_vectors,
(GimpCopyItemFunc) gimp_vectors_copy,
(GimpConvertItemFunc) NULL, (GimpConvertItemFunc) NULL,
(GimpNewItemFunc) vectors_new_vectors_query, (GimpNewItemFunc) vectors_new_vectors_query,
(GimpEditItemFunc) vectors_edit_vectors_query, (GimpEditItemFunc) vectors_edit_vectors_query,

View File

@ -200,9 +200,9 @@ layers_duplicate_cmd_callback (GtkWidget *widget,
GimpLayer *new_layer; GimpLayer *new_layer;
return_if_no_layer (gimage, active_layer, data); return_if_no_layer (gimage, active_layer, data);
new_layer = gimp_layer_copy (active_layer, new_layer = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (active_layer),
G_TYPE_FROM_INSTANCE (active_layer), G_TYPE_FROM_INSTANCE (active_layer),
TRUE); TRUE));
gimp_image_add_layer (gimage, new_layer, -1); gimp_image_add_layer (gimage, new_layer, -1);
gimp_image_flush (gimage); gimp_image_flush (gimage);

View File

@ -122,9 +122,9 @@ vectors_duplicate_vectors_cmd_callback (GtkWidget *widget,
GimpVectors *new_vectors; GimpVectors *new_vectors;
return_if_no_vectors (gimage, active_vectors, data); return_if_no_vectors (gimage, active_vectors, data);
new_vectors = gimp_vectors_copy (active_vectors, new_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (active_vectors),
G_TYPE_FROM_INSTANCE (active_vectors), G_TYPE_FROM_INSTANCE (active_vectors),
TRUE); TRUE));
gimp_image_add_vectors (gimage, new_vectors, -1); gimp_image_add_vectors (gimage, new_vectors, -1);
gimp_image_flush (gimage); gimp_image_flush (gimage);
} }

View File

@ -198,7 +198,7 @@ channel_copy_invoker (Gimp *gimp,
success = FALSE; success = FALSE;
if (success) if (success)
success = (copy = gimp_channel_copy (channel, G_TYPE_FROM_INSTANCE (channel), TRUE)) != NULL; success = (copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel), G_TYPE_FROM_INSTANCE (channel), FALSE))) != NULL;
return_args = procedural_db_return_args (&channel_copy_proc, success); return_args = procedural_db_return_args (&channel_copy_proc, success);

View File

@ -251,7 +251,7 @@ layer_copy_invoker (Gimp *gimp,
add_alpha = args[1].value.pdb_int ? TRUE : FALSE; add_alpha = args[1].value.pdb_int ? TRUE : FALSE;
if (success) if (success)
success = (copy = gimp_layer_copy (layer, G_TYPE_FROM_INSTANCE (layer), add_alpha)) != NULL; success = (copy = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer), G_TYPE_FROM_INSTANCE (layer), add_alpha))) != NULL;
return_args = procedural_db_return_args (&layer_copy_proc, success); return_args = procedural_db_return_args (&layer_copy_proc, success);

View File

@ -1024,9 +1024,9 @@ selection_combine_invoker (Gimp *gimp,
if (gimp_drawable_width (GIMP_DRAWABLE (channel)) == gimage->width && if (gimp_drawable_width (GIMP_DRAWABLE (channel)) == gimage->width &&
gimp_drawable_height (GIMP_DRAWABLE (channel)) == gimage->height) gimp_drawable_height (GIMP_DRAWABLE (channel)) == gimage->height)
{ {
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), new_channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (gimp_image_get_mask (gimage)),
G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)), G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)),
TRUE); FALSE));
gimp_channel_combine_mask (new_channel, gimp_channel_combine_mask (new_channel,
channel, channel,
operation, operation,

View File

@ -32,6 +32,8 @@
#include "paint-funcs/paint-funcs.h" #include "paint-funcs/paint-funcs.h"
#include "config/gimpconfig.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "gimptext.h" #include "gimptext.h"
@ -39,20 +41,23 @@
#include "gimptextlayout.h" #include "gimptextlayout.h"
static void gimp_text_layer_class_init (GimpTextLayerClass *klass); static void gimp_text_layer_class_init (GimpTextLayerClass *klass);
static void gimp_text_layer_init (GimpTextLayer *layer); static void gimp_text_layer_init (GimpTextLayer *layer);
static void gimp_text_layer_dispose (GObject *object); static void gimp_text_layer_dispose (GObject *object);
static gsize gimp_text_layer_get_memsize (GimpObject *object); static gsize gimp_text_layer_get_memsize (GimpObject *object);
static TempBuf * gimp_text_layer_get_preview (GimpViewable *viewable, static TempBuf * gimp_text_layer_get_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static GimpItem * gimp_text_layer_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
static void gimp_text_layer_notify_text (GimpTextLayer *layer); static void gimp_text_layer_notify_text (GimpTextLayer *layer);
static gboolean gimp_text_layer_idle_render (GimpTextLayer *layer); static gboolean gimp_text_layer_idle_render (GimpTextLayer *layer);
static gboolean gimp_text_layer_render (GimpTextLayer *layer); static gboolean gimp_text_layer_render (GimpTextLayer *layer);
static void gimp_text_layer_render_layout (GimpTextLayer *layer, static void gimp_text_layer_render_layout (GimpTextLayer *layer,
GimpTextLayout *layout); GimpTextLayout *layout);
static GimpLayerClass *parent_class = NULL; static GimpLayerClass *parent_class = NULL;
@ -92,18 +97,22 @@ gimp_text_layer_class_init (GimpTextLayerClass *klass)
GObjectClass *object_class; GObjectClass *object_class;
GimpObjectClass *gimp_object_class; GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class; GimpViewableClass *viewable_class;
GimpItemClass *item_class;
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass); gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass); viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
object_class->dispose = gimp_text_layer_dispose; object_class->dispose = gimp_text_layer_dispose;
gimp_object_class->get_memsize = gimp_text_layer_get_memsize; gimp_object_class->get_memsize = gimp_text_layer_get_memsize;
viewable_class->get_preview = gimp_text_layer_get_preview; viewable_class->get_preview = gimp_text_layer_get_preview;
item_class->duplicate = gimp_text_layer_duplicate;
} }
static void static void
@ -133,6 +142,64 @@ gimp_text_layer_dispose (GObject *object)
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
static gsize
gimp_text_layer_get_memsize (GimpObject *object)
{
GimpTextLayer *text_layer;
gsize memsize = 0;
text_layer = GIMP_TEXT_LAYER (object);
if (text_layer->text)
{
memsize += sizeof (GimpText);
if (text_layer->text->text)
memsize += strlen (text_layer->text->text);
}
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static TempBuf *
gimp_text_layer_get_preview (GimpViewable *viewable,
gint width,
gint height)
{
return GIMP_VIEWABLE_CLASS (parent_class)->get_preview (viewable,
width, height);
}
static GimpItem *
gimp_text_layer_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpTextLayer *text_layer;
GimpItem *new_item;
GimpTextLayer *new_text_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_TEXT_LAYER (new_item))
return new_item;
text_layer = GIMP_TEXT_LAYER (item);
new_text_layer = GIMP_TEXT_LAYER (new_item);
new_text_layer->text =
GIMP_TEXT (gimp_config_duplicate (G_OBJECT (text_layer->text)));
g_signal_connect_object (new_text_layer->text, "notify",
G_CALLBACK (gimp_text_layer_notify_text),
new_text_layer, G_CONNECT_SWAPPED);
return new_item;
}
GimpLayer * GimpLayer *
gimp_text_layer_new (GimpImage *image, gimp_text_layer_new (GimpImage *image,
GimpText *text) GimpText *text)
@ -176,34 +243,6 @@ gimp_text_layer_get_text (GimpTextLayer *layer)
return layer->text; return layer->text;
} }
static gsize
gimp_text_layer_get_memsize (GimpObject *object)
{
GimpTextLayer *text_layer;
gsize memsize = 0;
text_layer = GIMP_TEXT_LAYER (object);
if (text_layer->text)
{
memsize += sizeof (GimpText);
if (text_layer->text->text)
memsize += strlen (text_layer->text->text);
}
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static TempBuf *
gimp_text_layer_get_preview (GimpViewable *viewable,
gint width,
gint height)
{
return GIMP_VIEWABLE_CLASS (parent_class)->get_preview (viewable,
width, height);
}
static void static void
gimp_text_layer_notify_text (GimpTextLayer *layer) gimp_text_layer_notify_text (GimpTextLayer *layer)
{ {

View File

@ -2706,9 +2706,9 @@ undo_push_vectors_mod (GimpImage *gimage,
new->free_func = undo_free_vectors_mod; new->free_func = undo_free_vectors_mod;
vmu->vectors = vectors; vmu->vectors = vectors;
vmu->undo_vectors = gimp_vectors_copy (vectors, vmu->undo_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
G_TYPE_FROM_INSTANCE (vectors), G_TYPE_FROM_INSTANCE (vectors),
FALSE); FALSE));
return TRUE; return TRUE;
} }
@ -2729,9 +2729,9 @@ undo_pop_vectors_mod (GimpImage *gimage,
temp = vmu->undo_vectors; temp = vmu->undo_vectors;
vmu->undo_vectors = gimp_vectors_copy (vmu->vectors, vmu->undo_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vmu->vectors),
G_TYPE_FROM_INSTANCE (vmu->vectors), G_TYPE_FROM_INSTANCE (vmu->vectors),
FALSE); FALSE));
gimp_vectors_copy_strokes (temp, vmu->vectors); gimp_vectors_copy_strokes (temp, vmu->vectors);

View File

@ -33,12 +33,16 @@
#include "gimpvectors-preview.h" #include "gimpvectors-preview.h"
static void gimp_vectors_class_init (GimpVectorsClass *klass); static void gimp_vectors_class_init (GimpVectorsClass *klass);
static void gimp_vectors_init (GimpVectors *vectors); static void gimp_vectors_init (GimpVectors *vectors);
static void gimp_vectors_finalize (GObject *object); static void gimp_vectors_finalize (GObject *object);
static gsize gimp_vectors_get_memsize (GimpObject *object); static gsize gimp_vectors_get_memsize (GimpObject *object);
static GimpItem * gimp_vectors_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
/* private variables */ /* private variables */
@ -80,10 +84,12 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
GObjectClass *object_class; GObjectClass *object_class;
GimpObjectClass *gimp_object_class; GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class; GimpViewableClass *viewable_class;
GimpItemClass *item_class;
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass); gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass); viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
@ -93,6 +99,8 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
viewable_class->get_new_preview = gimp_vectors_get_new_preview; viewable_class->get_new_preview = gimp_vectors_get_new_preview;
item_class->duplicate = gimp_vectors_duplicate;
klass->changed = NULL; klass->changed = NULL;
klass->stroke_add = NULL; klass->stroke_add = NULL;
@ -140,6 +148,31 @@ gimp_vectors_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
} }
static GimpItem *
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);
gimp_vectors_copy_strokes (vectors, new_vectors);
return new_item;;
}
/* public functions */ /* public functions */
@ -158,27 +191,6 @@ gimp_vectors_new (GimpImage *gimage,
return vectors; return vectors;
} }
GimpVectors *
gimp_vectors_copy (const GimpVectors *vectors,
GType new_type,
gboolean add_alpha /* unused */)
{
GimpVectors *new_vectors;
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_VECTORS), NULL);
new_vectors = GIMP_VECTORS (gimp_item_copy (GIMP_ITEM (vectors),
new_type,
add_alpha));
#ifdef __GNUC__
#warning FIXME: implement gimp_vectors_copy()
#endif
return new_vectors;
}
void void
gimp_vectors_copy_strokes (const GimpVectors *src_vectors, gimp_vectors_copy_strokes (const GimpVectors *src_vectors,
GimpVectors *dest_vectors) GimpVectors *dest_vectors)

View File

@ -96,9 +96,6 @@ GType gimp_vectors_get_type (void) G_GNUC_CONST;
GimpVectors * gimp_vectors_new (GimpImage *gimage, GimpVectors * gimp_vectors_new (GimpImage *gimage,
const gchar *name); const gchar *name);
GimpVectors * gimp_vectors_copy (const GimpVectors *vectors,
GType new_type,
gboolean add_alpha /* unused */);
void gimp_vectors_copy_strokes (const GimpVectors *src_vectors, void gimp_vectors_copy_strokes (const GimpVectors *src_vectors,
GimpVectors *dest_vectors); GimpVectors *dest_vectors);

View File

@ -285,7 +285,6 @@ gimp_item_list_view_new (gint preview_size,
GimpReorderItemFunc reorder_item_func, GimpReorderItemFunc reorder_item_func,
GimpAddItemFunc add_item_func, GimpAddItemFunc add_item_func,
GimpRemoveItemFunc remove_item_func, GimpRemoveItemFunc remove_item_func,
GimpCopyItemFunc copy_item_func,
GimpConvertItemFunc convert_item_func, GimpConvertItemFunc convert_item_func,
GimpNewItemFunc new_item_func, GimpNewItemFunc new_item_func,
GimpEditItemFunc edit_item_func, GimpEditItemFunc edit_item_func,
@ -306,7 +305,6 @@ gimp_item_list_view_new (gint preview_size,
g_return_val_if_fail (reorder_item_func != NULL, NULL); g_return_val_if_fail (reorder_item_func != NULL, NULL);
g_return_val_if_fail (add_item_func != NULL, NULL); g_return_val_if_fail (add_item_func != NULL, NULL);
g_return_val_if_fail (remove_item_func != NULL, NULL); g_return_val_if_fail (remove_item_func != NULL, NULL);
g_return_val_if_fail (copy_item_func != NULL, NULL);
/* convert_item_func may be NULL */ /* convert_item_func may be NULL */
g_return_val_if_fail (new_item_func != NULL, NULL); g_return_val_if_fail (new_item_func != NULL, NULL);
g_return_val_if_fail (edit_item_func != NULL, NULL); g_return_val_if_fail (edit_item_func != NULL, NULL);
@ -348,7 +346,6 @@ gimp_item_list_view_new (gint preview_size,
list_view->reorder_item_func = reorder_item_func; list_view->reorder_item_func = reorder_item_func;
list_view->add_item_func = add_item_func; list_view->add_item_func = add_item_func;
list_view->remove_item_func = remove_item_func; list_view->remove_item_func = remove_item_func;
list_view->copy_item_func = copy_item_func;
list_view->convert_item_func = convert_item_func; list_view->convert_item_func = convert_item_func;
list_view->new_item_func = new_item_func; list_view->new_item_func = new_item_func;
list_view->edit_item_func = edit_item_func; list_view->edit_item_func = edit_item_func;
@ -581,9 +578,10 @@ gimp_item_list_view_duplicate_clicked (GtkWidget *widget,
viewable = view->get_item_func (view->gimage); viewable = view->get_item_func (view->gimage);
new_viewable = view->copy_item_func (viewable, new_viewable = (GimpViewable *)
G_TYPE_FROM_INSTANCE (viewable), gimp_item_duplicate (GIMP_ITEM (viewable),
TRUE); G_TYPE_FROM_INSTANCE (viewable),
TRUE);
if (GIMP_IS_VIEWABLE (new_viewable)) if (GIMP_IS_VIEWABLE (new_viewable))
{ {

View File

@ -39,9 +39,6 @@ typedef void (* GimpAddItemFunc) (GimpImage *gimage,
gint index); gint index);
typedef void (* GimpRemoveItemFunc) (GimpImage *gimage, typedef void (* GimpRemoveItemFunc) (GimpImage *gimage,
GimpViewable *viewable); GimpViewable *viewable);
typedef GimpViewable * (* GimpCopyItemFunc) (GimpViewable *viewable,
GType new_type,
gboolean add_alpha);
typedef GimpViewable * (* GimpConvertItemFunc) (GimpViewable *viewable, typedef GimpViewable * (* GimpConvertItemFunc) (GimpViewable *viewable,
GimpImage *dest_gimage); GimpImage *dest_gimage);
@ -77,7 +74,6 @@ struct _GimpItemListView
GimpReorderItemFunc reorder_item_func; GimpReorderItemFunc reorder_item_func;
GimpAddItemFunc add_item_func; GimpAddItemFunc add_item_func;
GimpRemoveItemFunc remove_item_func; GimpRemoveItemFunc remove_item_func;
GimpCopyItemFunc copy_item_func;
GimpConvertItemFunc convert_item_func; GimpConvertItemFunc convert_item_func;
GimpNewItemFunc new_item_func; GimpNewItemFunc new_item_func;
@ -115,7 +111,6 @@ GtkWidget * gimp_item_list_view_new (gint preview_size,
GimpReorderItemFunc reorder_item_func, GimpReorderItemFunc reorder_item_func,
GimpAddItemFunc add_item_func, GimpAddItemFunc add_item_func,
GimpRemoveItemFunc remove_item_func, GimpRemoveItemFunc remove_item_func,
GimpCopyItemFunc copy_item_func,
GimpConvertItemFunc convert_item_func, GimpConvertItemFunc convert_item_func,
GimpNewItemFunc new_item_func, GimpNewItemFunc new_item_func,
GimpEditItemFunc edit_item_func, GimpEditItemFunc edit_item_func,

View File

@ -285,7 +285,6 @@ gimp_item_list_view_new (gint preview_size,
GimpReorderItemFunc reorder_item_func, GimpReorderItemFunc reorder_item_func,
GimpAddItemFunc add_item_func, GimpAddItemFunc add_item_func,
GimpRemoveItemFunc remove_item_func, GimpRemoveItemFunc remove_item_func,
GimpCopyItemFunc copy_item_func,
GimpConvertItemFunc convert_item_func, GimpConvertItemFunc convert_item_func,
GimpNewItemFunc new_item_func, GimpNewItemFunc new_item_func,
GimpEditItemFunc edit_item_func, GimpEditItemFunc edit_item_func,
@ -306,7 +305,6 @@ gimp_item_list_view_new (gint preview_size,
g_return_val_if_fail (reorder_item_func != NULL, NULL); g_return_val_if_fail (reorder_item_func != NULL, NULL);
g_return_val_if_fail (add_item_func != NULL, NULL); g_return_val_if_fail (add_item_func != NULL, NULL);
g_return_val_if_fail (remove_item_func != NULL, NULL); g_return_val_if_fail (remove_item_func != NULL, NULL);
g_return_val_if_fail (copy_item_func != NULL, NULL);
/* convert_item_func may be NULL */ /* convert_item_func may be NULL */
g_return_val_if_fail (new_item_func != NULL, NULL); g_return_val_if_fail (new_item_func != NULL, NULL);
g_return_val_if_fail (edit_item_func != NULL, NULL); g_return_val_if_fail (edit_item_func != NULL, NULL);
@ -348,7 +346,6 @@ gimp_item_list_view_new (gint preview_size,
list_view->reorder_item_func = reorder_item_func; list_view->reorder_item_func = reorder_item_func;
list_view->add_item_func = add_item_func; list_view->add_item_func = add_item_func;
list_view->remove_item_func = remove_item_func; list_view->remove_item_func = remove_item_func;
list_view->copy_item_func = copy_item_func;
list_view->convert_item_func = convert_item_func; list_view->convert_item_func = convert_item_func;
list_view->new_item_func = new_item_func; list_view->new_item_func = new_item_func;
list_view->edit_item_func = edit_item_func; list_view->edit_item_func = edit_item_func;
@ -581,9 +578,10 @@ gimp_item_list_view_duplicate_clicked (GtkWidget *widget,
viewable = view->get_item_func (view->gimage); viewable = view->get_item_func (view->gimage);
new_viewable = view->copy_item_func (viewable, new_viewable = (GimpViewable *)
G_TYPE_FROM_INSTANCE (viewable), gimp_item_duplicate (GIMP_ITEM (viewable),
TRUE); G_TYPE_FROM_INSTANCE (viewable),
TRUE);
if (GIMP_IS_VIEWABLE (new_viewable)) if (GIMP_IS_VIEWABLE (new_viewable))
{ {

View File

@ -39,9 +39,6 @@ typedef void (* GimpAddItemFunc) (GimpImage *gimage,
gint index); gint index);
typedef void (* GimpRemoveItemFunc) (GimpImage *gimage, typedef void (* GimpRemoveItemFunc) (GimpImage *gimage,
GimpViewable *viewable); GimpViewable *viewable);
typedef GimpViewable * (* GimpCopyItemFunc) (GimpViewable *viewable,
GType new_type,
gboolean add_alpha);
typedef GimpViewable * (* GimpConvertItemFunc) (GimpViewable *viewable, typedef GimpViewable * (* GimpConvertItemFunc) (GimpViewable *viewable,
GimpImage *dest_gimage); GimpImage *dest_gimage);
@ -77,7 +74,6 @@ struct _GimpItemListView
GimpReorderItemFunc reorder_item_func; GimpReorderItemFunc reorder_item_func;
GimpAddItemFunc add_item_func; GimpAddItemFunc add_item_func;
GimpRemoveItemFunc remove_item_func; GimpRemoveItemFunc remove_item_func;
GimpCopyItemFunc copy_item_func;
GimpConvertItemFunc convert_item_func; GimpConvertItemFunc convert_item_func;
GimpNewItemFunc new_item_func; GimpNewItemFunc new_item_func;
@ -115,7 +111,6 @@ GtkWidget * gimp_item_list_view_new (gint preview_size,
GimpReorderItemFunc reorder_item_func, GimpReorderItemFunc reorder_item_func,
GimpAddItemFunc add_item_func, GimpAddItemFunc add_item_func,
GimpRemoveItemFunc remove_item_func, GimpRemoveItemFunc remove_item_func,
GimpCopyItemFunc copy_item_func,
GimpConvertItemFunc convert_item_func, GimpConvertItemFunc convert_item_func,
GimpNewItemFunc new_item_func, GimpNewItemFunc new_item_func,
GimpEditItemFunc edit_item_func, GimpEditItemFunc edit_item_func,

View File

@ -867,15 +867,15 @@ toolbox_drop_drawable (GtkWidget *widget,
if (GIMP_IS_LAYER (drawable)) if (GIMP_IS_LAYER (drawable))
{ {
new_layer = gimp_layer_copy (GIMP_LAYER (drawable), new_layer = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (drawable),
G_TYPE_FROM_INSTANCE (drawable), G_TYPE_FROM_INSTANCE (drawable),
FALSE); FALSE));
} }
else else
{ {
new_layer = GIMP_LAYER (gimp_drawable_copy (drawable, new_layer = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (drawable),
GIMP_TYPE_LAYER, GIMP_TYPE_LAYER,
TRUE)); TRUE));
} }
gimp_item_set_image (GIMP_ITEM (new_layer), new_gimage); gimp_item_set_image (GIMP_ITEM (new_layer), new_gimage);

View File

@ -202,7 +202,7 @@ HELP
desc => 'The newly copied channel', alias => 'copy' } desc => 'The newly copied channel', alias => 'copy' }
); );
%invoke = ( code => 'success = (copy = gimp_channel_copy (channel, G_TYPE_FROM_INSTANCE (channel), TRUE)) != NULL;' ); %invoke = ( code => 'success = (copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel), G_TYPE_FROM_INSTANCE (channel), FALSE))) != NULL;' );
} }
sub channel_delete { sub channel_delete {

View File

@ -289,7 +289,7 @@ HELP
); );
%invoke = ( %invoke = (
code => 'success = (copy = gimp_layer_copy (layer, G_TYPE_FROM_INSTANCE (layer), add_alpha)) != NULL;' code => 'success = (copy = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer), G_TYPE_FROM_INSTANCE (layer), add_alpha))) != NULL;'
); );
} }

View File

@ -370,9 +370,9 @@ HELP
if (gimp_drawable_width (GIMP_DRAWABLE (channel)) == gimage->width && if (gimp_drawable_width (GIMP_DRAWABLE (channel)) == gimage->width &&
gimp_drawable_height (GIMP_DRAWABLE (channel)) == gimage->height) gimp_drawable_height (GIMP_DRAWABLE (channel)) == gimage->height)
{ {
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), new_channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (gimp_image_get_mask (gimage)),
G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)), G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)),
TRUE); FALSE));
gimp_channel_combine_mask (new_channel, gimp_channel_combine_mask (new_channel,
channel, channel,
operation, operation,