/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

/* NOTE: This file is auto-generated by pdbgen.pl. */

#include "config.h"

#include "stamp-pdbgen.h"

#include <gegl.h>

#include <gdk-pixbuf/gdk-pixbuf.h>

#include "libpikabase/pikabase.h"

#include "pdb-types.h"

#include "core/pika.h"
#include "core/pikaparamspecs.h"
#include "plug-in/pikaplugin.h"
#include "plug-in/pikapluginmanager-help-domain.h"
#include "plug-in/pikapluginmanager.h"

#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"


static PikaValueArray *
help_invoker (PikaProcedure         *procedure,
              Pika                  *pika,
              PikaContext           *context,
              PikaProgress          *progress,
              const PikaValueArray  *args,
              GError               **error)
{
  gboolean success = TRUE;
  const gchar *help_domain;
  const gchar *help_id;

  help_domain = g_value_get_string (pika_value_array_index (args, 0));
  help_id = g_value_get_string (pika_value_array_index (args, 1));

  if (success)
    {
      PikaPlugInManager *manager = pika->plug_in_manager;

      if (! help_domain && manager->current_plug_in)
        help_domain = (gchar *)
          pika_plug_in_manager_get_help_domain (manager,
                                                manager->current_plug_in->file,
                                                NULL);

      pika_help (pika, progress, help_domain, help_id);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

void
register_help_procs (PikaPDB *pdb)
{
  PikaProcedure *procedure;

  /*
   * pika-help
   */
  procedure = pika_procedure_new (help_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-help");
  pika_procedure_set_static_help (procedure,
                                  "Load a help page.",
                                  "This procedure loads the specified help page into the helpbrowser or what ever is configured as help viewer. The help page is identified by its domain and ID: if help_domain is NULL, we use the help_domain which was registered using the 'pika-plugin-help-register' procedure. If help_domain is NULL and no help domain was registered, the help domain of the main PIKA installation is used.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Michael Natterer <mitch@gimp.org>",
                                         "Michael Natterer",
                                         "2000");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("help-domain",
                                                       "help domain",
                                                       "The help domain in which help_id is registered",
                                                       FALSE, TRUE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("help-id",
                                                       "help id",
                                                       "The help page's ID",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);
}
