pdb: reorder stuff in the "pdb" group to make more sense

This commit is contained in:
Michael Natterer 2019-09-10 20:23:19 +02:00
parent 21ff9999e4
commit 56fee73441
4 changed files with 349 additions and 349 deletions

View File

@ -263,6 +263,94 @@ pdb_get_proc_info_invoker (GimpProcedure *procedure,
return return_vals;
}
static GimpValueArray *
pdb_get_proc_argument_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
const gchar *procedure_name;
gint arg_num;
GParamSpec *param_spec = NULL;
procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
arg_num = g_value_get_int (gimp_value_array_index (args, 1));
if (success)
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
error);
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
{
param_spec = g_param_spec_ref (proc->args[arg_num]);
}
else
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_param (gimp_value_array_index (return_vals, 1), param_spec);
return return_vals;
}
static GimpValueArray *
pdb_get_proc_return_value_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
const gchar *procedure_name;
gint val_num;
GParamSpec *param_spec = NULL;
procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
val_num = g_value_get_int (gimp_value_array_index (args, 1));
if (success)
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
error);
if (proc && (val_num >= 0 && val_num < proc->num_values))
{
param_spec = g_param_spec_ref (proc->values[val_num]);
}
else
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_param (gimp_value_array_index (return_vals, 1), param_spec);
return return_vals;
}
static GimpValueArray *
pdb_set_proc_image_types_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -723,94 +811,6 @@ pdb_get_proc_attribution_invoker (GimpProcedure *procedure,
return return_vals;
}
static GimpValueArray *
pdb_get_proc_argument_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
const gchar *procedure_name;
gint arg_num;
GParamSpec *param_spec = NULL;
procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
arg_num = g_value_get_int (gimp_value_array_index (args, 1));
if (success)
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
error);
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
{
param_spec = g_param_spec_ref (proc->args[arg_num]);
}
else
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_param (gimp_value_array_index (return_vals, 1), param_spec);
return return_vals;
}
static GimpValueArray *
pdb_get_proc_return_value_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
const gchar *procedure_name;
gint val_num;
GParamSpec *param_spec = NULL;
procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
val_num = g_value_get_int (gimp_value_array_index (args, 1));
if (success)
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
error);
if (proc && (val_num >= 0 && val_num < proc->num_values))
{
param_spec = g_param_spec_ref (proc->values[val_num]);
}
else
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_param (gimp_value_array_index (return_vals, 1), param_spec);
return return_vals;
}
static GimpValueArray *
pdb_get_data_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1128,6 +1128,78 @@ register_pdb_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-pdb-get-proc-argument
*/
procedure = gimp_procedure_new (pdb_get_proc_argument_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-pdb-get-proc-argument");
gimp_procedure_set_static_help (procedure,
"Queries the procedural database for information on the specified procedure's argument.",
"This procedure returns the #GParamSpec of procedure_name's argument.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2019");
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("procedure-name",
"procedure name",
"The procedure name",
FALSE, FALSE, TRUE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("arg-num",
"arg num",
"The argument number",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_param ("param-spec",
"param spec",
"The GParamSpec of the argument",
G_TYPE_PARAM,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-pdb-get-proc-return-value
*/
procedure = gimp_procedure_new (pdb_get_proc_return_value_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-pdb-get-proc-return-value");
gimp_procedure_set_static_help (procedure,
"Queries the procedural database for information on the specified procedure's return value.",
"This procedure returns the #GParamSpec of procedure_name's return value.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2019");
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("procedure-name",
"procedure name",
"The procedure name",
FALSE, FALSE, TRUE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("val-num",
"val num",
"The return value number",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_param ("param-spec",
"param spec",
"The GParamSpec of the return value",
G_TYPE_PARAM,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-pdb-set-proc-image-types
*/
@ -1540,78 +1612,6 @@ register_pdb_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-pdb-get-proc-argument
*/
procedure = gimp_procedure_new (pdb_get_proc_argument_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-pdb-get-proc-argument");
gimp_procedure_set_static_help (procedure,
"Queries the procedural database for information on the specified procedure's argument.",
"This procedure returns the #GParamSpec of procedure_name's argument.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2019");
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("procedure-name",
"procedure name",
"The procedure name",
FALSE, FALSE, TRUE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("arg-num",
"arg num",
"The argument number",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_param ("param-spec",
"param spec",
"The GParamSpec of the argument",
G_TYPE_PARAM,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-pdb-get-proc-return-value
*/
procedure = gimp_procedure_new (pdb_get_proc_return_value_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-pdb-get-proc-return-value");
gimp_procedure_set_static_help (procedure,
"Queries the procedural database for information on the specified procedure's return value.",
"This procedure returns the #GParamSpec of procedure_name's return value.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2019");
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("procedure-name",
"procedure name",
"The procedure name",
FALSE, FALSE, TRUE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("val-num",
"val num",
"The return value number",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_param ("param-spec",
"param spec",
"The GParamSpec of the return value",
G_TYPE_PARAM,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-pdb-get-data
*/

View File

@ -262,6 +262,89 @@ _gimp_pdb_get_proc_info (const gchar *procedure_name,
return success;
}
/**
* _gimp_pdb_get_proc_argument:
* @procedure_name: The procedure name.
* @arg_num: The argument number.
*
* Queries the procedural database for information on the specified
* procedure's argument.
*
* This procedure returns the #GParamSpec of procedure_name's argument.
*
* Returns: (transfer full): The GParamSpec of the argument.
* The returned value must be freed with g_param_spec_unref().
*
* Since: 3.0
**/
GParamSpec *
_gimp_pdb_get_proc_argument (const gchar *procedure_name,
gint arg_num)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GParamSpec *param_spec = NULL;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, procedure_name,
G_TYPE_INT, arg_num,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-pdb-get-proc-argument",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
param_spec = GIMP_VALUES_DUP_PARAM (return_vals, 1);
gimp_value_array_unref (return_vals);
return param_spec;
}
/**
* _gimp_pdb_get_proc_return_value:
* @procedure_name: The procedure name.
* @val_num: The return value number.
*
* Queries the procedural database for information on the specified
* procedure's return value.
*
* This procedure returns the #GParamSpec of procedure_name's return
* value.
*
* Returns: (transfer full): The GParamSpec of the return value.
* The returned value must be freed with g_param_spec_unref().
*
* Since: 3.0
**/
GParamSpec *
_gimp_pdb_get_proc_return_value (const gchar *procedure_name,
gint val_num)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GParamSpec *param_spec = NULL;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, procedure_name,
G_TYPE_INT, val_num,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-pdb-get-proc-return-value",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
param_spec = GIMP_VALUES_DUP_PARAM (return_vals, 1);
gimp_value_array_unref (return_vals);
return param_spec;
}
/**
* _gimp_pdb_set_proc_image_types:
* @procedure_name: The procedure for which to install the menu path.
@ -740,89 +823,6 @@ _gimp_pdb_get_proc_attribution (const gchar *procedure_name,
return success;
}
/**
* _gimp_pdb_get_proc_argument:
* @procedure_name: The procedure name.
* @arg_num: The argument number.
*
* Queries the procedural database for information on the specified
* procedure's argument.
*
* This procedure returns the #GParamSpec of procedure_name's argument.
*
* Returns: (transfer full): The GParamSpec of the argument.
* The returned value must be freed with g_param_spec_unref().
*
* Since: 3.0
**/
GParamSpec *
_gimp_pdb_get_proc_argument (const gchar *procedure_name,
gint arg_num)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GParamSpec *param_spec = NULL;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, procedure_name,
G_TYPE_INT, arg_num,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-pdb-get-proc-argument",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
param_spec = GIMP_VALUES_DUP_PARAM (return_vals, 1);
gimp_value_array_unref (return_vals);
return param_spec;
}
/**
* _gimp_pdb_get_proc_return_value:
* @procedure_name: The procedure name.
* @val_num: The return value number.
*
* Queries the procedural database for information on the specified
* procedure's return value.
*
* This procedure returns the #GParamSpec of procedure_name's return
* value.
*
* Returns: (transfer full): The GParamSpec of the return value.
* The returned value must be freed with g_param_spec_unref().
*
* Since: 3.0
**/
GParamSpec *
_gimp_pdb_get_proc_return_value (const gchar *procedure_name,
gint val_num)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GParamSpec *param_spec = NULL;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, procedure_name,
G_TYPE_INT, val_num,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-pdb-get-proc-return-value",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
param_spec = GIMP_VALUES_DUP_PARAM (return_vals, 1);
gimp_value_array_unref (return_vals);
return param_spec;
}
/**
* _gimp_pdb_get_data:
* @identifier: The identifier associated with data.

View File

@ -48,6 +48,10 @@ G_GNUC_INTERNAL gboolean _gimp_pdb_get_proc_info (const gchar
GimpPDBProcType *proc_type,
gint *num_args,
gint *num_values);
G_GNUC_INTERNAL GParamSpec* _gimp_pdb_get_proc_argument (const gchar *procedure_name,
gint arg_num);
G_GNUC_INTERNAL GParamSpec* _gimp_pdb_get_proc_return_value (const gchar *procedure_name,
gint val_num);
G_GNUC_INTERNAL gboolean _gimp_pdb_set_proc_image_types (const gchar *procedure_name,
const gchar *image_types);
G_GNUC_INTERNAL gchar* _gimp_pdb_get_proc_image_types (const gchar *procedure_name);
@ -78,10 +82,6 @@ G_GNUC_INTERNAL gboolean _gimp_pdb_get_proc_attribution (const gchar
gchar **authors,
gchar **copyright,
gchar **date);
G_GNUC_INTERNAL GParamSpec* _gimp_pdb_get_proc_argument (const gchar *procedure_name,
gint arg_num);
G_GNUC_INTERNAL GParamSpec* _gimp_pdb_get_proc_return_value (const gchar *procedure_name,
gint val_num);
G_GNUC_INTERNAL gboolean _gimp_pdb_get_data (const gchar *identifier,
gint *bytes,
guint8 **data);

View File

@ -246,6 +246,106 @@ CODE
);
}
sub pdb_get_proc_argument {
$blurb = <<BLURB;
Queries the procedural database for information on the specified procedure's
argument.
BLURB
$help = <<HELP;
This procedure returns the #GParamSpec of procedure_name's argument.
HELP
&mitch_pdb_misc;
$date = '2019';
$since = '3.0';
$lib_private = 1;
@inargs = (
{ name => 'procedure_name', type => 'string', non_empty => 1,
desc => 'The procedure name' },
{ name => 'arg_num', type => 'int32',
desc => 'The argument number' }
);
@outargs = (
{ name => 'param_spec', type => 'param',
desc => "The GParamSpec of the argument" }
);
%invoke = (
code => <<CODE
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
error);
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
{
param_spec = g_param_spec_ref (proc->args[arg_num]);
}
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
sub pdb_get_proc_return_value {
$blurb = <<BLURB;
Queries the procedural database for information on the specified procedure's
return value.
BLURB
$help = <<HELP;
This procedure returns the #GParamSpec of procedure_name's return value.
HELP
&mitch_pdb_misc;
$date = '2019';
$since = '3.0';
$lib_private = 1;
@inargs = (
{ name => 'procedure_name', type => 'string', non_empty => 1,
desc => 'The procedure name' },
{ name => 'val_num', type => 'int32',
desc => 'The return value number' }
);
@outargs = (
{ name => 'param_spec', type => 'param',
desc => "The GParamSpec of the return value" }
);
%invoke = (
code => <<CODE
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
error);
if (proc && (val_num >= 0 && val_num < proc->num_values))
{
param_spec = g_param_spec_ref (proc->values[val_num]);
}
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
sub pdb_set_proc_image_types {
$blurb = "Set the supported image types for a plug-in procedure.";
@ -738,106 +838,6 @@ CODE
);
}
sub pdb_get_proc_argument {
$blurb = <<BLURB;
Queries the procedural database for information on the specified procedure's
argument.
BLURB
$help = <<HELP;
This procedure returns the #GParamSpec of procedure_name's argument.
HELP
&mitch_pdb_misc;
$date = '2019';
$since = '3.0';
$lib_private = 1;
@inargs = (
{ name => 'procedure_name', type => 'string', non_empty => 1,
desc => 'The procedure name' },
{ name => 'arg_num', type => 'int32',
desc => 'The argument number' }
);
@outargs = (
{ name => 'param_spec', type => 'param',
desc => "The GParamSpec of the argument" }
);
%invoke = (
code => <<CODE
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
error);
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
{
param_spec = g_param_spec_ref (proc->args[arg_num]);
}
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
sub pdb_get_proc_return_value {
$blurb = <<BLURB;
Queries the procedural database for information on the specified procedure's
return value.
BLURB
$help = <<HELP;
This procedure returns the #GParamSpec of procedure_name's return value.
HELP
&mitch_pdb_misc;
$date = '2019';
$since = '3.0';
$lib_private = 1;
@inargs = (
{ name => 'procedure_name', type => 'string', non_empty => 1,
desc => 'The procedure name' },
{ name => 'val_num', type => 'int32',
desc => 'The return value number' }
);
@outargs = (
{ name => 'param_spec', type => 'param',
desc => "The GParamSpec of the return value" }
);
%invoke = (
code => <<CODE
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
error);
if (proc && (val_num >= 0 && val_num < proc->num_values))
{
param_spec = g_param_spec_ref (proc->values[val_num]);
}
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
sub pdb_get_data {
$blurb = 'Returns data associated with the specified identifier.';
@ -1005,6 +1005,8 @@ CODE
pdb_query
pdb_proc_exists
pdb_get_proc_info
pdb_get_proc_argument
pdb_get_proc_return_value
pdb_set_proc_image_types
pdb_get_proc_image_types
pdb_set_proc_menu_label
@ -1016,8 +1018,6 @@ CODE
pdb_get_proc_documentation
pdb_set_proc_attribution
pdb_get_proc_attribution
pdb_get_proc_argument
pdb_get_proc_return_value
pdb_get_data
pdb_get_data_size
pdb_set_data);