/* 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 .
*/
/* NOTE: This file is auto-generated by pdbgen.pl. */
#include "config.h"
#include "stamp-pdbgen.h"
#include
#include
#include
#include
#include "libpikacolor/pikacolor.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pika.h"
#include "core/pikacontext.h"
#include "core/pikadatafactory.h"
#include "core/pikapalette.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
palette_new_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *name;
PikaPalette *palette = NULL;
name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
palette = (PikaPalette*) pika_data_factory_data_new (pika->palette_factory,
context, name);
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_object (pika_value_array_index (return_vals, 1), palette);
return return_vals;
}
static PikaValueArray *
palette_get_by_name_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *name;
PikaPalette *palette = NULL;
name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
palette = PIKA_PALETTE (pika_pdb_get_resource (pika, PIKA_TYPE_PALETTE, name,
PIKA_PDB_DATA_ACCESS_READ, error));
if (! palette)
success = FALSE;
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_object (pika_value_array_index (return_vals, 1), palette);
return return_vals;
}
static PikaValueArray *
palette_get_color_count_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaPalette *palette;
gint num_colors = 0;
palette = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
num_colors = pika_palette_get_n_colors (palette);
}
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), num_colors);
return return_vals;
}
static PikaValueArray *
palette_get_colors_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaPalette *palette;
gint num_colors = 0;
PikaRGB *colors = NULL;
palette = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
GList *list = pika_palette_get_colors (palette);
gint i;
num_colors = pika_palette_get_n_colors (palette);
colors = g_new (PikaRGB, num_colors);
for (i = 0; i < num_colors; i++, list = g_list_next (list))
{
PikaPaletteEntry *entry = list->data;
colors[i] = entry->color;
}
}
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), num_colors);
pika_value_take_rgb_array (pika_value_array_index (return_vals, 2), colors, num_colors);
}
return return_vals;
}
static PikaValueArray *
palette_get_columns_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaPalette *palette;
gint num_columns = 0;
palette = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
num_columns = pika_palette_get_columns (palette);
}
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), num_columns);
return return_vals;
}
static PikaValueArray *
palette_set_columns_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaPalette *palette;
gint columns;
palette = g_value_get_object (pika_value_array_index (args, 0));
columns = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
if (pika_data_is_writable (PIKA_DATA (palette)))
pika_palette_set_columns (palette, columns);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
palette_add_entry_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaPalette *palette;
const gchar *entry_name;
PikaRGB color;
gint entry_num = 0;
palette = g_value_get_object (pika_value_array_index (args, 0));
entry_name = g_value_get_string (pika_value_array_index (args, 1));
pika_value_get_rgb (pika_value_array_index (args, 2), &color);
if (success)
{
/* Must check writeable here, because add_entry does not fail when not writeable. */
if (pika_data_is_writable (PIKA_DATA (palette)))
{
/* -1 for the index means append. */
PikaPaletteEntry *entry = pika_palette_add_entry (palette, -1, entry_name, &color);
entry_num = pika_palette_get_entry_position (palette, entry);
}
else
{
success = FALSE;
}
}
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), entry_num);
return return_vals;
}
static PikaValueArray *
palette_delete_entry_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaPalette *palette;
gint entry_num;
palette = g_value_get_object (pika_value_array_index (args, 0));
entry_num = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
if (pika_data_is_writable (PIKA_DATA (palette)))
{
PikaPaletteEntry *entry = pika_palette_get_entry (palette, entry_num);
if (entry)
pika_palette_delete_entry (palette, entry);
else
success = FALSE;
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
palette_entry_get_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaPalette *palette;
gint entry_num;
PikaRGB color = { 0.0, 0.0, 0.0, 1.0 };
palette = g_value_get_object (pika_value_array_index (args, 0));
entry_num = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
PikaPaletteEntry *entry = pika_palette_get_entry (palette, entry_num);
if (entry)
color = entry->color;
else
success = FALSE;
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
pika_value_set_rgb (pika_value_array_index (return_vals, 1), &color);
return return_vals;
}
static PikaValueArray *
palette_entry_set_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaPalette *palette;
gint entry_num;
PikaRGB color;
palette = g_value_get_object (pika_value_array_index (args, 0));
entry_num = g_value_get_int (pika_value_array_index (args, 1));
pika_value_get_rgb (pika_value_array_index (args, 2), &color);
if (success)
{
if (pika_data_is_writable (PIKA_DATA (palette)))
success = pika_palette_set_entry_color (palette, entry_num, &color);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
palette_entry_get_name_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaPalette *palette;
gint entry_num;
gchar *entry_name = NULL;
palette = g_value_get_object (pika_value_array_index (args, 0));
entry_num = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
PikaPaletteEntry *entry = pika_palette_get_entry (palette, entry_num);
if (entry)
entry_name = g_strdup (entry->name);
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), entry_name);
return return_vals;
}
static PikaValueArray *
palette_entry_set_name_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaPalette *palette;
gint entry_num;
const gchar *entry_name;
palette = g_value_get_object (pika_value_array_index (args, 0));
entry_num = g_value_get_int (pika_value_array_index (args, 1));
entry_name = g_value_get_string (pika_value_array_index (args, 2));
if (success)
{
if (pika_data_is_writable (PIKA_DATA (palette)))
success = pika_palette_set_entry_name (palette, entry_num, entry_name);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_palette_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-palette-new
*/
procedure = pika_procedure_new (palette_new_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-new");
pika_procedure_set_static_help (procedure,
"Creates a new palette",
"Creates a new palette. The new palette has no color entries. You must add color entries for a user to choose. The actual name might be different than the requested name, when the requested name is already in use.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("name",
"name",
"The requested name of the new palette",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-get-by-name
*/
procedure = pika_procedure_new (palette_get_by_name_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-get-by-name");
pika_procedure_set_static_help (procedure,
"Returns the palette with the given name.",
"Returns the palette with the given name.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("name",
"name",
"The name of the palette",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-get-color-count
*/
procedure = pika_procedure_new (palette_get_color_count_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-get-color-count");
pika_procedure_set_static_help (procedure,
"Get the count of colors in the palette.",
"Returns the number of colors in the palette.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("num-colors",
"num colors",
"The number of colors in the palette",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-get-colors
*/
procedure = pika_procedure_new (palette_get_colors_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-get-colors");
pika_procedure_set_static_help (procedure,
"Gets colors in the palette.",
"Returns an array of colors in the palette.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann ",
"Sven Neumann",
"2006");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("num-colors",
"num colors",
"Length of the colors array",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_rgb_array ("colors",
"colors",
"The colors in the palette",
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-get-columns
*/
procedure = pika_procedure_new (palette_get_columns_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-get-columns");
pika_procedure_set_static_help (procedure,
"Gets the number of columns used to display the palette",
"Gets the preferred number of columns to display the palette.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann ",
"Sven Neumann",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("num-columns",
"num columns",
"The number of columns used to display this palette",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-set-columns
*/
procedure = pika_procedure_new (palette_set_columns_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-set-columns");
pika_procedure_set_static_help (procedure,
"Sets the number of columns used to display the palette",
"Set the number of colors shown per row when the palette is displayed. Returns an error when the palette is not editable. The maximum allowed value is 64.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann ",
"Sven Neumann",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("columns",
"columns",
"The new number of columns",
0, 64, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-add-entry
*/
procedure = pika_procedure_new (palette_add_entry_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-add-entry");
pika_procedure_set_static_help (procedure,
"Appends an entry to the palette.",
"Appends an entry to the palette. Neither color nor name must be unique within the palette. When name is the empty string, this sets the entry name to \"Untitled\". Returns the index of the entry. Returns an error when palette is not editable.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("entry-name",
"entry name",
"A name for the entry",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_rgb ("color",
"color",
"The color for the added entry.",
FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("entry-num",
"entry num",
"The index of the added entry",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-delete-entry
*/
procedure = pika_procedure_new (palette_delete_entry_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-delete-entry");
pika_procedure_set_static_help (procedure,
"Deletes an entry from the palette.",
"Deletes an entry from the palette. Returns an error if the index is out or range. Returns an error if the palette is not editable.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
"entry num",
"The index of the entry to delete",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-entry-get-color
*/
procedure = pika_procedure_new (palette_entry_get_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-entry-get-color");
pika_procedure_set_static_help (procedure,
"Gets the color of an entry in the palette.",
"Returns the color of the entry at the given zero-based index into the palette. Returns an error when the index is out of range.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
"entry num",
"The index of the entry to get the color of.",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_rgb ("color",
"color",
"The color at the index.",
FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-entry-set-color
*/
procedure = pika_procedure_new (palette_entry_set_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-entry-set-color");
pika_procedure_set_static_help (procedure,
"Sets the color of an entry in the palette.",
"Sets the color of the entry at the zero-based index into the palette. Returns an error when the index is out of range. Returns an error when the palette is not editable.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
"entry num",
"The entry to get",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_rgb ("color",
"color",
"The new color",
FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-entry-get-name
*/
procedure = pika_procedure_new (palette_entry_get_name_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-entry-get-name");
pika_procedure_set_static_help (procedure,
"Gets the name of an entry in the palette.",
"Gets the name of the entry at the zero-based index into the palette. Returns an error when the index is out of range.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
"entry num",
"The entry to get",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("entry-name",
"entry name",
"The name of the entry.",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palette-entry-set-name
*/
procedure = pika_procedure_new (palette_entry_set_name_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palette-entry-set-name");
pika_procedure_set_static_help (procedure,
"Sets the name of an entry in the palette.",
"Sets the name of the entry at the zero-based index into the palette. Returns an error if the index is out or range. Returns an error if the palette is not editable.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer ",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_palette ("palette",
"palette",
"The palette",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("entry-num",
"entry num",
"The entry to get",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("entry-name",
"entry name",
"The new name",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}