PIKApp/app/pdb/unit-cmds.c

789 lines
35 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 <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pikaparamspecs.h"
#include "core/pikaunit.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
unit_get_number_of_units_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gint num_units = 0;
num_units = _pika_unit_get_number_of_units (pika);
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (pika_value_array_index (return_vals, 1), num_units);
return return_vals;
}
static PikaValueArray *
unit_get_number_of_built_in_units_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gint num_units = 0;
num_units = _pika_unit_get_number_of_built_in_units (pika);
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (pika_value_array_index (return_vals, 1), num_units);
return return_vals;
}
static PikaValueArray *
unit_new_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *identifier;
gdouble factor;
gint digits;
const gchar *symbol;
const gchar *abbreviation;
const gchar *singular;
const gchar *plural;
PikaUnit unit_id = PIKA_UNIT_PIXEL;
identifier = g_value_get_string (pika_value_array_index (args, 0));
factor = g_value_get_double (pika_value_array_index (args, 1));
digits = g_value_get_int (pika_value_array_index (args, 2));
symbol = g_value_get_string (pika_value_array_index (args, 3));
abbreviation = g_value_get_string (pika_value_array_index (args, 4));
singular = g_value_get_string (pika_value_array_index (args, 5));
plural = g_value_get_string (pika_value_array_index (args, 6));
if (success)
{
unit_id = _pika_unit_new (pika, identifier, factor, digits,
symbol, abbreviation, singular, plural);
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_int (pika_value_array_index (return_vals, 1), unit_id);
return return_vals;
}
static PikaValueArray *
unit_get_deletion_flag_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaUnit unit_id;
gboolean deletion_flag = FALSE;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
deletion_flag = _pika_unit_get_deletion_flag (pika, unit_id);
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (pika_value_array_index (return_vals, 1), deletion_flag);
return return_vals;
}
static PikaValueArray *
unit_set_deletion_flag_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaUnit unit_id;
gboolean deletion_flag;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
deletion_flag = g_value_get_boolean (pika_value_array_index (args, 1));
if (success)
{
_pika_unit_set_deletion_flag (pika, unit_id, deletion_flag);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
unit_get_identifier_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaUnit unit_id;
gchar *identifier = NULL;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
identifier = g_strdup (_pika_unit_get_identifier (pika, unit_id));
}
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), identifier);
return return_vals;
}
static PikaValueArray *
unit_get_factor_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaUnit unit_id;
gdouble factor = 0.0;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
factor = _pika_unit_get_factor (pika, unit_id);
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_double (pika_value_array_index (return_vals, 1), factor);
return return_vals;
}
static PikaValueArray *
unit_get_digits_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaUnit unit_id;
gint digits = 0;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
digits = _pika_unit_get_digits (pika, unit_id);
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_int (pika_value_array_index (return_vals, 1), digits);
return return_vals;
}
static PikaValueArray *
unit_get_symbol_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaUnit unit_id;
gchar *symbol = NULL;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
symbol = g_strdup (_pika_unit_get_symbol (pika, unit_id));
}
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), symbol);
return return_vals;
}
static PikaValueArray *
unit_get_abbreviation_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaUnit unit_id;
gchar *abbreviation = NULL;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
abbreviation = g_strdup (_pika_unit_get_abbreviation (pika, unit_id));
}
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), abbreviation);
return return_vals;
}
static PikaValueArray *
unit_get_singular_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaUnit unit_id;
gchar *singular = NULL;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
singular = g_strdup (_pika_unit_get_singular (pika, unit_id));
}
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), singular);
return return_vals;
}
static PikaValueArray *
unit_get_plural_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaUnit unit_id;
gchar *plural = NULL;
unit_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
plural = g_strdup (_pika_unit_get_plural (pika, unit_id));
}
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), plural);
return return_vals;
}
void
register_unit_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-unit-get-number-of-units
*/
procedure = pika_procedure_new (unit_get_number_of_units_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-number-of-units");
pika_procedure_set_static_help (procedure,
"Returns the number of units.",
"This procedure returns the number of defined units.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_return_value (procedure,
g_param_spec_int ("num-units",
"num units",
"The number of units",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-number-of-built-in-units
*/
procedure = pika_procedure_new (unit_get_number_of_built_in_units_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-number-of-built-in-units");
pika_procedure_set_static_help (procedure,
"Returns the number of built-in units.",
"This procedure returns the number of defined units built-in to PIKA.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_return_value (procedure,
g_param_spec_int ("num-units",
"num units",
"The number of built-in units",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-new
*/
procedure = pika_procedure_new (unit_new_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-new");
pika_procedure_set_static_help (procedure,
"Creates a new unit and returns it's integer ID.",
"This procedure creates a new unit and returns it's integer ID. Note that the new unit will have it's deletion flag set to TRUE, so you will have to set it to FALSE with 'pika-unit-set-deletion-flag' to make it persistent.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("identifier",
"identifier",
"The new unit's identifier",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("factor",
"factor",
"The new unit's factor",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("digits",
"digits",
"The new unit's digits",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("symbol",
"symbol",
"The new unit's symbol",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("abbreviation",
"abbreviation",
"The new unit's abbreviation",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("singular",
"singular",
"The new unit's singular form",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("plural",
"plural",
"The new unit's plural form",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The new unit's ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-deletion-flag
*/
procedure = pika_procedure_new (unit_get_deletion_flag_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-deletion-flag");
pika_procedure_set_static_help (procedure,
"Returns the deletion flag of the unit.",
"This procedure returns the deletion flag of the unit. If this value is TRUE the unit's definition will not be saved in the user's unitrc file on pika exit.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("deletion-flag",
"deletion flag",
"The unit's deletion flag",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-set-deletion-flag
*/
procedure = pika_procedure_new (unit_set_deletion_flag_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-set-deletion-flag");
pika_procedure_set_static_help (procedure,
"Sets the deletion flag of a unit.",
"This procedure sets the unit's deletion flag. If the deletion flag of a unit is TRUE on pika exit, this unit's definition will not be saved in the user's unitrc.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("deletion-flag",
"deletion flag",
"The new deletion flag of the unit",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-identifier
*/
procedure = pika_procedure_new (unit_get_identifier_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-identifier");
pika_procedure_set_static_help (procedure,
"Returns the textual identifier of the unit.",
"This procedure returns the textual identifier of the unit. For built-in units it will be the english singular form of the unit's name. For user-defined units this should equal to the singular form.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("identifier",
"identifier",
"The unit's textual identifier",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-factor
*/
procedure = pika_procedure_new (unit_get_factor_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-factor");
pika_procedure_set_static_help (procedure,
"Returns the factor of the unit.",
"This procedure returns the unit's factor which indicates how many units make up an inch. Note that asking for the factor of \"pixels\" will produce an error.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_double ("factor",
"factor",
"The unit's factor",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-digits
*/
procedure = pika_procedure_new (unit_get_digits_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-digits");
pika_procedure_set_static_help (procedure,
"Returns the number of digits of the unit.",
"This procedure returns the number of digits you should provide in input or output functions to get approximately the same accuracy as with two digits and inches. Note that asking for the digits of \"pixels\" will produce an error.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("digits",
"digits",
"The unit's number of digits",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-symbol
*/
procedure = pika_procedure_new (unit_get_symbol_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-symbol");
pika_procedure_set_static_help (procedure,
"Returns the symbol of the unit.",
"This procedure returns the symbol of the unit (\"''\" for inches).",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("symbol",
"symbol",
"The unit's symbol",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-abbreviation
*/
procedure = pika_procedure_new (unit_get_abbreviation_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-abbreviation");
pika_procedure_set_static_help (procedure,
"Returns the abbreviation of the unit.",
"This procedure returns the abbreviation of the unit (\"in\" for inches).",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("abbreviation",
"abbreviation",
"The unit's abbreviation",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-singular
*/
procedure = pika_procedure_new (unit_get_singular_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-singular");
pika_procedure_set_static_help (procedure,
"Returns the singular form of the unit.",
"This procedure returns the singular form of the unit.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("singular",
"singular",
"The unit's singular form",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-unit-get-plural
*/
procedure = pika_procedure_new (unit_get_plural_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-unit-get-plural");
pika_procedure_set_static_help (procedure,
"Returns the plural form of the unit.",
"This procedure returns the plural form of the unit.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_unit ("unit-id",
"unit id",
"The unit's integer ID",
TRUE,
FALSE,
PIKA_UNIT_PIXEL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("plural",
"plural",
"The unit's plural form",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}