[gimp] pdb: don't return any strings from _gimp_pdb_proc_info()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] pdb: don't return any strings from _gimp_pdb_proc_info()
- Date: Tue, 3 Sep 2019 23:40:35 +0000 (UTC)
commit feaf96735f63b3da3646671b74970dce3acc6a12
Author: Michael Natterer <mitch gimp org>
Date: Wed Sep 4 01:38:31 2019 +0200
pdb: don't return any strings from _gimp_pdb_proc_info()
and instead add _gimp_pdb_proc_documentation() and
_gimp_pdb_proc_attribution().
Remove the gimp_pdb_proc_info() utility function in app/.
app/pdb/gimppdb-query.c | 61 ----------
app/pdb/gimppdb-query.h | 39 +++---
app/pdb/gimpprocedure.c | 8 ++
app/pdb/gimpprocedure.h | 1 +
app/pdb/internal-procs.c | 2 +-
app/pdb/pdb-cmds.c | 293 ++++++++++++++++++++++++++++++++++-----------
libgimp/gimppdb_pdb.c | 141 +++++++++++++++++-----
libgimp/gimppdb_pdb.h | 67 ++++++-----
libgimp/gimppdbprocedure.c | 25 ++--
pdb/groups/pdb.pdb | 214 ++++++++++++++++++++++++---------
10 files changed, 558 insertions(+), 293 deletions(-)
---
diff --git a/app/pdb/gimppdb-query.c b/app/pdb/gimppdb-query.c
index 55276f622e..ec341981e1 100644
--- a/app/pdb/gimppdb-query.c
+++ b/app/pdb/gimppdb-query.c
@@ -262,67 +262,6 @@ gimp_pdb_query (GimpPDB *pdb,
return success;
}
-gboolean
-gimp_pdb_proc_info (GimpPDB *pdb,
- const gchar *proc_name,
- gchar **blurb,
- gchar **help,
- gchar **authors,
- gchar **copyright,
- gchar **date,
- GimpPDBProcType *proc_type,
- gint *num_args,
- gint *num_values,
- GError **error)
-{
- GimpProcedure *procedure;
- PDBStrings strings;
-
- g_return_val_if_fail (GIMP_IS_PDB (pdb), FALSE);
- g_return_val_if_fail (proc_name != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- procedure = gimp_pdb_lookup_procedure (pdb, proc_name);
-
- if (procedure)
- {
- gimp_pdb_get_strings (&strings, procedure, FALSE);
- }
- else
- {
- const gchar *compat_name;
-
- compat_name = gimp_pdb_lookup_compat_proc_name (pdb, proc_name);
-
- if (compat_name)
- {
- procedure = gimp_pdb_lookup_procedure (pdb, compat_name);
-
- if (procedure)
- gimp_pdb_get_strings (&strings, procedure, TRUE);
- }
- }
-
- if (procedure)
- {
- *blurb = strings.compat ? strings.blurb : g_strdup (strings.blurb);
- *help = strings.compat ? strings.help : g_strdup (strings.help);
- *authors = strings.compat ? strings.authors : g_strdup (strings.authors);
- *copyright = strings.compat ? strings.copyright : g_strdup (strings.copyright);
- *date = strings.compat ? strings.date : g_strdup (strings.date);
- *proc_type = procedure->proc_type;
- *num_args = procedure->num_args;
- *num_values = procedure->num_values;
-
- return TRUE;
- }
-
- g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_PROCEDURE_NOT_FOUND,
- _("Procedure '%s' not found"), proc_name);
-
- return FALSE;
-}
-
/* private functions */
diff --git a/app/pdb/gimppdb-query.h b/app/pdb/gimppdb-query.h
index 997d7ac3f1..b29b4f8be0 100644
--- a/app/pdb/gimppdb-query.h
+++ b/app/pdb/gimppdb-query.h
@@ -19,31 +19,20 @@
#define __GIMP_PDB_QUERY_H__
-gboolean gimp_pdb_dump (GimpPDB *pdb,
- GFile *file,
- GError **error);
-gboolean gimp_pdb_query (GimpPDB *pdb,
- const gchar *name,
- const gchar *blurb,
- const gchar *help,
- const gchar *authors,
- const gchar *copyright,
- const gchar *date,
- const gchar *proc_type,
- gint *num_procs,
- gchar ***procs,
- GError **error);
-gboolean gimp_pdb_proc_info (GimpPDB *pdb,
- const gchar *proc_name,
- gchar **blurb,
- gchar **help,
- gchar **authors,
- gchar **copyright,
- gchar **date,
- GimpPDBProcType *proc_type,
- gint *num_args,
- gint *num_values,
- GError **error);
+gboolean gimp_pdb_dump (GimpPDB *pdb,
+ GFile *file,
+ GError **error);
+gboolean gimp_pdb_query (GimpPDB *pdb,
+ const gchar *name,
+ const gchar *blurb,
+ const gchar *help,
+ const gchar *authors,
+ const gchar *copyright,
+ const gchar *date,
+ const gchar *proc_type,
+ gint *num_procs,
+ gchar ***procs,
+ GError **error);
#endif /* __GIMP_PDB_QUERY_H__ */
diff --git a/app/pdb/gimpprocedure.c b/app/pdb/gimpprocedure.c
index 9a54d0eae7..d2de0ffdf5 100644
--- a/app/pdb/gimpprocedure.c
+++ b/app/pdb/gimpprocedure.c
@@ -354,6 +354,14 @@ gimp_procedure_get_blurb (GimpProcedure *procedure)
return GIMP_PROCEDURE_GET_CLASS (procedure)->get_blurb (procedure);
}
+const gchar *
+gimp_procedure_get_help (GimpProcedure *procedure)
+{
+ g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
+
+ return procedure->help;
+}
+
const gchar *
gimp_procedure_get_help_id (GimpProcedure *procedure)
{
diff --git a/app/pdb/gimpprocedure.h b/app/pdb/gimpprocedure.h
index 5fcd222abd..5990c25c38 100644
--- a/app/pdb/gimpprocedure.h
+++ b/app/pdb/gimpprocedure.h
@@ -120,6 +120,7 @@ void gimp_procedure_take_strings (GimpProcedure *procedure,
const gchar * gimp_procedure_get_label (GimpProcedure *procedure);
const gchar * gimp_procedure_get_menu_label (GimpProcedure *procedure);
const gchar * gimp_procedure_get_blurb (GimpProcedure *procedure);
+const gchar * gimp_procedure_get_help (GimpProcedure *procedure);
const gchar * gimp_procedure_get_help_id (GimpProcedure *procedure);
gboolean gimp_procedure_get_sensitive (GimpProcedure *procedure,
GimpObject *object,
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 99d5a369d0..9a1782134e 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 743 procedures registered total */
+/* 745 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/pdb-cmds.c b/app/pdb/pdb-cmds.c
index 324bb91eec..ff088e91fc 100644
--- a/app/pdb/pdb-cmds.c
+++ b/app/pdb/pdb-cmds.c
@@ -37,10 +37,36 @@
#include "plug-in/gimppluginmanager-data.h"
#include "gimppdb.h"
+#include "gimppdberror.h"
#include "gimppdb-utils.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
+#include "gimp-intl.h"
+
+
+static GimpProcedure *
+lookup_procedure (GimpPDB *pdb,
+ const gchar *proc_name,
+ GError **error)
+{
+ GimpProcedure *proc = gimp_pdb_lookup_procedure (pdb, proc_name);
+
+ if (! proc)
+ {
+ const gchar *compat_name = gimp_pdb_lookup_compat_proc_name (pdb,
+ proc_name);
+
+ if (compat_name)
+ proc = gimp_pdb_lookup_procedure (pdb, compat_name);
+ }
+
+ if (! proc)
+ g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_PROCEDURE_NOT_FOUND,
+ _("Procedure '%s' not found"), proc_name);
+
+ return proc;
+}
static GimpValueArray *
pdb_temp_name_invoker (GimpProcedure *procedure,
@@ -157,20 +183,19 @@ pdb_proc_exists_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
- GimpProcedure *procedure;
-
- procedure = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
+ GimpProcedure *proc = gimp_pdb_lookup_procedure (gimp->pdb,
+ procedure_name);
- if (! procedure)
+ if (! proc)
{
procedure_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb,
procedure_name);
if (procedure_name)
- procedure = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
+ proc = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
}
- exists = (procedure != NULL);
+ exists = (proc != NULL);
}
else
success = FALSE;
@@ -196,11 +221,6 @@ pdb_proc_info_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpValueArray *return_vals;
const gchar *procedure_name;
- gchar *blurb = NULL;
- gchar *help = NULL;
- gchar *authors = NULL;
- gchar *copyright = NULL;
- gchar *date = NULL;
gint proc_type = 0;
gint num_args = 0;
gint num_values = 0;
@@ -211,14 +231,67 @@ pdb_proc_info_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
- GimpPDBProcType ptype;
-
- success = gimp_pdb_proc_info (gimp->pdb, procedure_name,
- &blurb, &help, &authors,
- ©right, &date, &ptype,
- &num_args, &num_values,
- error);
- proc_type = ptype;
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
+
+ if (proc)
+ {
+ proc_type = proc->proc_type;
+ num_args = proc->num_args;
+ num_values = proc->num_values;
+ }
+ else
+ success = FALSE;
+ }
+ else
+ success = FALSE;
+ }
+
+ return_vals = gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+
+ if (success)
+ {
+ g_value_set_enum (gimp_value_array_index (return_vals, 1), proc_type);
+ g_value_set_int (gimp_value_array_index (return_vals, 2), num_args);
+ g_value_set_int (gimp_value_array_index (return_vals, 3), num_values);
+ }
+
+ return return_vals;
+}
+
+static GimpValueArray *
+pdb_proc_documentation_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpValueArray *return_vals;
+ const gchar *procedure_name;
+ gchar *blurb = NULL;
+ gchar *help = NULL;
+ gchar *help_id = NULL;
+
+ procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
+
+ if (success)
+ {
+ if (gimp_pdb_is_canonical_procedure (procedure_name, error))
+ {
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
+
+ if (proc)
+ {
+ blurb = g_strdup (gimp_procedure_get_blurb (proc));
+ help = g_strdup (gimp_procedure_get_help (proc));
+ help_id = g_strdup (gimp_procedure_get_help_id (proc));
+ }
+ else
+ success = FALSE;
}
else
success = FALSE;
@@ -231,12 +304,57 @@ pdb_proc_info_invoker (GimpProcedure *procedure,
{
g_value_take_string (gimp_value_array_index (return_vals, 1), blurb);
g_value_take_string (gimp_value_array_index (return_vals, 2), help);
- g_value_take_string (gimp_value_array_index (return_vals, 3), authors);
- g_value_take_string (gimp_value_array_index (return_vals, 4), copyright);
- g_value_take_string (gimp_value_array_index (return_vals, 5), date);
- g_value_set_enum (gimp_value_array_index (return_vals, 6), proc_type);
- g_value_set_int (gimp_value_array_index (return_vals, 7), num_args);
- g_value_set_int (gimp_value_array_index (return_vals, 8), num_values);
+ g_value_take_string (gimp_value_array_index (return_vals, 3), help_id);
+ }
+
+ return return_vals;
+}
+
+static GimpValueArray *
+pdb_proc_attribution_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpValueArray *return_vals;
+ const gchar *procedure_name;
+ gchar *authors = NULL;
+ gchar *copyright = NULL;
+ gchar *date = NULL;
+
+ procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
+
+ if (success)
+ {
+ if (gimp_pdb_is_canonical_procedure (procedure_name, error))
+ {
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
+
+ if (proc)
+ {
+ authors = g_strdup (proc->authors);
+ copyright = g_strdup (proc->copyright);
+ date = g_strdup (proc->date);
+ }
+ else
+ success = FALSE;
+ }
+ else
+ success = FALSE;
+ }
+
+ return_vals = gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+
+ if (success)
+ {
+ g_value_take_string (gimp_value_array_index (return_vals, 1), authors);
+ g_value_take_string (gimp_value_array_index (return_vals, 2), copyright);
+ g_value_take_string (gimp_value_array_index (return_vals, 3), date);
}
return return_vals;
@@ -263,20 +381,8 @@ pdb_proc_argument_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
- GimpProcedure *proc;
-
- proc = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
-
- if (! proc)
- {
- const gchar *compat_name;
-
- compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb,
- procedure_name);
-
- if (compat_name)
- proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
- }
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
{
@@ -319,20 +425,8 @@ pdb_proc_return_value_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
- GimpProcedure *proc;
-
- proc = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
-
- if (! proc)
- {
- const gchar *compat_name;
-
- compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb,
- procedure_name);
-
- if (compat_name)
- proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
- }
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
if (proc && (val_num >= 0 && val_num < proc->num_values))
{
@@ -632,7 +726,7 @@ register_pdb_procs (GimpPDB *pdb)
"gimp-pdb-proc-info");
gimp_procedure_set_static_strings (procedure,
"Queries the procedural database for information on the specified
procedure.",
- "This procedure returns information on the specified procedure. A short
blurb, detailed help, authors, copyright information, procedure type, number of input, and number of return
values are returned. For specific information on each input argument and return value, use the
'gimp-pdb-db-proc-argument' and 'gimp-pdb-db-proc-return-value' procedures.",
+ "This procedure returns information on the specified procedure. The
procedure type, number of input, and number of return values are returned. For specific information on each
input argument and return value, use the 'gimp-pdb-db-proc-argument' and 'gimp-pdb-db-proc-return-value'
procedures.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997",
@@ -644,6 +738,48 @@ register_pdb_procs (GimpPDB *pdb)
FALSE, FALSE, TRUE,
NULL,
GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ g_param_spec_enum ("proc-type",
+ "proc type",
+ "The procedure type",
+ GIMP_TYPE_PDB_PROC_TYPE,
+ GIMP_PDB_PROC_TYPE_INTERNAL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ g_param_spec_int ("num-args",
+ "num args",
+ "The number of input arguments",
+ G_MININT32, G_MAXINT32, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ g_param_spec_int ("num-values",
+ "num values",
+ "The number of return values",
+ G_MININT32, G_MAXINT32, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
+ /*
+ * gimp-pdb-proc-documentation
+ */
+ procedure = gimp_procedure_new (pdb_proc_documentation_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "gimp-pdb-proc-documentation");
+ gimp_procedure_set_static_strings (procedure,
+ "Queries the procedural database for documentation on the specified
procedure.",
+ "This procedure returns documentation on the specified procedure. A
short blurb, detailed help and help_id.",
+ "Michael Natterer <mitch gimp org>",
+ "Michael Natterer",
+ "2019",
+ NULL);
+ 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_return_value (procedure,
gimp_param_spec_string ("blurb",
"blurb",
@@ -658,6 +794,36 @@ register_pdb_procs (GimpPDB *pdb)
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_string ("help-id",
+ "help id",
+ "The procedure help_id",
+ FALSE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
+ /*
+ * gimp-pdb-proc-attribution
+ */
+ procedure = gimp_procedure_new (pdb_proc_attribution_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "gimp-pdb-proc-attribution");
+ gimp_procedure_set_static_strings (procedure,
+ "Queries the procedural database for attribution information on the
specified procedure.",
+ "This procedure returns attribution information on the specified
procedure. The authors, copyright information and date are returned.",
+ "Michael Natterer <mitch gimp org>",
+ "Michael Natterer",
+ "2019",
+ NULL);
+ 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_return_value (procedure,
gimp_param_spec_string ("authors",
"authors",
@@ -679,25 +845,6 @@ register_pdb_procs (GimpPDB *pdb)
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
- gimp_procedure_add_return_value (procedure,
- g_param_spec_enum ("proc-type",
- "proc type",
- "The procedure type",
- GIMP_TYPE_PDB_PROC_TYPE,
- GIMP_PDB_PROC_TYPE_INTERNAL,
- GIMP_PARAM_READWRITE));
- gimp_procedure_add_return_value (procedure,
- g_param_spec_int ("num-args",
- "num args",
- "The number of input arguments",
- G_MININT32, G_MAXINT32, 0,
- GIMP_PARAM_READWRITE));
- gimp_procedure_add_return_value (procedure,
- g_param_spec_int ("num-values",
- "num values",
- "The number of return values",
- G_MININT32, G_MAXINT32, 0,
- GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
diff --git a/libgimp/gimppdb_pdb.c b/libgimp/gimppdb_pdb.c
index bd3a42e49e..eca4a10f0f 100644
--- a/libgimp/gimppdb_pdb.c
+++ b/libgimp/gimppdb_pdb.c
@@ -210,11 +210,6 @@ _gimp_pdb_proc_exists (const gchar *procedure_name)
/**
* _gimp_pdb_proc_info:
* @procedure_name: The procedure name.
- * @blurb: (out) (transfer full): A short blurb.
- * @help: (out) (transfer full): Detailed procedure help.
- * @authors: (out) (transfer full): Authors of the procedure.
- * @copyright: (out) (transfer full): The copyright.
- * @date: (out) (transfer full): Copyright date.
* @proc_type: (out): The procedure type.
* @num_args: (out): The number of input arguments.
* @num_values: (out): The number of return values.
@@ -222,8 +217,7 @@ _gimp_pdb_proc_exists (const gchar *procedure_name)
* Queries the procedural database for information on the specified
* procedure.
*
- * This procedure returns information on the specified procedure. A
- * short blurb, detailed help, authors, copyright information,
+ * This procedure returns information on the specified procedure. The
* procedure type, number of input, and number of return values are
* returned. For specific information on each input argument and return
* value, use the gimp_pdb_db_proc_argument() and
@@ -232,15 +226,10 @@ _gimp_pdb_proc_exists (const gchar *procedure_name)
* Returns: TRUE on success.
**/
gboolean
-_gimp_pdb_proc_info (const gchar *procedure_name,
- gchar **blurb,
- gchar **help,
- gchar **authors,
- gchar **copyright,
- gchar **date,
- GimpPDBProcType *proc_type,
- gint *num_args,
- gint *num_values)
+_gimp_pdb_proc_info (const gchar *procedure_name,
+ GimpPDBProcType *proc_type,
+ gint *num_args,
+ gint *num_values)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@@ -255,27 +244,125 @@ _gimp_pdb_proc_info (const gchar *procedure_name,
args);
gimp_value_array_unref (args);
- *blurb = NULL;
- *help = NULL;
- *authors = NULL;
- *copyright = NULL;
- *date = NULL;
*proc_type = 0;
*num_args = 0;
*num_values = 0;
success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
+ if (success)
+ {
+ *proc_type = g_value_get_enum (gimp_value_array_index (return_vals, 1));
+ *num_args = g_value_get_int (gimp_value_array_index (return_vals, 2));
+ *num_values = g_value_get_int (gimp_value_array_index (return_vals, 3));
+ }
+
+ gimp_value_array_unref (return_vals);
+
+ return success;
+}
+
+/**
+ * _gimp_pdb_proc_documentation:
+ * @procedure_name: The procedure name.
+ * @blurb: (out) (transfer full): A short blurb.
+ * @help: (out) (transfer full): Detailed procedure help.
+ * @help_id: (out) (transfer full): The procedure help_id.
+ *
+ * Queries the procedural database for documentation on the specified
+ * procedure.
+ *
+ * This procedure returns documentation on the specified procedure. A
+ * short blurb, detailed help and help_id.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 3.0
+ **/
+gboolean
+_gimp_pdb_proc_documentation (const gchar *procedure_name,
+ gchar **blurb,
+ gchar **help,
+ gchar **help_id)
+{
+ GimpValueArray *args;
+ GimpValueArray *return_vals;
+ gboolean success = TRUE;
+
+ args = gimp_value_array_new_from_types (NULL,
+ G_TYPE_STRING, procedure_name,
+ G_TYPE_NONE);
+
+ return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
+ "gimp-pdb-proc-documentation",
+ args);
+ gimp_value_array_unref (args);
+
+ *blurb = NULL;
+ *help = NULL;
+ *help_id = NULL;
+
+ success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
+
if (success)
{
*blurb = g_value_dup_string (gimp_value_array_index (return_vals, 1));
*help = g_value_dup_string (gimp_value_array_index (return_vals, 2));
- *authors = g_value_dup_string (gimp_value_array_index (return_vals, 3));
- *copyright = g_value_dup_string (gimp_value_array_index (return_vals, 4));
- *date = g_value_dup_string (gimp_value_array_index (return_vals, 5));
- *proc_type = g_value_get_enum (gimp_value_array_index (return_vals, 6));
- *num_args = g_value_get_int (gimp_value_array_index (return_vals, 7));
- *num_values = g_value_get_int (gimp_value_array_index (return_vals, 8));
+ *help_id = g_value_dup_string (gimp_value_array_index (return_vals, 3));
+ }
+
+ gimp_value_array_unref (return_vals);
+
+ return success;
+}
+
+/**
+ * _gimp_pdb_proc_attribution:
+ * @procedure_name: The procedure name.
+ * @authors: (out) (transfer full): Authors of the procedure.
+ * @copyright: (out) (transfer full): The copyright.
+ * @date: (out) (transfer full): Copyright date.
+ *
+ * Queries the procedural database for attribution information on the
+ * specified procedure.
+ *
+ * This procedure returns attribution information on the specified
+ * procedure. The authors, copyright information and date are returned.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 3.0
+ **/
+gboolean
+_gimp_pdb_proc_attribution (const gchar *procedure_name,
+ gchar **authors,
+ gchar **copyright,
+ gchar **date)
+{
+ GimpValueArray *args;
+ GimpValueArray *return_vals;
+ gboolean success = TRUE;
+
+ args = gimp_value_array_new_from_types (NULL,
+ G_TYPE_STRING, procedure_name,
+ G_TYPE_NONE);
+
+ return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
+ "gimp-pdb-proc-attribution",
+ args);
+ gimp_value_array_unref (args);
+
+ *authors = NULL;
+ *copyright = NULL;
+ *date = NULL;
+
+ success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
+
+ if (success)
+ {
+ *authors = g_value_dup_string (gimp_value_array_index (return_vals, 1));
+ *copyright = g_value_dup_string (gimp_value_array_index (return_vals, 2));
+ *date = g_value_dup_string (gimp_value_array_index (return_vals, 3));
}
gimp_value_array_unref (return_vals);
diff --git a/libgimp/gimppdb_pdb.h b/libgimp/gimppdb_pdb.h
index 78e1b8cf20..f105004aa4 100644
--- a/libgimp/gimppdb_pdb.h
+++ b/libgimp/gimppdb_pdb.h
@@ -32,38 +32,41 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
-G_GNUC_INTERNAL gchar* _gimp_pdb_temp_name (void);
-G_GNUC_INTERNAL gboolean _gimp_pdb_dump (const gchar *filename);
-G_GNUC_INTERNAL gboolean _gimp_pdb_query (const gchar *name,
- const gchar *blurb,
- const gchar *help,
- const gchar *authors,
- const gchar *copyright,
- const gchar *date,
- const gchar *proc_type,
- gint *num_matches,
- gchar ***procedure_names);
-G_GNUC_INTERNAL gboolean _gimp_pdb_proc_exists (const gchar *procedure_name);
-G_GNUC_INTERNAL gboolean _gimp_pdb_proc_info (const gchar *procedure_name,
- gchar **blurb,
- gchar **help,
- gchar **authors,
- gchar **copyright,
- gchar **date,
- GimpPDBProcType *proc_type,
- gint *num_args,
- gint *num_values);
-G_GNUC_INTERNAL GParamSpec* _gimp_pdb_proc_argument (const gchar *procedure_name,
- gint arg_num);
-G_GNUC_INTERNAL GParamSpec* _gimp_pdb_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);
-G_GNUC_INTERNAL gint _gimp_pdb_get_data_size (const gchar *identifier);
-G_GNUC_INTERNAL gboolean _gimp_pdb_set_data (const gchar *identifier,
- gint bytes,
- const guint8 *data);
+G_GNUC_INTERNAL gchar* _gimp_pdb_temp_name (void);
+G_GNUC_INTERNAL gboolean _gimp_pdb_dump (const gchar *filename);
+G_GNUC_INTERNAL gboolean _gimp_pdb_query (const gchar *name,
+ const gchar *blurb,
+ const gchar *help,
+ const gchar *authors,
+ const gchar *copyright,
+ const gchar *date,
+ const gchar *proc_type,
+ gint *num_matches,
+ gchar ***procedure_names);
+G_GNUC_INTERNAL gboolean _gimp_pdb_proc_exists (const gchar *procedure_name);
+G_GNUC_INTERNAL gboolean _gimp_pdb_proc_info (const gchar *procedure_name,
+ GimpPDBProcType *proc_type,
+ gint *num_args,
+ gint *num_values);
+G_GNUC_INTERNAL gboolean _gimp_pdb_proc_documentation (const gchar *procedure_name,
+ gchar **blurb,
+ gchar **help,
+ gchar **help_id);
+G_GNUC_INTERNAL gboolean _gimp_pdb_proc_attribution (const gchar *procedure_name,
+ gchar **authors,
+ gchar **copyright,
+ gchar **date);
+G_GNUC_INTERNAL GParamSpec* _gimp_pdb_proc_argument (const gchar *procedure_name,
+ gint arg_num);
+G_GNUC_INTERNAL GParamSpec* _gimp_pdb_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);
+G_GNUC_INTERNAL gint _gimp_pdb_get_data_size (const gchar *identifier);
+G_GNUC_INTERNAL gboolean _gimp_pdb_set_data (const gchar *identifier,
+ gint bytes,
+ const guint8 *data);
G_END_DECLS
diff --git a/libgimp/gimppdbprocedure.c b/libgimp/gimppdbprocedure.c
index 80996380e3..cc5857e5cb 100644
--- a/libgimp/gimppdbprocedure.c
+++ b/libgimp/gimppdbprocedure.c
@@ -180,25 +180,14 @@ _gimp_pdb_procedure_new (GimpPDB *pdb,
gchar *copyright;
gchar *date;
GimpPDBProcType type;
- gint n_params;
+ gint n_args;
gint n_return_vals;
gint i;
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
g_return_val_if_fail (gimp_is_canonical_identifier (name), NULL);
- _gimp_pdb_proc_info (name,
- &blurb,
- &help,
- /* FIXME &help_id, */
- &authors,
- ©right,
- &date,
- &type,
- &n_params,
- &n_return_vals);
-
- help_id = g_strdup (name); /* FIXME */
+ _gimp_pdb_proc_info (name, &type, &n_args, &n_return_vals);
procedure = g_object_new (GIMP_TYPE_PDB_PROCEDURE,
"plug-in", _gimp_pdb_get_plug_in (pdb),
@@ -207,17 +196,19 @@ _gimp_pdb_procedure_new (GimpPDB *pdb,
"pdb", pdb,
NULL);
- gimp_procedure_set_documentation (procedure, blurb, help, help_id);
- gimp_procedure_set_attribution (procedure, authors, copyright, date);
-
+ _gimp_pdb_proc_documentation (name, &blurb, &help, &help_id);
+ gimp_procedure_set_documentation (procedure, blurb, help, help_id);
g_free (blurb);
g_free (help);
g_free (help_id);
+
+ _gimp_pdb_proc_attribution (name, &authors, ©right, &date);
+ gimp_procedure_set_attribution (procedure, authors, copyright, date);
g_free (authors);
g_free (copyright);
g_free (date);
- for (i = 0; i < n_params; i++)
+ for (i = 0; i < n_args; i++)
{
GParamSpec *pspec = _gimp_pdb_proc_argument (name, i);
diff --git a/pdb/groups/pdb.pdb b/pdb/groups/pdb.pdb
index b24417721d..0bdd2a2c68 100644
--- a/pdb/groups/pdb.pdb
+++ b/pdb/groups/pdb.pdb
@@ -169,20 +169,19 @@ HELP
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
- GimpProcedure *procedure;
+ GimpProcedure *proc = gimp_pdb_lookup_procedure (gimp->pdb,
+ procedure_name);
- procedure = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
-
- if (! procedure)
+ if (! proc)
{
procedure_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb,
procedure_name);
if (procedure_name)
- procedure = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
+ proc = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
}
- exists = (procedure != NULL);
+ exists = (proc != NULL);
}
else
success = FALSE;
@@ -197,12 +196,11 @@ Queries the procedural database for information on the specified procedure.
BLURB
$help = <<'HELP';
-This procedure returns information on the specified procedure. A short
-blurb, detailed help, authors, copyright information, procedure
-type, number of input, and number of return values are returned. For
-specific information on each input argument and return value, use the
-gimp_pdb_db_proc_argument() and gimp_pdb_db_proc_return_value()
-procedures.
+This procedure returns information on the specified procedure. The
+procedure type, number of input, and number of return values are
+returned. For specific information on each input argument and return
+value, use the gimp_pdb_db_proc_argument() and
+gimp_pdb_db_proc_return_value() procedures.
HELP
&std_pdb_misc;
@@ -215,23 +213,118 @@ HELP
desc => 'The procedure name' }
);
+ @outargs = (
+ { name => 'proc_type', type => 'enum GimpPDBProcType', void_ret => 1,
+ desc => 'The procedure type' },
+ { name => 'num_args', type => 'int32',
+ desc => 'The number of input arguments' },
+ { name => 'num_values', type => 'int32',
+ desc => 'The number of return values' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ if (gimp_pdb_is_canonical_procedure (procedure_name, error))
+ {
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
+
+ if (proc)
+ {
+ proc_type = proc->proc_type;
+ num_args = proc->num_args;
+ num_values = proc->num_values;
+ }
+ else
+ success = FALSE;
+ }
+ else
+ success = FALSE;
+}
+CODE
+ );
+}
+
+sub pdb_proc_documentation {
+ $blurb = <<'BLURB';
+Queries the procedural database for documentation on the specified procedure.
+BLURB
+
+ $help = <<'HELP';
+This procedure returns documentation on the specified procedure. A
+short blurb, detailed help and help_id.
+HELP
+
+ &mitch_pdb_misc('2019', '3.0');
+
+ $lib_private = 1;
+
+ @inargs = (
+ { name => 'procedure_name', type => 'string', non_empty => 1,
+ desc => 'The procedure name' }
+ );
+
@outargs = (
{ name => 'blurb', type => 'string', void_ret => 1,
desc => 'A short blurb' },
{ name => 'help', type => 'string',
desc => 'Detailed procedure help' },
- { name => 'authors', type => 'string',
+ { name => 'help_id', type => 'string',
+ desc => 'The procedure help_id' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ if (gimp_pdb_is_canonical_procedure (procedure_name, error))
+ {
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
+
+ if (proc)
+ {
+ blurb = g_strdup (gimp_procedure_get_blurb (proc));
+ help = g_strdup (gimp_procedure_get_help (proc));
+ help_id = g_strdup (gimp_procedure_get_help_id (proc));
+ }
+ else
+ success = FALSE;
+ }
+ else
+ success = FALSE;
+}
+CODE
+ );
+}
+
+sub pdb_proc_attribution {
+ $blurb = <<'BLURB';
+Queries the procedural database for attribution information on the
+specified procedure.
+BLURB
+
+ $help = <<'HELP';
+This procedure returns attribution information on the specified
+procedure. The authors, copyright information and date are returned.
+HELP
+
+ &mitch_pdb_misc('2019', '3.0');
+
+ $lib_private = 1;
+
+ @inargs = (
+ { name => 'procedure_name', type => 'string', non_empty => 1,
+ desc => 'The procedure name' }
+ );
+
+ @outargs = (
+ { name => 'authors', type => 'string', void_ret => 1,
desc => 'Authors of the procedure' },
{ name => 'copyright', type => 'string',
desc => 'The copyright' },
{ name => 'date', type => 'string',
- desc => 'Copyright date' },
- { name => 'proc_type', type => 'enum GimpPDBProcType',
- desc => 'The procedure type' },
- { name => 'num_args', type => 'int32',
- desc => 'The number of input arguments' },
- { name => 'num_values', type => 'int32',
- desc => 'The number of return values' }
+ desc => 'Copyright date' }
);
%invoke = (
@@ -239,14 +332,17 @@ HELP
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
- GimpPDBProcType ptype;
-
- success = gimp_pdb_proc_info (gimp->pdb, procedure_name,
- &blurb, &help, &authors,
- ©right, &date, &ptype,
- &num_args, &num_values,
- error);
- proc_type = ptype;
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
+
+ if (proc)
+ {
+ authors = g_strdup (proc->authors);
+ copyright = g_strdup (proc->copyright);
+ date = g_strdup (proc->date);
+ }
+ else
+ success = FALSE;
}
else
success = FALSE;
@@ -288,20 +384,8 @@ HELP
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
- GimpProcedure *proc;
-
- proc = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
-
- if (! proc)
- {
- const gchar *compat_name;
-
- compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb,
- procedure_name);
-
- if (compat_name)
- proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
- }
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
{
@@ -350,20 +434,8 @@ HELP
{
if (gimp_pdb_is_canonical_procedure (procedure_name, error))
{
- GimpProcedure *proc;
-
- proc = gimp_pdb_lookup_procedure (gimp->pdb, procedure_name);
-
- if (! proc)
- {
- const gchar *compat_name;
-
- compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb,
- procedure_name);
-
- if (compat_name)
- proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
- }
+ GimpProcedure *proc = lookup_procedure (gimp->pdb, procedure_name,
+ error);
if (proc && (val_num >= 0 && val_num < proc->num_values))
{
@@ -503,6 +575,30 @@ CODE
);
}
+$extra{app}->{code} = <<'CODE';
+static GimpProcedure *
+lookup_procedure (GimpPDB *pdb,
+ const gchar *proc_name,
+ GError **error)
+{
+ GimpProcedure *proc = gimp_pdb_lookup_procedure (pdb, proc_name);
+
+ if (! proc)
+ {
+ const gchar *compat_name = gimp_pdb_lookup_compat_proc_name (pdb,
+ proc_name);
+
+ if (compat_name)
+ proc = gimp_pdb_lookup_procedure (pdb, compat_name);
+ }
+
+ if (! proc)
+ g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_PROCEDURE_NOT_FOUND,
+ _("Procedure '%s' not found"), proc_name);
+
+ return proc;
+}
+CODE
@headers = qw("libgimpbase/gimpbase.h"
"core/gimp.h"
@@ -510,13 +606,17 @@ CODE
"plug-in/gimppluginmanager-data.h"
"gimppdb-query.h"
"gimppdb-utils.h"
- "gimp-pdb-compat.h");
+ "gimppdberror.h"
+ "gimp-pdb-compat.h"
+ "gimp-intl.h");
@procs = qw(pdb_temp_name
pdb_dump
pdb_query
pdb_proc_exists
pdb_proc_info
+ pdb_proc_documentation
+ pdb_proc_attribution
pdb_proc_argument
pdb_proc_return_value
pdb_get_data
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]