[gimp] app: add gimp_pdb_image_get_guide() and use it in the guide PDB wrappers
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_pdb_image_get_guide() and use it in the guide PDB wrappers
- Date: Thu, 10 Jul 2014 18:27:40 +0000 (UTC)
commit c1f7ec52a8da8c7d80566a607ff6ec5aa54cbdce
Author: Michael Natterer <mitch gimp org>
Date: Thu Jul 10 20:24:10 2014 +0200
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.
app/pdb/gimppdb-utils.c | 24 ++++++++++++++++++++++++
app/pdb/gimppdb-utils.h | 4 ++++
app/pdb/guides-cmds.c | 17 ++++++++++++++---
tools/pdbgen/pdb/guides.pdb | 18 ++++++++++++++----
4 files changed, 56 insertions(+), 7 deletions(-)
---
diff --git a/app/pdb/gimppdb-utils.c b/app/pdb/gimppdb-utils.c
index 4000952..b8d71d5 100644
--- a/app/pdb/gimppdb-utils.c
+++ b/app/pdb/gimppdb-utils.c
@@ -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,
diff --git a/app/pdb/gimppdb-utils.h b/app/pdb/gimppdb-utils.h
index 9168b85..3d1dd4f 100644
--- a/app/pdb/gimppdb-utils.h
+++ b/app/pdb/gimppdb-utils.h
@@ -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,
diff --git a/app/pdb/guides-cmds.c b/app/pdb/guides-cmds.c
index 6047b4a..42f6294 100644
--- a/app/pdb/guides-cmds.c
+++ b/app/pdb/guides-cmds.c
@@ -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);
diff --git a/tools/pdbgen/pdb/guides.pdb b/tools/pdbgen/pdb/guides.pdb
index 7b16ebd..2926522 100644
--- a/tools/pdbgen/pdb/guides.pdb
+++ b/tools/pdbgen/pdb/guides.pdb
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]