Commit c1f7ec52 authored by Michael Natterer's avatar Michael Natterer 😴

app: add gimp_pdb_image_get_guide() and use it in the guide PDB wrappers

It returns a proper error message if a guide ID doesn't exist.
parent ad9fd339
......@@ -30,6 +30,7 @@
#include "core/gimpdatafactory.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-guides.h"
#include "core/gimpitem.h"
#include "text/gimptextlayer.h"
......@@ -678,6 +679,29 @@ gimp_pdb_image_is_not_precision (GimpImage *image,
return FALSE;
}
GimpGuide *
gimp_pdb_image_get_guide (GimpImage *image,
gint guide_ID,
GError **error)
{
GimpGuide *guide;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
guide = gimp_image_get_guide (image, guide_ID);
if (guide)
return guide;
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) does not contain guide with ID %d"),
gimp_image_get_display_name (image),
gimp_image_get_ID (image),
guide_ID);
return NULL;
}
GimpStroke *
gimp_pdb_get_vectors_stroke (GimpVectors *vectors,
gint stroke_ID,
......
......@@ -96,6 +96,10 @@ gboolean gimp_pdb_image_is_not_precision (GimpImage *image,
GimpPrecision precision,
GError **error);
GimpGuide * gimp_pdb_image_get_guide (GimpImage *image,
gint guide_ID,
GError **error);
GimpStroke * gimp_pdb_get_vectors_stroke (GimpVectors *vectors,
gint stroke_ID,
GimpPDBItemModify modify,
......
......@@ -34,9 +34,13 @@
#include "core/gimpparamspecs.h"
#include "gimppdb.h"
#include "gimppdberror.h"
#include "gimppdb-utils.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
#include "gimp-intl.h"
static GimpValueArray *
image_add_hguide_invoker (GimpProcedure *procedure,
......@@ -133,7 +137,7 @@ image_delete_guide_invoker (GimpProcedure *procedure,
if (success)
{
GimpGuide *g = gimp_image_get_guide (image, guide);
GimpGuide *g = gimp_pdb_image_get_guide (image, guide, error);
if (g)
gimp_image_remove_guide (image, g, TRUE);
......@@ -168,6 +172,13 @@ image_find_next_guide_invoker (GimpProcedure *procedure,
if (g)
next_guide = gimp_guide_get_ID (g);
if (! success)
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) does not contain guide with ID %d"),
gimp_image_get_display_name (image),
gimp_image_get_ID (image),
guide);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
......@@ -198,7 +209,7 @@ image_get_guide_orientation_invoker (GimpProcedure *procedure,
if (success)
{
GimpGuide *g = gimp_image_get_guide (image, guide);
GimpGuide *g = gimp_pdb_image_get_guide (image, guide, error);
if (g)
orientation = gimp_guide_get_orientation (g);
......@@ -234,7 +245,7 @@ image_get_guide_position_invoker (GimpProcedure *procedure,
if (success)
{
GimpGuide *g = gimp_image_get_guide (image, guide);
GimpGuide *g = gimp_pdb_image_get_guide (image, guide, error);
if (g)
position = gimp_guide_get_position (g);
......
......@@ -116,7 +116,7 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpGuide *g = gimp_image_get_guide (image, guide);
GimpGuide *g = gimp_pdb_image_get_guide (image, guide, error);
if (g)
gimp_image_remove_guide (image, g, TRUE);
......@@ -158,6 +158,13 @@ HELP
if (g)
next_guide = gimp_guide_get_ID (g);
if (! success)
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) does not contain guide with ID %d"),
gimp_image_get_display_name (image),
gimp_image_get_ID (image),
guide);
}
CODE
);
......@@ -190,7 +197,7 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpGuide *g = gimp_image_get_guide (image, guide);
GimpGuide *g = gimp_pdb_image_get_guide (image, guide, error);
if (g)
orientation = gimp_guide_get_orientation (g);
......@@ -227,7 +234,7 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpGuide *g = gimp_image_get_guide (image, guide);
GimpGuide *g = gimp_pdb_image_get_guide (image, guide, error);
if (g)
position = gimp_guide_get_position (g);
......@@ -241,7 +248,10 @@ CODE
@headers = qw("core/gimpguide.h"
"core/gimpimage-guides.h"
"core/gimpimage-undo-push.h");
"core/gimpimage-undo-push.h"
"gimppdb-utils.h"
"gimppdberror.h"
"gimp-intl.h");
@procs = qw(image_add_hguide image_add_vguide
image_delete_guide
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment