pdb, libgimp: remove _gimp_register_load_handler()

and rename _gimp_register_magic_load_handler() to
_gimp_register_load_handler().
This commit is contained in:
Michael Natterer 2019-09-10 12:29:17 +02:00
parent b1683ce692
commit 0745043ddb
6 changed files with 22 additions and 180 deletions

View File

@ -402,12 +402,12 @@ file_save_thumbnail_invoker (GimpProcedure *procedure,
} }
static GimpValueArray * static GimpValueArray *
register_magic_load_handler_invoker (GimpProcedure *procedure, register_load_handler_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GimpValueArray *args, const GimpValueArray *args,
GError **error) GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
const gchar *procedure_name; const gchar *procedure_name;
@ -433,36 +433,6 @@ register_magic_load_handler_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
} }
static GimpValueArray *
register_load_handler_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *procedure_name;
const gchar *extensions;
const gchar *prefixes;
procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
extensions = g_value_get_string (gimp_value_array_index (args, 1));
prefixes = g_value_get_string (gimp_value_array_index (args, 2));
if (success)
{
success = (gimp_pdb_is_canonical_procedure (procedure_name, error) &&
gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
procedure_name,
extensions, prefixes,
NULL));
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray * static GimpValueArray *
register_save_handler_invoker (GimpProcedure *procedure, register_save_handler_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -895,11 +865,11 @@ register_fileops_procs (GimpPDB *pdb)
g_object_unref (procedure); g_object_unref (procedure);
/* /*
* gimp-register-magic-load-handler * gimp-register-load-handler
*/ */
procedure = gimp_procedure_new (register_magic_load_handler_invoker); procedure = gimp_procedure_new (register_load_handler_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure), gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-register-magic-load-handler"); "gimp-register-load-handler");
gimp_procedure_set_static_help (procedure, gimp_procedure_set_static_help (procedure,
"Registers a file load handler procedure.", "Registers a file load handler procedure.",
"Registers a procedural database procedure to be called to load files of a particular file format using magic file information.", "Registers a procedural database procedure to be called to load files of a particular file format using magic file information.",
@ -939,44 +909,6 @@ register_fileops_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
/*
* gimp-register-load-handler
*/
procedure = gimp_procedure_new (register_load_handler_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-register-load-handler");
gimp_procedure_set_static_help (procedure,
"Registers a file load handler procedure.",
"Registers a procedural database procedure to be called to load files of a particular file format.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("procedure-name",
"procedure name",
"The name of the procedure to be used for loading",
FALSE, FALSE, TRUE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("extensions",
"extensions",
"comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\")",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("prefixes",
"prefixes",
"comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\")",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/* /*
* gimp-register-save-handler * gimp-register-save-handler
*/ */

View File

@ -28,7 +28,7 @@
#include "internal-procs.h" #include "internal-procs.h"
/* 753 procedures registered total */ /* 752 procedures registered total */
void void
internal_procs_init (GimpPDB *pdb) internal_procs_init (GimpPDB *pdb)

View File

@ -272,7 +272,7 @@ gimp_file_save_thumbnail (GimpImage *image,
} }
/** /**
* _gimp_register_magic_load_handler: * _gimp_register_load_handler:
* @procedure_name: The name of the procedure to be used for loading. * @procedure_name: The name of the procedure to be used for loading.
* @extensions: comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\"). * @extensions: comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\").
* @prefixes: comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\"). * @prefixes: comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\").
@ -286,10 +286,10 @@ gimp_file_save_thumbnail (GimpImage *image,
* Returns: TRUE on success. * Returns: TRUE on success.
**/ **/
gboolean gboolean
_gimp_register_magic_load_handler (const gchar *procedure_name, _gimp_register_load_handler (const gchar *procedure_name,
const gchar *extensions, const gchar *extensions,
const gchar *prefixes, const gchar *prefixes,
const gchar *magics) const gchar *magics)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -302,46 +302,6 @@ _gimp_register_magic_load_handler (const gchar *procedure_name,
G_TYPE_STRING, magics, G_TYPE_STRING, magics,
G_TYPE_NONE); G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-register-magic-load-handler",
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_register_load_handler:
* @procedure_name: The name of the procedure to be used for loading.
* @extensions: comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\").
* @prefixes: comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\").
*
* Registers a file load handler procedure.
*
* Registers a procedural database procedure to be called to load files
* of a particular file format.
*
* Returns: TRUE on success.
**/
gboolean
_gimp_register_load_handler (const gchar *procedure_name,
const gchar *extensions,
const gchar *prefixes)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, procedure_name,
G_TYPE_STRING, extensions,
G_TYPE_STRING, prefixes,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-register-load-handler", "gimp-register-load-handler",
args); args);

View File

@ -49,13 +49,10 @@ gboolean gimp_file_save (GimpRunMode run
const gchar *raw_filename); const gchar *raw_filename);
gboolean gimp_file_save_thumbnail (GimpImage *image, gboolean gimp_file_save_thumbnail (GimpImage *image,
const gchar *filename); const gchar *filename);
G_GNUC_INTERNAL gboolean _gimp_register_magic_load_handler (const gchar *procedure_name, G_GNUC_INTERNAL gboolean _gimp_register_load_handler (const gchar *procedure_name,
const gchar *extensions, const gchar *extensions,
const gchar *prefixes, const gchar *prefixes,
const gchar *magics); const gchar *magics);
G_GNUC_INTERNAL gboolean _gimp_register_load_handler (const gchar *procedure_name,
const gchar *extensions,
const gchar *prefixes);
G_GNUC_INTERNAL gboolean _gimp_register_save_handler (const gchar *procedure_name, G_GNUC_INTERNAL gboolean _gimp_register_save_handler (const gchar *procedure_name,
const gchar *extensions, const gchar *extensions,
const gchar *prefixes); const gchar *prefixes);

View File

@ -119,19 +119,10 @@ gimp_load_procedure_install (GimpProcedure *procedure)
GIMP_PROCEDURE_CLASS (parent_class)->install (procedure); GIMP_PROCEDURE_CLASS (parent_class)->install (procedure);
if (gimp_file_procedure_get_magics (file_proc)) _gimp_register_load_handler (gimp_procedure_get_name (procedure),
{ gimp_file_procedure_get_extensions (file_proc),
_gimp_register_magic_load_handler (gimp_procedure_get_name (procedure), gimp_file_procedure_get_prefixes (file_proc),
gimp_file_procedure_get_extensions (file_proc), gimp_file_procedure_get_magics (file_proc));
gimp_file_procedure_get_prefixes (file_proc),
gimp_file_procedure_get_magics (file_proc));
}
else
{
_gimp_register_load_handler (gimp_procedure_get_name (procedure),
gimp_file_procedure_get_extensions (file_proc),
gimp_file_procedure_get_prefixes (file_proc));
}
if (gimp_file_procedure_get_handles_remote (file_proc)) if (gimp_file_procedure_get_handles_remote (file_proc))
_gimp_register_file_handler_remote (gimp_procedure_get_name (procedure)); _gimp_register_file_handler_remote (gimp_procedure_get_name (procedure));

View File

@ -436,7 +436,7 @@ CODE
); );
} }
sub register_magic_load_handler { sub register_load_handler {
$blurb = 'Registers a file load handler procedure.'; $blurb = 'Registers a file load handler procedure.';
$help = <<'HELP'; $help = <<'HELP';
@ -475,43 +475,6 @@ CODE
); );
} }
sub register_load_handler {
$blurb = 'Registers a file load handler procedure.';
$help = <<'HELP';
Registers a procedural database procedure to be called to load files of a
particular file format.
HELP
&std_pdb_misc;
$lib_private = 1;
@inargs = (
{ name => 'procedure_name', type => 'string', non_empty => 1,
desc => 'The name of the procedure to be used for loading' },
{ name => 'extensions', type => 'string', no_validate => 1,
desc => 'comma separated list of extensions this handler
can load (i.e. "jpg,jpeg")' },
{ name => 'prefixes', type => 'string', no_validate => 1,
desc => 'comma separated list of prefixes this handler
can load (i.e. "http:,ftp:")' }
);
%invoke = (
code => <<'CODE'
{
success = (gimp_pdb_is_canonical_procedure (procedure_name, error) &&
gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
procedure_name,
extensions, prefixes,
NULL));
}
CODE
);
}
sub register_save_handler { sub register_save_handler {
$blurb = 'Registers a file save handler procedure.'; $blurb = 'Registers a file save handler procedure.';
@ -724,7 +687,6 @@ CODE
file_save file_save
file_load_thumbnail file_load_thumbnail
file_save_thumbnail file_save_thumbnail
register_magic_load_handler
register_load_handler register_load_handler
register_save_handler register_save_handler
register_file_handler_priority register_file_handler_priority
@ -733,7 +695,7 @@ CODE
register_file_handler_raw register_file_handler_raw
register_thumbnail_loader); register_thumbnail_loader);
%exports = (app => [@procs], lib => [@procs[0..3,5..13]]); %exports = (app => [@procs], lib => [@procs[0..3,5..12]]);
$desc = 'File Operations'; $desc = 'File Operations';
$doc_title = 'gimpfileops'; $doc_title = 'gimpfileops';