[gimp] pdb: add gimp_pdb_set_proc_documentation() and _attribution()



commit 22a780c9d14b4e235de71c35c5fd3161ed2a8eb8
Author: Michael Natterer <mitch gimp org>
Date:   Mon Sep 9 00:36:24 2019 +0200

    pdb: add gimp_pdb_set_proc_documentation() and _attribution()
    
    and all the needed code in libgimp/ and app/ to set them on a
    procedure using the new API. Remove the strings from GPProcInstall.

 app/pdb/internal-procs.c         |   2 +-
 app/pdb/pdb-cmds.c               | 164 +++++++++++++++++++++++++++++++++++++++
 app/plug-in/gimpplugin-message.c |  62 +++++----------
 app/plug-in/gimpplugin-proc.c    |  69 ++++++++++++++++
 app/plug-in/gimpplugin-proc.h    |  10 +++
 libgimp/gimppdb_pdb.c            |  88 +++++++++++++++++++++
 libgimp/gimppdb_pdb.h            |   8 ++
 libgimp/gimpprocedure.c          |  51 +++++++++---
 libgimpbase/gimpprotocol.c       |  80 +++----------------
 libgimpbase/gimpprotocol.h       |   6 --
 pdb/groups/pdb.pdb               |  82 ++++++++++++++++++++
 11 files changed, 496 insertions(+), 126 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index b28c50fb30..ab84499432 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 751 procedures registered total */
+/* 753 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/pdb-cmds.c b/app/pdb/pdb-cmds.c
index e6755b83ca..1bdc95a440 100644
--- a/app/pdb/pdb-cmds.c
+++ b/app/pdb/pdb-cmds.c
@@ -547,6 +547,43 @@ pdb_set_proc_icon_invoker (GimpProcedure         *procedure,
                                            error ? *error : NULL);
 }
 
+static GimpValueArray *
+pdb_set_proc_documentation_invoker (GimpProcedure         *procedure,
+                                    Gimp                  *gimp,
+                                    GimpContext           *context,
+                                    GimpProgress          *progress,
+                                    const GimpValueArray  *args,
+                                    GError               **error)
+{
+  gboolean success = TRUE;
+  const gchar *procedure_name;
+  const gchar *blurb;
+  const gchar *help;
+  const gchar *help_id;
+
+  procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
+  blurb = g_value_get_string (gimp_value_array_index (args, 1));
+  help = g_value_get_string (gimp_value_array_index (args, 2));
+  help_id = g_value_get_string (gimp_value_array_index (args, 3));
+
+  if (success)
+    {
+      GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
+
+      if (plug_in &&
+          gimp_pdb_is_canonical_procedure (procedure_name, error))
+        {
+          success = gimp_plug_in_set_proc_help (plug_in, procedure_name,
+                                                blurb, help, help_id);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
 static GimpValueArray *
 pdb_get_proc_documentation_invoker (GimpProcedure         *procedure,
                                     Gimp                  *gimp,
@@ -597,6 +634,43 @@ pdb_get_proc_documentation_invoker (GimpProcedure         *procedure,
   return return_vals;
 }
 
+static GimpValueArray *
+pdb_set_proc_attribution_invoker (GimpProcedure         *procedure,
+                                  Gimp                  *gimp,
+                                  GimpContext           *context,
+                                  GimpProgress          *progress,
+                                  const GimpValueArray  *args,
+                                  GError               **error)
+{
+  gboolean success = TRUE;
+  const gchar *procedure_name;
+  const gchar *authors;
+  const gchar *copyright;
+  const gchar *date;
+
+  procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
+  authors = g_value_get_string (gimp_value_array_index (args, 1));
+  copyright = g_value_get_string (gimp_value_array_index (args, 2));
+  date = g_value_get_string (gimp_value_array_index (args, 3));
+
+  if (success)
+    {
+      GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
+
+      if (plug_in &&
+          gimp_pdb_is_canonical_procedure (procedure_name, error))
+        {
+          success = gimp_plug_in_set_proc_attribution (plug_in, procedure_name,
+                                                       authors, copyright, date);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
 static GimpValueArray *
 pdb_get_proc_attribution_invoker (GimpProcedure         *procedure,
                                   Gimp                  *gimp,
@@ -1284,6 +1358,51 @@ register_pdb_procs (GimpPDB *pdb)
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
 
+  /*
+   * gimp-pdb-set-proc-documentation
+   */
+  procedure = gimp_procedure_new (pdb_set_proc_documentation_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-pdb-set-proc-documentation");
+  gimp_procedure_set_static_help (procedure,
+                                  "Set the documentation for a plug-in procedure.",
+                                  "This procedure sets the documentation for the given procedure.",
+                                  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 for which to install the menu path",
+                                                       FALSE, FALSE, TRUE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("blurb",
+                                                       "blurb",
+                                                       "A short blurb",
+                                                       FALSE, TRUE, FALSE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("help",
+                                                       "help",
+                                                       "Detailed procedure help",
+                                                       FALSE, TRUE, FALSE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("help-id",
+                                                       "help id",
+                                                       "The procedure help_id",
+                                                       FALSE, TRUE, FALSE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
   /*
    * gimp-pdb-get-proc-documentation
    */
@@ -1329,6 +1448,51 @@ register_pdb_procs (GimpPDB *pdb)
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
 
+  /*
+   * gimp-pdb-set-proc-attribution
+   */
+  procedure = gimp_procedure_new (pdb_set_proc_attribution_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-pdb-set-proc-attribution");
+  gimp_procedure_set_static_help (procedure,
+                                  "Set the attribution for a plug-in procedure.",
+                                  "This procedure sets the attribution for the given procedure.",
+                                  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 for which to install the menu path",
+                                                       FALSE, FALSE, TRUE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("authors",
+                                                       "authors",
+                                                       "Authors of the procedure",
+                                                       FALSE, TRUE, FALSE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("copyright",
+                                                       "copyright",
+                                                       "The copyright",
+                                                       FALSE, TRUE, FALSE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("date",
+                                                       "date",
+                                                       "Copyright date",
+                                                       FALSE, TRUE, FALSE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
   /*
    * gimp-pdb-get-proc-attribution
    */
diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c
index b019dd10bb..216abc39be 100644
--- a/app/plug-in/gimpplugin-message.c
+++ b/app/plug-in/gimpplugin-message.c
@@ -704,7 +704,7 @@ gimp_plug_in_handle_proc_install (GimpPlugIn    *plug_in,
   GimpPlugInProcedure *proc       = NULL;
   GimpProcedure       *procedure  = NULL;
   gboolean             null_name  = FALSE;
-  gboolean             valid_utf8 = FALSE;
+  gboolean             valid_utf8 = TRUE;
   gint                 i;
 
   g_return_if_fail (proc_install != NULL);
@@ -755,43 +755,31 @@ gimp_plug_in_handle_proc_install (GimpPlugIn    *plug_in,
 #define VALIDATE(str)         (g_utf8_validate ((str), -1, NULL))
 #define VALIDATE_OR_NULL(str) ((str) == NULL || g_utf8_validate ((str), -1, NULL))
 
-  if (VALIDATE         (proc_install->name)       &&
-      VALIDATE_OR_NULL (proc_install->blurb)      &&
-      VALIDATE_OR_NULL (proc_install->help)       &&
-      VALIDATE_OR_NULL (proc_install->help_id)    &&
-      VALIDATE_OR_NULL (proc_install->authors)    &&
-      VALIDATE_OR_NULL (proc_install->copyright)  &&
-      VALIDATE_OR_NULL (proc_install->date))
+  for (i = 0; i < proc_install->nparams && valid_utf8 && ! null_name; i++)
     {
-      null_name  = FALSE;
-      valid_utf8 = TRUE;
-
-      for (i = 0; i < proc_install->nparams && valid_utf8 && ! null_name; i++)
+      if (! proc_install->params[i].name)
         {
-          if (! proc_install->params[i].name)
-            {
-              null_name = TRUE;
-            }
-          else if (! (VALIDATE         (proc_install->params[i].name) &&
-                      VALIDATE_OR_NULL (proc_install->params[i].nick) &&
-                      VALIDATE_OR_NULL (proc_install->params[i].blurb)))
-            {
-              valid_utf8 = FALSE;
-            }
+          null_name = TRUE;
+        }
+      else if (! (VALIDATE         (proc_install->params[i].name) &&
+                  VALIDATE_OR_NULL (proc_install->params[i].nick) &&
+                  VALIDATE_OR_NULL (proc_install->params[i].blurb)))
+        {
+          valid_utf8 = FALSE;
         }
+    }
 
-      for (i = 0; i < proc_install->nreturn_vals && valid_utf8 && !null_name; i++)
+  for (i = 0; i < proc_install->nreturn_vals && valid_utf8 && !null_name; i++)
+    {
+      if (! proc_install->return_vals[i].name)
         {
-          if (! proc_install->return_vals[i].name)
-            {
-              null_name = TRUE;
-            }
-          else if (! (VALIDATE         (proc_install->return_vals[i].name) &&
-                      VALIDATE_OR_NULL (proc_install->return_vals[i].nick) &&
-                      VALIDATE_OR_NULL (proc_install->return_vals[i].blurb)))
-            {
-              valid_utf8 = FALSE;
-            }
+          null_name = TRUE;
+        }
+      else if (! (VALIDATE         (proc_install->return_vals[i].name) &&
+                  VALIDATE_OR_NULL (proc_install->return_vals[i].nick) &&
+                  VALIDATE_OR_NULL (proc_install->return_vals[i].blurb)))
+        {
+          valid_utf8 = FALSE;
         }
     }
 
@@ -843,14 +831,6 @@ gimp_plug_in_handle_proc_install (GimpPlugIn    *plug_in,
   proc->installed_during_init = (plug_in->call_mode == GIMP_PLUG_IN_CALL_INIT);
 
   gimp_object_set_name (GIMP_OBJECT (procedure), proc_install->name);
-  gimp_procedure_set_help (procedure,
-                           proc_install->blurb,
-                           proc_install->help,
-                           proc_install->help_id);
-  gimp_procedure_set_attribution (procedure,
-                                  proc_install->authors,
-                                  proc_install->copyright,
-                                  proc_install->date);
 
   for (i = 0; i < proc_install->nparams; i++)
     {
diff --git a/app/plug-in/gimpplugin-proc.c b/app/plug-in/gimpplugin-proc.c
index 43c1cba661..633c780ad1 100644
--- a/app/plug-in/gimpplugin-proc.c
+++ b/app/plug-in/gimpplugin-proc.c
@@ -202,6 +202,75 @@ gimp_plug_in_set_proc_icon (GimpPlugIn   *plug_in,
   return TRUE;
 }
 
+gboolean
+gimp_plug_in_set_proc_help (GimpPlugIn  *plug_in,
+                            const gchar *proc_name,
+                            const gchar *blurb,
+                            const gchar *help,
+                            const gchar *help_id)
+{
+  GimpPlugInProcedure *proc;
+
+  g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
+  g_return_val_if_fail (proc_name != NULL, FALSE);
+
+  proc = gimp_plug_in_proc_find (plug_in, proc_name);
+
+  if (! proc)
+    {
+      gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
+                    "Plug-in \"%s\"\n(%s)\n"
+                    "attempted to register help "
+                    "for procedure \"%s\".\n"
+                    "It has however not installed that procedure. "
+                    "This is not allowed.",
+                    gimp_object_get_name (plug_in),
+                    gimp_file_get_utf8_name (plug_in->file),
+                    proc_name);
+
+      return FALSE;
+    }
+
+  gimp_procedure_set_help (GIMP_PROCEDURE (proc),
+                           blurb, help, help_id);
+
+  return TRUE;
+}
+
+gboolean
+gimp_plug_in_set_proc_attribution (GimpPlugIn  *plug_in,
+                                   const gchar *proc_name,
+                                   const gchar *authors,
+                                   const gchar *copyright,
+                                   const gchar *date)
+{
+  GimpPlugInProcedure *proc;
+
+  g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
+  g_return_val_if_fail (proc_name != NULL, FALSE);
+
+  proc = gimp_plug_in_proc_find (plug_in, proc_name);
+
+  if (! proc)
+    {
+      gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
+                    "Plug-in \"%s\"\n(%s)\n"
+                    "attempted to register the attribution "
+                    "for procedure \"%s\".\n"
+                    "It has however not installed that procedure. "
+                    "This is not allowed.",
+                    gimp_object_get_name (plug_in),
+                    gimp_file_get_utf8_name (plug_in->file),
+                    proc_name);
+
+      return FALSE;
+    }
+
+  gimp_procedure_set_attribution (GIMP_PROCEDURE (proc),
+                                  authors, copyright, date);
+
+  return TRUE;
+}
 
 /*  private functions  */
 
diff --git a/app/plug-in/gimpplugin-proc.h b/app/plug-in/gimpplugin-proc.h
index 91f818d612..5ead2b9e03 100644
--- a/app/plug-in/gimpplugin-proc.h
+++ b/app/plug-in/gimpplugin-proc.h
@@ -35,6 +35,16 @@ gboolean   gimp_plug_in_set_proc_icon        (GimpPlugIn   *plug_in,
                                               GimpIconType  type,
                                               const guint8 *data,
                                               gint          data_length);
+gboolean   gimp_plug_in_set_proc_help        (GimpPlugIn   *plug_in,
+                                              const gchar  *proc_name,
+                                              const gchar  *blurb,
+                                              const gchar  *help,
+                                              const gchar  *help_id);
+gboolean   gimp_plug_in_set_proc_attribution (GimpPlugIn   *plug_in,
+                                              const gchar  *proc_name,
+                                              const gchar  *authors,
+                                              const gchar  *copyright,
+                                              const gchar  *date);
 
 
 #endif /* __GIMP_PLUG_IN_PROC_H__ */
diff --git a/libgimp/gimppdb_pdb.c b/libgimp/gimppdb_pdb.c
index 7739309805..2aeae2751f 100644
--- a/libgimp/gimppdb_pdb.c
+++ b/libgimp/gimppdb_pdb.c
@@ -544,6 +544,50 @@ _gimp_pdb_set_proc_icon (const gchar  *procedure_name,
   return success;
 }
 
+/**
+ * _gimp_pdb_set_proc_documentation:
+ * @procedure_name: The procedure for which to install the menu path.
+ * @blurb: A short blurb.
+ * @help: Detailed procedure help.
+ * @help_id: The procedure help_id.
+ *
+ * Set the documentation for a plug-in procedure.
+ *
+ * This procedure sets the documentation for the given procedure.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 3.0
+ **/
+gboolean
+_gimp_pdb_set_proc_documentation (const gchar *procedure_name,
+                                  const gchar *blurb,
+                                  const gchar *help,
+                                  const 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_STRING, blurb,
+                                          G_TYPE_STRING, help,
+                                          G_TYPE_STRING, help_id,
+                                          G_TYPE_NONE);
+
+  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
+                                              "gimp-pdb-set-proc-documentation",
+                                              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_pdb_get_proc_documentation:
  * @procedure_name: The procedure name.
@@ -598,6 +642,50 @@ _gimp_pdb_get_proc_documentation (const gchar  *procedure_name,
   return success;
 }
 
+/**
+ * _gimp_pdb_set_proc_attribution:
+ * @procedure_name: The procedure for which to install the menu path.
+ * @authors: Authors of the procedure.
+ * @copyright: The copyright.
+ * @date: Copyright date.
+ *
+ * Set the attribution for a plug-in procedure.
+ *
+ * This procedure sets the attribution for the given procedure.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 3.0
+ **/
+gboolean
+_gimp_pdb_set_proc_attribution (const gchar *procedure_name,
+                                const gchar *authors,
+                                const gchar *copyright,
+                                const 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_STRING, authors,
+                                          G_TYPE_STRING, copyright,
+                                          G_TYPE_STRING, date,
+                                          G_TYPE_NONE);
+
+  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
+                                              "gimp-pdb-set-proc-attribution",
+                                              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_pdb_get_proc_attribution:
  * @procedure_name: The procedure name.
diff --git a/libgimp/gimppdb_pdb.h b/libgimp/gimppdb_pdb.h
index 4ddd4eb107..21afc8b703 100644
--- a/libgimp/gimppdb_pdb.h
+++ b/libgimp/gimppdb_pdb.h
@@ -62,10 +62,18 @@ G_GNUC_INTERNAL gboolean    _gimp_pdb_set_proc_icon          (const gchar
                                                               GimpIconType       icon_type,
                                                               gint               icon_data_length,
                                                               const guint8      *icon_data);
+G_GNUC_INTERNAL gboolean    _gimp_pdb_set_proc_documentation (const gchar       *procedure_name,
+                                                              const gchar       *blurb,
+                                                              const gchar       *help,
+                                                              const gchar       *help_id);
 G_GNUC_INTERNAL gboolean    _gimp_pdb_get_proc_documentation (const gchar       *procedure_name,
                                                               gchar            **blurb,
                                                               gchar            **help,
                                                               gchar            **help_id);
+G_GNUC_INTERNAL gboolean    _gimp_pdb_set_proc_attribution   (const gchar       *procedure_name,
+                                                              const gchar       *authors,
+                                                              const gchar       *copyright,
+                                                              const gchar       *date);
 G_GNUC_INTERNAL gboolean    _gimp_pdb_get_proc_attribution   (const gchar       *procedure_name,
                                                               gchar            **authors,
                                                               gchar            **copyright,
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index a89b2f8bbc..c733487d64 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -365,12 +365,6 @@ gimp_procedure_real_install (GimpProcedure *procedure)
   return_vals = gimp_procedure_get_return_values (procedure, &n_return_vals);
 
   proc_install.name         = (gchar *) gimp_procedure_get_name (procedure);
-  proc_install.blurb        = (gchar *) gimp_procedure_get_blurb (procedure);
-  proc_install.help         = (gchar *) gimp_procedure_get_help (procedure);
-  proc_install.help_id      = (gchar *) gimp_procedure_get_help_id (procedure);
-  proc_install.authors      = (gchar *) gimp_procedure_get_authors (procedure);
-  proc_install.copyright    = (gchar *) gimp_procedure_get_copyright (procedure);
-  proc_install.date         = (gchar *) gimp_procedure_get_date (procedure);
   proc_install.type         = gimp_procedure_get_proc_type (procedure);
   proc_install.nparams      = n_args;
   proc_install.nreturn_vals = n_return_vals;
@@ -400,12 +394,17 @@ gimp_procedure_real_install (GimpProcedure *procedure)
 
   gimp_procedure_install_icon (procedure);
 
-  _gimp_pdb_set_proc_image_types (gimp_procedure_get_name (procedure),
-                                  procedure->priv->image_types);
+  if (procedure->priv->image_types)
+    {
+      _gimp_pdb_set_proc_image_types (gimp_procedure_get_name (procedure),
+                                      procedure->priv->image_types);
+    }
 
   if (procedure->priv->menu_label)
-    _gimp_pdb_set_proc_menu_label (gimp_procedure_get_name (procedure),
-                                   procedure->priv->menu_label);
+    {
+      _gimp_pdb_set_proc_menu_label (gimp_procedure_get_name (procedure),
+                                     procedure->priv->menu_label);
+    }
 
   for (list = gimp_procedure_get_menu_paths (procedure);
        list;
@@ -415,6 +414,26 @@ gimp_procedure_real_install (GimpProcedure *procedure)
                                     list->data);
     }
 
+  if (procedure->priv->blurb ||
+      procedure->priv->help  ||
+      procedure->priv->help_id)
+    {
+      _gimp_pdb_set_proc_documentation (gimp_procedure_get_name (procedure),
+                                        procedure->priv->blurb,
+                                        procedure->priv->help,
+                                        procedure->priv->help_id);
+    }
+
+  if (procedure->priv->authors   ||
+      procedure->priv->copyright ||
+      procedure->priv->date)
+    {
+      _gimp_pdb_set_proc_attribution (gimp_procedure_get_name (procedure),
+                                      procedure->priv->authors,
+                                      procedure->priv->copyright,
+                                      procedure->priv->date);
+    }
+
   procedure->priv->installed = TRUE;
 }
 
@@ -907,6 +926,12 @@ gimp_procedure_set_documentation (GimpProcedure *procedure,
   procedure->priv->blurb   = g_strdup (blurb);
   procedure->priv->help    = g_strdup (help);
   procedure->priv->help_id = g_strdup (help_id);
+
+  if (procedure->priv->installed)
+    _gimp_pdb_set_proc_documentation (gimp_procedure_get_name (procedure),
+                                      procedure->priv->blurb,
+                                      procedure->priv->help,
+                                      procedure->priv->help_id);
 }
 
 /**
@@ -986,6 +1011,12 @@ gimp_procedure_set_attribution (GimpProcedure *procedure,
   procedure->priv->authors   = g_strdup (authors);
   procedure->priv->copyright = g_strdup (copyright);
   procedure->priv->date      = g_strdup (date);
+
+  if (procedure->priv->installed)
+    _gimp_pdb_set_proc_attribution (gimp_procedure_get_name (procedure),
+                                    procedure->priv->authors,
+                                    procedure->priv->copyright,
+                                    procedure->priv->date);
 }
 
 /**
diff --git a/libgimpbase/gimpprotocol.c b/libgimpbase/gimpprotocol.c
index e4fbc9c748..b14d0648e6 100644
--- a/libgimpbase/gimpprotocol.c
+++ b/libgimpbase/gimpprotocol.c
@@ -1201,34 +1201,12 @@ _gp_proc_install_read (GIOChannel      *channel,
   gint           i;
 
   if (! _gimp_wire_read_string (channel,
-                                &proc_install->name, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_string (channel,
-                                &proc_install->blurb, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_string (channel,
-                                &proc_install->help, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_string (channel,
-                                &proc_install->help_id, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_string (channel,
-                                &proc_install->authors, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_string (channel,
-                                &proc_install->copyright, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_string (channel,
-                                &proc_install->date, 1, user_data))
-    goto cleanup;
-
-  if (! _gimp_wire_read_int32 (channel,
-                               &proc_install->type, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_int32 (channel,
-                               &proc_install->nparams, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_int32 (channel,
+                                &proc_install->name, 1, user_data)   ||
+      ! _gimp_wire_read_int32 (channel,
+                               &proc_install->type, 1, user_data)    ||
+      ! _gimp_wire_read_int32 (channel,
+                               &proc_install->nparams, 1, user_data) ||
+      ! _gimp_wire_read_int32 (channel,
                                &proc_install->nreturn_vals, 1, user_data))
     goto cleanup;
 
@@ -1257,12 +1235,6 @@ _gp_proc_install_read (GIOChannel      *channel,
 
  cleanup:
   g_free (proc_install->name);
-  g_free (proc_install->blurb);
-  g_free (proc_install->help);
-  g_free (proc_install->help_id);
-  g_free (proc_install->authors);
-  g_free (proc_install->copyright);
-  g_free (proc_install->date);
 
   if (proc_install->params)
     {
@@ -1441,34 +1413,12 @@ _gp_proc_install_write (GIOChannel      *channel,
   gint           i;
 
   if (! _gimp_wire_write_string (channel,
-                                 &proc_install->name, 1, user_data))
-    return;
-  if (! _gimp_wire_write_string (channel,
-                                 &proc_install->blurb, 1, user_data))
-    return;
-  if (! _gimp_wire_write_string (channel,
-                                 &proc_install->help, 1, user_data))
-    return;
-  if (! _gimp_wire_write_string (channel,
-                                 &proc_install->help_id, 1, user_data))
-    return;
-  if (! _gimp_wire_write_string (channel,
-                                 &proc_install->authors, 1, user_data))
-    return;
-  if (! _gimp_wire_write_string (channel,
-                                 &proc_install->copyright, 1, user_data))
-    return;
-  if (! _gimp_wire_write_string (channel,
-                                 &proc_install->date, 1, user_data))
-    return;
-
-  if (! _gimp_wire_write_int32 (channel,
-                                &proc_install->type, 1, user_data))
-    return;
-  if (! _gimp_wire_write_int32 (channel,
-                                &proc_install->nparams, 1, user_data))
-    return;
-  if (! _gimp_wire_write_int32 (channel,
+                                 &proc_install->name, 1, user_data)   ||
+      ! _gimp_wire_write_int32 (channel,
+                                &proc_install->type, 1, user_data)    ||
+      ! _gimp_wire_write_int32 (channel,
+                                &proc_install->nparams, 1, user_data) ||
+      ! _gimp_wire_write_int32 (channel,
                                 &proc_install->nreturn_vals, 1, user_data))
     return;
 
@@ -1499,12 +1449,6 @@ _gp_proc_install_destroy (GimpWireMessage *msg)
       gint i;
 
       g_free (proc_install->name);
-      g_free (proc_install->blurb);
-      g_free (proc_install->help);
-      g_free (proc_install->help_id);
-      g_free (proc_install->authors);
-      g_free (proc_install->copyright);
-      g_free (proc_install->date);
 
       for (i = 0; i < proc_install->nparams; i++)
         {
diff --git a/libgimpbase/gimpprotocol.h b/libgimpbase/gimpprotocol.h
index 722735baa3..76a998786d 100644
--- a/libgimpbase/gimpprotocol.h
+++ b/libgimpbase/gimpprotocol.h
@@ -282,12 +282,6 @@ struct _GPProcReturn
 struct _GPProcInstall
 {
   gchar      *name;
-  gchar      *blurb;
-  gchar      *help;
-  gchar      *help_id;
-  gchar      *authors;
-  gchar      *copyright;
-  gchar      *date;
   guint32     type;
   guint32     nparams;
   guint32     nreturn_vals;
diff --git a/pdb/groups/pdb.pdb b/pdb/groups/pdb.pdb
index 599c6c2827..43cb168bd7 100644
--- a/pdb/groups/pdb.pdb
+++ b/pdb/groups/pdb.pdb
@@ -551,6 +551,46 @@ CODE
     );
 }
 
+sub pdb_set_proc_documentation {
+    $blurb = "Set the documentation for a plug-in procedure.";
+
+    $help = <<HELP;
+This procedure sets the documentation for the given procedure.
+HELP
+
+    &mitch_pdb_misc('2019', '3.0');
+
+    $lib_private = 1;
+
+    @inargs = (
+       { name => 'procedure_name', type => 'string', non_empty => 1,
+         desc => 'The procedure for which to install the menu path' },
+       { name => 'blurb', type => 'string', null_ok => 1,
+         desc => 'A short blurb' },
+       { name => 'help', type => 'string', null_ok => 1,
+         desc => 'Detailed procedure help' },
+       { name => 'help_id', type => 'string', null_ok => 1,
+         desc => 'The procedure help_id' }
+    );
+
+    %invoke = (
+        code => <<'CODE'
+{
+  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
+
+  if (plug_in &&
+      gimp_pdb_is_canonical_procedure (procedure_name, error))
+    {
+      success = gimp_plug_in_set_proc_help (plug_in, procedure_name,
+                                            blurb, help, help_id);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub pdb_get_proc_documentation {
     $blurb = <<'BLURB';
 Queries the procedural database for documentation on the specified procedure.
@@ -603,6 +643,46 @@ CODE
     );
 }
 
+sub pdb_set_proc_attribution {
+    $blurb = "Set the attribution for a plug-in procedure.";
+
+    $help = <<HELP;
+This procedure sets the attribution for the given procedure.
+HELP
+
+    &mitch_pdb_misc('2019', '3.0');
+
+    $lib_private = 1;
+
+    @inargs = (
+       { name => 'procedure_name', type => 'string', non_empty => 1,
+         desc => 'The procedure for which to install the menu path' },
+       { name => 'authors', type => 'string', null_ok => 1,
+         desc => 'Authors of the procedure' },
+       { name => 'copyright', type => 'string', null_ok => 1,
+         desc => 'The copyright' },
+       { name => 'date', type => 'string', null_ok => 1,
+         desc => 'Copyright date' }
+    );
+
+    %invoke = (
+        code => <<'CODE'
+{
+  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
+
+  if (plug_in &&
+      gimp_pdb_is_canonical_procedure (procedure_name, error))
+    {
+      success = gimp_plug_in_set_proc_attribution (plug_in, procedure_name,
+                                                   authors, copyright, date);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub pdb_get_proc_attribution {
     $blurb = <<'BLURB';
 Queries the procedural database for attribution information on the
@@ -930,7 +1010,9 @@ CODE
             pdb_add_proc_menu_path
             pdb_get_proc_menu_paths
             pdb_set_proc_icon
+            pdb_set_proc_documentation
             pdb_get_proc_documentation
+            pdb_set_proc_attribution
             pdb_get_proc_attribution
             pdb_get_proc_argument
             pdb_get_proc_return_value


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]