PIKApp/app/pdb/pikarc-cmds.c

413 lines
18 KiB
C
Raw Permalink Normal View History

2023-09-26 00:35:21 +02:00
/* 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 <string.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "libpikamodule/pikamodule.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "config/pikarc.h"
#include "core/pika-utils.h"
#include "core/pika.h"
#include "core/pikaparamspecs.h"
#include "core/pikatemplate.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
pikarc_query_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *token;
gchar *value = NULL;
token = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
if (strlen (token))
{
/* use edit_config because unknown tokens are set there */
value = pika_rc_query (PIKA_RC (pika->edit_config), token);
if (! value)
success = FALSE;
}
else
success = FALSE;
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_string (pika_value_array_index (return_vals, 1), value);
return return_vals;
}
static PikaValueArray *
pikarc_set_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *token;
const gchar *value;
token = g_value_get_string (pika_value_array_index (args, 0));
value = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
if (strlen (token))
{
/* use edit_config because that's the one that gets saved */
pika_rc_set_unknown_token (PIKA_RC (pika->edit_config), token, value);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
get_default_comment_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gchar *comment = NULL;
comment = g_strdup (pika_template_get_comment (pika->config->default_image));
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_take_string (pika_value_array_index (return_vals, 1), comment);
return return_vals;
}
static PikaValueArray *
get_default_unit_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
PikaUnit unit_id = PIKA_UNIT_PIXEL;
unit_id = pika_get_default_unit ();
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (pika_value_array_index (return_vals, 1), unit_id);
return return_vals;
}
static PikaValueArray *
get_monitor_resolution_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gdouble xres = 0.0;
gdouble yres = 0.0;
xres = PIKA_DISPLAY_CONFIG (pika->config)->monitor_xres;
yres = PIKA_DISPLAY_CONFIG (pika->config)->monitor_yres;
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_double (pika_value_array_index (return_vals, 1), xres);
g_value_set_double (pika_value_array_index (return_vals, 2), yres);
return return_vals;
}
static PikaValueArray *
get_color_configuration_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gchar *config = NULL;
config = pika_config_serialize_to_string (PIKA_CONFIG (pika->config->color_management), NULL);
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_take_string (pika_value_array_index (return_vals, 1), config);
return return_vals;
}
static PikaValueArray *
get_module_load_inhibit_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gchar *load_inhibit = NULL;
load_inhibit = g_strdup (pika_module_db_get_load_inhibit (pika->module_db));
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_take_string (pika_value_array_index (return_vals, 1), load_inhibit);
return return_vals;
}
void
register_pikarc_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-pikarc-query
*/
procedure = pika_procedure_new (pikarc_query_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-pikarc-query");
pika_procedure_set_static_help (procedure,
"Queries the pikarc file parser for information on a specified token.",
"This procedure is used to locate additional information contained in the pikarc file considered extraneous to the operation of PIKA. Plug-ins that need configuration information can expect it will be stored in the user pikarc file and can use this procedure to retrieve it. This query procedure will return the value associated with the specified token. This corresponds _only_ to entries with the format: (<token> <value>). The value must be a string. Entries not corresponding to this format will cause warnings to be issued on pikarc parsing and will not be queryable.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("token",
"token",
"The token to query for",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("value",
"value",
"The value associated with the queried token",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-pikarc-set
*/
procedure = pika_procedure_new (pikarc_set_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-pikarc-set");
pika_procedure_set_static_help (procedure,
"Sets a pikarc token to a value and saves it in the pikarc.",
"This procedure is used to add or change additional information in the pikarc file that is considered extraneous to the operation of PIKA. Plug-ins that need configuration information can use this function to store it, and 'pika-pikarc-query' to retrieve it. This will accept _only_ string values in UTF-8 encoding.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Seth Burgess",
"Seth Burgess",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("token",
"token",
"The token to add or modify",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("value",
"value",
"The value to set the token to",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-get-default-comment
*/
procedure = pika_procedure_new (get_default_comment_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-get-default-comment");
pika_procedure_set_static_help (procedure,
"Get the default image comment as specified in the Preferences.",
"Returns a copy of the default image comment.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("comment",
"comment",
"Default image comment",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-get-default-unit
*/
procedure = pika_procedure_new (get_default_unit_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-get-default-unit");
pika_procedure_set_static_help (procedure,
"Get the default unit (taken from the user's locale).",
"Returns the default unit's integer ID.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_return_value (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"Default unit",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-get-monitor-resolution
*/
procedure = pika_procedure_new (get_monitor_resolution_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-get-monitor-resolution");
pika_procedure_set_static_help (procedure,
"Get the monitor resolution as specified in the Preferences.",
"Returns the resolution of the monitor in pixels/inch. This value is taken from the Preferences (or the windowing system if this is set in the Preferences) and there's no guarantee for the value to be reasonable.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_return_value (procedure,
g_param_spec_double ("xres",
"xres",
"X resolution",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_double ("yres",
"yres",
"Y resolution",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-get-color-configuration
*/
procedure = pika_procedure_new (get_color_configuration_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-get-color-configuration");
pika_procedure_set_static_help (procedure,
"Get a serialized version of the color management configuration.",
"Returns a string that can be deserialized into a PikaColorConfig object representing the current color management configuration.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005");
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("config",
"config",
"Serialized color management configuration",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-get-module-load-inhibit
*/
procedure = pika_procedure_new (get_module_load_inhibit_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-get-module-load-inhibit");
pika_procedure_set_static_help (procedure,
"Get the list of modules which should not be loaded.",
"Returns a copy of the list of modules which should not be loaded.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("load-inhibit",
"load inhibit",
"The list of modules",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}