diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/image-autocrop-cmds.c similarity index 78% rename from app/pdb/plug-in-compat-cmds.c rename to app/pdb/image-autocrop-cmds.c index ed79df25a7..a77e750de7 100644 --- a/app/pdb/plug-in-compat-cmds.c +++ b/app/pdb/image-autocrop-cmds.c @@ -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", diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c index d66cc65fc0..704577eca0 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -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); diff --git a/app/pdb/internal-procs.h b/app/pdb/internal-procs.h index 9cdf078982..7599787b5b 100644 --- a/app/pdb/internal-procs.h +++ b/app/pdb/internal-procs.h @@ -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); diff --git a/app/pdb/meson.build b/app/pdb/meson.build index b98c1c1f29..02a83d69d4 100644 --- a/app/pdb/meson.build +++ b/app/pdb/meson.build @@ -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', diff --git a/libgimp/gimp.def b/libgimp/gimp.def index 1ad7d88100..94f07816b6 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -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 diff --git a/libgimp/gimp_pdb_headers.h b/libgimp/gimp_pdb_headers.h index 04b735eca9..65ef2e9104 100644 --- a/libgimp/gimp_pdb_headers.h +++ b/libgimp/gimp_pdb_headers.h @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include diff --git a/libgimp/gimpimageautocrop_pdb.c b/libgimp/gimpimageautocrop_pdb.c new file mode 100644 index 0000000000..c2942106a0 --- /dev/null +++ b/libgimp/gimpimageautocrop_pdb.c @@ -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 + * . + */ + +/* 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; +} diff --git a/libgimp/gimpimageautocrop_pdb.h b/libgimp/gimpimageautocrop_pdb.h new file mode 100644 index 0000000000..d7610dfa98 --- /dev/null +++ b/libgimp/gimpimageautocrop_pdb.h @@ -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 + * . + */ + +/* NOTE: This file is auto-generated by pdbgen.pl */ + +#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION) +#error "Only 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__ */ diff --git a/libgimp/meson.build b/libgimp/meson.build index 1abae1a472..0a71df8892 100644 --- a/libgimp/meson.build +++ b/libgimp/meson.build @@ -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', diff --git a/pdb/groups.pl b/pdb/groups.pl index 0a46177743..84927dd054 100644 --- a/pdb/groups.pl +++ b/pdb/groups.pl @@ -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 diff --git a/pdb/groups/plug_in_compat.pdb b/pdb/groups/image_autocrop.pdb similarity index 85% rename from pdb/groups/plug_in_compat.pdb rename to pdb/groups/image_autocrop.pdb index e0f33b6d39..0ea48bfc72 100644 --- a/pdb/groups/plug_in_compat.pdb +++ b/pdb/groups/image_autocrop.pdb @@ -17,12 +17,7 @@ # "Perlized" from C source by Manish Singh -# 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; diff --git a/pdb/meson.build b/pdb/meson.build index 163c4cf9e4..abef127d4f 100644 --- a/pdb/meson.build +++ b/pdb/meson.build @@ -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', diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c index f2813e5d3f..39271289fb 100644 --- a/plug-ins/file-tiff/file-tiff-load.c +++ b/plug-ins/file-tiff/file-tiff-load.c @@ -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; diff --git a/plug-ins/script-fu/scripts/spinning-globe.scm b/plug-ins/script-fu/scripts/spinning-globe.scm index 3d09f90d02..eeab457524 100644 --- a/plug-ins/script-fu/scripts/spinning-globe.scm +++ b/plug-ins/script-fu/scripts/spinning-globe.scm @@ -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) ()