added gimp_image_get_guide() and gimp_image_get_next_guide(), which take a
2006-03-13 Michael Natterer <mitch@gimp.org> * app/core/gimpimage-guides.[ch]: added gimp_image_get_guide() and gimp_image_get_next_guide(), which take a guide_ID and return the image's GimpGuide with that ID (the one after that for next_guide()) * tools/pdbgen/pdb/guides.pdb: use them instead of having this code here. * app/pdb/guides_cmds.c: regenerated.
This commit is contained in:
committed by
Michael Natterer
parent
68ea81c382
commit
4d973a0805
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2006-03-13 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimage-guides.[ch]: added gimp_image_get_guide() and
|
||||
gimp_image_get_next_guide(), which take a guide_ID and return the
|
||||
image's GimpGuide with that ID (the one after that for next_guide())
|
||||
|
||||
* tools/pdbgen/pdb/guides.pdb: use them instead of having this
|
||||
code here.
|
||||
|
||||
* app/pdb/guides_cmds.c: regenerated.
|
||||
|
||||
2006-03-13 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpimage.c (gimp_image_raise_layer_to_top,
|
||||
|
||||
@ -171,6 +171,57 @@ gimp_image_move_guide (GimpImage *gimage,
|
||||
gimp_image_update_guide (gimage, guide);
|
||||
}
|
||||
|
||||
GimpGuide *
|
||||
gimp_image_get_guide (GimpImage *gimage,
|
||||
guint32 id)
|
||||
{
|
||||
GList *guides;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *guide = guides->data;
|
||||
|
||||
if (guide->guide_ID == id && guide->position >= 0)
|
||||
return guide;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpGuide *
|
||||
gimp_image_get_next_guide (GimpImage *gimage,
|
||||
guint32 id,
|
||||
gboolean *guide_found)
|
||||
{
|
||||
GList *guides;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (guide_found != NULL, NULL);
|
||||
|
||||
if (id == 0)
|
||||
*guide_found = TRUE;
|
||||
else
|
||||
*guide_found = FALSE;
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *guide = guides->data;
|
||||
|
||||
if (guide->position < 0)
|
||||
continue;
|
||||
|
||||
if (*guide_found) /* this is the first guide after the found one */
|
||||
return guide;
|
||||
|
||||
if (guide->guide_ID == id) /* found it, next one will be returned */
|
||||
*guide_found = TRUE;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpGuide *
|
||||
gimp_image_find_guide (GimpImage *gimage,
|
||||
gdouble x,
|
||||
|
||||
@ -50,6 +50,12 @@ void gimp_image_move_guide (GimpImage *gimage,
|
||||
gint position,
|
||||
gboolean push_undo);
|
||||
|
||||
GimpGuide * gimp_image_get_guide (GimpImage *gimage,
|
||||
guint32 id);
|
||||
GimpGuide * gimp_image_get_next_guide (GimpImage *gimage,
|
||||
guint32 id,
|
||||
gboolean *guide_found);
|
||||
|
||||
GimpGuide * gimp_image_find_guide (GimpImage *gimage,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
|
||||
@ -58,8 +58,7 @@ image_add_hguide_invoker (Gimp *gimp,
|
||||
Argument *return_args;
|
||||
GimpImage *gimage;
|
||||
gint32 offset;
|
||||
gint32 guide_ID = 0;
|
||||
GimpGuide *guide;
|
||||
gint32 guide = 0;
|
||||
|
||||
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
|
||||
if (! GIMP_IS_IMAGE (gimage))
|
||||
@ -73,8 +72,10 @@ image_add_hguide_invoker (Gimp *gimp,
|
||||
{
|
||||
if (offset <= gimage->height)
|
||||
{
|
||||
guide = gimp_image_add_hguide (gimage, offset, TRUE);
|
||||
guide_ID = guide->guide_ID;
|
||||
GimpGuide *g;
|
||||
|
||||
g = gimp_image_add_hguide (gimage, offset, TRUE);
|
||||
guide = g->guide_ID;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
@ -83,7 +84,7 @@ image_add_hguide_invoker (Gimp *gimp,
|
||||
return_args = procedural_db_return_args (&image_add_hguide_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = guide_ID;
|
||||
return_args[1].value.pdb_int = guide;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
@ -139,8 +140,7 @@ image_add_vguide_invoker (Gimp *gimp,
|
||||
Argument *return_args;
|
||||
GimpImage *gimage;
|
||||
gint32 offset;
|
||||
gint32 guide_ID = 0;
|
||||
GimpGuide *guide;
|
||||
gint32 guide = 0;
|
||||
|
||||
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
|
||||
if (! GIMP_IS_IMAGE (gimage))
|
||||
@ -154,8 +154,10 @@ image_add_vguide_invoker (Gimp *gimp,
|
||||
{
|
||||
if (offset <= gimage->width)
|
||||
{
|
||||
guide = gimp_image_add_vguide (gimage, offset, TRUE);
|
||||
guide_ID = guide->guide_ID;
|
||||
GimpGuide *g;
|
||||
|
||||
g = gimp_image_add_vguide (gimage, offset, TRUE);
|
||||
guide = g->guide_ID;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
@ -164,7 +166,7 @@ image_add_vguide_invoker (Gimp *gimp,
|
||||
return_args = procedural_db_return_args (&image_add_vguide_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = guide_ID;
|
||||
return_args[1].value.pdb_int = guide;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
@ -219,7 +221,6 @@ image_delete_guide_invoker (Gimp *gimp,
|
||||
gboolean success = TRUE;
|
||||
GimpImage *gimage;
|
||||
gint32 guide;
|
||||
GList *guides;
|
||||
|
||||
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
|
||||
if (! GIMP_IS_IMAGE (gimage))
|
||||
@ -229,19 +230,12 @@ image_delete_guide_invoker (Gimp *gimp,
|
||||
|
||||
if (success)
|
||||
{
|
||||
success = FALSE;
|
||||
GimpGuide *g = gimp_image_get_guide (gimage, guide);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *g = (GimpGuide *) guides->data;
|
||||
|
||||
if ((g->guide_ID == guide) && (g->position >= 0))
|
||||
{
|
||||
gimp_image_remove_guide (gimage, g, TRUE);
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g)
|
||||
gimp_image_remove_guide (gimage, g, TRUE);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&image_delete_guide_proc, success);
|
||||
@ -290,8 +284,6 @@ image_find_next_guide_invoker (Gimp *gimp,
|
||||
GimpImage *gimage;
|
||||
gint32 guide;
|
||||
gint32 next_guide = 0;
|
||||
GList *guides;
|
||||
gboolean guide_found;
|
||||
|
||||
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
|
||||
if (! GIMP_IS_IMAGE (gimage))
|
||||
@ -301,41 +293,10 @@ image_find_next_guide_invoker (Gimp *gimp,
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (gimage->guides != NULL)
|
||||
{
|
||||
success = FALSE;
|
||||
guide_found = FALSE;
|
||||
GimpGuide *g = gimp_image_get_next_guide (gimage, guide, &success);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *g = (GimpGuide *) guides->data;
|
||||
|
||||
if (g->position < 0)
|
||||
continue;
|
||||
|
||||
if (guide == 0) /* init - Return first guide ID in list */
|
||||
{
|
||||
next_guide = g->guide_ID;
|
||||
|
||||
guide_found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (! guide_found)
|
||||
{
|
||||
if (g->guide_ID == guide)
|
||||
guide_found = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
next_guide = g->guide_ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (guide_found)
|
||||
success = TRUE;
|
||||
}
|
||||
if (g)
|
||||
next_guide = g->guide_ID;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&image_find_next_guide_proc, success);
|
||||
@ -398,7 +359,6 @@ image_get_guide_orientation_invoker (Gimp *gimp,
|
||||
GimpImage *gimage;
|
||||
gint32 guide;
|
||||
gint32 orientation = 0;
|
||||
GList *guides;
|
||||
|
||||
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
|
||||
if (! GIMP_IS_IMAGE (gimage))
|
||||
@ -408,20 +368,12 @@ image_get_guide_orientation_invoker (Gimp *gimp,
|
||||
|
||||
if (success)
|
||||
{
|
||||
success = FALSE;
|
||||
GimpGuide *g = gimp_image_get_guide (gimage, guide);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *g = (GimpGuide *) guides->data;
|
||||
|
||||
if ((g->guide_ID == guide) && (g->position >= 0))
|
||||
{
|
||||
orientation = g->orientation;
|
||||
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g)
|
||||
orientation = g->orientation;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&image_get_guide_orientation_proc, success);
|
||||
@ -484,7 +436,6 @@ image_get_guide_position_invoker (Gimp *gimp,
|
||||
GimpImage *gimage;
|
||||
gint32 guide;
|
||||
gint32 position = 0;
|
||||
GList *guides;
|
||||
|
||||
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
|
||||
if (! GIMP_IS_IMAGE (gimage))
|
||||
@ -494,20 +445,12 @@ image_get_guide_position_invoker (Gimp *gimp,
|
||||
|
||||
if (success)
|
||||
{
|
||||
success = FALSE;
|
||||
GimpGuide *g = gimp_image_get_guide (gimage, guide);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *g = (GimpGuide *) guides->data;
|
||||
|
||||
if ((g->guide_ID == guide) && (g->position >= 0))
|
||||
{
|
||||
position = g->position;
|
||||
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g)
|
||||
position = g->position;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&image_get_guide_position_proc, success);
|
||||
|
||||
@ -43,19 +43,20 @@ HELP
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'guide', type => 'guide', init => 1, alias => 'guide_ID',
|
||||
{ name => 'guide', type => 'guide', init => 1,
|
||||
desc => 'The new guide' }
|
||||
);
|
||||
|
||||
my $func = substr($desc, 0, 1);
|
||||
%invoke = (
|
||||
vars => [ 'GimpGuide *guide' ],
|
||||
code => <<CODE
|
||||
{
|
||||
if (offset <= gimage->$max)
|
||||
{
|
||||
guide = gimp_image_add_${func}guide (gimage, offset, TRUE);
|
||||
guide_ID = guide->guide_ID;
|
||||
GimpGuide *g;
|
||||
|
||||
g = gimp_image_add_${func}guide (gimage, offset, TRUE);
|
||||
guide = g->guide_ID;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
@ -91,22 +92,14 @@ HELP
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GList *guides' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
success = FALSE;
|
||||
GimpGuide *g = gimp_image_get_guide (gimage, guide);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *g = (GimpGuide *) guides->data;
|
||||
|
||||
if ((g->guide_ID == guide) && (g->position >= 0))
|
||||
{
|
||||
gimp_image_remove_guide (gimage, g, TRUE);
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g)
|
||||
gimp_image_remove_guide (gimage, g, TRUE);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
@ -136,44 +129,12 @@ HELP
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GList *guides', 'gboolean guide_found' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (gimage->guides != NULL)
|
||||
{
|
||||
success = FALSE;
|
||||
guide_found = FALSE;
|
||||
GimpGuide *g = gimp_image_get_next_guide (gimage, guide, &success);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *g = (GimpGuide *) guides->data;
|
||||
|
||||
if (g->position < 0)
|
||||
continue;
|
||||
|
||||
if (guide == 0) /* init - Return first guide ID in list */
|
||||
{
|
||||
next_guide = g->guide_ID;
|
||||
|
||||
guide_found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (! guide_found)
|
||||
{
|
||||
if (g->guide_ID == guide)
|
||||
guide_found = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
next_guide = g->guide_ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (guide_found)
|
||||
success = TRUE;
|
||||
}
|
||||
if (g)
|
||||
next_guide = g->guide_ID;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
@ -202,23 +163,14 @@ HELP
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GList *guides' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
success = FALSE;
|
||||
GimpGuide *g = gimp_image_get_guide (gimage, guide);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *g = (GimpGuide *) guides->data;
|
||||
|
||||
if ((g->guide_ID == guide) && (g->position >= 0))
|
||||
{
|
||||
orientation = g->orientation;
|
||||
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g)
|
||||
orientation = g->orientation;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
@ -246,23 +198,14 @@ HELP
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GList *guides' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
success = FALSE;
|
||||
GimpGuide *g = gimp_image_get_guide (gimage, guide);
|
||||
|
||||
for (guides = gimage->guides; guides; guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *g = (GimpGuide *) guides->data;
|
||||
|
||||
if ((g->guide_ID == guide) && (g->position >= 0))
|
||||
{
|
||||
position = g->position;
|
||||
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g)
|
||||
position = g->position;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user