From 21d24467ade674275e0571fd68f0767b36218903 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Thu, 18 Jan 2024 02:27:56 +0000 Subject: [PATCH] scripts: Fix "Remove all Guides" script bug Resolves #10651 The "Remove All Guides" script calls gimp-image-find-next-guide, which per its description can take in 0. However, the parameter sets 1 as the minimum value. This patch fixes the range so that it can accept 0, which enables the Remove All Guides script to work again. It also updates the script to the new multi-layer aware API. --- app/pdb/image-guides-cmds.c | 14 +++++++------- libgimp/gimpimageguides_pdb.c | 4 ++-- libgimp/gimpimageguides_pdb.h | 2 +- pdb/groups/image_guides.pdb | 2 +- plug-ins/script-fu/scripts/guides-remove-all.scm | 7 +++---- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/pdb/image-guides-cmds.c b/app/pdb/image-guides-cmds.c index b63eb0a6a0..3c74cd7735 100644 --- a/app/pdb/image-guides-cmds.c +++ b/app/pdb/image-guides-cmds.c @@ -163,11 +163,11 @@ image_find_next_guide_invoker (GimpProcedure *procedure, gboolean success = TRUE; GimpValueArray *return_vals; GimpImage *image; - guint guide; + gint guide; guint next_guide = 0; image = g_value_get_object (gimp_value_array_index (args, 0)); - guide = g_value_get_uint (gimp_value_array_index (args, 1)); + guide = g_value_get_int (gimp_value_array_index (args, 1)); if (success) { @@ -390,11 +390,11 @@ register_image_guides_procs (GimpPDB *pdb) FALSE, GIMP_PARAM_READWRITE)); gimp_procedure_add_argument (procedure, - g_param_spec_uint ("guide", - "guide", - "The ID of the current guide (0 if first invocation)", - 1, G_MAXUINT32, 1, - GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE)); + g_param_spec_int ("guide", + "guide", + "The ID of the current guide (0 if first invocation)", + 0, G_MAXINT32, 1, + GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE)); gimp_procedure_add_return_value (procedure, g_param_spec_uint ("next-guide", "next guide", diff --git a/libgimp/gimpimageguides_pdb.c b/libgimp/gimpimageguides_pdb.c index b257d33135..e3829b1d40 100644 --- a/libgimp/gimpimageguides_pdb.c +++ b/libgimp/gimpimageguides_pdb.c @@ -168,7 +168,7 @@ gimp_image_delete_guide (GimpImage *image, **/ guint gimp_image_find_next_guide (GimpImage *image, - guint guide) + gint guide) { GimpValueArray *args; GimpValueArray *return_vals; @@ -176,7 +176,7 @@ gimp_image_find_next_guide (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE, image, - G_TYPE_UINT, guide, + G_TYPE_INT, guide, G_TYPE_NONE); return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (), diff --git a/libgimp/gimpimageguides_pdb.h b/libgimp/gimpimageguides_pdb.h index 78b1359949..38a6baf42f 100644 --- a/libgimp/gimpimageguides_pdb.h +++ b/libgimp/gimpimageguides_pdb.h @@ -39,7 +39,7 @@ guint gimp_image_add_vguide (GimpImage *image, gboolean gimp_image_delete_guide (GimpImage *image, guint guide); guint gimp_image_find_next_guide (GimpImage *image, - guint guide); + gint guide); GimpOrientationType gimp_image_get_guide_orientation (GimpImage *image, guint guide); gint gimp_image_get_guide_position (GimpImage *image, diff --git a/pdb/groups/image_guides.pdb b/pdb/groups/image_guides.pdb index ed7c7e7d64..e1c52bfa23 100644 --- a/pdb/groups/image_guides.pdb +++ b/pdb/groups/image_guides.pdb @@ -142,7 +142,7 @@ HELP @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, - { name => 'guide', type => 'guide', no_validate => 1, + { name => 'guide', type => '0 <= int32', default => 1, no_validate => 1, desc => 'The ID of the current guide (0 if first invocation)' } ); diff --git a/plug-ins/script-fu/scripts/guides-remove-all.scm b/plug-ins/script-fu/scripts/guides-remove-all.scm index 61cc3ed8d0..e2989999f6 100644 --- a/plug-ins/script-fu/scripts/guides-remove-all.scm +++ b/plug-ins/script-fu/scripts/guides-remove-all.scm @@ -1,6 +1,6 @@ ;; -*-scheme-*- -(define (script-fu-guides-remove image drawable) +(define (script-fu-guides-remove image drawables) (let* ((guide-id 0)) (gimp-image-undo-group-start image) @@ -15,15 +15,14 @@ ) ) -(script-fu-register "script-fu-guides-remove" +(script-fu-register-filter "script-fu-guides-remove" _"_Remove all Guides" _"Remove all horizontal and vertical guides" "Alan Horkan" "Alan Horkan, 2004. Public Domain." "April 2004" "*" - SF-IMAGE "Image" 0 - SF-DRAWABLE "Drawable" 0 + SF-ONE-OR-MORE-DRAWABLE ) (script-fu-menu-register "script-fu-guides-remove"