PIKApp/app/pdb/plug-in-cmds.c

386 lines
18 KiB
C

/* 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 <stdlib.h>
#include <string.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.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/pikaplugindef.h"
#include "plug-in/pikapluginmanager-menu-branch.h"
#include "plug-in/pikapluginmanager-query.h"
#include "plug-in/pikapluginmanager.h"
#include "plug-in/pikapluginprocedure.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
plug_ins_query_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
const gchar *search_string;
gchar **procedures = NULL;
gchar **accelerators = NULL;
gchar **locations = NULL;
gint num_install_times = 0;
gint32 *install_times = NULL;
search_string = g_value_get_string (pika_value_array_index (args, 0));
num_install_times = pika_plug_in_manager_query (pika->plug_in_manager,
search_string,
&procedures,
&accelerators,
&locations,
&install_times);
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_take_boxed (pika_value_array_index (return_vals, 1), procedures);
g_value_take_boxed (pika_value_array_index (return_vals, 2), accelerators);
g_value_take_boxed (pika_value_array_index (return_vals, 3), locations);
g_value_set_int (pika_value_array_index (return_vals, 4), num_install_times);
pika_value_take_int32_array (pika_value_array_index (return_vals, 5), install_times, num_install_times);
return return_vals;
}
static PikaValueArray *
plug_in_help_register_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *domain_name;
GFile *domain_file;
domain_name = g_value_get_string (pika_value_array_index (args, 0));
domain_file = g_value_get_object (pika_value_array_index (args, 1));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->call_mode == PIKA_PLUG_IN_CALL_QUERY)
{
gchar *domain_uri = domain_file ? g_file_get_uri (domain_file) : NULL;
pika_plug_in_def_set_help_domain (plug_in->plug_in_def,
domain_name, domain_uri);
g_free (domain_uri);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
plug_in_menu_branch_register_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *menu_path;
const gchar *menu_name;
menu_path = g_value_get_string (pika_value_array_index (args, 0));
menu_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in)
{
pika_plug_in_manager_add_menu_branch (pika->plug_in_manager,
plug_in->file, menu_path, menu_name);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
plug_in_set_pdb_error_handler_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint handler;
handler = g_value_get_enum (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in)
{
pika_plug_in_set_error_handler (plug_in, handler);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
plug_in_get_pdb_error_handler_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint handler = 0;
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in)
{
handler = pika_plug_in_get_error_handler (plug_in);
}
else
success = FALSE;
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_enum (pika_value_array_index (return_vals, 1), handler);
return return_vals;
}
void
register_plug_in_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-plug-ins-query
*/
procedure = pika_procedure_new (plug_ins_query_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-plug-ins-query");
pika_procedure_set_static_help (procedure,
"Queries the plug-in database for its contents.",
"This procedure queries the contents of the plug-in database.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("search-string",
"search string",
"If not an empty string then use this as a search pattern",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("procedures",
"procedures",
"The plug-in procedure name",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("accelerators",
"accelerators",
"String representing keyboard accelerator (could be empty string)",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("locations",
"locations",
"Location of the plug-in program",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("num-install-times",
"num install times",
"The number of matching procedures",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_int32_array ("install-times",
"install times",
"Time that the plug-in was installed",
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-plug-in-help-register
*/
procedure = pika_procedure_new (plug_in_help_register_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-plug-in-help-register");
pika_procedure_set_static_help (procedure,
"Register a help path for a plug-in.",
"This procedure registers user documentation for the calling plug-in with the PIKA help system. The domain_uri parameter points to the root directory where the plug-in help is installed. For each supported language there should be a file called 'pika-help.xml' that maps the help IDs to the actual help files.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2000");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("domain-name",
"domain name",
"The XML namespace of the plug-in's help pages",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_object ("domain-file",
"domain file",
"The root URI of the plug-in's help pages",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-plug-in-menu-branch-register
*/
procedure = pika_procedure_new (plug_in_menu_branch_register_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-plug-in-menu-branch-register");
pika_procedure_set_static_help (procedure,
"Register a sub-menu.",
"This procedure installs a sub-menu which does not belong to any procedure. The menu-name should be the untranslated menu label. PIKA will look up the translation in the textdomain registered for the plug-in.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("menu-path",
"menu path",
"The sub-menu's menu path",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("menu-name",
"menu name",
"The name of the sub-menu",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-plug-in-set-pdb-error-handler
*/
procedure = pika_procedure_new (plug_in_set_pdb_error_handler_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-plug-in-set-pdb-error-handler");
pika_procedure_set_static_help (procedure,
"Sets an error handler for procedure calls.",
"This procedure changes the way that errors in procedure calls are handled. By default PIKA will raise an error dialog if a procedure call made by a plug-in fails. Using this procedure the plug-in can change this behavior. If the error handler is set to %PIKA_PDB_ERROR_HANDLER_PLUGIN, then the plug-in is responsible for calling 'pika-get-pdb-error' and handling the error whenever one if its procedure calls fails. It can do this by displaying the error message or by forwarding it in its own return values.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2008");
pika_procedure_add_argument (procedure,
g_param_spec_enum ("handler",
"handler",
"Who is responsible for handling procedure call errors",
PIKA_TYPE_PDB_ERROR_HANDLER,
PIKA_PDB_ERROR_HANDLER_INTERNAL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-plug-in-get-pdb-error-handler
*/
procedure = pika_procedure_new (plug_in_get_pdb_error_handler_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-plug-in-get-pdb-error-handler");
pika_procedure_set_static_help (procedure,
"Retrieves the active error handler for procedure calls.",
"This procedure retrieves the currently active error handler for procedure calls made by the calling plug-in. See 'pika-plugin-set-pdb-error-handler' for details.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2008");
pika_procedure_add_return_value (procedure,
g_param_spec_enum ("handler",
"handler",
"Who is responsible for handling procedure call errors",
PIKA_TYPE_PDB_ERROR_HANDLER,
PIKA_PDB_ERROR_HANDLER_INTERNAL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}