PIKApp/app/pdb/buffer-cmds.c

505 lines
20 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 <string.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pika.h"
#include "core/pikabuffer.h"
#include "core/pikacontainer-filter.h"
#include "core/pikacontainer.h"
#include "core/pikaparamspecs.h"
#include "gegl/pika-babl-compat.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
buffers_get_list_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *filter;
gchar **buffer_list = NULL;
filter = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
buffer_list = pika_container_get_filtered_name_array (pika->named_buffers,
filter);
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_boxed (pika_value_array_index (return_vals, 1), buffer_list);
return return_vals;
}
static PikaValueArray *
buffer_rename_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *buffer_name;
const gchar *new_name;
gchar *real_name = NULL;
buffer_name = g_value_get_string (pika_value_array_index (args, 0));
new_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
PikaBuffer *buffer = pika_pdb_get_buffer (pika, buffer_name, error);
if (buffer)
{
pika_object_set_name (PIKA_OBJECT (buffer), new_name);
real_name = g_strdup (pika_object_get_name (buffer));
}
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), real_name);
return return_vals;
}
static PikaValueArray *
buffer_delete_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *buffer_name;
buffer_name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaBuffer *buffer = pika_pdb_get_buffer (pika, buffer_name, error);
if (buffer)
success = pika_container_remove (pika->named_buffers, PIKA_OBJECT (buffer));
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
buffer_get_width_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *buffer_name;
gint width = 0;
buffer_name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaBuffer *buffer = pika_pdb_get_buffer (pika, buffer_name, error);
if (buffer)
width = pika_buffer_get_width (buffer);
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), width);
return return_vals;
}
static PikaValueArray *
buffer_get_height_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *buffer_name;
gint height = 0;
buffer_name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaBuffer *buffer = pika_pdb_get_buffer (pika, buffer_name, error);
if (buffer)
height = pika_buffer_get_height (buffer);
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), height);
return return_vals;
}
static PikaValueArray *
buffer_get_bytes_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *buffer_name;
gint bytes = 0;
buffer_name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaBuffer *buffer = pika_pdb_get_buffer (pika, buffer_name, error);
if (buffer)
{
const Babl *format = pika_buffer_get_format (buffer);
bytes = babl_format_get_bytes_per_pixel (format);
}
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), bytes);
return return_vals;
}
static PikaValueArray *
buffer_get_image_type_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *buffer_name;
gint image_type = 0;
buffer_name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaBuffer *buffer = pika_pdb_get_buffer (pika, buffer_name, error);
if (buffer)
image_type = pika_babl_format_get_image_type (pika_buffer_get_format (buffer));
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), image_type);
return return_vals;
}
void
register_buffer_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-buffers-get-list
*/
procedure = pika_procedure_new (buffers_get_list_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-buffers-get-list");
pika_procedure_set_static_help (procedure,
"Retrieve a complete listing of the available buffers.",
"This procedure returns a complete listing of available named buffers.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("filter",
"filter",
"An optional regular expression used to filter the list",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("buffer-list",
"buffer list",
"The list of buffer names",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-buffer-rename
*/
procedure = pika_procedure_new (buffer_rename_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-buffer-rename");
pika_procedure_set_static_help (procedure,
"Renames a named buffer.",
"This procedure renames a named buffer.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("buffer-name",
"buffer name",
"The buffer name",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("new-name",
"new name",
"The buffer's new name",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("real-name",
"real name",
"The real name given to the buffer",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-buffer-delete
*/
procedure = pika_procedure_new (buffer_delete_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-buffer-delete");
pika_procedure_set_static_help (procedure,
"Deletes a named buffer.",
"This procedure deletes a named buffer.",
NULL);
pika_procedure_set_static_attribution (procedure,
"David Gowers <neota@softhome.net>",
"David Gowers <neota@softhome.net>",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("buffer-name",
"buffer name",
"The buffer name",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-buffer-get-width
*/
procedure = pika_procedure_new (buffer_get_width_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-buffer-get-width");
pika_procedure_set_static_help (procedure,
"Retrieves the specified buffer's width.",
"This procedure retrieves the specified named buffer's width.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("buffer-name",
"buffer name",
"The buffer name",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("width",
"width",
"The buffer width",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-buffer-get-height
*/
procedure = pika_procedure_new (buffer_get_height_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-buffer-get-height");
pika_procedure_set_static_help (procedure,
"Retrieves the specified buffer's height.",
"This procedure retrieves the specified named buffer's height.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("buffer-name",
"buffer name",
"The buffer name",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("height",
"height",
"The buffer height",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-buffer-get-bytes
*/
procedure = pika_procedure_new (buffer_get_bytes_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-buffer-get-bytes");
pika_procedure_set_static_help (procedure,
"Retrieves the specified buffer's bytes.",
"This procedure retrieves the specified named buffer's bytes.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("buffer-name",
"buffer name",
"The buffer name",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("bytes",
"bytes",
"The buffer bpp",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-buffer-get-image-type
*/
procedure = pika_procedure_new (buffer_get_image_type_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-buffer-get-image-type");
pika_procedure_set_static_help (procedure,
"Retrieves the specified buffer's image type.",
"This procedure retrieves the specified named buffer's image type.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("buffer-name",
"buffer name",
"The buffer name",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_enum ("image-type",
"image type",
"The buffer image type",
PIKA_TYPE_IMAGE_BASE_TYPE,
PIKA_RGB,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}