2006-12-09 21:33:38 +00:00
/* GIMP - The GNU Image Manipulation Program
2003-07-03 00:47:26 +00:00
* Copyright ( C ) 1995 - 2003 Spencer Kimball and Peter Mattis
1999-04-30 21:11:27 +00:00
*
2009-01-17 22:28:01 +00:00
* This program is free software : you can redistribute it and / or modify
1999-04-30 21:11:27 +00:00
* it under the terms of the GNU General Public License as published by
2009-01-17 22:28:01 +00:00
* the Free Software Foundation ; either version 3 of the License , or
1999-04-30 21:11:27 +00:00
* ( at your option ) any later version .
*
* This program 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 General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2018-07-11 23:27:07 +02:00
* along with this program . If not , see < https : //www.gnu.org/licenses/>.
1999-04-30 21:11:27 +00:00
*/
2007-01-09 10:52:47 +00:00
/* NOTE: This file is auto-generated by pdbgen.pl. */
1999-04-30 21:11:27 +00:00
# include "config.h"
2022-03-28 15:13:17 +02:00
# include "stamp-pdbgen.h"
1999-04-30 21:11:27 +00:00
# include <string.h>
2000-12-29 15:22:01 +00:00
2008-10-09 20:24:04 +00:00
# include <gegl.h>
2000-12-29 15:22:01 +00:00
2012-05-03 03:36:22 +02:00
# include <gdk-pixbuf/gdk-pixbuf.h>
2012-05-04 00:50:23 +02:00
# include "libgimpbase/gimpbase.h"
2001-08-17 14:27:31 +00:00
# include "pdb-types.h"
2000-12-29 15:22:01 +00:00
2001-10-29 11:47:11 +00:00
# include "core/gimp.h"
2001-05-09 02:32:03 +00:00
# include "core/gimpimage.h"
2005-10-17 15:15:20 +00:00
# include "core/gimplayer.h"
2008-02-07 17:08:54 +00:00
# include "core/gimpparamspecs.h"
2005-10-17 16:41:51 +00:00
# include "file/file-open.h"
2006-11-03 17:12:27 +00:00
# include "file/file-save.h"
2001-10-25 13:30:01 +00:00
# include "file/file-utils.h"
2006-04-28 22:26:51 +00:00
# include "plug-in/gimppluginmanager-file.h"
1999-04-30 21:11:27 +00:00
2008-02-07 17:08:54 +00:00
# include "gimppdb.h"
# include "gimpprocedure.h"
2008-04-04 11:15:55 +00:00
# include "internal-procs.h"
2006-10-31 19:02:56 +00:00
1999-04-30 21:11:27 +00:00
2012-05-04 00:50:23 +02:00
static GimpValueArray *
2012-05-28 19:55:28 +02:00
file_load_invoker ( GimpProcedure * procedure ,
2012-05-04 00:50:23 +02:00
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
const GimpValueArray * args ,
GError * * error )
1999-04-30 21:11:27 +00:00
{
2012-05-04 00:50:23 +02:00
GimpValueArray * new_args ;
GimpValueArray * return_vals ;
2006-04-05 08:38:33 +00:00
GimpPlugInProcedure * file_proc ;
GimpProcedure * proc ;
2014-07-07 00:46:25 +02:00
GFile * file ;
2006-04-05 08:38:33 +00:00
gint i ;
1999-04-30 21:11:27 +00:00
2019-09-11 21:48:34 +02:00
file = g_value_get_object ( gimp_value_array_index ( args , 1 ) ) ;
2003-05-22 16:58:57 +00:00
2014-07-08 10:25:25 +02:00
if ( ! file )
2008-08-16 13:57:57 +00:00
return gimp_procedure_get_return_values ( procedure , FALSE ,
error ? * error : NULL ) ;
2003-05-22 16:58:57 +00:00
2016-01-03 20:05:27 +01:00
file_proc = gimp_plug_in_manager_file_procedure_find ( gimp - > plug_in_manager ,
GIMP_FILE_PROCEDURE_GROUP_OPEN ,
file , error ) ;
2003-05-22 16:58:57 +00:00
2001-10-29 11:47:11 +00:00
if ( ! file_proc )
2019-09-11 21:48:34 +02:00
return gimp_procedure_get_return_values ( procedure , FALSE ,
error ? * error : NULL ) ;
1999-04-30 21:11:27 +00:00
2006-04-05 08:38:33 +00:00
proc = GIMP_PROCEDURE ( file_proc ) ;
1999-04-30 21:11:27 +00:00
2006-03-31 09:15:08 +00:00
new_args = gimp_procedure_get_arguments ( proc ) ;
2006-03-29 23:56:07 +00:00
2014-10-18 01:14:58 +02:00
g_value_transform ( gimp_value_array_index ( args , 0 ) ,
gimp_value_array_index ( new_args , 0 ) ) ;
2019-09-11 22:48:32 +02:00
g_value_transform ( gimp_value_array_index ( args , 1 ) ,
gimp_value_array_index ( new_args , 1 ) ) ;
2014-10-18 01:14:58 +02:00
2019-09-11 00:21:03 +02:00
for ( i = 2 ; i < proc - > num_args ; i + + )
2025-09-26 23:57:51 +00:00
if ( GIMP_IS_PARAM_SPEC_CHOICE ( proc - > args [ i ] ) )
{
GParamSpecString * string_spec = G_PARAM_SPEC_STRING ( proc - > args [ i ] ) ;
g_value_set_static_string ( gimp_value_array_index ( new_args , i ) ,
string_spec - > default_value ) ;
}
else if ( G_IS_PARAM_SPEC_STRING ( proc - > args [ i ] ) )
{
g_value_set_static_string ( gimp_value_array_index ( new_args , i ) , " " ) ;
}
2003-10-08 10:14:17 +00:00
2006-11-06 08:14:46 +00:00
return_vals =
gimp_pdb_execute_procedure_by_name_args ( gimp - > pdb ,
2007-12-02 18:05:54 +00:00
context , progress , error ,
2009-08-29 12:40:40 +02:00
gimp_object_get_name ( proc ) ,
2006-11-06 08:14:46 +00:00
new_args ) ;
2006-03-29 23:56:07 +00:00
2012-05-04 00:50:23 +02:00
gimp_value_array_unref ( new_args ) ;
2003-10-08 10:14:17 +00:00
2012-05-04 00:50:23 +02:00
if ( g_value_get_enum ( gimp_value_array_index ( return_vals , 0 ) ) = =
GIMP_PDB_SUCCESS )
2007-09-20 21:23:05 +00:00
{
2012-05-04 00:50:23 +02:00
if ( gimp_value_array_length ( return_vals ) > 1 & &
2019-08-29 11:25:35 +02:00
GIMP_VALUE_HOLDS_IMAGE ( gimp_value_array_index ( return_vals , 1 ) ) )
2007-09-20 21:23:05 +00:00
{
2012-05-04 00:50:23 +02:00
GimpImage * image =
2019-08-29 11:25:35 +02:00
g_value_get_object ( gimp_value_array_index ( return_vals , 1 ) ) ;
2025-09-29 17:28:33 +02:00
if ( ! gimp_image_get_load_proc ( image ) )
/* Leave the initial load procedure if it already exists as
* it will give information about the source format . See
* similar code in file_open_image ( ) .
*/
gimp_image_set_load_proc ( image , file_proc ) ;
if ( ! gimp_image_get_file ( image ) )
gimp_image_set_imported_file ( image , file ) ;
2007-09-20 21:23:05 +00:00
}
}
2003-10-08 10:14:17 +00:00
return return_vals ;
1999-04-30 21:11:27 +00:00
}
2012-05-04 00:50:23 +02:00
static GimpValueArray *
2012-05-28 19:55:28 +02:00
file_load_layer_invoker ( GimpProcedure * procedure ,
2012-05-04 00:50:23 +02:00
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
const GimpValueArray * args ,
GError * * error )
1999-04-30 21:11:27 +00:00
{
2005-10-17 15:15:20 +00:00
gboolean success = TRUE ;
2012-05-04 00:50:23 +02:00
GimpValueArray * return_vals ;
2019-08-15 14:04:56 +02:00
gint run_mode ;
2005-10-17 15:15:20 +00:00
GimpImage * image ;
2019-09-11 21:48:34 +02:00
GFile * file ;
2005-10-17 15:15:20 +00:00
GimpLayer * layer = NULL ;
2003-05-22 16:58:57 +00:00
2012-05-04 00:50:23 +02:00
run_mode = g_value_get_enum ( gimp_value_array_index ( args , 0 ) ) ;
2019-08-29 11:25:35 +02:00
image = g_value_get_object ( gimp_value_array_index ( args , 1 ) ) ;
2019-09-11 21:48:34 +02:00
file = g_value_get_object ( gimp_value_array_index ( args , 2 ) ) ;
1999-04-30 21:11:27 +00:00
2005-10-17 15:15:20 +00:00
if ( success )
{
2019-09-11 21:48:34 +02:00
GList * layers ;
GimpPDBStatusType status ;
2014-07-07 00:46:25 +02:00
2019-09-11 21:48:34 +02:00
layers = file_open_layers ( gimp , context , progress ,
2025-08-26 16:44:38 +02:00
image , FALSE , FALSE ,
2019-09-11 21:48:34 +02:00
file , run_mode , NULL , & status , error ) ;
2006-11-03 17:12:27 +00:00
2019-09-11 21:48:34 +02:00
if ( layers )
{
layer = layers - > data ;
g_list_free ( layers ) ;
2006-11-03 17:12:27 +00:00
}
else
success = FALSE ;
}
2008-08-16 13:57:57 +00:00
return_vals = gimp_procedure_get_return_values ( procedure , success ,
error ? * error : NULL ) ;
2006-11-03 17:12:27 +00:00
if ( success )
2019-08-29 11:25:35 +02:00
g_value_set_object ( gimp_value_array_index ( return_vals , 1 ) , layer ) ;
2006-11-03 17:12:27 +00:00
return return_vals ;
}
2012-05-04 00:50:23 +02:00
static GimpValueArray *
2012-05-28 19:55:28 +02:00
file_load_layers_invoker ( GimpProcedure * procedure ,
2012-05-04 00:50:23 +02:00
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
const GimpValueArray * args ,
GError * * error )
2006-11-03 17:12:27 +00:00
{
gboolean success = TRUE ;
2012-05-04 00:50:23 +02:00
GimpValueArray * return_vals ;
2019-08-15 14:04:56 +02:00
gint run_mode ;
2006-11-03 17:12:27 +00:00
GimpImage * image ;
2019-09-11 21:48:34 +02:00
GFile * file ;
2019-09-05 12:57:43 +02:00
GimpLayer * * layers = NULL ;
2006-11-03 17:12:27 +00:00
2012-05-04 00:50:23 +02:00
run_mode = g_value_get_enum ( gimp_value_array_index ( args , 0 ) ) ;
2019-08-29 11:25:35 +02:00
image = g_value_get_object ( gimp_value_array_index ( args , 1 ) ) ;
2019-09-11 21:48:34 +02:00
file = g_value_get_object ( gimp_value_array_index ( args , 2 ) ) ;
2006-11-03 17:12:27 +00:00
if ( success )
{
2019-09-11 21:48:34 +02:00
GList * layer_list ;
GimpPDBStatusType status ;
2006-11-03 17:12:27 +00:00
2019-09-11 21:48:34 +02:00
layer_list = file_open_layers ( gimp , context , progress ,
2025-08-26 16:44:38 +02:00
image , FALSE , FALSE ,
2019-09-11 21:48:34 +02:00
file , run_mode , NULL , & status , error ) ;
2023-06-13 04:55:13 +00:00
if ( layer_list )
2006-11-03 17:12:27 +00:00
{
2019-09-11 21:48:34 +02:00
GList * list ;
2024-10-22 01:47:45 +02:00
gsize num_layers ;
gint i ;
2006-11-03 17:12:27 +00:00
2019-09-11 21:48:34 +02:00
num_layers = g_list_length ( layer_list ) ;
2014-07-07 00:46:25 +02:00
2024-10-22 01:47:45 +02:00
layers = g_new0 ( GimpLayer * , num_layers + 1 ) ;
2006-11-03 17:12:27 +00:00
2019-09-11 21:48:34 +02:00
for ( i = 0 , list = layer_list ;
i < num_layers ;
i + + , list = g_list_next ( list ) )
2006-11-03 17:12:27 +00:00
{
2024-10-22 01:47:45 +02:00
layers [ i ] = list - > data ;
2006-11-03 17:12:27 +00:00
}
2019-09-11 21:48:34 +02:00
g_list_free ( layer_list ) ;
2006-03-24 21:57:47 +00:00
}
else
2024-10-22 01:47:45 +02:00
{
success = FALSE ;
}
2003-08-18 18:09:26 +00:00
}
1999-09-01 18:46:25 +00:00
2008-08-16 13:57:57 +00:00
return_vals = gimp_procedure_get_return_values ( procedure , success ,
error ? * error : NULL ) ;
1999-04-30 21:11:27 +00:00
2005-10-17 15:15:20 +00:00
if ( success )
2024-10-22 01:47:45 +02:00
g_value_take_boxed ( gimp_value_array_index ( return_vals , 1 ) , layers ) ;
2005-10-17 15:15:20 +00:00
2006-03-27 21:09:32 +00:00
return return_vals ;
1999-04-30 21:11:27 +00:00
}
2012-05-04 00:50:23 +02:00
static GimpValueArray *
2012-05-28 19:55:28 +02:00
file_save_invoker ( GimpProcedure * procedure ,
2012-05-04 00:50:23 +02:00
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
const GimpValueArray * args ,
GError * * error )
2006-04-09 23:40:45 +00:00
{
2012-05-04 00:50:23 +02:00
GimpValueArray * new_args ;
GimpValueArray * return_vals ;
2006-04-09 23:40:45 +00:00
GimpPlugInProcedure * file_proc ;
2014-07-07 00:46:25 +02:00
GFile * file ;
2019-09-11 21:48:34 +02:00
GimpProcedure * proc ;
2024-09-01 01:21:45 +00:00
gint custom_args_start = 3 ;
2006-04-09 23:40:45 +00:00
gint i ;
2024-05-02 13:06:18 +00:00
file = g_value_get_object ( gimp_value_array_index ( args , 2 ) ) ;
2006-04-09 23:40:45 +00:00
2016-01-03 20:05:27 +01:00
file_proc = gimp_plug_in_manager_file_procedure_find ( gimp - > plug_in_manager ,
GIMP_FILE_PROCEDURE_GROUP_SAVE ,
file , NULL ) ;
2006-04-09 23:40:45 +00:00
2009-04-26 16:14:09 +02:00
if ( ! file_proc )
2016-01-03 20:05:27 +01:00
file_proc = gimp_plug_in_manager_file_procedure_find ( gimp - > plug_in_manager ,
GIMP_FILE_PROCEDURE_GROUP_EXPORT ,
file , error ) ;
2009-04-26 16:14:09 +02:00
2006-04-09 23:40:45 +00:00
if ( ! file_proc )
2019-09-11 21:48:34 +02:00
return gimp_procedure_get_return_values ( procedure , FALSE ,
error ? * error : NULL ) ;
2006-04-09 23:40:45 +00:00
proc = GIMP_PROCEDURE ( file_proc ) ;
new_args = gimp_procedure_get_arguments ( proc ) ;
2014-10-18 01:14:58 +02:00
g_value_transform ( gimp_value_array_index ( args , 0 ) ,
gimp_value_array_index ( new_args , 0 ) ) ;
g_value_transform ( gimp_value_array_index ( args , 1 ) ,
gimp_value_array_index ( new_args , 1 ) ) ;
g_value_transform ( gimp_value_array_index ( args , 2 ) ,
gimp_value_array_index ( new_args , 2 ) ) ;
2024-09-01 01:21:45 +00:00
if ( proc - > num_args > 3 )
{
custom_args_start + + ;
g_value_transform ( gimp_value_array_index ( args , 3 ) ,
gimp_value_array_index ( new_args , 3 ) ) ;
}
2014-10-18 01:14:58 +02:00
2024-09-01 01:21:45 +00:00
for ( i = custom_args_start ; i < proc - > num_args ; i + + )
2024-11-12 13:46:38 +00:00
if ( GIMP_IS_PARAM_SPEC_CHOICE ( proc - > args [ i ] ) )
{
GParamSpecString * string_spec = G_PARAM_SPEC_STRING ( proc - > args [ i ] ) ;
g_value_set_static_string ( gimp_value_array_index ( new_args , i ) ,
string_spec - > default_value ) ;
}
else if ( G_IS_PARAM_SPEC_STRING ( proc - > args [ i ] ) )
{
g_value_set_static_string ( gimp_value_array_index ( new_args , i ) , " " ) ;
}
2006-04-09 23:40:45 +00:00
2007-12-02 18:05:54 +00:00
return_vals =
gimp_pdb_execute_procedure_by_name_args ( gimp - > pdb ,
context , progress , error ,
2009-08-29 12:40:40 +02:00
gimp_object_get_name ( proc ) ,
2007-12-02 18:05:54 +00:00
new_args ) ;
2006-04-09 23:40:45 +00:00
2025-06-20 14:27:00 +00:00
if ( g_value_get_enum ( gimp_value_array_index ( return_vals , 0 ) ) = =
GIMP_PDB_SUCCESS )
{
GimpImage * image =
g_value_get_object ( gimp_value_array_index ( new_args , 1 ) ) ;
if ( ! strcmp ( gimp_object_get_name ( proc ) , " gimp-xcf-save " ) )
{
gimp_image_set_file ( image , file ) ;
gimp_image_set_imported_file ( image , NULL ) ;
gimp_image_clean_all ( image ) ;
}
else
{
gimp_image_set_exported_file ( image , file ) ;
gimp_image_set_export_proc ( image , file_proc ) ;
gimp_image_set_imported_file ( image , NULL ) ;
gimp_image_export_clean_all ( image ) ;
}
}
2012-05-04 00:50:23 +02:00
gimp_value_array_unref ( new_args ) ;
2006-04-09 23:40:45 +00:00
return return_vals ;
}
2012-05-04 00:50:23 +02:00
static GimpValueArray *
2012-05-28 19:55:28 +02:00
file_load_thumbnail_invoker ( GimpProcedure * procedure ,
2012-05-04 00:50:23 +02:00
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
const GimpValueArray * args ,
GError * * error )
1999-12-14 19:38:39 +00:00
{
gboolean success = TRUE ;
2012-05-04 00:50:23 +02:00
GimpValueArray * return_vals ;
2019-09-11 21:48:34 +02:00
GFile * file ;
2019-08-15 14:04:56 +02:00
gint width = 0 ;
gint height = 0 ;
2023-05-23 23:37:46 +02:00
GBytes * thumb_data = NULL ;
1999-12-14 19:38:39 +00:00
2019-09-11 21:48:34 +02:00
file = g_value_get_object ( gimp_value_array_index ( args , 0 ) ) ;
1999-12-14 19:38:39 +00:00
if ( success )
{
2019-09-11 21:48:34 +02:00
GdkPixbuf * pixbuf = file_utils_load_thumbnail ( file ) ;
2004-03-26 16:38:44 +00:00
2004-01-11 01:23:58 +00:00
if ( pixbuf )
2004-03-26 16:49:18 +00:00
{
2006-04-10 12:59:17 +00:00
width = gdk_pixbuf_get_width ( pixbuf ) ;
height = gdk_pixbuf_get_height ( pixbuf ) ;
2023-05-23 23:37:46 +02:00
thumb_data = g_bytes_new ( gdk_pixbuf_get_pixels ( pixbuf ) ,
3 * width * height ) ;
2004-03-26 16:38:44 +00:00
2004-03-26 16:49:18 +00:00
g_object_unref ( pixbuf ) ;
}
1999-12-14 19:38:39 +00:00
else
2006-03-24 21:57:47 +00:00
success = FALSE ;
1999-12-14 19:38:39 +00:00
}
2008-08-16 13:57:57 +00:00
return_vals = gimp_procedure_get_return_values ( procedure , success ,
error ? * error : NULL ) ;
1999-12-14 19:38:39 +00:00
if ( success )
{
2012-05-04 00:50:23 +02:00
g_value_set_int ( gimp_value_array_index ( return_vals , 1 ) , width ) ;
g_value_set_int ( gimp_value_array_index ( return_vals , 2 ) , height ) ;
2023-05-23 23:37:46 +02:00
g_value_take_boxed ( gimp_value_array_index ( return_vals , 3 ) , thumb_data ) ;
1999-12-14 19:38:39 +00:00
}
2006-03-27 21:09:32 +00:00
return return_vals ;
1999-12-14 19:38:39 +00:00
}
2012-05-04 00:50:23 +02:00
static GimpValueArray *
2025-01-21 20:20:07 +01:00
file_create_thumbnail_invoker ( GimpProcedure * procedure ,
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
const GimpValueArray * args ,
GError * * error )
1999-12-14 19:38:39 +00:00
{
gboolean success = TRUE ;
2006-03-23 21:17:16 +00:00
GimpImage * image ;
2019-09-11 21:48:34 +02:00
GFile * file ;
1999-12-14 19:38:39 +00:00
2019-08-29 11:25:35 +02:00
image = g_value_get_object ( gimp_value_array_index ( args , 0 ) ) ;
2019-09-11 21:48:34 +02:00
file = g_value_get_object ( gimp_value_array_index ( args , 1 ) ) ;
1999-12-14 19:38:39 +00:00
if ( success )
{
2019-09-11 21:48:34 +02:00
success = file_utils_save_thumbnail ( image , file ) ;
1999-12-14 19:38:39 +00:00
}
2008-08-16 13:57:57 +00:00
return gimp_procedure_get_return_values ( procedure , success ,
error ? * error : NULL ) ;
1999-12-14 19:38:39 +00:00
}
2006-04-04 21:11:45 +00:00
void
2019-09-10 21:38:11 +02:00
register_file_procs ( GimpPDB * pdb )
2006-04-04 21:11:45 +00:00
{
GimpProcedure * procedure ;
/*
* gimp - file - load
*/
2025-02-25 19:34:00 +01:00
procedure = gimp_procedure_new ( file_load_invoker , FALSE ) ;
2008-04-04 10:58:56 +00:00
gimp_object_set_static_name ( GIMP_OBJECT ( procedure ) ,
" gimp-file-load " ) ;
2019-09-08 23:40:34 +02:00
gimp_procedure_set_static_help ( procedure ,
" Loads an image file by invoking the right load handler. " ,
2020-04-13 20:25:32 +02:00
" This procedure invokes the correct file load handler using magic if possible, and falling back on the file's extension and/or prefix if not. " ,
2019-09-08 23:40:34 +02:00
NULL ) ;
gimp_procedure_set_static_attribution ( procedure ,
" Josh MacDonald " ,
" Josh MacDonald " ,
" 1997 " ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_argument ( procedure ,
gimp_param_spec_enum ( " run-mode " ,
" run mode " ,
2006-05-18 17:25:15 +00:00
" The run mode " ,
2006-04-04 21:11:45 +00:00
GIMP_TYPE_RUN_MODE ,
GIMP_RUN_INTERACTIVE ,
GIMP_PARAM_READWRITE ) ) ;
gimp_param_spec_enum_exclude_value ( GIMP_PARAM_SPEC_ENUM ( procedure - > args [ 0 ] ) ,
GIMP_RUN_WITH_LAST_VALS ) ;
gimp_procedure_add_argument ( procedure ,
2019-09-11 21:48:34 +02:00
g_param_spec_object ( " file " ,
" file " ,
" The file to load " ,
G_TYPE_FILE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_return_value ( procedure ,
2019-08-29 11:25:35 +02:00
gimp_param_spec_image ( " image " ,
" image " ,
" The output image " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-26 09:13:47 +00:00
gimp_pdb_register_procedure ( pdb , procedure ) ;
2006-04-07 08:16:26 +00:00
g_object_unref ( procedure ) ;
2006-04-04 21:11:45 +00:00
/*
* gimp - file - load - layer
*/
2025-02-25 19:34:00 +01:00
procedure = gimp_procedure_new ( file_load_layer_invoker , FALSE ) ;
2008-04-04 10:58:56 +00:00
gimp_object_set_static_name ( GIMP_OBJECT ( procedure ) ,
" gimp-file-load-layer " ) ;
2019-09-08 23:40:34 +02:00
gimp_procedure_set_static_help ( procedure ,
" Loads an image file as a layer for an existing image. " ,
" This procedure behaves like the file-load procedure but opens the specified image as a layer for an existing image. The returned layer needs to be added to the existing image with 'gimp-image-insert-layer'. " ,
NULL ) ;
gimp_procedure_set_static_attribution ( procedure ,
" Sven Neumann <sven@gimp.org> " ,
" Sven Neumann " ,
" 2005 " ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_argument ( procedure ,
gimp_param_spec_enum ( " run-mode " ,
" run mode " ,
2006-05-18 17:25:15 +00:00
" The run mode " ,
2006-04-04 21:11:45 +00:00
GIMP_TYPE_RUN_MODE ,
GIMP_RUN_INTERACTIVE ,
GIMP_PARAM_READWRITE ) ) ;
gimp_param_spec_enum_exclude_value ( GIMP_PARAM_SPEC_ENUM ( procedure - > args [ 0 ] ) ,
GIMP_RUN_WITH_LAST_VALS ) ;
gimp_procedure_add_argument ( procedure ,
2019-08-29 11:25:35 +02:00
gimp_param_spec_image ( " image " ,
" image " ,
" Destination image " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_argument ( procedure ,
2019-09-11 21:48:34 +02:00
g_param_spec_object ( " file " ,
" file " ,
" The file to load " ,
G_TYPE_FILE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_return_value ( procedure ,
2019-08-29 11:25:35 +02:00
gimp_param_spec_layer ( " layer " ,
" layer " ,
" The layer created when loading the image file " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-26 09:13:47 +00:00
gimp_pdb_register_procedure ( pdb , procedure ) ;
2006-04-07 08:16:26 +00:00
g_object_unref ( procedure ) ;
2006-04-04 21:11:45 +00:00
2006-11-03 17:12:27 +00:00
/*
* gimp - file - load - layers
*/
2025-02-25 19:34:00 +01:00
procedure = gimp_procedure_new ( file_load_layers_invoker , FALSE ) ;
2008-04-04 10:58:56 +00:00
gimp_object_set_static_name ( GIMP_OBJECT ( procedure ) ,
" gimp-file-load-layers " ) ;
2019-09-08 23:40:34 +02:00
gimp_procedure_set_static_help ( procedure ,
" Loads an image file as layers for an existing image. " ,
" This procedure behaves like the file-load procedure but opens the specified image as layers for an existing image. The returned layers needs to be added to the existing image with 'gimp-image-insert-layer'. " ,
NULL ) ;
gimp_procedure_set_static_attribution ( procedure ,
" Michael Natterer <mitch@gimp.org> " ,
" Michael Natterer " ,
" 2006 " ) ;
2006-11-03 17:12:27 +00:00
gimp_procedure_add_argument ( procedure ,
gimp_param_spec_enum ( " run-mode " ,
" run mode " ,
" The run mode " ,
GIMP_TYPE_RUN_MODE ,
GIMP_RUN_INTERACTIVE ,
GIMP_PARAM_READWRITE ) ) ;
gimp_param_spec_enum_exclude_value ( GIMP_PARAM_SPEC_ENUM ( procedure - > args [ 0 ] ) ,
GIMP_RUN_WITH_LAST_VALS ) ;
gimp_procedure_add_argument ( procedure ,
2019-08-29 11:25:35 +02:00
gimp_param_spec_image ( " image " ,
" image " ,
" Destination image " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
2006-11-03 17:12:27 +00:00
gimp_procedure_add_argument ( procedure ,
2019-09-11 21:48:34 +02:00
g_param_spec_object ( " file " ,
" file " ,
" The file to load " ,
G_TYPE_FILE ,
GIMP_PARAM_READWRITE ) ) ;
2006-11-03 17:12:27 +00:00
gimp_procedure_add_return_value ( procedure ,
2024-10-22 01:47:45 +02:00
gimp_param_spec_core_object_array ( " layers " ,
" layers " ,
" The list of loaded layers " ,
GIMP_TYPE_LAYER ,
GIMP_PARAM_READWRITE ) ) ;
2006-11-03 17:12:27 +00:00
gimp_pdb_register_procedure ( pdb , procedure ) ;
g_object_unref ( procedure ) ;
2006-04-04 21:11:45 +00:00
/*
* gimp - file - save
*/
2025-02-25 19:34:00 +01:00
procedure = gimp_procedure_new ( file_save_invoker , FALSE ) ;
2008-04-04 10:58:56 +00:00
gimp_object_set_static_name ( GIMP_OBJECT ( procedure ) ,
" gimp-file-save " ) ;
2019-09-08 23:40:34 +02:00
gimp_procedure_set_static_help ( procedure ,
2025-01-21 17:18:48 +01:00
" Saves to XCF or export @image to any supported format by extension. " ,
" This procedure invokes the correct file save/export handler according to @file's extension and/or prefix. \n "
" \n "
app, libgimp*, pdb, plug-ins: review and enhance MR !1549.
- Fix annotations for gimp_export_options_get_image() to make it
actually introspectable with the GimpImage being both input and
output. Even though the logic doesn't change much (the input image may
be overriden or not), it doesn't matter for introspection because
images are handled centrally by libgimp and therefore must not be
freed. Actually deleting the image from the central list of images
though remains a manual action depending on code logic, not some
automatic action to be handled by binding engines.
- Add G_GNUC_WARN_UNUSED_RESULT to gimp_export_options_get_image()
because ignoring the returned value is rarely a good idea (as you
usually want to delete the image).
- Remove gimp_export_options_new(): we don't need this constructor
because at this point, the best is to tell plug-in developers to just
pass NULL everywhere. This leaves us free to create a more useful
default constructor if needed, in the future. Main description for
GimpExportOptions has also been updated to say this.
- Add a data_destroy callback for the user data passed in
gimp_export_procedure_set_capabilities().
- Fixing annotations of 'export_options' object from pdb/pdb.pl: input
args would actually be (nullable) and would not transfer ownership
(calling code must still free the object). Return value's ownership on
the other hand is fully transfered.
- Add C and Python unit testing for GimpExportOptions and
gimp_export_options_get_image() in particular.
- Fix or improve various details.
Note that I have also considered for a long time changing the signature
of gimp_export_options_get_image() to return a boolean indicating
whether `image` had been replaced (hence needed deletion) or not. This
also meant getting rid of the GimpExportReturn enum. Right now it would
work because there are no third case, but I was considering the future
possibility that for instance we got some impossible conversion for some
future capability. I'm not sure it would ever happen; and for sure, this
is not desirable because it implies an export failure a bit late in the
workflow. But just in case, let's keep the enum return value. It does
not even make the using code that much more complicated (well just a
value comparison instead of a simple boolean test).
2024-08-17 15:06:27 +02:00
" The @options argument is currently unused and should be set to %NULL right now. " ,
2019-09-08 23:40:34 +02:00
NULL ) ;
gimp_procedure_set_static_attribution ( procedure ,
" Josh MacDonald " ,
" Josh MacDonald " ,
" 1997 " ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_argument ( procedure ,
g_param_spec_enum ( " run-mode " ,
" run mode " ,
2006-05-18 17:25:15 +00:00
" The run mode " ,
2006-04-04 21:11:45 +00:00
GIMP_TYPE_RUN_MODE ,
GIMP_RUN_INTERACTIVE ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_argument ( procedure ,
2019-08-29 11:25:35 +02:00
gimp_param_spec_image ( " image " ,
" image " ,
" Input image " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_argument ( procedure ,
2019-09-11 21:48:34 +02:00
g_param_spec_object ( " file " ,
" file " ,
2025-01-21 17:18:48 +01:00
" The file to save or export the image in " ,
2019-09-11 21:48:34 +02:00
G_TYPE_FILE ,
GIMP_PARAM_READWRITE ) ) ;
2024-05-06 18:38:12 +00:00
gimp_procedure_add_argument ( procedure ,
gimp_param_spec_export_options ( " options " ,
" options " ,
" Export option settings " ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-26 09:13:47 +00:00
gimp_pdb_register_procedure ( pdb , procedure ) ;
2006-04-07 08:16:26 +00:00
g_object_unref ( procedure ) ;
2004-05-14 00:01:11 +00:00
2006-04-09 23:40:45 +00:00
/*
* gimp - file - load - thumbnail
*/
2025-02-25 19:34:00 +01:00
procedure = gimp_procedure_new ( file_load_thumbnail_invoker , FALSE ) ;
2008-04-04 10:58:56 +00:00
gimp_object_set_static_name ( GIMP_OBJECT ( procedure ) ,
" gimp-file-load-thumbnail " ) ;
2019-09-08 23:40:34 +02:00
gimp_procedure_set_static_help ( procedure ,
" Loads the thumbnail for a file. " ,
2020-04-13 20:25:32 +02:00
" This procedure tries to load a thumbnail that belongs to the given file. The returned data is an array of colordepth 3 (RGB), regardless of the image type. Width and height of the thumbnail are also returned. Don't use this function if you need a thumbnail of an already opened image, use 'gimp-image-thumbnail' instead. " ,
2019-09-08 23:40:34 +02:00
NULL ) ;
gimp_procedure_set_static_attribution ( procedure ,
" Adam D. Moss, Sven Neumann " ,
" Adam D. Moss, Sven Neumann " ,
" 1999-2003 " ) ;
2006-04-09 23:40:45 +00:00
gimp_procedure_add_argument ( procedure ,
2019-09-11 21:48:34 +02:00
g_param_spec_object ( " file " ,
" file " ,
" The file that owns the thumbnail to load " ,
G_TYPE_FILE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-09 23:40:45 +00:00
gimp_procedure_add_return_value ( procedure ,
2019-08-15 14:04:56 +02:00
g_param_spec_int ( " width " ,
" width " ,
" The width of the thumbnail " ,
G_MININT32 , G_MAXINT32 , 0 ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-09 23:40:45 +00:00
gimp_procedure_add_return_value ( procedure ,
2019-08-15 14:04:56 +02:00
g_param_spec_int ( " height " ,
" height " ,
" The height of the thumbnail " ,
G_MININT32 , G_MAXINT32 , 0 ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-09 23:40:45 +00:00
gimp_procedure_add_return_value ( procedure ,
2023-05-23 23:37:46 +02:00
g_param_spec_boxed ( " thumb-data " ,
" thumb data " ,
" The thumbnail data " ,
G_TYPE_BYTES ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-26 09:13:47 +00:00
gimp_pdb_register_procedure ( pdb , procedure ) ;
2006-04-09 23:40:45 +00:00
g_object_unref ( procedure ) ;
2006-04-04 21:11:45 +00:00
/*
2025-01-21 20:20:07 +01:00
* gimp - file - create - thumbnail
2006-04-04 21:11:45 +00:00
*/
2025-02-25 19:34:00 +01:00
procedure = gimp_procedure_new ( file_create_thumbnail_invoker , FALSE ) ;
2008-04-04 10:58:56 +00:00
gimp_object_set_static_name ( GIMP_OBJECT ( procedure ) ,
2025-01-21 20:20:07 +01:00
" gimp-file-create-thumbnail " ) ;
2019-09-08 23:40:34 +02:00
gimp_procedure_set_static_help ( procedure ,
2025-01-21 20:20:07 +01:00
" Creates a thumbnail of @image for the given @file " ,
" This procedure creates a thumbnail for the given @file and stores it according to relevant standards. \n "
" In particular, it will follow the [Free Desktop Thumbnail Managing Standard](https://specifications.freedesktop.org/thumbnail-spec/latest/thumbsave.html) when relevant. \n "
" \n "
" The thumbnail is stored so that it belongs to the given @file. This means you have to save @image under this name first. As a fallback, the call will work if @image was exported or imported as @file. In any other case, this procedure will fail. " ,
2019-09-08 23:40:34 +02:00
NULL ) ;
gimp_procedure_set_static_attribution ( procedure ,
" Josh MacDonald " ,
" Josh MacDonald " ,
" 1997 " ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_argument ( procedure ,
2019-08-29 11:25:35 +02:00
gimp_param_spec_image ( " image " ,
" image " ,
" The image " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-04 21:11:45 +00:00
gimp_procedure_add_argument ( procedure ,
2019-09-11 21:48:34 +02:00
g_param_spec_object ( " file " ,
" file " ,
" The file the thumbnail belongs to " ,
G_TYPE_FILE ,
GIMP_PARAM_READWRITE ) ) ;
2006-04-26 09:13:47 +00:00
gimp_pdb_register_procedure ( pdb , procedure ) ;
2006-04-07 08:16:26 +00:00
g_object_unref ( procedure ) ;
2004-11-13 17:06:06 +00:00
}