API: fix #12860 autocrop is internal, not a compatibility plugin

Rename plug_in_compat.pdb to image_autocrop.pdb so we retain commit history.

All procedures defined there are related to autocrop.
   - made internal, not plugins
   - renamed from plug-in- to gimp-image-
   - exposed in libgimp

If we need plugin compatibility PDB group in the future,
a starting template can be recovered from plug_in_compat.pdb 2.10 or late 2.99.

Fixed plugins that call.  The C plugin now calls libgimp instead of a PDB procedure.
This commit is contained in:
lloyd konneker 2025-02-06 14:55:27 -05:00 committed by Jehan
parent d5f730d589
commit 9e2d8e4e16
14 changed files with 202 additions and 68 deletions

View file

@ -47,19 +47,19 @@
static GimpValueArray *
plug_in_autocrop_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
image_autocrop_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
GimpDrawable *drawable;
image = g_value_get_object (gimp_value_array_index (args, 1));
drawable = g_value_get_object (gimp_value_array_index (args, 2));
image = g_value_get_object (gimp_value_array_index (args, 0));
drawable = g_value_get_object (gimp_value_array_index (args, 1));
if (success)
{
@ -110,19 +110,19 @@ plug_in_autocrop_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
plug_in_autocrop_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
image_autocrop_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
GimpDrawable *drawable;
image = g_value_get_object (gimp_value_array_index (args, 1));
drawable = g_value_get_object (gimp_value_array_index (args, 2));
image = g_value_get_object (gimp_value_array_index (args, 0));
drawable = g_value_get_object (gimp_value_array_index (args, 1));
if (success)
{
@ -173,16 +173,16 @@ plug_in_autocrop_layer_invoker (GimpProcedure *procedure,
}
void
register_plug_in_compat_procs (GimpPDB *pdb)
register_image_autocrop_procs (GimpPDB *pdb)
{
GimpProcedure *procedure;
/*
* gimp-plug-in-autocrop
* gimp-image-autocrop
*/
procedure = gimp_procedure_new (plug_in_autocrop_invoker, TRUE, FALSE);
procedure = gimp_procedure_new (image_autocrop_invoker, TRUE, FALSE);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-autocrop");
"gimp-image-autocrop");
gimp_procedure_set_static_help (procedure,
"Remove empty borders from the image",
"Remove empty borders from the image.",
@ -191,13 +191,6 @@ register_plug_in_compat_procs (GimpPDB *pdb)
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997");
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image ("image",
"image",
@ -214,11 +207,11 @@ register_plug_in_compat_procs (GimpPDB *pdb)
g_object_unref (procedure);
/*
* gimp-plug-in-autocrop-layer
* gimp-image-autocrop-layer
*/
procedure = gimp_procedure_new (plug_in_autocrop_layer_invoker, TRUE, FALSE);
procedure = gimp_procedure_new (image_autocrop_layer_invoker, TRUE, FALSE);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-autocrop-layer");
"gimp-image-autocrop-layer");
gimp_procedure_set_static_help (procedure,
"Crop the selected layers based on empty borders of the input drawable",
"Crop the selected layers of the input \"image\" based on empty borders of the input \"drawable\". \n\nThe input drawable serves as a base for detecting cropping extents (transparency or background color), and is not necessarily among the cropped layers (the current selected layers).",
@ -227,13 +220,6 @@ register_plug_in_compat_procs (GimpPDB *pdb)
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997");
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image ("image",
"image",

View file

@ -65,6 +65,7 @@ internal_procs_init (GimpPDB *pdb)
register_group_layer_procs (pdb);
register_help_procs (pdb);
register_image_procs (pdb);
register_image_autocrop_procs (pdb);
register_image_color_profile_procs (pdb);
register_image_convert_procs (pdb);
register_image_grid_procs (pdb);
@ -87,7 +88,6 @@ internal_procs_init (GimpPDB *pdb)
register_patterns_procs (pdb);
register_pdb_procs (pdb);
register_plug_in_procs (pdb);
register_plug_in_compat_procs (pdb);
register_progress_procs (pdb);
register_resource_procs (pdb);
register_selection_procs (pdb);

View file

@ -52,6 +52,7 @@ void register_gradients_procs (GimpPDB *pdb);
void register_group_layer_procs (GimpPDB *pdb);
void register_help_procs (GimpPDB *pdb);
void register_image_procs (GimpPDB *pdb);
void register_image_autocrop_procs (GimpPDB *pdb);
void register_image_color_profile_procs (GimpPDB *pdb);
void register_image_convert_procs (GimpPDB *pdb);
void register_image_grid_procs (GimpPDB *pdb);
@ -74,7 +75,6 @@ void register_pattern_select_procs (GimpPDB *pdb);
void register_patterns_procs (GimpPDB *pdb);
void register_pdb_procs (GimpPDB *pdb);
void register_plug_in_procs (GimpPDB *pdb);
void register_plug_in_compat_procs (GimpPDB *pdb);
void register_progress_procs (GimpPDB *pdb);
void register_resource_procs (GimpPDB *pdb);
void register_selection_procs (GimpPDB *pdb);

View file

@ -36,6 +36,7 @@ libappinternalprocs_sources = [
'group-layer-cmds.c',
'help-cmds.c',
'image-cmds.c',
'image-autocrop-cmds.c',
'image-color-profile-cmds.c',
'image-convert-cmds.c',
'image-grid-cmds.c',
@ -59,7 +60,6 @@ libappinternalprocs_sources = [
'patterns-cmds.c',
'pdb-cmds.c',
'plug-in-cmds.c',
'plug-in-compat-cmds.c',
'progress-cmds.c',
'resource-cmds.c',
'selection-cmds.c',

View file

@ -408,6 +408,8 @@ EXPORTS
gimp_image_add_sample_point
gimp_image_add_vguide
gimp_image_attach_parasite
gimp_image_autocrop
gimp_image_autocrop_layer
gimp_image_clean_all
gimp_image_convert_color_profile
gimp_image_convert_color_profile_from_file

View file

@ -55,6 +55,7 @@
#include <libgimp/gimpgrouplayer_pdb.h>
#include <libgimp/gimphelp_pdb.h>
#include <libgimp/gimpimage_pdb.h>
#include <libgimp/gimpimageautocrop_pdb.h>
#include <libgimp/gimpimagecolorprofile_pdb.h>
#include <libgimp/gimpimageconvert_pdb.h>
#include <libgimp/gimpimagegrid_pdb.h>

View file

@ -0,0 +1,114 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpimageautocrop_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "gimp.h"
/**
* SECTION: gimpimageautocrop
* @title: gimpimageautocrop
* @short_description: Functions that crop images to a layer.
*
* Functions that crop images to a layer.
**/
/**
* gimp_image_autocrop:
* @image: Input image).
* @drawable: Input drawable.
*
* Remove empty borders from the image
*
* Remove empty borders from the image.
*
* Returns: TRUE on success.
**/
gboolean
gimp_image_autocrop (GimpImage *image,
GimpDrawable *drawable)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
GIMP_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-image-autocrop",
args);
gimp_value_array_unref (args);
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/**
* gimp_image_autocrop_layer:
* @image: Input image).
* @drawable: Input drawable.
*
* Crop the selected layers based on empty borders of the input
* drawable
*
* Crop the selected layers of the input \"image\" based on empty
* borders of the input \"drawable\". \n\nThe input drawable serves as
* a base for detecting cropping extents (transparency or background
* color), and is not necessarily among the cropped layers (the current
* selected layers).
*
* Returns: TRUE on success.
**/
gboolean
gimp_image_autocrop_layer (GimpImage *image,
GimpDrawable *drawable)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
GIMP_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-image-autocrop-layer",
args);
gimp_value_array_unref (args);
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}

View file

@ -0,0 +1,43 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpimageautocrop_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif
#ifndef __GIMP_IMAGE_AUTOCROP_PDB_H__
#define __GIMP_IMAGE_AUTOCROP_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_image_autocrop (GimpImage *image,
GimpDrawable *drawable);
gboolean gimp_image_autocrop_layer (GimpImage *image,
GimpDrawable *drawable);
G_END_DECLS
#endif /* __GIMP_IMAGE_AUTOCROP_PDB_H__ */

View file

@ -87,6 +87,7 @@ pdb_wrappers_sources = [
'gimpgrouplayer_pdb.c',
'gimphelp_pdb.c',
'gimpimage_pdb.c',
'gimpimageautocrop_pdb.c',
'gimpimagecolorprofile_pdb.c',
'gimpimageconvert_pdb.c',
'gimpimagegrid_pdb.c',
@ -145,6 +146,7 @@ pdb_wrappers_headers = [
'gimpgrouplayer_pdb.h',
'gimphelp_pdb.h',
'gimpimage_pdb.h',
'gimpimageautocrop_pdb.h',
'gimpimagecolorprofile_pdb.h',
'gimpimageconvert_pdb.h',
'gimpimagegrid_pdb.h',

View file

@ -28,6 +28,7 @@
group_layer
help
image
image_autocrop
image_color_profile
image_convert
image_grid
@ -50,7 +51,6 @@
patterns
pdb
plug_in
plug_in_compat
progress
resource
selection

View file

@ -17,12 +17,7 @@
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
# The declared ranges generate min/max in GParamSpecs
# and the min becomes the default in the GParamSpecs.
# A declared range must correspond with range declared in GEGL
# else args defaulted from min may generate out-of-range warnings.
sub plug_in_autocrop {
sub image_autocrop {
$blurb = 'Remove empty borders from the image';
$help = <<'HELP';
@ -33,8 +28,6 @@ HELP
$date = '1997';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Input image)' },
{ name => 'drawable', type => 'drawable',
@ -89,7 +82,7 @@ CODE
);
}
sub plug_in_autocrop_layer {
sub image_autocrop_layer {
$blurb = 'Crop the selected layers based on empty borders of the input drawable';
$help = <<'HELP';
@ -101,8 +94,6 @@ HELP
$date = '1997';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Input image)' },
{ name => 'drawable', type => 'drawable',
@ -165,14 +156,14 @@ CODE
"gimppdb-utils.h"
"gimp-intl.h");
@procs = qw(plug_in_autocrop
plug_in_autocrop_layer);
@procs = qw(image_autocrop
image_autocrop_layer);
%exports = (app => [@procs], lib => []);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Plug-in Compat';
$doc_title = 'gimpplugincompat';
$doc_short_desc = 'Compatibility for removed plug-ins.';
$doc_long_desc = 'Functions that perform the operation of removed plug-ins using GEGL operations or other GIMP internal functions.';
$desc = 'Image Autocrop';
$doc_title = 'gimpimageautocrop';
$doc_short_desc = 'Functions that crop images to a layer.';
$doc_long_desc = 'Functions that crop images to a layer.';
1;

View file

@ -29,6 +29,7 @@ pdb_names = [
'gradients',
'group_layer',
'help',
'image_autocrop',
'image_color_profile',
'image_convert',
'image_grid',
@ -51,7 +52,6 @@ pdb_names = [
'pattern',
'patterns',
'pdb',
'plug_in_compat',
'plug_in',
'progress',
'resource',

View file

@ -2478,13 +2478,8 @@ load_sketchbook_layers (TIFF *tif,
* offset. Since the layer width can also shrink due to the
* crop, we calculate the before and after difference and
* adjust the x offset too. */
procedure = gimp_pdb_lookup_procedure (gimp_get_pdb (),
"plug-in-autocrop-layer");
gimp_procedure_run (procedure,
"run-mode", GIMP_RUN_NONINTERACTIVE,
"image", image,
"drawable", layer,
NULL);
(void) gimp_image_autocrop (image, layer);
x_pos += (layer_width - gimp_drawable_get_width (GIMP_DRAWABLE (layer)));
y_pos = image_height - gimp_drawable_get_height (GIMP_DRAWABLE (layer)) - y_pos;

View file

@ -93,7 +93,7 @@
)
(gimp-image-remove-layer theImage theLayer)
(plug-in-autocrop RUN-NONINTERACTIVE theImage theFrame)
(gimp-image-autocrop theImage theFrame)
(if (= inIndex 0)
()