Commit 8f6bca32 authored by GMT 2000 Andy Thomas's avatar GMT 2000 Andy Thomas Committed by Andy Thomas

gimp/app/gimpdrawable.c gimp/app/channel.c gimp/app/layer.c


Tue Feb 15 23:27:42 GMT 2000 Andy Thomas <alt@gimp.org>

	 * gimp/app/gimpdrawable.c
	 * gimp/app/channel.c
	 * gimp/app/layer.c
	 * gimp/app/channel.h
	 * gimp/app/layer.h
	 * gimp/app/gimpimage.c
	 * gimp/app/gimpimage.h
	 * gimp/app/gimpdrawable.h
	 * gimp/tools/pdbgen/pdb/paths.pdb
	 * gimp/tools/pdbgen/pdb/layer.pdb
	 * gimp/tools/pdbgen/pdb/channel.pdb
	 * gimp/tools/pdbgen/pdb/gimage.pdb
	 * gimp/app/channel_cmds.c
	 * gimp/app/gimage_cmds.c
	 * gimp/app/internal_procs.c
	 * gimp/app/layer_cmds.c
	 * gimp/app/paths_cmds.c

	New gimp_*_set_tattoo procedures. This allows save/load plugins
        to save/restore tattoo states of layers, channels and paths. Note the
	internal tattoo state can also be set, however rigorous checks are
	performed to make sure that the internal tattoo states of layer,
	channels and paths are consistent and that the new state value is
	newval > MAX(MAX(layertattoo),MAX(channeltattoo),MAX(pathtattoo)).
parent 9ee718ca
Tue Feb 15 23:27:42 GMT 2000 Andy Thomas <alt@gimp.org>
* gimp/app/gimpdrawable.c
* gimp/app/channel.c
* gimp/app/layer.c
* gimp/app/channel.h
* gimp/app/layer.h
* gimp/app/gimpimage.c
* gimp/app/gimpimage.h
* gimp/app/gimpdrawable.h
* gimp/tools/pdbgen/pdb/paths.pdb
* gimp/tools/pdbgen/pdb/layer.pdb
* gimp/tools/pdbgen/pdb/channel.pdb
* gimp/tools/pdbgen/pdb/gimage.pdb
* gimp/app/channel_cmds.c
* gimp/app/gimage_cmds.c
* gimp/app/internal_procs.c
* gimp/app/layer_cmds.c
* gimp/app/paths_cmds.c
New gimp_*_set_tattoo procedures. This allows save/load plugins
to save/restore tattoo states of layers, channels and paths. Note the
internal tattoo state can also be set, however rigorous checks are
performed to make sure that the internal tattoo states of layer,
channels and paths are consistent and that the new state value is
newval > MAX(MAX(layertattoo),MAX(channeltattoo),MAX(pathtattoo)).
Tue Feb 15 13:14:31 CET 2000 Sven Neumann <sven@gimp.org>
* plug-ins/common/unsharp.c:
......
......@@ -590,6 +590,12 @@ channel_get_tattoo (const Channel *channel)
return (gimp_drawable_get_tattoo (GIMP_DRAWABLE (channel)));
}
void
channel_set_tattoo (const Channel *channel, Tattoo val)
{
gimp_drawable_set_tattoo(GIMP_DRAWABLE (channel),val);
}
/******************************/
/* selection mask functions */
/******************************/
......
......@@ -100,6 +100,7 @@ TempBuf * channel_preview (Channel *, gint, gint);
void channel_invalidate_previews (GimpImage*);
Tattoo channel_get_tattoo (const Channel *);
void channel_set_tattoo (const Channel *,Tattoo);
/* selection mask functions */
......
......@@ -39,6 +39,7 @@ static ProcRecord channel_set_opacity_proc;
static ProcRecord channel_get_color_proc;
static ProcRecord channel_set_color_proc;
static ProcRecord channel_get_tattoo_proc;
static ProcRecord channel_set_tattoo_proc;
void
register_channel_procs (void)
......@@ -57,6 +58,7 @@ register_channel_procs (void)
procedural_db_register (&channel_get_color_proc);
procedural_db_register (&channel_set_color_proc);
procedural_db_register (&channel_get_tattoo_proc);
procedural_db_register (&channel_set_tattoo_proc);
}
static Argument *
......@@ -828,8 +830,8 @@ static ProcArg channel_get_tattoo_outargs[] =
static ProcRecord channel_get_tattoo_proc =
{
"gimp_channel_get_tattoo",
"Returns the tattoo associated with the specified channel.",
"This procedure returns the tattoo associated with the specified channel. A tattoo is a unique and permanent identifier attached to a channel that can be used to uniquely identify a channel within an image even between sessions",
"Get the tattoo of the specified channel.",
"This procedure returns the specified channel's tattoo. A tattoo is a unique and permanent identifier attached to a channel that can be used to uniquely identify a channel within an image even between sessions.",
"Jay Cox",
"Jay Cox",
"1998",
......@@ -840,3 +842,54 @@ static ProcRecord channel_get_tattoo_proc =
channel_get_tattoo_outargs,
{ { channel_get_tattoo_invoker } }
};
static Argument *
channel_set_tattoo_invoker (Argument *args)
{
gboolean success = TRUE;
Channel *channel;
gint32 tattoo;
channel = channel_get_ID (args[0].value.pdb_int);
if (channel == NULL)
success = FALSE;
tattoo = args[1].value.pdb_int;
if (tattoo == 0)
success = FALSE;
if (success)
channel_set_tattoo (channel, tattoo);
return procedural_db_return_args (&channel_set_tattoo_proc, success);
}
static ProcArg channel_set_tattoo_inargs[] =
{
{
PDB_CHANNEL,
"channel",
"The channel"
},
{
PDB_INT32,
"tattoo",
"The new channel tattoo"
}
};
static ProcRecord channel_set_tattoo_proc =
{
"gimp_channel_set_tattoo",
"Set the tattoo of the specified channel.",
"This procedure sets the specified channel's tattoo. A tattoo is a unique and permanent identifier attached to a channel that can be used to uniquely identify a channel within an image even between sessions.",
"Jay Cox",
"Jay Cox",
"1998",
PDB_INTERNAL,
2,
channel_set_tattoo_inargs,
0,
NULL,
{ { channel_set_tattoo_invoker } }
};
......@@ -590,6 +590,12 @@ channel_get_tattoo (const Channel *channel)
return (gimp_drawable_get_tattoo (GIMP_DRAWABLE (channel)));
}
void
channel_set_tattoo (const Channel *channel, Tattoo val)
{
gimp_drawable_set_tattoo(GIMP_DRAWABLE (channel),val);
}
/******************************/
/* selection mask functions */
/******************************/
......
......@@ -100,6 +100,7 @@ TempBuf * channel_preview (Channel *, gint, gint);
void channel_invalidate_previews (GimpImage*);
Tattoo channel_get_tattoo (const Channel *);
void channel_set_tattoo (const Channel *,Tattoo);
/* selection mask functions */
......
......@@ -590,6 +590,12 @@ channel_get_tattoo (const Channel *channel)
return (gimp_drawable_get_tattoo (GIMP_DRAWABLE (channel)));
}
void
channel_set_tattoo (const Channel *channel, Tattoo val)
{
gimp_drawable_set_tattoo(GIMP_DRAWABLE (channel),val);
}
/******************************/
/* selection mask functions */
/******************************/
......
......@@ -100,6 +100,7 @@ TempBuf * channel_preview (Channel *, gint, gint);
void channel_invalidate_previews (GimpImage*);
Tattoo channel_get_tattoo (const Channel *);
void channel_set_tattoo (const Channel *,Tattoo);
/* selection mask functions */
......
......@@ -542,6 +542,14 @@ gimp_drawable_get_tattoo (const GimpDrawable *drawable)
return drawable->tattoo;
}
void
gimp_drawable_set_tattoo(GimpDrawable *drawable, Tattoo val)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
drawable->tattoo = val;
}
gboolean
gimp_drawable_is_rgb (GimpDrawable *drawable)
{
......
......@@ -77,6 +77,7 @@ Parasite * gimp_drawable_parasite_find (const GimpDrawable *,
gchar ** gimp_drawable_parasite_list (GimpDrawable *drawable,
gint *count);
Tattoo gimp_drawable_get_tattoo (const GimpDrawable *);
void gimp_drawable_set_tattoo (GimpDrawable *, Tattoo);
GimpDrawable * gimp_drawable_get_ID (gint);
void gimp_drawable_deallocate (GimpDrawable *);
......
......@@ -1169,6 +1169,96 @@ gimp_image_get_new_tattoo (GimpImage *image)
return (image->tattoo_state);
}
Tattoo
gimp_image_get_tattoo_state(GimpImage *image)
{
return (image->tattoo_state);
}
int
gimp_image_set_tattoo_state(GimpImage *gimage, Tattoo val)
{
Layer *layer;
GSList *layers = gimage->layers;
int retval = TRUE;
Channel *channel;
GSList *channels = gimage->channels;
Tattoo maxval = 0;
PATHP pptr = NULL;
PathsList *plist;
while (layers)
{
Tattoo ltattoo;
layer = (Layer *) layers->data;
ltattoo = layer_get_tattoo (layer);
if(ltattoo > maxval)
maxval = ltattoo;
if(gimp_image_get_channel_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in channel */
}
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
layers = g_slist_next (layers);
}
/* Now check that the paths channel tattoos don't overlap */
while (channels)
{
Tattoo ctattoo;
channel = (Channel *) channels->data;
ctattoo = channel_get_tattoo (channel);
if(ctattoo > maxval)
maxval = ctattoo;
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ctattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
channels = g_slist_next (channels);
}
/* Find the max tatto value in the paths */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
Tattoo ptattoo;
while (pl)
{
pptr = pl->data;
ptattoo = paths_get_tattoo (pptr);
if(ptattoo > maxval)
maxval = ptattoo;
pl = pl->next;
}
}
if(val <= maxval)
retval = FALSE;
/* Must check the state is valid */
if(retval == TRUE)
gimage->tattoo_state = val;
return retval;
}
void
gimp_image_colormap_changed (GimpImage *image,
gint col)
......
......@@ -168,6 +168,8 @@ void gimp_image_parasite_attach (GimpImage *, Parasite *);
void gimp_image_parasite_detach (GimpImage *, const gchar *);
Tattoo gimp_image_get_new_tattoo (GimpImage *);
int gimp_image_set_tattoo_state (GimpImage *, Tattoo);
Tattoo gimp_image_get_tattoo_state (GimpImage *);
void gimp_image_set_paths (GimpImage *, PathsList *);
PathsList * gimp_image_get_paths (GimpImage *);
......
......@@ -1169,6 +1169,96 @@ gimp_image_get_new_tattoo (GimpImage *image)
return (image->tattoo_state);
}
Tattoo
gimp_image_get_tattoo_state(GimpImage *image)
{
return (image->tattoo_state);
}
int
gimp_image_set_tattoo_state(GimpImage *gimage, Tattoo val)
{
Layer *layer;
GSList *layers = gimage->layers;
int retval = TRUE;
Channel *channel;
GSList *channels = gimage->channels;
Tattoo maxval = 0;
PATHP pptr = NULL;
PathsList *plist;
while (layers)
{
Tattoo ltattoo;
layer = (Layer *) layers->data;
ltattoo = layer_get_tattoo (layer);
if(ltattoo > maxval)
maxval = ltattoo;
if(gimp_image_get_channel_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in channel */
}
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
layers = g_slist_next (layers);
}
/* Now check that the paths channel tattoos don't overlap */
while (channels)
{
Tattoo ctattoo;
channel = (Channel *) channels->data;
ctattoo = channel_get_tattoo (channel);
if(ctattoo > maxval)
maxval = ctattoo;
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ctattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
channels = g_slist_next (channels);
}
/* Find the max tatto value in the paths */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
Tattoo ptattoo;
while (pl)
{
pptr = pl->data;
ptattoo = paths_get_tattoo (pptr);
if(ptattoo > maxval)
maxval = ptattoo;
pl = pl->next;
}
}
if(val <= maxval)
retval = FALSE;
/* Must check the state is valid */
if(retval == TRUE)
gimage->tattoo_state = val;
return retval;
}
void
gimp_image_colormap_changed (GimpImage *image,
gint col)
......
......@@ -168,6 +168,8 @@ void gimp_image_parasite_attach (GimpImage *, Parasite *);
void gimp_image_parasite_detach (GimpImage *, const gchar *);
Tattoo gimp_image_get_new_tattoo (GimpImage *);
int gimp_image_set_tattoo_state (GimpImage *, Tattoo);
Tattoo gimp_image_get_tattoo_state (GimpImage *);
void gimp_image_set_paths (GimpImage *, PathsList *);
PathsList * gimp_image_get_paths (GimpImage *);
......
......@@ -1169,6 +1169,96 @@ gimp_image_get_new_tattoo (GimpImage *image)
return (image->tattoo_state);
}
Tattoo
gimp_image_get_tattoo_state(GimpImage *image)
{
return (image->tattoo_state);
}
int
gimp_image_set_tattoo_state(GimpImage *gimage, Tattoo val)
{
Layer *layer;
GSList *layers = gimage->layers;
int retval = TRUE;
Channel *channel;
GSList *channels = gimage->channels;
Tattoo maxval = 0;
PATHP pptr = NULL;
PathsList *plist;
while (layers)
{
Tattoo ltattoo;
layer = (Layer *) layers->data;
ltattoo = layer_get_tattoo (layer);
if(ltattoo > maxval)
maxval = ltattoo;
if(gimp_image_get_channel_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in channel */
}
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
layers = g_slist_next (layers);
}
/* Now check that the paths channel tattoos don't overlap */
while (channels)
{
Tattoo ctattoo;
channel = (Channel *) channels->data;
ctattoo = channel_get_tattoo (channel);
if(ctattoo > maxval)
maxval = ctattoo;
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ctattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
channels = g_slist_next (channels);
}
/* Find the max tatto value in the paths */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
Tattoo ptattoo;
while (pl)
{
pptr = pl->data;
ptattoo = paths_get_tattoo (pptr);
if(ptattoo > maxval)
maxval = ptattoo;
pl = pl->next;
}
}
if(val <= maxval)
retval = FALSE;
/* Must check the state is valid */
if(retval == TRUE)
gimage->tattoo_state = val;
return retval;
}
void
gimp_image_colormap_changed (GimpImage *image,
gint col)
......
......@@ -168,6 +168,8 @@ void gimp_image_parasite_attach (GimpImage *, Parasite *);
void gimp_image_parasite_detach (GimpImage *, const gchar *);
Tattoo gimp_image_get_new_tattoo (GimpImage *);
int gimp_image_set_tattoo_state (GimpImage *, Tattoo);
Tattoo gimp_image_get_tattoo_state (GimpImage *);
void gimp_image_set_paths (GimpImage *, PathsList *);
PathsList * gimp_image_get_paths (GimpImage *);
......
......@@ -1169,6 +1169,96 @@ gimp_image_get_new_tattoo (GimpImage *image)
return (image->tattoo_state);
}
Tattoo
gimp_image_get_tattoo_state(GimpImage *image)
{
return (image->tattoo_state);
}
int
gimp_image_set_tattoo_state(GimpImage *gimage, Tattoo val)
{
Layer *layer;
GSList *layers = gimage->layers;
int retval = TRUE;
Channel *channel;
GSList *channels = gimage->channels;
Tattoo maxval = 0;
PATHP pptr = NULL;
PathsList *plist;
while (layers)
{
Tattoo ltattoo;
layer = (Layer *) layers->data;
ltattoo = layer_get_tattoo (layer);
if(ltattoo > maxval)
maxval = ltattoo;
if(gimp_image_get_channel_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in channel */
}
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
layers = g_slist_next (layers);
}
/* Now check that the paths channel tattoos don't overlap */
while (channels)
{
Tattoo ctattoo;
channel = (Channel *) channels->data;
ctattoo = channel_get_tattoo (channel);
if(ctattoo > maxval)
maxval = ctattoo;
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ctattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
channels = g_slist_next (channels);
}
/* Find the max tatto value in the paths */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
Tattoo ptattoo;
while (pl)
{
pptr = pl->data;
ptattoo = paths_get_tattoo (pptr);
if(ptattoo > maxval)
maxval = ptattoo;
pl = pl->next;
}
}
if(val <= maxval)
retval = FALSE;
/* Must check the state is valid */
if(retval == TRUE)
gimage->tattoo_state = val;
return retval;
}
void
gimp_image_colormap_changed (GimpImage *image,
gint col)
......
......@@ -168,6 +168,8 @@ void gimp_image_parasite_attach (GimpImage *, Parasite *);
void gimp_image_parasite_detach (GimpImage *, const gchar *);
Tattoo gimp_image_get_new_tattoo (GimpImage *);
int gimp_image_set_tattoo_state (GimpImage *, Tattoo);
Tattoo gimp_image_get_tattoo_state (GimpImage *);
void gimp_image_set_paths (GimpImage *, PathsList *);
PathsList * gimp_image_get_paths (GimpImage *);
......
......@@ -1169,6 +1169,96 @@ gimp_image_get_new_tattoo (GimpImage *image)
return (image->tattoo_state);
}
Tattoo
gimp_image_get_tattoo_state(GimpImage *image)
{
return (image->tattoo_state);
}
int
gimp_image_set_tattoo_state(GimpImage *gimage, Tattoo val)
{
Layer *layer;
GSList *layers = gimage->layers;
int retval = TRUE;
Channel *channel;
GSList *channels = gimage->channels;
Tattoo maxval = 0;
PATHP pptr = NULL;
PathsList *plist;
while (layers)
{
Tattoo ltattoo;
layer = (Layer *) layers->data;
ltattoo = layer_get_tattoo (layer);
if(ltattoo > maxval)
maxval = ltattoo;
if(gimp_image_get_channel_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in channel */
}
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ltattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
layers = g_slist_next (layers);
}
/* Now check that the paths channel tattoos don't overlap */
while (channels)
{
Tattoo ctattoo;
channel = (Channel *) channels->data;
ctattoo = channel_get_tattoo (channel);
if(ctattoo > maxval)
maxval = ctattoo;
/* Now check path an't got this tattoo */
if(paths_get_path_by_tattoo(gimage,ctattoo) != NULL)
{
retval = FALSE; /* Oopps duplicated tattoo in layer */
}
channels = g_slist_next (channels);
}
/* Find the max tatto value in the paths */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
Tattoo ptattoo;
while (pl)
{
pptr = pl->data;
ptattoo = paths_get_tattoo (pptr);
if(ptattoo > maxval)
maxval = ptattoo;
pl = pl->next;
}
}
if(val <= maxval)
retval = FALSE;