Initial checkin of Pika from heckimp

This commit is contained in:
2023-09-25 15:35:21 -07:00
commit 891e999216
6761 changed files with 5240685 additions and 0 deletions

7
app/pdb/README Normal file
View File

@ -0,0 +1,7 @@
This directory contains the PDB-wrappers for various internal
Pika functions.
THESE FILES ARE AUTOGENERATED AND CHANGES HERE ARE USELESS!
If you need to change the code please have a look in ../../pdb/groups.

1414
app/pdb/brush-cmds.c Normal file

File diff suppressed because it is too large Load Diff

229
app/pdb/brush-select-cmds.c Normal file
View File

@ -0,0 +1,229 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
brushes_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *brush_callback;
const gchar *popup_title;
const gchar *initial_brush_name;
brush_callback = g_value_get_string (pika_value_array_index (args, 0));
popup_title = g_value_get_string (pika_value_array_index (args, 1));
initial_brush_name = g_value_get_string (pika_value_array_index (args, 2));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, brush_callback) ||
! pika_pdb_dialog_new (pika, context, progress,
pika_data_factory_get_container (pika->brush_factory),
popup_title, brush_callback, initial_brush_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
brushes_close_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *brush_callback;
brush_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, brush_callback) ||
! pika_pdb_dialog_close (pika, pika_data_factory_get_container (pika->brush_factory),
brush_callback))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
brushes_set_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *brush_callback;
const gchar *brush_name;
brush_callback = g_value_get_string (pika_value_array_index (args, 0));
brush_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, brush_callback) ||
! pika_pdb_dialog_set (pika, pika_data_factory_get_container (pika->brush_factory),
brush_callback, brush_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_brush_select_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-brushes-popup
*/
procedure = pika_procedure_new (brushes_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-brushes-popup");
pika_procedure_set_static_help (procedure,
"Invokes the PIKA brush selection dialog.",
"Opens a dialog letting a user choose a brush.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("brush-callback",
"brush callback",
"The callback PDB proc to call when user chooses a brush",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("popup-title",
"popup title",
"Title of the brush selection dialog",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("initial-brush-name",
"initial brush name",
"The name of the brush to set as the initial choice",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-brushes-close-popup
*/
procedure = pika_procedure_new (brushes_close_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-brushes-close-popup");
pika_procedure_set_static_help (procedure,
"Close the brush selection dialog.",
"Closes an open brush selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("brush-callback",
"brush callback",
"The name of the callback registered for this pop-up",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-brushes-set-popup
*/
procedure = pika_procedure_new (brushes_set_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-brushes-set-popup");
pika_procedure_set_static_help (procedure,
"Sets the selected brush in a brush selection dialog.",
"Sets the selected brush in a brush selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("brush-callback",
"brush callback",
"The name of the callback registered for this pop-up",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("brush-name",
"brush name",
"The name of the brush to set as selected",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

146
app/pdb/brushes-cmds.c Normal file
View File

@ -0,0 +1,146 @@
/* 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/pikabrush.h"
#include "core/pikacontainer-filter.h"
#include "core/pikacontext.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "core/pikatempbuf.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
brushes_refresh_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
pika_data_factory_data_refresh (pika->brush_factory, context);
return pika_procedure_get_return_values (procedure, TRUE, NULL);
}
static PikaValueArray *
brushes_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 **brush_list = NULL;
filter = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
brush_list = pika_container_get_filtered_name_array (pika_data_factory_get_container (pika->brush_factory),
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), brush_list);
return return_vals;
}
void
register_brushes_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-brushes-refresh
*/
procedure = pika_procedure_new (brushes_refresh_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-brushes-refresh");
pika_procedure_set_static_help (procedure,
"Refresh current brushes. This function always succeeds.",
"This procedure retrieves all brushes currently in the user's brush path and updates the brush dialogs accordingly.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Seth Burgess",
"Seth Burgess",
"1997");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-brushes-get-list
*/
procedure = pika_procedure_new (brushes_get_list_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-brushes-get-list");
pika_procedure_set_static_help (procedure,
"Retrieve a complete listing of the available brushes.",
"This procedure returns a complete listing of available PIKA brushes. Each name returned can be used as input to the 'pika-context-set-brush' procedure.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
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 ("brush-list",
"brush list",
"The list of brush names",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

504
app/pdb/buffer-cmds.c Normal file
View File

@ -0,0 +1,504 @@
/* 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);
}

742
app/pdb/channel-cmds.c Normal file
View File

@ -0,0 +1,742 @@
/* 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 <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.h"
#include "libpikacolor/pikacolor.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pikachannel-combine.h"
#include "core/pikachannel.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
channel_new_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gint width;
gint height;
const gchar *name;
gdouble opacity;
PikaRGB color;
PikaChannel *channel = NULL;
image = g_value_get_object (pika_value_array_index (args, 0));
width = g_value_get_int (pika_value_array_index (args, 1));
height = g_value_get_int (pika_value_array_index (args, 2));
name = g_value_get_string (pika_value_array_index (args, 3));
opacity = g_value_get_double (pika_value_array_index (args, 4));
pika_value_get_rgb (pika_value_array_index (args, 5), &color);
if (success)
{
PikaRGB rgb_color = color;
rgb_color.a = opacity / 100.0;
channel = pika_channel_new (image, width, height, name, &rgb_color);
if (! channel)
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), channel);
return return_vals;
}
static PikaValueArray *
channel_new_from_component_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gint component;
const gchar *name;
PikaChannel *channel = NULL;
image = g_value_get_object (pika_value_array_index (args, 0));
component = g_value_get_enum (pika_value_array_index (args, 1));
name = g_value_get_string (pika_value_array_index (args, 2));
if (success)
{
if (pika_image_get_component_format (image, component) != NULL)
channel = pika_channel_new_from_component (image,
component, name, NULL);
if (channel)
pika_item_set_visible (PIKA_ITEM (channel), FALSE, FALSE);
else
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), channel);
return return_vals;
}
static PikaValueArray *
channel_copy_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaChannel *channel;
PikaChannel *channel_copy = NULL;
channel = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaImage *image = pika_item_get_image (PIKA_ITEM (channel));
gint width = pika_image_get_width (image);
gint height = pika_image_get_height (image);
if (pika_item_get_width (PIKA_ITEM (channel)) == width &&
pika_item_get_height (PIKA_ITEM (channel)) == height)
{
channel_copy = PIKA_CHANNEL (pika_item_duplicate (PIKA_ITEM (channel),
PIKA_TYPE_CHANNEL));
if (! channel_copy)
success = FALSE;
}
else
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), channel_copy);
return return_vals;
}
static PikaValueArray *
channel_combine_masks_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaChannel *channel1;
PikaChannel *channel2;
gint operation;
gint offx;
gint offy;
channel1 = g_value_get_object (pika_value_array_index (args, 0));
channel2 = g_value_get_object (pika_value_array_index (args, 1));
operation = g_value_get_enum (pika_value_array_index (args, 2));
offx = g_value_get_int (pika_value_array_index (args, 3));
offy = g_value_get_int (pika_value_array_index (args, 4));
if (success)
{
if (pika_item_is_attached (PIKA_ITEM (channel1)))
pika_channel_push_undo (channel1, _("Combine Masks"));
pika_channel_combine_mask (channel1, channel2, operation, offx, offy);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
channel_get_show_masked_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaChannel *channel;
gboolean show_masked = FALSE;
channel = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
show_masked = pika_channel_get_show_masked (channel);
}
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), show_masked);
return return_vals;
}
static PikaValueArray *
channel_set_show_masked_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaChannel *channel;
gboolean show_masked;
channel = g_value_get_object (pika_value_array_index (args, 0));
show_masked = g_value_get_boolean (pika_value_array_index (args, 1));
if (success)
{
pika_channel_set_show_masked (channel, show_masked);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
channel_get_opacity_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaChannel *channel;
gdouble opacity = 0.0;
channel = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
opacity = pika_channel_get_opacity (channel) * 100;
}
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), opacity);
return return_vals;
}
static PikaValueArray *
channel_set_opacity_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaChannel *channel;
gdouble opacity;
channel = g_value_get_object (pika_value_array_index (args, 0));
opacity = g_value_get_double (pika_value_array_index (args, 1));
if (success)
{
pika_channel_set_opacity (channel, opacity / 100.0, TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
channel_get_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaChannel *channel;
PikaRGB color = { 0.0, 0.0, 0.0, 1.0 };
channel = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_channel_get_color (channel, &color);
pika_rgb_set_alpha (&color, 1.0);
}
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 *
channel_set_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaChannel *channel;
PikaRGB color;
channel = g_value_get_object (pika_value_array_index (args, 0));
pika_value_get_rgb (pika_value_array_index (args, 1), &color);
if (success)
{
PikaRGB rgb_color = color;
rgb_color.a = channel->color.a;
pika_channel_set_color (channel, &rgb_color, TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_channel_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-channel-new
*/
procedure = pika_procedure_new (channel_new_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-new");
pika_procedure_set_static_help (procedure,
"Create a new channel.",
"This procedure creates a new channel with the specified width, height, name, opacity and color.\n"
"The new channel still needs to be added to the image, as this is not automatic. Add the new channel with 'pika-image-insert-channel'. Other attributes, such as channel visibility, should be set with explicit procedure calls.\n"
"The channel's contents are undefined initially.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image to which to add the channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("width",
"width",
"The channel width",
1, PIKA_MAX_IMAGE_SIZE, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("height",
"height",
"The channel height",
1, PIKA_MAX_IMAGE_SIZE, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("name",
"name",
"The channel name",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("opacity",
"opacity",
"The channel opacity",
0, 100, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_rgb ("color",
"color",
"The channel compositing color",
FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_channel ("channel",
"channel",
"The newly created channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-new-from-component
*/
procedure = pika_procedure_new (channel_new_from_component_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-new-from-component");
pika_procedure_set_static_help (procedure,
"Create a new channel from a color component",
"This procedure creates a new channel from a color component.\n"
"The new channel still needs to be added to the image, as this is not automatic. Add the new channel with 'pika-image-insert-channel'. Other attributes, such as channel visibility, should be set with explicit procedure calls.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Shlomi Fish <shlomif@iglu.org.il>",
"Shlomi Fish",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image to which to add the channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("component",
"component",
"The image component",
PIKA_TYPE_CHANNEL_TYPE,
PIKA_CHANNEL_RED,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("name",
"name",
"The channel name",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_channel ("channel",
"channel",
"The newly created channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-copy
*/
procedure = pika_procedure_new (channel_copy_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-copy");
pika_procedure_set_static_help (procedure,
"Copy a channel.",
"This procedure copies the specified channel and returns the copy.\n"
"The new channel still needs to be added to the image, as this is not automatic. Add the new channel with 'pika-image-insert-channel'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel",
"channel",
"The channel to copy",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_channel ("channel-copy",
"channel copy",
"The newly copied channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-combine-masks
*/
procedure = pika_procedure_new (channel_combine_masks_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-combine-masks");
pika_procedure_set_static_help (procedure,
"Combine two channel masks.",
"This procedure combines two channel masks. The result is stored in the first channel.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel1",
"channel1",
"The channel1",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel2",
"channel2",
"The channel2",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The selection operation",
PIKA_TYPE_CHANNEL_OPS,
PIKA_CHANNEL_OP_ADD,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offx",
"offx",
"x offset between upper left corner of channels: (second - first)",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offy",
"offy",
"y offset between upper left corner of channels: (second - first)",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-get-show-masked
*/
procedure = pika_procedure_new (channel_get_show_masked_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-get-show-masked");
pika_procedure_set_static_help (procedure,
"Get the composite method of the specified channel.",
"This procedure returns the specified channel's composite method. If it is TRUE, then the channel is composited with the image so that masked regions are shown. Otherwise, selected regions are shown.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel",
"channel",
"The channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("show-masked",
"show masked",
"The channel composite method",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-set-show-masked
*/
procedure = pika_procedure_new (channel_set_show_masked_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-set-show-masked");
pika_procedure_set_static_help (procedure,
"Set the composite method of the specified channel.",
"This procedure sets the specified channel's composite method. If it is TRUE, then the channel is composited with the image so that masked regions are shown. Otherwise, selected regions are shown.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel",
"channel",
"The channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("show-masked",
"show masked",
"The new channel composite method",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-get-opacity
*/
procedure = pika_procedure_new (channel_get_opacity_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-get-opacity");
pika_procedure_set_static_help (procedure,
"Get the opacity of the specified channel.",
"This procedure returns the specified channel's opacity.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel",
"channel",
"The channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_double ("opacity",
"opacity",
"The channel opacity",
0, 100, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-set-opacity
*/
procedure = pika_procedure_new (channel_set_opacity_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-set-opacity");
pika_procedure_set_static_help (procedure,
"Set the opacity of the specified channel.",
"This procedure sets the specified channel's opacity.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel",
"channel",
"The channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("opacity",
"opacity",
"The new channel opacity",
0, 100, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-get-color
*/
procedure = pika_procedure_new (channel_get_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-get-color");
pika_procedure_set_static_help (procedure,
"Get the compositing color of the specified channel.",
"This procedure returns the specified channel's compositing color.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel",
"channel",
"The channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_rgb ("color",
"color",
"The channel compositing color",
FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-channel-set-color
*/
procedure = pika_procedure_new (channel_set_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-channel-set-color");
pika_procedure_set_static_help (procedure,
"Set the compositing color of the specified channel.",
"This procedure sets the specified channel's compositing color.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_channel ("channel",
"channel",
"The channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_rgb ("color",
"color",
"The new channel compositing color",
FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

5783
app/pdb/context-cmds.c Normal file

File diff suppressed because it is too large Load Diff

146
app/pdb/debug-cmds.c Normal file
View File

@ -0,0 +1,146 @@
/* 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 "pdb-types.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static GTimer *pika_debug_timer = NULL;
static gint pika_debug_timer_counter = 0;
static PikaValueArray *
debug_timer_start_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
if (pika_debug_timer_counter++ == 0)
pika_debug_timer = g_timer_new ();
return pika_procedure_get_return_values (procedure, TRUE, NULL);
}
static PikaValueArray *
debug_timer_end_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gdouble elapsed = 0.0;
elapsed = 0.0;
if (pika_debug_timer_counter == 0)
success = FALSE;
else if (--pika_debug_timer_counter == 0)
{
elapsed = g_timer_elapsed (pika_debug_timer, NULL);
g_printerr ("PIKA debug timer: %g seconds\n", elapsed);
g_timer_destroy (pika_debug_timer);
pika_debug_timer = NULL;
}
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), elapsed);
return return_vals;
}
void
register_debug_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-debug-timer-start
*/
procedure = pika_procedure_new (debug_timer_start_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-debug-timer-start");
pika_procedure_set_static_help (procedure,
"Starts measuring elapsed time.",
"This procedure starts a timer, measuring the elapsed time since the call. Each call to this procedure should be matched by a call to 'pika-debug-timer-end', which returns the elapsed time.\n"
"If there is already an active timer, it is not affected by the call, however, a matching 'pika-debug-timer-end' call is still required.\n"
"\n"
"This is a debug utility procedure. It is subject to change at any point, and should not be used in production.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Ell",
"Ell",
"2017");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-debug-timer-end
*/
procedure = pika_procedure_new (debug_timer_end_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-debug-timer-end");
pika_procedure_set_static_help (procedure,
"Finishes measuring elapsed time.",
"This procedure stops the timer started by a previous 'pika-debug-timer-start' call, and prints and returns the elapsed time.\n"
"If there was already an active timer at the time of corresponding call to 'pika-debug-timer-start', a dummy value is returned.\n"
"\n"
"This is a debug utility procedure. It is subject to change at any point, and should not be used in production.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Ell",
"Ell",
"2017");
pika_procedure_add_return_value (procedure,
g_param_spec_double ("elapsed",
"elapsed",
"The elapsed time, in seconds",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

422
app/pdb/display-cmds.c Normal file
View File

@ -0,0 +1,422 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikacontainer.h"
#include "core/pikadisplay.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
display_id_is_valid_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint display_id;
gboolean valid = FALSE;
display_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
valid = (pika_display_get_by_id (pika, display_id) != NULL);
}
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), valid);
return return_vals;
}
static PikaValueArray *
display_new_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
PikaDisplay *display = NULL;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_image_flush (image);
display = pika_create_display (pika, image, PIKA_UNIT_PIXEL, 1.0, NULL);
if (display)
{
/* the first display takes ownership of the image */
if (pika_image_get_display_count (image) == 1)
g_object_unref (image);
}
else
{
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), display);
return return_vals;
}
static PikaValueArray *
display_delete_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaDisplay *display;
display = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_delete_display (pika, display);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
display_get_window_handle_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaDisplay *display;
gint window = 0;
display = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
window = (gint32) pika_get_display_window_id (pika, display);
}
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), window);
return return_vals;
}
static PikaValueArray *
display_present_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaDisplay *display;
display = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_display_present (display);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
displays_flush_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
pika_container_foreach (pika->images, (GFunc) pika_image_flush, NULL);
return pika_procedure_get_return_values (procedure, TRUE, NULL);
}
static PikaValueArray *
displays_reconnect_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *old_image;
PikaImage *new_image;
old_image = g_value_get_object (pika_value_array_index (args, 0));
new_image = g_value_get_object (pika_value_array_index (args, 1));
if (success)
{
success = (old_image != new_image &&
pika_image_get_display_count (old_image) > 0 &&
pika_image_get_display_count (new_image) == 0);
if (success)
{
pika_reconnect_displays (pika, old_image, new_image);
/* take ownership of the image */
if (pika_image_get_display_count (new_image) > 0)
g_object_unref (new_image);
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_display_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-display-id-is-valid
*/
procedure = pika_procedure_new (display_id_is_valid_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-display-id-is-valid");
pika_procedure_set_static_help (procedure,
"Returns TRUE if the display ID is valid.",
"This procedure checks if the given display ID is valid and refers to an existing display.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2007");
pika_procedure_add_argument (procedure,
g_param_spec_int ("display-id",
"display id",
"The display ID to check",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("valid",
"valid",
"Whether the display ID is valid",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-display-new
*/
procedure = pika_procedure_new (display_new_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-display-new");
pika_procedure_set_static_help (procedure,
"Create a new display for the specified image.",
"Creates a new display for the specified image. If the image already has a display, another is added. Multiple displays are handled transparently by PIKA. The newly created display is returned and can be subsequently destroyed with a call to 'pika-display-delete'. This procedure only makes sense for use with the PIKA UI, and will result in an execution error if called when PIKA has no UI.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_display ("display",
"display",
"The new display",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-display-delete
*/
procedure = pika_procedure_new (display_delete_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-display-delete");
pika_procedure_set_static_help (procedure,
"Delete the specified display.",
"This procedure removes the specified display. If this is the last remaining display for the underlying image, then the image is deleted also. Note that the display is closed no matter if the image is dirty or not. Better save the image before calling this procedure.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_display ("display",
"display",
"The display to delete",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-display-get-window-handle
*/
procedure = pika_procedure_new (display_get_window_handle_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-display-get-window-handle");
pika_procedure_set_static_help (procedure,
"Get a handle to the native window for an image display.",
"This procedure returns a handle to the native window for a given image display. For example in the X backend of GDK, a native window handle is an Xlib XID. A value of 0 is returned for an invalid display or if this function is unimplemented for the windowing system that is being used.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_display ("display",
"display",
"The display to get the window handle from",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("window",
"window",
"The native window handle or 0",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-display-present
*/
procedure = pika_procedure_new (display_present_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-display-present");
pika_procedure_set_static_help (procedure,
"Present the specified display.",
"This procedure presents the specified display at the top of the display stack.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2021");
pika_procedure_add_argument (procedure,
pika_param_spec_display ("display",
"display",
"The display to present",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-displays-flush
*/
procedure = pika_procedure_new (displays_flush_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-displays-flush");
pika_procedure_set_static_help (procedure,
"Flush all internal changes to the user interface",
"This procedure takes no arguments and returns nothing except a success status. Its purpose is to flush all pending updates of image manipulations to the user interface. It should be called whenever appropriate.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-displays-reconnect
*/
procedure = pika_procedure_new (displays_reconnect_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-displays-reconnect");
pika_procedure_set_static_help (procedure,
"Reconnect displays from one image to another image.",
"This procedure connects all displays of the old_image to the new_image. If the old_image has no display or new_image already has a display the reconnect is not performed and the procedure returns without success. You should rarely need to use this function.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("old-image",
"old image",
"The old image (must have at least one display)",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_image ("new-image",
"new image",
"The new image (must not have a display)",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

1710
app/pdb/drawable-cmds.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,630 @@
/* 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 "libpikaconfig/pikaconfig.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pika-gradients.h"
#include "core/pika.h"
#include "core/pikabuffer.h"
#include "core/pikadrawable-bucket-fill.h"
#include "core/pikadrawable-edit.h"
#include "core/pikadrawable-gradient.h"
#include "core/pikadrawable.h"
#include "core/pikaimage.h"
#include "core/pikaitem.h"
#include "core/pikaparamspecs.h"
#include "core/pikaprogress.h"
#include "core/pikastrokeoptions.h"
#include "paint/pikapaintoptions.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikapdbcontext.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
drawable_edit_clear_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaDrawable *drawable;
drawable = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
PIKA_PDB_ITEM_CONTENT, error) &&
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error))
{
pika_drawable_edit_clear (drawable, context);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
drawable_edit_fill_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaDrawable *drawable;
gint fill_type;
drawable = g_value_get_object (pika_value_array_index (args, 0));
fill_type = g_value_get_enum (pika_value_array_index (args, 1));
if (success)
{
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
PIKA_PDB_ITEM_CONTENT, error) &&
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error))
{
PikaFillOptions *options = pika_fill_options_new (pika, NULL, FALSE);
pika_context_set_opacity (PIKA_CONTEXT (options),
pika_context_get_opacity (context));
pika_context_set_paint_mode (PIKA_CONTEXT (options),
pika_context_get_paint_mode (context));
if (pika_fill_options_set_by_fill_type (options, context,
fill_type, error))
{
pika_drawable_edit_fill (drawable, options, NULL);
}
else
success = FALSE;
g_object_unref (options);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
drawable_edit_bucket_fill_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaDrawable *drawable;
gint fill_type;
gdouble x;
gdouble y;
drawable = g_value_get_object (pika_value_array_index (args, 0));
fill_type = g_value_get_enum (pika_value_array_index (args, 1));
x = g_value_get_double (pika_value_array_index (args, 2));
y = g_value_get_double (pika_value_array_index (args, 3));
if (success)
{
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
PIKA_PDB_ITEM_CONTENT, error) &&
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error))
{
PikaFillOptions *options = pika_fill_options_new (pika, NULL, FALSE);
pika_context_set_opacity (PIKA_CONTEXT (options),
pika_context_get_opacity (context));
pika_context_set_paint_mode (PIKA_CONTEXT (options),
pika_context_get_paint_mode (context));
pika_fill_options_set_antialias (options,
PIKA_PDB_CONTEXT (context)->antialias);
if (pika_fill_options_set_by_fill_type (options, context,
fill_type, error))
{
pika_drawable_bucket_fill (drawable, options,
PIKA_PDB_CONTEXT (context)->sample_transparent,
PIKA_PDB_CONTEXT (context)->sample_criterion,
PIKA_PDB_CONTEXT (context)->sample_threshold,
PIKA_PDB_CONTEXT (context)->sample_merged,
PIKA_PDB_CONTEXT (context)->diagonal_neighbors,
x, y);
}
else
success = FALSE;
g_object_unref (options);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
drawable_edit_gradient_fill_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaDrawable *drawable;
gint gradient_type;
gdouble offset;
gboolean supersample;
gint supersample_max_depth;
gdouble supersample_threshold;
gboolean dither;
gdouble x1;
gdouble y1;
gdouble x2;
gdouble y2;
drawable = g_value_get_object (pika_value_array_index (args, 0));
gradient_type = g_value_get_enum (pika_value_array_index (args, 1));
offset = g_value_get_double (pika_value_array_index (args, 2));
supersample = g_value_get_boolean (pika_value_array_index (args, 3));
supersample_max_depth = g_value_get_int (pika_value_array_index (args, 4));
supersample_threshold = g_value_get_double (pika_value_array_index (args, 5));
dither = g_value_get_boolean (pika_value_array_index (args, 6));
x1 = g_value_get_double (pika_value_array_index (args, 7));
y1 = g_value_get_double (pika_value_array_index (args, 8));
x2 = g_value_get_double (pika_value_array_index (args, 9));
y2 = g_value_get_double (pika_value_array_index (args, 10));
if (success)
{
success = (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
PIKA_PDB_ITEM_CONTENT, error) &&
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error));
if (success)
{
if (supersample)
{
if (supersample_max_depth < 1 || supersample_max_depth > 9)
success = FALSE;
if (supersample_threshold < 0.0 || supersample_threshold > 4.0)
success = FALSE;
}
else
{
supersample_max_depth = CLAMP (supersample_max_depth, 1, 9);
supersample_threshold = CLAMP (supersample_threshold, 0.0, 4.0);
}
}
if (success)
{
/* all options should have the same value, so pick a random one */
PikaPaintOptions *options =
pika_pdb_context_get_paint_options (PIKA_PDB_CONTEXT (context),
"pika-paintbrush");
if (progress)
pika_progress_start (progress, FALSE, _("Gradient"));
pika_drawable_gradient (drawable,
context,
pika_context_get_gradient (context),
PIKA_PDB_CONTEXT (context)->distance_metric,
pika_context_get_paint_mode (context),
gradient_type,
pika_context_get_opacity (context),
offset,
options->gradient_options->gradient_repeat,
options->gradient_options->gradient_reverse,
options->gradient_options->gradient_blend_color_space,
supersample,
supersample_max_depth,
supersample_threshold,
dither,
x1, y1, x2, y2,
progress);
if (progress)
pika_progress_end (progress);
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
drawable_edit_stroke_selection_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaDrawable *drawable;
drawable = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
PIKA_PDB_ITEM_CONTENT, error) &&
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error))
{
PikaImage *image = pika_item_get_image (PIKA_ITEM (drawable));
PikaStrokeOptions *options;
PikaPaintOptions *paint_options;
GList *drawables = g_list_prepend (NULL, drawable);
options = pika_pdb_context_get_stroke_options (PIKA_PDB_CONTEXT (context));
paint_options =
pika_pdb_context_get_paint_options (PIKA_PDB_CONTEXT (context), NULL);
paint_options = pika_config_duplicate (PIKA_CONFIG (paint_options));
success = pika_item_stroke (PIKA_ITEM (pika_image_get_mask (image)),
drawables, context, options, paint_options,
TRUE, progress, error);
g_object_unref (paint_options);
g_list_free (drawables);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
drawable_edit_stroke_item_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaDrawable *drawable;
PikaItem *item;
drawable = g_value_get_object (pika_value_array_index (args, 0));
item = g_value_get_object (pika_value_array_index (args, 1));
if (success)
{
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
PIKA_PDB_ITEM_CONTENT, error) &&
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error) &&
pika_pdb_item_is_attached (item,
pika_item_get_image (PIKA_ITEM (drawable)),
0, error))
{
PikaStrokeOptions *options;
PikaPaintOptions *paint_options;
GList *drawables = g_list_prepend (NULL, drawable);
options = pika_pdb_context_get_stroke_options (PIKA_PDB_CONTEXT (context));
paint_options =
pika_pdb_context_get_paint_options (PIKA_PDB_CONTEXT (context), NULL);
paint_options = pika_config_duplicate (PIKA_CONFIG (paint_options));
success = pika_item_stroke (item, drawables,
context, options, paint_options,
TRUE, progress, error);
g_object_unref (paint_options);
g_list_free (drawables);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_drawable_edit_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-drawable-edit-clear
*/
procedure = pika_procedure_new (drawable_edit_clear_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-drawable-edit-clear");
pika_procedure_set_static_help (procedure,
"Clear selected area of drawable.",
"This procedure clears the specified drawable. If the drawable has an alpha channel, the cleared pixels will become transparent. If the drawable does not have an alpha channel, cleared pixels will be set to the background color. This procedure only affects regions within a selection if there is a selection active.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-background'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The drawable to clear from",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-drawable-edit-fill
*/
procedure = pika_procedure_new (drawable_edit_fill_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-drawable-edit-fill");
pika_procedure_set_static_help (procedure,
"Fill selected area of drawable.",
"This procedure fills the specified drawable according to fill mode. This procedure only affects regions within a selection if there is a selection active. If you want to fill the whole drawable, regardless of the selection, use 'pika-drawable-fill'.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-opacity', 'pika-context-set-paint-mode', 'pika-context-set-foreground', 'pika-context-set-background', 'pika-context-set-pattern'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis & Raphael Quinet",
"Spencer Kimball & Peter Mattis",
"1995-2000");
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The drawable to fill to",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("fill-type",
"fill type",
"The type of fill",
PIKA_TYPE_FILL_TYPE,
PIKA_FILL_FOREGROUND,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-drawable-edit-bucket-fill
*/
procedure = pika_procedure_new (drawable_edit_bucket_fill_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-drawable-edit-bucket-fill");
pika_procedure_set_static_help (procedure,
"Fill the area by a seed fill starting at the specified coordinates.",
"This procedure does a seed fill at the specified coordinates, using various parameters from the current context.\n"
"In the case of merged sampling, the x and y coordinates are relative to the image's origin; otherwise, they are relative to the drawable's origin.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-opacity', 'pika-context-set-paint-mode', 'pika-context-set-foreground', 'pika-context-set-background', 'pika-context-set-pattern', 'pika-context-set-sample-threshold', 'pika-context-set-sample-merged', 'pika-context-set-sample-criterion', 'pika-context-set-diagonal-neighbors', 'pika-context-set-antialias'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2018");
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The affected drawable",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("fill-type",
"fill type",
"The type of fill",
PIKA_TYPE_FILL_TYPE,
PIKA_FILL_FOREGROUND,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("x",
"x",
"The x coordinate of this bucket fill's application.",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("y",
"y",
"The y coordinate of this bucket fill's application.",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-drawable-edit-gradient-fill
*/
procedure = pika_procedure_new (drawable_edit_gradient_fill_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-drawable-edit-gradient-fill");
pika_procedure_set_static_help (procedure,
"Draw a gradient between the starting and ending coordinates with the specified gradient type.",
"This tool requires information on the gradient type. It creates the specified variety of gradient using the starting and ending coordinates as defined for each gradient type. For shapeburst gradient types, the context's distance metric is also relevant and can be updated with 'pika-context-set-distance-metric'.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-opacity', 'pika-context-set-paint-mode', 'pika-context-set-foreground', 'pika-context-set-background', 'pika-context-set-gradient' and all gradient property settings, 'pika-context-set-distance-metric'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2018");
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The affected drawable",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("gradient-type",
"gradient type",
"The type of gradient",
PIKA_TYPE_GRADIENT_TYPE,
PIKA_GRADIENT_LINEAR,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("offset",
"offset",
"Offset relates to the starting and ending coordinates specified for the blend. This parameter is mode dependent.",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("supersample",
"supersample",
"Do adaptive supersampling",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("supersample-max-depth",
"supersample max depth",
"Maximum recursion levels for supersampling",
1, 9, 1,
PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("supersample-threshold",
"supersample threshold",
"Supersampling threshold",
0, 4, 0,
PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("dither",
"dither",
"Use dithering to reduce banding",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("x1",
"x1",
"The x coordinate of this gradient's starting point",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("y1",
"y1",
"The y coordinate of this gradient's starting point",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("x2",
"x2",
"The x coordinate of this gradient's ending point",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("y2",
"y2",
"The y coordinate of this gradient's ending point",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-drawable-edit-stroke-selection
*/
procedure = pika_procedure_new (drawable_edit_stroke_selection_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-drawable-edit-stroke-selection");
pika_procedure_set_static_help (procedure,
"Stroke the current selection",
"This procedure strokes the current selection, painting along the selection boundary with the active paint method and brush, or using a plain line with configurable properties. The paint is applied to the specified drawable regardless of the active selection.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-opacity', 'pika-context-set-paint-mode', 'pika-context-set-paint-method', 'pika-context-set-stroke-method', 'pika-context-set-foreground', 'pika-context-set-brush' and all brush property settings, 'pika-context-set-gradient' and all gradient property settings, 'pika-context-set-line-width' and all line property settings, 'pika-context-set-antialias'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The drawable to stroke to",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-drawable-edit-stroke-item
*/
procedure = pika_procedure_new (drawable_edit_stroke_item_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-drawable-edit-stroke-item");
pika_procedure_set_static_help (procedure,
"Stroke the specified item",
"This procedure strokes the specified item, painting along its outline (e.g. along a path, or along a channel's boundary), with the active paint method and brush, or using a plain line with configurable properties.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-opacity', 'pika-context-set-paint-mode', 'pika-context-set-paint-method', 'pika-context-set-stroke-method', 'pika-context-set-foreground', 'pika-context-set-brush' and all brush property settings, 'pika-context-set-gradient' and all gradient property settings, 'pika-context-set-line-width' and all line property settings, 'pika-context-set-antialias'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2018");
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The drawable to stroke to",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_item ("item",
"item",
"The item to stroke",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

141
app/pdb/dynamics-cmds.c Normal file
View File

@ -0,0 +1,141 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikacontainer-filter.h"
#include "core/pikacontainer.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
dynamics_refresh_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
pika_data_factory_data_refresh (pika->dynamics_factory, context);
return pika_procedure_get_return_values (procedure, TRUE, NULL);
}
static PikaValueArray *
dynamics_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 **dynamics_list = NULL;
filter = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
dynamics_list = pika_container_get_filtered_name_array (pika_data_factory_get_container (pika->dynamics_factory),
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), dynamics_list);
return return_vals;
}
void
register_dynamics_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-dynamics-refresh
*/
procedure = pika_procedure_new (dynamics_refresh_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-dynamics-refresh");
pika_procedure_set_static_help (procedure,
"Refresh current paint dynamics. This function always succeeds.",
"This procedure retrieves all paint dynamics currently in the user's paint dynamics path and updates the paint dynamics dialogs accordingly.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2011");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-dynamics-get-list
*/
procedure = pika_procedure_new (dynamics_get_list_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-dynamics-get-list");
pika_procedure_set_static_help (procedure,
"Retrieve the list of loaded paint dynamics.",
"This procedure returns a list of the paint dynamics that are currently available.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2011");
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 ("dynamics-list",
"dynamics list",
"The list of paint dynamics names",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

1029
app/pdb/edit-cmds.c Normal file

File diff suppressed because it is too large Load Diff

611
app/pdb/file-cmds.c Normal file
View File

@ -0,0 +1,611 @@
/* 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/pikaimage.h"
#include "core/pikalayer.h"
#include "core/pikaparamspecs.h"
#include "file/file-open.h"
#include "file/file-save.h"
#include "file/file-utils.h"
#include "plug-in/pikapluginmanager-file.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
file_load_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *new_args;
PikaValueArray *return_vals;
PikaPlugInProcedure *file_proc;
PikaProcedure *proc;
GFile *file;
gint i;
file = g_value_get_object (pika_value_array_index (args, 1));
if (! file)
return pika_procedure_get_return_values (procedure, FALSE,
error ? *error : NULL);
file_proc = pika_plug_in_manager_file_procedure_find (pika->plug_in_manager,
PIKA_FILE_PROCEDURE_GROUP_OPEN,
file, error);
if (! file_proc)
return pika_procedure_get_return_values (procedure, FALSE,
error ? *error : NULL);
proc = PIKA_PROCEDURE (file_proc);
new_args = pika_procedure_get_arguments (proc);
g_value_transform (pika_value_array_index (args, 0),
pika_value_array_index (new_args, 0));
g_value_transform (pika_value_array_index (args, 1),
pika_value_array_index (new_args, 1));
for (i = 2; i < proc->num_args; i++)
if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
g_value_set_static_string (pika_value_array_index (new_args, i), "");
return_vals =
pika_pdb_execute_procedure_by_name_args (pika->pdb,
context, progress, error,
pika_object_get_name (proc),
new_args);
pika_value_array_unref (new_args);
if (g_value_get_enum (pika_value_array_index (return_vals, 0)) ==
PIKA_PDB_SUCCESS)
{
if (pika_value_array_length (return_vals) > 1 &&
PIKA_VALUE_HOLDS_IMAGE (pika_value_array_index (return_vals, 1)))
{
PikaImage *image =
g_value_get_object (pika_value_array_index (return_vals, 1));
pika_image_set_load_proc (image, file_proc);
}
}
return return_vals;
}
static PikaValueArray *
file_load_layer_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint run_mode;
PikaImage *image;
GFile *file;
PikaLayer *layer = NULL;
run_mode = g_value_get_enum (pika_value_array_index (args, 0));
image = g_value_get_object (pika_value_array_index (args, 1));
file = g_value_get_object (pika_value_array_index (args, 2));
if (success)
{
GList *layers;
PikaPDBStatusType status;
layers = file_open_layers (pika, context, progress,
image, FALSE,
file, run_mode, NULL, &status, error);
if (layers)
{
layer = layers->data;
g_list_free (layers);
}
else
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), layer);
return return_vals;
}
static PikaValueArray *
file_load_layers_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint run_mode;
PikaImage *image;
GFile *file;
gint num_layers = 0;
PikaLayer **layers = NULL;
run_mode = g_value_get_enum (pika_value_array_index (args, 0));
image = g_value_get_object (pika_value_array_index (args, 1));
file = g_value_get_object (pika_value_array_index (args, 2));
if (success)
{
GList *layer_list;
PikaPDBStatusType status;
layer_list = file_open_layers (pika, context, progress,
image, FALSE,
file, run_mode, NULL, &status, error);
if (layer_list)
{
GList *list;
gint i;
num_layers = g_list_length (layer_list);
layers = g_new (PikaLayer *, num_layers);
for (i = 0, list = layer_list;
i < num_layers;
i++, list = g_list_next (list))
{
layers[i] = g_object_ref (list->data);
}
g_list_free (layer_list);
}
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), num_layers);
pika_value_take_object_array (pika_value_array_index (return_vals, 2), PIKA_TYPE_LAYER, (GObject **) layers, num_layers);
}
return return_vals;
}
static PikaValueArray *
file_save_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *new_args;
PikaValueArray *return_vals;
PikaPlugInProcedure *file_proc;
GFile *file;
PikaProcedure *proc;
gint i;
file = g_value_get_object (pika_value_array_index (args, 4));
file_proc = pika_plug_in_manager_file_procedure_find (pika->plug_in_manager,
PIKA_FILE_PROCEDURE_GROUP_SAVE,
file, NULL);
if (! file_proc)
file_proc = pika_plug_in_manager_file_procedure_find (pika->plug_in_manager,
PIKA_FILE_PROCEDURE_GROUP_EXPORT,
file, error);
if (! file_proc)
return pika_procedure_get_return_values (procedure, FALSE,
error ? *error : NULL);
proc = PIKA_PROCEDURE (file_proc);
new_args = pika_procedure_get_arguments (proc);
g_value_transform (pika_value_array_index (args, 0),
pika_value_array_index (new_args, 0));
g_value_transform (pika_value_array_index (args, 1),
pika_value_array_index (new_args, 1));
g_value_transform (pika_value_array_index (args, 2),
pika_value_array_index (new_args, 2));
g_value_transform (pika_value_array_index (args, 3),
pika_value_array_index (new_args, 3));
g_value_transform (pika_value_array_index (args, 4),
pika_value_array_index (new_args, 4));
for (i = 5; i < proc->num_args; i++)
if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
g_value_set_static_string (pika_value_array_index (new_args, i), "");
return_vals =
pika_pdb_execute_procedure_by_name_args (pika->pdb,
context, progress, error,
pika_object_get_name (proc),
new_args);
pika_value_array_unref (new_args);
return return_vals;
}
static PikaValueArray *
file_load_thumbnail_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
GFile *file;
gint width = 0;
gint height = 0;
GBytes *thumb_data = NULL;
file = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
GdkPixbuf *pixbuf = file_utils_load_thumbnail (file);
if (pixbuf)
{
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
thumb_data = g_bytes_new (gdk_pixbuf_get_pixels (pixbuf),
3 * width * height);
g_object_unref (pixbuf);
}
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);
g_value_set_int (pika_value_array_index (return_vals, 2), height);
g_value_take_boxed (pika_value_array_index (return_vals, 3), thumb_data);
}
return return_vals;
}
static PikaValueArray *
file_save_thumbnail_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
GFile *file;
image = g_value_get_object (pika_value_array_index (args, 0));
file = g_value_get_object (pika_value_array_index (args, 1));
if (success)
{
success = file_utils_save_thumbnail (image, file);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_file_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-file-load
*/
procedure = pika_procedure_new (file_load_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-file-load");
pika_procedure_set_static_help (procedure,
"Loads an image file by invoking the right load handler.",
"This procedure invokes the correct file load handler using magic if possible, and falling back on the file's extension and/or prefix if not.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Josh MacDonald",
"Josh MacDonald",
"1997");
pika_procedure_add_argument (procedure,
pika_param_spec_enum ("run-mode",
"run mode",
"The run mode",
PIKA_TYPE_RUN_MODE,
PIKA_RUN_INTERACTIVE,
PIKA_PARAM_READWRITE));
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->args[0]),
PIKA_RUN_WITH_LAST_VALS);
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file to load",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_image ("image",
"image",
"The output image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-file-load-layer
*/
procedure = pika_procedure_new (file_load_layer_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-file-load-layer");
pika_procedure_set_static_help (procedure,
"Loads an image file as a layer for an existing image.",
"This procedure behaves like the file-load procedure but opens the specified image as a layer for an existing image. The returned layer needs to be added to the existing image with 'pika-image-insert-layer'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_enum ("run-mode",
"run mode",
"The run mode",
PIKA_TYPE_RUN_MODE,
PIKA_RUN_INTERACTIVE,
PIKA_PARAM_READWRITE));
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->args[0]),
PIKA_RUN_WITH_LAST_VALS);
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"Destination image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file to load",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_layer ("layer",
"layer",
"The layer created when loading the image file",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-file-load-layers
*/
procedure = pika_procedure_new (file_load_layers_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-file-load-layers");
pika_procedure_set_static_help (procedure,
"Loads an image file as layers for an existing image.",
"This procedure behaves like the file-load procedure but opens the specified image as layers for an existing image. The returned layers needs to be added to the existing image with 'pika-image-insert-layer'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2006");
pika_procedure_add_argument (procedure,
pika_param_spec_enum ("run-mode",
"run mode",
"The run mode",
PIKA_TYPE_RUN_MODE,
PIKA_RUN_INTERACTIVE,
PIKA_PARAM_READWRITE));
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->args[0]),
PIKA_RUN_WITH_LAST_VALS);
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"Destination image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file to load",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("num-layers",
"num layers",
"The number of loaded layers",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_object_array ("layers",
"layers",
"The list of loaded layers",
PIKA_TYPE_LAYER,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-file-save
*/
procedure = pika_procedure_new (file_save_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-file-save");
pika_procedure_set_static_help (procedure,
"Saves a file by extension.",
"This procedure invokes the correct file save handler according to the file's extension and/or prefix.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Josh MacDonald",
"Josh MacDonald",
"1997");
pika_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
PIKA_TYPE_RUN_MODE,
PIKA_RUN_INTERACTIVE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"Input image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("num-drawables",
"num drawables",
"The number of drawables to save",
1, G_MAXINT32, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_object_array ("drawables",
"drawables",
"Drawables to save",
PIKA_TYPE_ITEM,
PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file to save the image in",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-file-load-thumbnail
*/
procedure = pika_procedure_new (file_load_thumbnail_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-file-load-thumbnail");
pika_procedure_set_static_help (procedure,
"Loads the thumbnail for a file.",
"This procedure tries to load a thumbnail that belongs to the given file. The returned data is an array of colordepth 3 (RGB), regardless of the image type. Width and height of the thumbnail are also returned. Don't use this function if you need a thumbnail of an already opened image, use 'pika-image-thumbnail' instead.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss, Sven Neumann",
"Adam D. Moss, Sven Neumann",
"1999-2003");
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file that owns the thumbnail to load",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("width",
"width",
"The width of the thumbnail",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("height",
"height",
"The height of the thumbnail",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("thumb-data",
"thumb data",
"The thumbnail data",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-file-save-thumbnail
*/
procedure = pika_procedure_new (file_save_thumbnail_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-file-save-thumbnail");
pika_procedure_set_static_help (procedure,
"Saves a thumbnail for the given image",
"This procedure saves a thumbnail for the given image according to the Free Desktop Thumbnail Managing Standard. The thumbnail is saved so that it belongs to the given file. This means you have to save the image under this name first, otherwise this procedure will fail. This procedure may become useful if you want to explicitly save a thumbnail with a file.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Josh MacDonald",
"Josh MacDonald",
"1997");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file the thumbnail belongs to",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

289
app/pdb/floating-sel-cmds.c Normal file
View File

@ -0,0 +1,289 @@
/* 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 "pdb-types.h"
#include "core/pikadrawable.h"
#include "core/pikaimage.h"
#include "core/pikalayer-floating-selection.h"
#include "core/pikalayer.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikapdberror.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
floating_sel_remove_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaLayer *floating_sel;
floating_sel = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
if (pika_layer_is_floating_sel (floating_sel))
{
pika_image_remove_layer (pika_item_get_image (PIKA_ITEM (floating_sel)),
floating_sel, TRUE, NULL);
}
else
{
g_set_error_literal (error, PIKA_PDB_ERROR,
PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Cannot remove this layer because "
"it is not a floating selection."));
success = FALSE;
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
floating_sel_anchor_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaLayer *floating_sel;
floating_sel = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
if (pika_layer_is_floating_sel (floating_sel))
{
floating_sel_anchor (floating_sel);
}
else
{
g_set_error_literal (error, PIKA_PDB_ERROR,
PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Cannot anchor this layer because "
"it is not a floating selection."));
success = FALSE;
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
floating_sel_to_layer_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaLayer *floating_sel;
floating_sel = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
if (pika_layer_is_floating_sel (floating_sel))
{
success = floating_sel_to_layer (floating_sel, error);
}
else
{
g_set_error_literal (error, PIKA_PDB_ERROR,
PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Cannot convert this layer to a normal layer "
"because it is not a floating selection."));
success = FALSE;
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
floating_sel_attach_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaLayer *layer;
PikaDrawable *drawable;
layer = g_value_get_object (pika_value_array_index (args, 0));
drawable = g_value_get_object (pika_value_array_index (args, 1));
if (success)
{
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
PIKA_PDB_ITEM_CONTENT, error) &&
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error))
{
/* see layer-new */
if (pika_drawable_is_gray (PIKA_DRAWABLE (layer)) &&
PIKA_IS_LAYER (drawable))
pika_layer_fix_format_space (layer, TRUE, FALSE);
floating_sel_attach (layer, drawable);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_floating_sel_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-floating-sel-remove
*/
procedure = pika_procedure_new (floating_sel_remove_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-floating-sel-remove");
pika_procedure_set_static_help (procedure,
"Remove the specified floating selection from its associated drawable.",
"This procedure removes the floating selection completely, without any side effects. The associated drawable is then set to active.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_layer ("floating-sel",
"floating sel",
"The floating selection",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-floating-sel-anchor
*/
procedure = pika_procedure_new (floating_sel_anchor_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-floating-sel-anchor");
pika_procedure_set_static_help (procedure,
"Anchor the specified floating selection to its associated drawable.",
"This procedure anchors the floating selection to its associated drawable. This is similar to merging with a merge type of ClipToBottomLayer. The floating selection layer is no longer valid after this operation.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_layer ("floating-sel",
"floating sel",
"The floating selection",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-floating-sel-to-layer
*/
procedure = pika_procedure_new (floating_sel_to_layer_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-floating-sel-to-layer");
pika_procedure_set_static_help (procedure,
"Transforms the specified floating selection into a layer.",
"This procedure transforms the specified floating selection into a layer with the same offsets and extents. The composited image will look precisely the same, but the floating selection layer will no longer be clipped to the extents of the drawable it was attached to. The floating selection will become the active layer. This procedure will not work if the floating selection has a different base type from the underlying image. This might be the case if the floating selection is above an auxiliary channel or a layer mask.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_layer ("floating-sel",
"floating sel",
"The floating selection",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-floating-sel-attach
*/
procedure = pika_procedure_new (floating_sel_attach_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-floating-sel-attach");
pika_procedure_set_static_help (procedure,
"Attach the specified layer as floating to the specified drawable.",
"This procedure attaches the layer as floating selection to the drawable.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_layer ("layer",
"layer",
"The layer (is attached as floating selection)",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The drawable (where to attach the floating selection)",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

112
app/pdb/font-cmds.c Normal file
View File

@ -0,0 +1,112 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikaparamspecs.h"
#include "text/pikafont.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
font_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;
PikaFont *font = NULL;
name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
font = PIKA_FONT (pika_pdb_get_resource (pika, PIKA_TYPE_FONT, name, PIKA_PDB_DATA_ACCESS_READ, error));
if (! font)
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), font);
return return_vals;
}
void
register_font_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-font-get-by-name
*/
procedure = pika_procedure_new (font_get_by_name_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-font-get-by-name");
pika_procedure_set_static_help (procedure,
"Returns the font with the given name.",
"Returns the font with the given name.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("name",
"name",
"The name of the font",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_font ("font",
"font",
"The font",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

233
app/pdb/font-select-cmds.c Normal file
View File

@ -0,0 +1,233 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
fonts_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *font_callback;
const gchar *popup_title;
const gchar *initial_font_name;
font_callback = g_value_get_string (pika_value_array_index (args, 0));
popup_title = g_value_get_string (pika_value_array_index (args, 1));
initial_font_name = g_value_get_string (pika_value_array_index (args, 2));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, font_callback) ||
! pika_data_factory_data_wait (pika->font_factory) ||
! pika_pdb_dialog_new (pika, context, progress,
pika_data_factory_get_container (pika->font_factory),
popup_title, font_callback, initial_font_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
fonts_close_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *font_callback;
font_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, font_callback) ||
! pika_pdb_dialog_close (pika,
pika_data_factory_get_container (pika->font_factory),
font_callback))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
fonts_set_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *font_callback;
const gchar *font_name;
font_callback = g_value_get_string (pika_value_array_index (args, 0));
font_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, font_callback) ||
! pika_data_factory_data_wait (pika->font_factory) ||
! pika_pdb_dialog_set (pika,
pika_data_factory_get_container (pika->font_factory),
font_callback, font_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_font_select_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-fonts-popup
*/
procedure = pika_procedure_new (fonts_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-fonts-popup");
pika_procedure_set_static_help (procedure,
"Invokes the Pika font selection dialog.",
"Opens a dialog letting a user choose a font.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2003");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("font-callback",
"font callback",
"The callback PDB proc to call when user chooses a font",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("popup-title",
"popup title",
"Title of the font selection dialog",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("initial-font-name",
"initial font name",
"The name of the initial font choice.",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-fonts-close-popup
*/
procedure = pika_procedure_new (fonts_close_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-fonts-close-popup");
pika_procedure_set_static_help (procedure,
"Close the font selection dialog.",
"Closes an open font selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2003");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("font-callback",
"font callback",
"The name of the callback registered in the PDB for this dialog",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-fonts-set-popup
*/
procedure = pika_procedure_new (fonts_set_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-fonts-set-popup");
pika_procedure_set_static_help (procedure,
"Sets the current font in a font selection dialog.",
"Sets the current font in a font selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2003");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("font-callback",
"font callback",
"The name of the callback registered in the PDB for the dialog.",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("font-name",
"font name",
"The name of the font to set as selected",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

148
app/pdb/fonts-cmds.c Normal file
View File

@ -0,0 +1,148 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikacontainer-filter.h"
#include "core/pikacontainer.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
fonts_refresh_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
pika_data_factory_data_refresh (pika->font_factory, context);
pika_data_factory_data_wait (pika->font_factory);
return pika_procedure_get_return_values (procedure, TRUE, NULL);
}
static PikaValueArray *
fonts_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 **font_list = NULL;
filter = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
if (! pika_data_factory_data_wait (pika->font_factory))
success = FALSE;
if (success)
{
font_list = pika_container_get_filtered_name_array (pika_data_factory_get_container (pika->font_factory),
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), font_list);
return return_vals;
}
void
register_fonts_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-fonts-refresh
*/
procedure = pika_procedure_new (fonts_refresh_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-fonts-refresh");
pika_procedure_set_static_help (procedure,
"Refresh current fonts. This function always succeeds.",
"This procedure retrieves all fonts currently in the user's font path and updates the font dialogs accordingly. Depending on the amount of fonts on the system, this can take considerable time.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2003");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-fonts-get-list
*/
procedure = pika_procedure_new (fonts_get_list_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-fonts-get-list");
pika_procedure_set_static_help (procedure,
"Retrieve the list of loaded fonts.",
"This procedure returns a list of the fonts that are currently available.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2003");
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 ("font-list",
"font list",
"The list of font names",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

2391
app/pdb/gradient-cmds.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,236 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikadatafactory.h"
#include "core/pikagradient.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
gradients_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *gradient_callback;
const gchar *popup_title;
const gchar *initial_gradient_name;
gradient_callback = g_value_get_string (pika_value_array_index (args, 0));
popup_title = g_value_get_string (pika_value_array_index (args, 1));
initial_gradient_name = g_value_get_string (pika_value_array_index (args, 2));
if (success)
{
/* Formerly, this procedure had another parameter:
* the sample size of the gradient's data passed in the changed callback.
* Now the sample size is determined by core, and in the future,
* the callback won't return a sample of the data at all.
*/
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, gradient_callback) ||
! pika_pdb_dialog_new (pika, context, progress,
pika_data_factory_get_container (pika->gradient_factory),
popup_title, gradient_callback, initial_gradient_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
gradients_close_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *gradient_callback;
gradient_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, gradient_callback) ||
! pika_pdb_dialog_close (pika, pika_data_factory_get_container (pika->gradient_factory),
gradient_callback))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
gradients_set_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *gradient_callback;
const gchar *gradient_name;
gradient_callback = g_value_get_string (pika_value_array_index (args, 0));
gradient_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, gradient_callback) ||
! pika_pdb_dialog_set (pika, pika_data_factory_get_container (pika->gradient_factory),
gradient_callback, gradient_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_gradient_select_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-gradients-popup
*/
procedure = pika_procedure_new (gradients_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-gradients-popup");
pika_procedure_set_static_help (procedure,
"Invokes the Pika gradients selection dialog.",
"Opens a dialog letting a user choose a gradient.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("gradient-callback",
"gradient callback",
"The callback PDB proc to call when user chooses a gradient",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("popup-title",
"popup title",
"Title of the gradient selection dialog",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("initial-gradient-name",
"initial gradient name",
"The name of the initial gradient choice",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-gradients-close-popup
*/
procedure = pika_procedure_new (gradients_close_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-gradients-close-popup");
pika_procedure_set_static_help (procedure,
"Close the gradient selection dialog.",
"Closes an open gradient selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("gradient-callback",
"gradient callback",
"The name of the callback registered for this pop-up",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-gradients-set-popup
*/
procedure = pika_procedure_new (gradients_set_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-gradients-set-popup");
pika_procedure_set_static_help (procedure,
"Sets the current gradient in a gradient selection dialog.",
"Sets the current gradient in a gradient selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("gradient-callback",
"gradient callback",
"The name of the callback registered for this pop-up",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("gradient-name",
"gradient name",
"The name of the gradient to set as selected",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

145
app/pdb/gradients-cmds.c Normal file
View File

@ -0,0 +1,145 @@
/* 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/pikacontainer-filter.h"
#include "core/pikacontext.h"
#include "core/pikadatafactory.h"
#include "core/pikagradient.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
gradients_refresh_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
pika_data_factory_data_refresh (pika->gradient_factory, context);
return pika_procedure_get_return_values (procedure, TRUE, NULL);
}
static PikaValueArray *
gradients_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 **gradient_list = NULL;
filter = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
gradient_list = pika_container_get_filtered_name_array (pika_data_factory_get_container (pika->gradient_factory),
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), gradient_list);
return return_vals;
}
void
register_gradients_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-gradients-refresh
*/
procedure = pika_procedure_new (gradients_refresh_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-gradients-refresh");
pika_procedure_set_static_help (procedure,
"Refresh current gradients. This function always succeeds.",
"This procedure retrieves all gradients currently in the user's gradient path and updates the gradient dialogs accordingly.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2002");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-gradients-get-list
*/
procedure = pika_procedure_new (gradients_get_list_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-gradients-get-list");
pika_procedure_set_static_help (procedure,
"Retrieve the list of loaded gradients.",
"This procedure returns a list of the gradients that are currently loaded. You can later use the 'pika-context-set-gradient' function to set the active gradient.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Federico Mena Quintero",
"Federico Mena Quintero",
"1997");
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 ("gradient-list",
"gradient list",
"The list of gradient names",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

114
app/pdb/help-cmds.c Normal file
View File

@ -0,0 +1,114 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikaparamspecs.h"
#include "plug-in/pikaplugin.h"
#include "plug-in/pikapluginmanager-help-domain.h"
#include "plug-in/pikapluginmanager.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
help_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *help_domain;
const gchar *help_id;
help_domain = g_value_get_string (pika_value_array_index (args, 0));
help_id = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
PikaPlugInManager *manager = pika->plug_in_manager;
if (! help_domain && manager->current_plug_in)
help_domain = (gchar *)
pika_plug_in_manager_get_help_domain (manager,
manager->current_plug_in->file,
NULL);
pika_help (pika, progress, help_domain, help_id);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_help_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-help
*/
procedure = pika_procedure_new (help_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-help");
pika_procedure_set_static_help (procedure,
"Load a help page.",
"This procedure loads the specified help page into the helpbrowser or what ever is configured as help viewer. The help page is identified by its domain and ID: if help_domain is NULL, we use the help_domain which was registered using the 'pika-plugin-help-register' procedure. If help_domain is NULL and no help domain was registered, the help domain of the main PIKA installation is used.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2000");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("help-domain",
"help domain",
"The help domain in which help_id is registered",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("help-id",
"help id",
"The help page's ID",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

5712
app/pdb/image-cmds.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,957 @@
/* 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 <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikacolor/pikacolor.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pikaimage-color-profile.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
image_get_color_profile_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
GBytes *profile_data = NULL;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaColorProfile *profile;
profile = pika_image_get_color_profile (image);
if (profile)
{
const guint8 *data;
gsize length;
data = pika_color_profile_get_icc_profile (profile, &length);
profile_data = g_bytes_new (data, length);
}
}
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), profile_data);
return return_vals;
}
static PikaValueArray *
image_get_effective_color_profile_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
GBytes *profile_data = NULL;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaColorProfile *profile;
profile = pika_color_managed_get_color_profile (PIKA_COLOR_MANAGED (image));
if (profile)
{
const guint8 *data;
gsize length;
data = pika_color_profile_get_icc_profile (profile, &length);
profile_data = g_bytes_new (data, length);
}
}
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), profile_data);
return return_vals;
}
static PikaValueArray *
image_set_color_profile_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
GBytes *color_profile;
image = g_value_get_object (pika_value_array_index (args, 0));
color_profile = g_value_get_boxed (pika_value_array_index (args, 1));
if (success)
{
if (color_profile)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
g_bytes_get_size (color_profile),
error);
if (profile)
{
success = pika_image_assign_color_profile (image, profile,
progress, error);
g_object_unref (profile);
}
else
success = FALSE;
}
else
{
success = pika_image_assign_color_profile (image, NULL,
progress, error);
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_set_color_profile_from_file_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
GFile *file;
image = g_value_get_object (pika_value_array_index (args, 0));
file = g_value_get_object (pika_value_array_index (args, 1));
if (success)
{
if (file)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_file (file, error);
if (profile)
{
success = pika_image_assign_color_profile (image, profile,
progress, error);
g_object_unref (profile);
}
else
success = FALSE;
}
else
{
success = pika_image_assign_color_profile (image, NULL,
progress, error);
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_get_simulation_profile_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
GBytes *profile_data = NULL;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaColorProfile *profile;
profile = pika_image_get_simulation_profile (image);
if (profile)
{
const guint8 *data;
gsize length;
data = pika_color_profile_get_icc_profile (profile, &length);
profile_data = g_bytes_new (data, length);
}
}
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), profile_data);
return return_vals;
}
static PikaValueArray *
image_set_simulation_profile_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
GBytes *color_profile;
image = g_value_get_object (pika_value_array_index (args, 0));
color_profile = g_value_get_boxed (pika_value_array_index (args, 1));
if (success)
{
if (color_profile)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
g_bytes_get_size (color_profile),
error);
if (profile)
{
pika_image_set_simulation_profile (image, profile);
g_object_unref (profile);
}
else
{
success = FALSE;
}
}
else
{
pika_image_set_simulation_profile (image, NULL);
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_set_simulation_profile_from_file_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
GFile *file;
image = g_value_get_object (pika_value_array_index (args, 0));
file = g_value_get_object (pika_value_array_index (args, 1));
if (success)
{
if (file)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_file (file, error);
if (profile)
{
pika_image_set_simulation_profile (image, profile);
g_object_unref (profile);
}
else
{
success = FALSE;
}
}
else
{
pika_image_set_simulation_profile (image, NULL);
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_get_simulation_intent_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gint intent = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
intent = pika_image_get_simulation_intent (image);
}
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), intent);
return return_vals;
}
static PikaValueArray *
image_set_simulation_intent_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint intent;
image = g_value_get_object (pika_value_array_index (args, 0));
intent = g_value_get_enum (pika_value_array_index (args, 1));
if (success)
{
pika_image_set_simulation_intent (image, intent);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_get_simulation_bpc_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gboolean bpc = FALSE;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
bpc = pika_image_get_simulation_bpc (image);
}
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), bpc);
return return_vals;
}
static PikaValueArray *
image_set_simulation_bpc_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gboolean bpc;
image = g_value_get_object (pika_value_array_index (args, 0));
bpc = g_value_get_boolean (pika_value_array_index (args, 1));
if (success)
{
pika_image_set_simulation_bpc (image, bpc);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_convert_color_profile_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
GBytes *color_profile;
gint intent;
gboolean bpc;
image = g_value_get_object (pika_value_array_index (args, 0));
color_profile = g_value_get_boxed (pika_value_array_index (args, 1));
intent = g_value_get_enum (pika_value_array_index (args, 2));
bpc = g_value_get_boolean (pika_value_array_index (args, 3));
if (success)
{
if (color_profile)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
g_bytes_get_size (color_profile),
error);
if (profile)
{
success = pika_image_convert_color_profile (image, profile,
intent, bpc,
progress, error);
g_object_unref (profile);
}
else
success = FALSE;
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_convert_color_profile_from_file_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
GFile *file;
gint intent;
gboolean bpc;
image = g_value_get_object (pika_value_array_index (args, 0));
file = g_value_get_object (pika_value_array_index (args, 1));
intent = g_value_get_enum (pika_value_array_index (args, 2));
bpc = g_value_get_boolean (pika_value_array_index (args, 3));
if (success)
{
if (file)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_file (file, error);
if (profile)
{
success = pika_image_convert_color_profile (image, profile,
intent, bpc,
progress, error);
g_object_unref (profile);
}
else
success = FALSE;
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_image_color_profile_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-image-get-color-profile
*/
procedure = pika_procedure_new (image_get_color_profile_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-get-color-profile");
pika_procedure_set_static_help (procedure,
"Returns the image's color profile",
"This procedure returns the image's color profile, or NULL if the image has no color profile assigned.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2015");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("profile-data",
"profile data",
"The image's serialized color profile.",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-get-effective-color-profile
*/
procedure = pika_procedure_new (image_get_effective_color_profile_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-get-effective-color-profile");
pika_procedure_set_static_help (procedure,
"Returns the color profile that is used for the image",
"This procedure returns the color profile that is actually used for this image, which is the profile returned by 'pika-image-get-color-profile' if the image has a profile assigned, or a generated default RGB or grayscale profile, according to the image's type.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2015");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("profile-data",
"profile data",
"The image's serialized color profile.",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-set-color-profile
*/
procedure = pika_procedure_new (image_set_color_profile_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-set-color-profile");
pika_procedure_set_static_help (procedure,
"Sets the image's color profile",
"This procedure sets the image's color profile, or unsets it if NULL is passed as 'color_profile'. This procedure does no color conversion. However, it will change the pixel format of all layers to contain the babl space matching the profile. You must call this procedure before adding layers to the image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2015");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boxed ("color-profile",
"color profile",
"The new serialized color profile",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-set-color-profile-from-file
*/
procedure = pika_procedure_new (image_set_color_profile_from_file_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-set-color-profile-from-file");
pika_procedure_set_static_help (procedure,
"Sets the image's color profile from an ICC file",
"This procedure sets the image's color profile from a file containing an ICC profile, or unsets it if NULL is passed as 'file'. This procedure does no color conversion. However, it will change the pixel format of all layers to contain the babl space matching the profile. You must call this procedure before adding layers to the image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2015");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file containing the new color profile",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-get-simulation-profile
*/
procedure = pika_procedure_new (image_get_simulation_profile_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-get-simulation-profile");
pika_procedure_set_static_help (procedure,
"Returns the image's simulation color profile",
"This procedure returns the image's simulation color profile, or NULL if the image has no simulation color profile assigned.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Alex S.",
"Alex S.",
"2022");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("profile-data",
"profile data",
"The image's serialized simulation color profile.",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-set-simulation-profile
*/
procedure = pika_procedure_new (image_set_simulation_profile_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-set-simulation-profile");
pika_procedure_set_static_help (procedure,
"Sets the image's simulation color profile",
"This procedure sets the image's simulation color profile, or unsets it if NULL is passed as 'color_profile'. This procedure does no color conversion.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Alex S.",
"Alex S.",
"2022");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boxed ("color-profile",
"color profile",
"The new serialized simulation color profile",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-set-simulation-profile-from-file
*/
procedure = pika_procedure_new (image_set_simulation_profile_from_file_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-set-simulation-profile-from-file");
pika_procedure_set_static_help (procedure,
"Sets the image's simulation color profile from an ICC file",
"This procedure sets the image's simulation color profile from a file containing an ICC profile, or unsets it if NULL is passed as 'file'. This procedure does no color conversion.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Alex S.",
"Alex S.",
"2022");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file containing the new simulation color profile",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-get-simulation-intent
*/
procedure = pika_procedure_new (image_get_simulation_intent_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-get-simulation-intent");
pika_procedure_set_static_help (procedure,
"Returns the image's simulation rendering intent",
"This procedure returns the image's simulation rendering intent.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Alex S.",
"Alex S.",
"2022");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_enum ("intent",
"intent",
"The image's simulation rendering intent.",
PIKA_TYPE_COLOR_RENDERING_INTENT,
PIKA_COLOR_RENDERING_INTENT_PERCEPTUAL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-set-simulation-intent
*/
procedure = pika_procedure_new (image_set_simulation_intent_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-set-simulation-intent");
pika_procedure_set_static_help (procedure,
"Sets the image's simulation rendering intent",
"This procedure sets the image's simulation rendering intent.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Alex S.",
"Alex S.",
"2022");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("intent",
"intent",
"A PikaColorRenderingIntent",
PIKA_TYPE_COLOR_RENDERING_INTENT,
PIKA_COLOR_RENDERING_INTENT_PERCEPTUAL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-get-simulation-bpc
*/
procedure = pika_procedure_new (image_get_simulation_bpc_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-get-simulation-bpc");
pika_procedure_set_static_help (procedure,
"Returns whether the image has Black Point Compensation enabled for its simulation",
"This procedure returns whether the image has Black Point Compensation enabled for its simulation",
NULL);
pika_procedure_set_static_attribution (procedure,
"Alex S.",
"Alex S.",
"2022");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("bpc",
"bpc",
"The Black Point Compensation status.",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-set-simulation-bpc
*/
procedure = pika_procedure_new (image_set_simulation_bpc_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-set-simulation-bpc");
pika_procedure_set_static_help (procedure,
"Sets whether the image has Black Point Compensation enabled for its simulation",
"This procedure whether the image has Black Point Compensation enabled for its simulation",
NULL);
pika_procedure_set_static_attribution (procedure,
"Alex S.",
"Alex S.",
"2022");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("bpc",
"bpc",
"The Black Point Compensation status.",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-convert-color-profile
*/
procedure = pika_procedure_new (image_convert_color_profile_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-convert-color-profile");
pika_procedure_set_static_help (procedure,
"Convert the image's layers to a color profile",
"This procedure converts from the image's color profile (or the default RGB or grayscale profile if none is set) to the given color profile. Only RGB and grayscale color profiles are accepted, according to the image's type.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2015");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boxed ("color-profile",
"color profile",
"The serialized color profile",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("intent",
"intent",
"Rendering intent",
PIKA_TYPE_COLOR_RENDERING_INTENT,
PIKA_COLOR_RENDERING_INTENT_PERCEPTUAL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("bpc",
"bpc",
"Black point compensation",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-convert-color-profile-from-file
*/
procedure = pika_procedure_new (image_convert_color_profile_from_file_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-convert-color-profile-from-file");
pika_procedure_set_static_help (procedure,
"Convert the image's layers to a color profile",
"This procedure converts from the image's color profile (or the default RGB or grayscale profile if none is set) to an ICC profile specified by 'file'. Only RGB and grayscale color profiles are accepted, according to the image's type.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2015");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_object ("file",
"file",
"The file containing the new color profile",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("intent",
"intent",
"Rendering intent",
PIKA_TYPE_COLOR_RENDERING_INTENT,
PIKA_COLOR_RENDERING_INTENT_PERCEPTUAL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("bpc",
"bpc",
"Black point compensation",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View File

@ -0,0 +1,446 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikaimage-convert-indexed.h"
#include "core/pikaimage-convert-precision.h"
#include "core/pikaimage-convert-type.h"
#include "core/pikaimage.h"
#include "core/pikaitemstack.h"
#include "core/pikapalette.h"
#include "core/pikaparamspecs.h"
#include "gegl/pika-babl.h"
#include "pikapdb.h"
#include "pikapdberror.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
image_convert_rgb_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
if (pika_pdb_image_is_not_base_type (image, PIKA_RGB, error) &&
pika_babl_is_valid (PIKA_RGB, pika_image_get_precision (image)))
{
success = pika_image_convert_type (image, PIKA_RGB, NULL, NULL, error);
}
else
{
success = FALSE;
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_convert_grayscale_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
if (pika_pdb_image_is_not_base_type (image, PIKA_GRAY, error) &&
pika_babl_is_valid (PIKA_GRAY, pika_image_get_precision (image)))
{
success = pika_image_convert_type (image, PIKA_GRAY, NULL, NULL, error);
}
else
{
success = FALSE;
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_convert_indexed_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint dither_type;
gint palette_type;
gint num_cols;
gboolean alpha_dither;
gboolean remove_unused;
const gchar *palette;
image = g_value_get_object (pika_value_array_index (args, 0));
dither_type = g_value_get_enum (pika_value_array_index (args, 1));
palette_type = g_value_get_enum (pika_value_array_index (args, 2));
num_cols = g_value_get_int (pika_value_array_index (args, 3));
alpha_dither = g_value_get_boolean (pika_value_array_index (args, 4));
remove_unused = g_value_get_boolean (pika_value_array_index (args, 5));
palette = g_value_get_string (pika_value_array_index (args, 6));
if (success)
{
PikaPalette *pal = NULL;
if (pika_pdb_image_is_not_base_type (image, PIKA_INDEXED, error) &&
pika_pdb_image_is_precision (image, PIKA_PRECISION_U8_NON_LINEAR, error) &&
pika_babl_is_valid (PIKA_INDEXED, pika_image_get_precision (image)) &&
pika_item_stack_is_flat (PIKA_ITEM_STACK (pika_image_get_layers (image))))
{
switch (palette_type)
{
case PIKA_CONVERT_PALETTE_GENERATE:
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE;
break;
case PIKA_CONVERT_PALETTE_CUSTOM:
pal = PIKA_PALETTE (pika_pdb_get_resource (pika, PIKA_TYPE_PALETTE, palette,
PIKA_PDB_DATA_ACCESS_READ, error));
if (! pal)
{
success = FALSE;
}
else if (pal->n_colors > MAXNUMCOLORS)
{
g_set_error_literal (error,
PIKA_PDB_ERROR,
PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Cannot convert to a palette "
"with more than 256 colors."));
success = FALSE;
}
break;
default:
break;
}
}
else
{
success = FALSE;
}
if (success)
success = pika_image_convert_indexed (image,
palette_type, num_cols, remove_unused,
dither_type, alpha_dither, FALSE,
pal,
NULL, error);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_convert_set_dither_matrix_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint width;
gint height;
GBytes *matrix;
width = g_value_get_int (pika_value_array_index (args, 0));
height = g_value_get_int (pika_value_array_index (args, 1));
matrix = g_value_get_boxed (pika_value_array_index (args, 2));
if (success)
{
if (width == 0 || height == 0 || g_bytes_get_size (matrix) == width * height)
{
pika_image_convert_indexed_set_dither_matrix (g_bytes_get_data (matrix, NULL),
width, height);
}
else
{
g_set_error_literal (error, PIKA_PDB_ERROR,
PIKA_PDB_ERROR_INVALID_ARGUMENT,
"Dither matrix length must be width * height");
success = FALSE;
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_convert_precision_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint precision;
image = g_value_get_object (pika_value_array_index (args, 0));
precision = g_value_get_enum (pika_value_array_index (args, 1));
if (success)
{
if (pika_pdb_image_is_not_base_type (image, PIKA_INDEXED, error) &&
pika_pdb_image_is_not_precision (image, precision, error) &&
pika_babl_is_valid (pika_image_get_base_type (image), precision))
{
pika_image_convert_precision (image, precision,
GEGL_DITHER_NONE,
GEGL_DITHER_NONE,
GEGL_DITHER_NONE,
progress);
}
else
{
success = FALSE;
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_image_convert_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-image-convert-rgb
*/
procedure = pika_procedure_new (image_convert_rgb_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-convert-rgb");
pika_procedure_set_static_help (procedure,
"Convert specified image to RGB color",
"This procedure converts the specified image to RGB color. This process requires an image in Grayscale or Indexed color mode. No image content is lost in this process aside from the colormap for an indexed image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-convert-grayscale
*/
procedure = pika_procedure_new (image_convert_grayscale_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-convert-grayscale");
pika_procedure_set_static_help (procedure,
"Convert specified image to grayscale",
"This procedure converts the specified image to grayscale. This process requires an image in RGB or Indexed color mode.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-convert-indexed
*/
procedure = pika_procedure_new (image_convert_indexed_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-convert-indexed");
pika_procedure_set_static_help (procedure,
"Convert specified image to and Indexed image",
"This procedure converts the specified image to 'indexed' color. This process requires an image in RGB or Grayscale mode. The 'palette_type' specifies what kind of palette to use, A type of '0' means to use an optimal palette of 'num_cols' generated from the colors in the image. A type of '1' means to re-use the previous palette (not currently implemented). A type of '2' means to use the so-called WWW-optimized palette. Type '3' means to use only black and white colors. A type of '4' means to use a palette from the pika palettes directories. The 'dither type' specifies what kind of dithering to use. '0' means no dithering, '1' means standard Floyd-Steinberg error diffusion, '2' means Floyd-Steinberg error diffusion with reduced bleeding, '3' means dithering based on pixel location ('Fixed' dithering).",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("dither-type",
"dither type",
"The dither type to use",
PIKA_TYPE_CONVERT_DITHER_TYPE,
PIKA_CONVERT_DITHER_NONE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("palette-type",
"palette type",
"The type of palette to use",
PIKA_TYPE_CONVERT_PALETTE_TYPE,
PIKA_CONVERT_PALETTE_GENERATE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("num-cols",
"num cols",
"The number of colors to quantize to, ignored unless (palette_type == PIKA_CONVERT_PALETTE_GENERATE)",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("alpha-dither",
"alpha dither",
"Dither transparency to fake partial opacity",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("remove-unused",
"remove unused",
"Remove unused or duplicate color entries from final palette, ignored if (palette_type == PIKA_CONVERT_PALETTE_GENERATE)",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("palette",
"palette",
"The name of the custom palette to use, ignored unless (palette_type == PIKA_CONVERT_PALETTE_CUSTOM)",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-convert-set-dither-matrix
*/
procedure = pika_procedure_new (image_convert_set_dither_matrix_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-convert-set-dither-matrix");
pika_procedure_set_static_help (procedure,
"Set dither matrix for conversion to indexed",
"This procedure sets the dither matrix used when converting images to INDEXED mode with positional dithering.",
NULL);
pika_procedure_set_static_attribution (procedure,
"David Gowers",
"David Gowers",
"2006");
pika_procedure_add_argument (procedure,
g_param_spec_int ("width",
"width",
"Width of the matrix (0 to reset to default matrix)",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("height",
"height",
"Height of the matrix (0 to reset to default matrix)",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boxed ("matrix",
"matrix",
"The matrix -- all values must be >= 1",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-convert-precision
*/
procedure = pika_procedure_new (image_convert_precision_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-convert-precision");
pika_procedure_set_static_help (procedure,
"Convert the image to the specified precision",
"This procedure converts the image to the specified precision. Note that indexed images cannot be converted and are always in PIKA_PRECISION_U8.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2012");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("precision",
"precision",
"The new precision",
PIKA_TYPE_PRECISION,
PIKA_PRECISION_U8_LINEAR,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

714
app/pdb/image-grid-cmds.c Normal file
View File

@ -0,0 +1,714 @@
/* 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 <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabaseenums.h"
#include "libpikacolor/pikacolor.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pikagrid.h"
#include "core/pikaimage-grid.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
image_grid_get_spacing_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gdouble xspacing = 0.0;
gdouble yspacing = 0.0;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
g_object_get (grid,
"xspacing", &xspacing,
"yspacing", &yspacing,
NULL);
else
success = FALSE;
}
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), xspacing);
g_value_set_double (pika_value_array_index (return_vals, 2), yspacing);
}
return return_vals;
}
static PikaValueArray *
image_grid_set_spacing_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gdouble xspacing;
gdouble yspacing;
image = g_value_get_object (pika_value_array_index (args, 0));
xspacing = g_value_get_double (pika_value_array_index (args, 1));
yspacing = g_value_get_double (pika_value_array_index (args, 2));
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
g_object_set (grid,
"xspacing", xspacing,
"yspacing", yspacing,
NULL);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_grid_get_offset_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gdouble xoffset = 0.0;
gdouble yoffset = 0.0;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
g_object_get (grid,
"xoffset", &xoffset,
"yoffset", &yoffset,
NULL);
else
success = FALSE;
}
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), xoffset);
g_value_set_double (pika_value_array_index (return_vals, 2), yoffset);
}
return return_vals;
}
static PikaValueArray *
image_grid_set_offset_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gdouble xoffset;
gdouble yoffset;
image = g_value_get_object (pika_value_array_index (args, 0));
xoffset = g_value_get_double (pika_value_array_index (args, 1));
yoffset = g_value_get_double (pika_value_array_index (args, 2));
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
g_object_set (grid,
"xoffset", xoffset,
"yoffset", yoffset,
NULL);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_grid_get_foreground_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
PikaRGB fgcolor = { 0.0, 0.0, 0.0, 1.0 };
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
fgcolor = grid->fgcolor;
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), &fgcolor);
return return_vals;
}
static PikaValueArray *
image_grid_set_foreground_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
PikaRGB fgcolor;
image = g_value_get_object (pika_value_array_index (args, 0));
pika_value_get_rgb (pika_value_array_index (args, 1), &fgcolor);
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
g_object_set (grid, "fgcolor", &fgcolor, NULL);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_grid_get_background_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
PikaRGB bgcolor = { 0.0, 0.0, 0.0, 1.0 };
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
bgcolor = grid->bgcolor;
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), &bgcolor);
return return_vals;
}
static PikaValueArray *
image_grid_set_background_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
PikaRGB bgcolor;
image = g_value_get_object (pika_value_array_index (args, 0));
pika_value_get_rgb (pika_value_array_index (args, 1), &bgcolor);
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
g_object_set (grid, "bgcolor", &bgcolor, NULL);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_grid_get_style_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gint style = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
g_object_get (grid, "style", &style, NULL);
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), style);
return return_vals;
}
static PikaValueArray *
image_grid_set_style_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint style;
image = g_value_get_object (pika_value_array_index (args, 0));
style = g_value_get_enum (pika_value_array_index (args, 1));
if (success)
{
PikaGrid *grid = pika_image_get_grid (image);
if (grid)
g_object_set (grid, "style", style, NULL);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_image_grid_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-image-grid-get-spacing
*/
procedure = pika_procedure_new (image_grid_get_spacing_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-get-spacing");
pika_procedure_set_static_help (procedure,
"Gets the spacing of an image's grid.",
"This procedure retrieves the horizontal and vertical spacing of an image's grid. It takes the image as parameter.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_double ("xspacing",
"xspacing",
"The image's grid horizontal spacing",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_double ("yspacing",
"yspacing",
"The image's grid vertical spacing",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-set-spacing
*/
procedure = pika_procedure_new (image_grid_set_spacing_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-set-spacing");
pika_procedure_set_static_help (procedure,
"Sets the spacing of an image's grid.",
"This procedure sets the horizontal and vertical spacing of an image's grid.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("xspacing",
"xspacing",
"The image's grid horizontal spacing",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("yspacing",
"yspacing",
"The image's grid vertical spacing",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-get-offset
*/
procedure = pika_procedure_new (image_grid_get_offset_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-get-offset");
pika_procedure_set_static_help (procedure,
"Gets the offset of an image's grid.",
"This procedure retrieves the horizontal and vertical offset of an image's grid. It takes the image as parameter.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_double ("xoffset",
"xoffset",
"The image's grid horizontal offset",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_double ("yoffset",
"yoffset",
"The image's grid vertical offset",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-set-offset
*/
procedure = pika_procedure_new (image_grid_set_offset_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-set-offset");
pika_procedure_set_static_help (procedure,
"Sets the offset of an image's grid.",
"This procedure sets the horizontal and vertical offset of an image's grid.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("xoffset",
"xoffset",
"The image's grid horizontal offset",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("yoffset",
"yoffset",
"The image's grid vertical offset",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-get-foreground-color
*/
procedure = pika_procedure_new (image_grid_get_foreground_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-get-foreground-color");
pika_procedure_set_static_help (procedure,
"Sets the foreground color of an image's grid.",
"This procedure gets the foreground color of an image's grid.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_rgb ("fgcolor",
"fgcolor",
"The image's grid foreground color",
TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-set-foreground-color
*/
procedure = pika_procedure_new (image_grid_set_foreground_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-set-foreground-color");
pika_procedure_set_static_help (procedure,
"Gets the foreground color of an image's grid.",
"This procedure sets the foreground color of an image's grid.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_rgb ("fgcolor",
"fgcolor",
"The new foreground color",
TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-get-background-color
*/
procedure = pika_procedure_new (image_grid_get_background_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-get-background-color");
pika_procedure_set_static_help (procedure,
"Sets the background color of an image's grid.",
"This procedure gets the background color of an image's grid.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_rgb ("bgcolor",
"bgcolor",
"The image's grid background color",
TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-set-background-color
*/
procedure = pika_procedure_new (image_grid_set_background_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-set-background-color");
pika_procedure_set_static_help (procedure,
"Gets the background color of an image's grid.",
"This procedure sets the background color of an image's grid.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_rgb ("bgcolor",
"bgcolor",
"The new background color",
TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-get-style
*/
procedure = pika_procedure_new (image_grid_get_style_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-get-style");
pika_procedure_set_static_help (procedure,
"Gets the style of an image's grid.",
"This procedure retrieves the style of an image's grid.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_enum ("style",
"style",
"The image's grid style",
PIKA_TYPE_GRID_STYLE,
PIKA_GRID_DOTS,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-grid-set-style
*/
procedure = pika_procedure_new (image_grid_set_style_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-grid-set-style");
pika_procedure_set_static_help (procedure,
"Sets the style unit of an image's grid.",
"This procedure sets the style of an image's grid. It takes the image and the new style as parameters.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sylvain Foret",
"Sylvain Foret",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("style",
"style",
"The image's grid style",
PIKA_TYPE_GRID_STYLE,
PIKA_GRID_DOTS,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

483
app/pdb/image-guides-cmds.c Normal file
View File

@ -0,0 +1,483 @@
/* 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 "pdb-types.h"
#include "cairo.h"
#include "core/pikaguide.h"
#include "core/pikaimage-guides.h"
#include "core/pikaimage-undo-push.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikapdberror.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
image_add_hguide_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gint yposition;
guint guide = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
yposition = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
if (yposition <= pika_image_get_height (image))
{
PikaGuide *g;
g = pika_image_add_hguide (image, yposition, TRUE);
guide = pika_aux_item_get_id (PIKA_AUX_ITEM (g));
}
else
success = FALSE;
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_uint (pika_value_array_index (return_vals, 1), guide);
return return_vals;
}
static PikaValueArray *
image_add_vguide_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gint xposition;
guint guide = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
xposition = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
if (xposition <= pika_image_get_width (image))
{
PikaGuide *g;
g = pika_image_add_vguide (image, xposition, TRUE);
guide = pika_aux_item_get_id (PIKA_AUX_ITEM (g));
}
else
success = FALSE;
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_uint (pika_value_array_index (return_vals, 1), guide);
return return_vals;
}
static PikaValueArray *
image_delete_guide_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
guint guide;
image = g_value_get_object (pika_value_array_index (args, 0));
guide = g_value_get_uint (pika_value_array_index (args, 1));
if (success)
{
PikaGuide *g = pika_pdb_image_get_guide (image, guide, error);
if (g)
pika_image_remove_guide (image, g, TRUE);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_find_next_guide_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
guint guide;
guint next_guide = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
guide = g_value_get_uint (pika_value_array_index (args, 1));
if (success)
{
PikaGuide *g = pika_image_get_next_guide (image, guide, &success);
if (g)
next_guide = pika_aux_item_get_id (PIKA_AUX_ITEM (g));
if (! success)
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) does not contain guide with ID %d"),
pika_image_get_display_name (image),
pika_image_get_id (image),
guide);
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_uint (pika_value_array_index (return_vals, 1), next_guide);
return return_vals;
}
static PikaValueArray *
image_get_guide_orientation_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
guint guide;
gint orientation = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
guide = g_value_get_uint (pika_value_array_index (args, 1));
if (success)
{
PikaGuide *g = pika_pdb_image_get_guide (image, guide, error);
if (g)
orientation = pika_guide_get_orientation (g);
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), orientation);
return return_vals;
}
static PikaValueArray *
image_get_guide_position_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
guint guide;
gint position = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
guide = g_value_get_uint (pika_value_array_index (args, 1));
if (success)
{
PikaGuide *g = pika_pdb_image_get_guide (image, guide, error);
if (g)
position = pika_guide_get_position (g);
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), position);
return return_vals;
}
void
register_image_guides_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-image-add-hguide
*/
procedure = pika_procedure_new (image_add_hguide_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-add-hguide");
pika_procedure_set_static_help (procedure,
"Add a horizontal guide to an image.",
"This procedure adds a horizontal guide to an image. It takes the input image and the y-position of the new guide as parameters. It returns the guide ID of the new guide.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss",
"Adam D. Moss",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("yposition",
"yposition",
"The guide's y-offset from top of image",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_uint ("guide",
"guide",
"The new guide",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-add-vguide
*/
procedure = pika_procedure_new (image_add_vguide_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-add-vguide");
pika_procedure_set_static_help (procedure,
"Add a vertical guide to an image.",
"This procedure adds a vertical guide to an image. It takes the input image and the x-position of the new guide as parameters. It returns the guide ID of the new guide.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss",
"Adam D. Moss",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("xposition",
"xposition",
"The guide's x-offset from left of image",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_uint ("guide",
"guide",
"The new guide",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-delete-guide
*/
procedure = pika_procedure_new (image_delete_guide_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-delete-guide");
pika_procedure_set_static_help (procedure,
"Deletes a guide from an image.",
"This procedure takes an image and a guide ID as input and removes the specified guide from the specified image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss",
"Adam D. Moss",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_uint ("guide",
"guide",
"The ID of the guide to be removed",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-find-next-guide
*/
procedure = pika_procedure_new (image_find_next_guide_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-find-next-guide");
pika_procedure_set_static_help (procedure,
"Find next guide on an image.",
"This procedure takes an image and a guide ID as input and finds the guide ID of the successor of the given guide ID in the image's guide list. If the supplied guide ID is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide ID as an argument or the image has no guides.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss",
"Adam D. Moss",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_uint ("guide",
"guide",
"The ID of the current guide (0 if first invocation)",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
pika_procedure_add_return_value (procedure,
g_param_spec_uint ("next-guide",
"next guide",
"The next guide's ID",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-get-guide-orientation
*/
procedure = pika_procedure_new (image_get_guide_orientation_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-get-guide-orientation");
pika_procedure_set_static_help (procedure,
"Get orientation of a guide on an image.",
"This procedure takes an image and a guide ID as input and returns the orientations of the guide.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss",
"Adam D. Moss",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_uint ("guide",
"guide",
"The guide",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_enum ("orientation",
"orientation",
"The guide's orientation",
PIKA_TYPE_ORIENTATION_TYPE,
PIKA_ORIENTATION_HORIZONTAL,
PIKA_PARAM_READWRITE));
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->values[0]),
PIKA_ORIENTATION_UNKNOWN);
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-get-guide-position
*/
procedure = pika_procedure_new (image_get_guide_position_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-get-guide-position");
pika_procedure_set_static_help (procedure,
"Get position of a guide on an image.",
"This procedure takes an image and a guide ID as input and returns the position of the guide relative to the top or left of the image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss",
"Adam D. Moss",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_uint ("guide",
"guide",
"The guide",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("position",
"position",
"The guide's position relative to top or left of image",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View File

@ -0,0 +1,356 @@
/* 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 "pdb-types.h"
#include "core/pikaimage-sample-points.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "core/pikasamplepoint.h"
#include "pikapdb.h"
#include "pikapdberror.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
image_add_sample_point_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gint position_x;
gint position_y;
guint sample_point = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
position_x = g_value_get_int (pika_value_array_index (args, 1));
position_y = g_value_get_int (pika_value_array_index (args, 2));
if (success)
{
if (position_x <= pika_image_get_width (image) &&
position_y <= pika_image_get_height (image))
{
PikaSamplePoint *sp;
sp = pika_image_add_sample_point_at_pos (image, position_x, position_y,
TRUE);
sample_point = pika_aux_item_get_id (PIKA_AUX_ITEM (sp));
}
else
success = FALSE;
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_uint (pika_value_array_index (return_vals, 1), sample_point);
return return_vals;
}
static PikaValueArray *
image_delete_sample_point_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
guint sample_point;
image = g_value_get_object (pika_value_array_index (args, 0));
sample_point = g_value_get_uint (pika_value_array_index (args, 1));
if (success)
{
PikaSamplePoint *sp = pika_pdb_image_get_sample_point (image, sample_point,
error);
if (sp)
pika_image_remove_sample_point (image, sp, TRUE);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_find_next_sample_point_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
guint sample_point;
guint next_sample_point = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
sample_point = g_value_get_uint (pika_value_array_index (args, 1));
if (success)
{
PikaSamplePoint *sp = pika_image_get_next_sample_point (image, sample_point,
&success);
if (sp)
next_sample_point = pika_aux_item_get_id (PIKA_AUX_ITEM (sp));
if (! success)
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) does not contain sample point with ID %d"),
pika_image_get_display_name (image),
pika_image_get_id (image),
sample_point);
}
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_uint (pika_value_array_index (return_vals, 1), next_sample_point);
return return_vals;
}
static PikaValueArray *
image_get_sample_point_position_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
guint sample_point;
gint position_x = 0;
gint position_y = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
sample_point = g_value_get_uint (pika_value_array_index (args, 1));
if (success)
{
PikaSamplePoint *sp = pika_pdb_image_get_sample_point (image, sample_point,
error);
if (sp)
pika_sample_point_get_position (sp, &position_x, &position_y);
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), position_x);
g_value_set_int (pika_value_array_index (return_vals, 2), position_y);
}
return return_vals;
}
void
register_image_sample_points_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-image-add-sample-point
*/
procedure = pika_procedure_new (image_add_sample_point_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-add-sample-point");
pika_procedure_set_static_help (procedure,
"Add a sample point to an image.",
"This procedure adds a sample point to an image. It takes the input image and the position of the new sample points as parameters. It returns the sample point ID of the new sample point.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2016");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("position-x",
"position x",
"The sample point's x-offset from left of image",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("position-y",
"position y",
"The sample point's y-offset from top of image",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_uint ("sample-point",
"sample point",
"The new sample point",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-delete-sample-point
*/
procedure = pika_procedure_new (image_delete_sample_point_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-delete-sample-point");
pika_procedure_set_static_help (procedure,
"Deletes a sample point from an image.",
"This procedure takes an image and a sample point ID as input and removes the specified sample point from the specified image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2016");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_uint ("sample-point",
"sample point",
"The ID of the sample point to be removed",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-find-next-sample-point
*/
procedure = pika_procedure_new (image_find_next_sample_point_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-find-next-sample-point");
pika_procedure_set_static_help (procedure,
"Find next sample point on an image.",
"This procedure takes an image and a sample point ID as input and finds the sample point ID of the successor of the given sample point ID in the image's sample point list. If the supplied sample point ID is 0, the procedure will return the first sample point. The procedure will return 0 if given the final sample point ID as an argument or the image has no sample points.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2016");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_uint ("sample-point",
"sample point",
"The ID of the current sample point (0 if first invocation)",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
pika_procedure_add_return_value (procedure,
g_param_spec_uint ("next-sample-point",
"next sample point",
"The next sample point's ID",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-get-sample-point-position
*/
procedure = pika_procedure_new (image_get_sample_point_position_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-get-sample-point-position");
pika_procedure_set_static_help (procedure,
"Get position of a sample point on an image.",
"This procedure takes an image and a sample point ID as input and returns the position of the sample point relative to the top and left of the image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2016");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_uint ("sample-point",
"sample point",
"The guide",
1, G_MAXUINT32, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("position-x",
"position x",
"The sample point's x-offset relative to left of image",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("position-y",
"position y",
"The sample point's y-offset relative to top of image",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

726
app/pdb/image-select-cmds.c Normal file
View File

@ -0,0 +1,726 @@
/* 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 <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.h"
#include "libpikacolor/pikacolor.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pikachannel-select.h"
#include "core/pikadrawable.h"
#include "core/pikaimage.h"
#include "core/pikaitem.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikapdbcontext.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
image_select_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint operation;
PikaDrawable *drawable;
PikaRGB color;
image = g_value_get_object (pika_value_array_index (args, 0));
operation = g_value_get_enum (pika_value_array_index (args, 1));
drawable = g_value_get_object (pika_value_array_index (args, 2));
pika_value_get_rgb (pika_value_array_index (args, 3), &color);
if (success)
{
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
if (pdb_context->sample_merged ||
pika_pdb_item_is_attached (PIKA_ITEM (drawable), image, 0, error))
{
GList *drawables = g_list_prepend (NULL, drawable);
pika_channel_select_by_color (pika_image_get_mask (image), drawables,
pdb_context->sample_merged,
&color,
pdb_context->sample_threshold,
pdb_context->sample_transparent,
pdb_context->sample_criterion,
operation,
pdb_context->antialias,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y);
g_list_free (drawables);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_select_contiguous_color_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint operation;
PikaDrawable *drawable;
gdouble x;
gdouble y;
image = g_value_get_object (pika_value_array_index (args, 0));
operation = g_value_get_enum (pika_value_array_index (args, 1));
drawable = g_value_get_object (pika_value_array_index (args, 2));
x = g_value_get_double (pika_value_array_index (args, 3));
y = g_value_get_double (pika_value_array_index (args, 4));
if (success)
{
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
if (pdb_context->sample_merged ||
pika_pdb_item_is_attached (PIKA_ITEM (drawable), image, 0, error))
{
pika_channel_select_fuzzy (pika_image_get_mask (image),
drawable,
pdb_context->sample_merged,
x, y,
pdb_context->sample_threshold,
pdb_context->sample_transparent,
pdb_context->sample_criterion,
pdb_context->diagonal_neighbors,
operation,
pdb_context->antialias,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_select_rectangle_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint operation;
gdouble x;
gdouble y;
gdouble width;
gdouble height;
image = g_value_get_object (pika_value_array_index (args, 0));
operation = g_value_get_enum (pika_value_array_index (args, 1));
x = g_value_get_double (pika_value_array_index (args, 2));
y = g_value_get_double (pika_value_array_index (args, 3));
width = g_value_get_double (pika_value_array_index (args, 4));
height = g_value_get_double (pika_value_array_index (args, 5));
if (success)
{
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
pika_channel_select_rectangle (pika_image_get_mask (image),
(gint) x, (gint) y,
(gint) width, (gint) height,
operation,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y,
TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_select_round_rectangle_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint operation;
gdouble x;
gdouble y;
gdouble width;
gdouble height;
gdouble corner_radius_x;
gdouble corner_radius_y;
image = g_value_get_object (pika_value_array_index (args, 0));
operation = g_value_get_enum (pika_value_array_index (args, 1));
x = g_value_get_double (pika_value_array_index (args, 2));
y = g_value_get_double (pika_value_array_index (args, 3));
width = g_value_get_double (pika_value_array_index (args, 4));
height = g_value_get_double (pika_value_array_index (args, 5));
corner_radius_x = g_value_get_double (pika_value_array_index (args, 6));
corner_radius_y = g_value_get_double (pika_value_array_index (args, 7));
if (success)
{
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
pika_channel_select_round_rect (pika_image_get_mask (image),
(gint) x, (gint) y,
(gint) width, (gint) height,
corner_radius_x,
corner_radius_y,
operation,
pdb_context->antialias,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y,
TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_select_ellipse_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint operation;
gdouble x;
gdouble y;
gdouble width;
gdouble height;
image = g_value_get_object (pika_value_array_index (args, 0));
operation = g_value_get_enum (pika_value_array_index (args, 1));
x = g_value_get_double (pika_value_array_index (args, 2));
y = g_value_get_double (pika_value_array_index (args, 3));
width = g_value_get_double (pika_value_array_index (args, 4));
height = g_value_get_double (pika_value_array_index (args, 5));
if (success)
{
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
pika_channel_select_ellipse (pika_image_get_mask (image),
(gint) x, (gint) y,
(gint) width, (gint) height,
operation,
pdb_context->antialias,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y,
TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_select_polygon_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint operation;
gint num_segs;
const gdouble *segs;
image = g_value_get_object (pika_value_array_index (args, 0));
operation = g_value_get_enum (pika_value_array_index (args, 1));
num_segs = g_value_get_int (pika_value_array_index (args, 2));
segs = pika_value_get_float_array (pika_value_array_index (args, 3));
if (success)
{
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
pika_channel_select_polygon (pika_image_get_mask (image),
_("Free Select"),
num_segs / 2,
(PikaVector2 *) segs,
operation,
pdb_context->antialias,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y,
TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_select_item_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint operation;
PikaItem *item;
image = g_value_get_object (pika_value_array_index (args, 0));
operation = g_value_get_enum (pika_value_array_index (args, 1));
item = g_value_get_object (pika_value_array_index (args, 2));
if (success)
{
if (pika_pdb_item_is_attached (item, image, 0, error))
{
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
pika_item_to_selection (item, operation,
pdb_context->antialias,
pdb_context->feather,
pdb_context->feather_radius_x,
pdb_context->feather_radius_y);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_image_select_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-image-select-color
*/
procedure = pika_procedure_new (image_select_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-select-color");
pika_procedure_set_static_help (procedure,
"Create a selection by selecting all pixels (in the specified drawable) with the same (or similar) color to that specified.",
"This tool creates a selection over the specified image. A by-color selection is determined by the supplied color under the constraints of the current context settings. Essentially, all pixels (in the drawable) that have color sufficiently close to the specified color (as determined by the threshold and criterion context values) are included in the selection. To select transparent regions, the color specified must also have minimum alpha.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-antialias', 'pika-context-set-feather', 'pika-context-set-feather-radius', 'pika-context-set-sample-merged', 'pika-context-set-sample-criterion', 'pika-context-set-sample-threshold', 'pika-context-set-sample-transparent'.\n"
"\n"
"In the case of a merged sampling, the supplied drawable is ignored.",
NULL);
pika_procedure_set_static_attribution (procedure,
"David Gowers",
"David Gowers",
"2010");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The affected image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The selection operation",
PIKA_TYPE_CHANNEL_OPS,
PIKA_CHANNEL_OP_ADD,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The affected drawable",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_rgb ("color",
"color",
"The color to select",
FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-select-contiguous-color
*/
procedure = pika_procedure_new (image_select_contiguous_color_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-select-contiguous-color");
pika_procedure_set_static_help (procedure,
"Create a selection by selecting all pixels around specified coordinates with the same (or similar) color to that at the coordinates.",
"This tool creates a contiguous selection over the specified image. A contiguous color selection is determined by a seed fill under the constraints of the current context settings. Essentially, the color at the specified coordinates (in the drawable) is measured and the selection expands outwards from that point to any adjacent pixels which are not significantly different (as determined by the threshold and criterion context settings). This process continues until no more expansion is possible. If antialiasing is turned on, the final selection mask will contain intermediate values based on close misses to the threshold bar at pixels along the seed fill boundary.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-antialias', 'pika-context-set-feather', 'pika-context-set-feather-radius', 'pika-context-set-sample-merged', 'pika-context-set-sample-criterion', 'pika-context-set-sample-threshold', 'pika-context-set-sample-transparent', 'pika-context-set-diagonal-neighbors'.\n"
"\n"
"In the case of a merged sampling, the supplied drawable is ignored. If the sample is merged, the specified coordinates are relative to the image origin; otherwise, they are relative to the drawable's origin.",
NULL);
pika_procedure_set_static_attribution (procedure,
"David Gowers",
"David Gowers",
"2010");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The affected image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The selection operation",
PIKA_TYPE_CHANNEL_OPS,
PIKA_CHANNEL_OP_ADD,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The affected drawable",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("x",
"x",
"x coordinate of initial seed fill point: (image coordinates)",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("y",
"y",
"y coordinate of initial seed fill point: (image coordinates)",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-select-rectangle
*/
procedure = pika_procedure_new (image_select_rectangle_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-select-rectangle");
pika_procedure_set_static_help (procedure,
"Create a rectangular selection over the specified image;",
"This tool creates a rectangular selection over the specified image. The rectangular region can be either added to, subtracted from, or replace the contents of the previous selection mask.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-feather', 'pika-context-set-feather-radius'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The selection operation",
PIKA_TYPE_CHANNEL_OPS,
PIKA_CHANNEL_OP_ADD,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("x",
"x",
"x coordinate of upper-left corner of rectangle",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("y",
"y",
"y coordinate of upper-left corner of rectangle",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("width",
"width",
"The width of the rectangle",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("height",
"height",
"The height of the rectangle",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-select-round-rectangle
*/
procedure = pika_procedure_new (image_select_round_rectangle_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-select-round-rectangle");
pika_procedure_set_static_help (procedure,
"Create a rectangular selection with round corners over the specified image;",
"This tool creates a rectangular selection with round corners over the specified image. The rectangular region can be either added to, subtracted from, or replace the contents of the previous selection mask.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-antialias', 'pika-context-set-feather', 'pika-context-set-feather-radius'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Martin Nordholts",
"Martin Nordholts",
"2010");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The selection operation",
PIKA_TYPE_CHANNEL_OPS,
PIKA_CHANNEL_OP_ADD,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("x",
"x",
"x coordinate of upper-left corner of rectangle",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("y",
"y",
"y coordinate of upper-left corner of rectangle",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("width",
"width",
"The width of the rectangle",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("height",
"height",
"The height of the rectangle",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("corner-radius-x",
"corner radius x",
"The corner radius in X direction",
0, PIKA_MAX_IMAGE_SIZE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("corner-radius-y",
"corner radius y",
"The corner radius in Y direction",
0, PIKA_MAX_IMAGE_SIZE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-select-ellipse
*/
procedure = pika_procedure_new (image_select_ellipse_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-select-ellipse");
pika_procedure_set_static_help (procedure,
"Create an elliptical selection over the specified image.",
"This tool creates an elliptical selection over the specified image. The elliptical region can be either added to, subtracted from, or replace the contents of the previous selection mask.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-antialias', 'pika-context-set-feather', 'pika-context-set-feather-radius'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The selection operation",
PIKA_TYPE_CHANNEL_OPS,
PIKA_CHANNEL_OP_ADD,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("x",
"x",
"x coordinate of upper-left corner of ellipse bounding box",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("y",
"y",
"y coordinate of upper-left corner of ellipse bounding box",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("width",
"width",
"The width of the ellipse",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("height",
"height",
"The height of the ellipse",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-select-polygon
*/
procedure = pika_procedure_new (image_select_polygon_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-select-polygon");
pika_procedure_set_static_help (procedure,
"Create a polygonal selection over the specified image.",
"This tool creates a polygonal selection over the specified image. The polygonal region can be either added to, subtracted from, or replace the contents of the previous selection mask. The polygon is specified through an array of floating point numbers and its length. The length of array must be 2n, where n is the number of points. Each point is defined by 2 floating point values which correspond to the x and y coordinates. If the final point does not connect to the starting point, a connecting segment is automatically added.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-antialias', 'pika-context-set-feather', 'pika-context-set-feather-radius'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The selection operation",
PIKA_TYPE_CHANNEL_OPS,
PIKA_CHANNEL_OP_ADD,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("num-segs",
"num segs",
"Number of points (count 1 coordinate as two points)",
2, G_MAXINT32, 2,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_float_array ("segs",
"segs",
"Array of points: { p1.x, p1.y, p2.x, p2.y, ..., pn.x, pn.y}",
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-select-item
*/
procedure = pika_procedure_new (image_select_item_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-select-item");
pika_procedure_set_static_help (procedure,
"Transforms the specified item into a selection",
"This procedure renders the item's outline into the current selection of the image the item belongs to. What exactly the item's outline is depends on the item type: for layers, it's the layer's alpha channel, for vectors the vector's shape.\n"
"\n"
"This procedure is affected by the following context setters: 'pika-context-set-antialias', 'pika-context-set-feather', 'pika-context-set-feather-radius'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("operation",
"operation",
"The desired operation with current selection",
PIKA_TYPE_CHANNEL_OPS,
PIKA_CHANNEL_OP_ADD,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_item ("item",
"item",
"The item to render to the selection",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View File

@ -0,0 +1,452 @@
/* 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 "pdb-types.h"
#include "core/pikaimage-crop.h"
#include "core/pikaimage-flip.h"
#include "core/pikaimage-resize.h"
#include "core/pikaimage-rotate.h"
#include "core/pikaimage-scale.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "core/pikaprogress.h"
#include "pikapdb.h"
#include "pikapdbcontext.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
image_resize_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint new_width;
gint new_height;
gint offx;
gint offy;
image = g_value_get_object (pika_value_array_index (args, 0));
new_width = g_value_get_int (pika_value_array_index (args, 1));
new_height = g_value_get_int (pika_value_array_index (args, 2));
offx = g_value_get_int (pika_value_array_index (args, 3));
offy = g_value_get_int (pika_value_array_index (args, 4));
if (success)
{
pika_image_resize (image, context,
new_width, new_height, offx, offy, NULL);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_resize_to_layers_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_image_resize_to_layers (image, context, NULL, NULL, NULL, NULL, NULL);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_scale_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint new_width;
gint new_height;
image = g_value_get_object (pika_value_array_index (args, 0));
new_width = g_value_get_int (pika_value_array_index (args, 1));
new_height = g_value_get_int (pika_value_array_index (args, 2));
if (success)
{
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
if (progress)
pika_progress_start (progress, FALSE, _("Scaling"));
pika_image_scale (image, new_width, new_height,
pdb_context->interpolation,
progress);
if (progress)
pika_progress_end (progress);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_crop_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint new_width;
gint new_height;
gint offx;
gint offy;
image = g_value_get_object (pika_value_array_index (args, 0));
new_width = g_value_get_int (pika_value_array_index (args, 1));
new_height = g_value_get_int (pika_value_array_index (args, 2));
offx = g_value_get_int (pika_value_array_index (args, 3));
offy = g_value_get_int (pika_value_array_index (args, 4));
if (success)
{
if (new_width > pika_image_get_width (image) ||
new_height > pika_image_get_height (image) ||
offx > (pika_image_get_width (image) - new_width) ||
offy > (pika_image_get_height (image) - new_height))
success = FALSE;
else
pika_image_crop (image, context, PIKA_FILL_TRANSPARENT,
offx, offy, new_width, new_height,
TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_flip_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint flip_type;
image = g_value_get_object (pika_value_array_index (args, 0));
flip_type = g_value_get_enum (pika_value_array_index (args, 1));
if (success)
{
pika_image_flip (image, context, flip_type, NULL);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_rotate_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint rotate_type;
image = g_value_get_object (pika_value_array_index (args, 0));
rotate_type = g_value_get_enum (pika_value_array_index (args, 1));
if (success)
{
if (progress)
pika_progress_start (progress, FALSE, _("Rotating"));
pika_image_rotate (image, context, rotate_type, progress);
if (progress)
pika_progress_end (progress);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_image_transform_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-image-resize
*/
procedure = pika_procedure_new (image_resize_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-resize");
pika_procedure_set_static_help (procedure,
"Resize the image to the specified extents.",
"This procedure resizes the image so that it's new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous image's content. All channels within the image are resized according to the specified parameters; this includes the image selection mask. All layers within the image are repositioned according to the specified offsets.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("new-width",
"new width",
"New image width",
1, PIKA_MAX_IMAGE_SIZE, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("new-height",
"new height",
"New image height",
1, PIKA_MAX_IMAGE_SIZE, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offx",
"offx",
"x offset between upper left corner of old and new images: (new - old)",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offy",
"offy",
"y offset between upper left corner of old and new images: (new - old)",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-resize-to-layers
*/
procedure = pika_procedure_new (image_resize_to_layers_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-resize-to-layers");
pika_procedure_set_static_help (procedure,
"Resize the image to fit all layers.",
"This procedure resizes the image to the bounding box of all layers of the image. All channels within the image are resized to the new size; this includes the image selection mask. All layers within the image are repositioned to the new image area.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Simon Budig",
"Simon Budig",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-scale
*/
procedure = pika_procedure_new (image_scale_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-scale");
pika_procedure_set_static_help (procedure,
"Scale the image using the default interpolation method.",
"This procedure scales the image so that its new width and height are equal to the supplied parameters. All layers and channels within the image are scaled according to the specified parameters; this includes the image selection mask. The interpolation method used can be set with 'pika-context-set-interpolation'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("new-width",
"new width",
"New image width",
1, PIKA_MAX_IMAGE_SIZE, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("new-height",
"new height",
"New image height",
1, PIKA_MAX_IMAGE_SIZE, 1,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-crop
*/
procedure = pika_procedure_new (image_crop_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-crop");
pika_procedure_set_static_help (procedure,
"Crop the image to the specified extents.",
"This procedure crops the image so that it's new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous image's content. All channels and layers within the image are cropped to the new image extents; this includes the image selection mask. If any parameters are out of range, an error is returned.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("new-width",
"new width",
"New image width: (0 < new_width <= width)",
1, PIKA_MAX_IMAGE_SIZE, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("new-height",
"new height",
"New image height: (0 < new_height <= height)",
1, PIKA_MAX_IMAGE_SIZE, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offx",
"offx",
"X offset: (0 <= offx <= (width - new_width))",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offy",
"offy",
"Y offset: (0 <= offy <= (height - new_height))",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-flip
*/
procedure = pika_procedure_new (image_flip_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-flip");
pika_procedure_set_static_help (procedure,
"Flips the image horizontally or vertically.",
"This procedure flips (mirrors) the image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_enum ("flip-type",
"flip type",
"Type of flip",
PIKA_TYPE_ORIENTATION_TYPE,
PIKA_ORIENTATION_HORIZONTAL,
PIKA_PARAM_READWRITE));
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->args[1]),
PIKA_ORIENTATION_UNKNOWN);
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-rotate
*/
procedure = pika_procedure_new (image_rotate_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-rotate");
pika_procedure_set_static_help (procedure,
"Rotates the image by the specified degrees.",
"This procedure rotates the image.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2003");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("rotate-type",
"rotate type",
"Angle of rotation",
PIKA_TYPE_ROTATION_TYPE,
PIKA_ROTATE_90,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

483
app/pdb/image-undo-cmds.c Normal file
View File

@ -0,0 +1,483 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikaimage-undo.h"
#include "core/pikaimage.h"
#include "core/pikaparamspecs.h"
#include "plug-in/pikaplugin-cleanup.h"
#include "plug-in/pikaplugin.h"
#include "plug-in/pikapluginmanager.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
image_undo_group_start_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
const gchar *undo_desc = NULL;
if (plug_in)
{
success = pika_plug_in_cleanup_undo_group_start (plug_in, image);
if (success)
undo_desc = pika_plug_in_get_undo_desc (plug_in);
}
if (success)
pika_image_undo_group_start (image, PIKA_UNDO_GROUP_MISC, undo_desc);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_undo_group_end_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in)
success = pika_plug_in_cleanup_undo_group_end (plug_in, image);
if (success)
pika_image_undo_group_end (image);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
image_undo_is_enabled_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gboolean enabled = FALSE;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
enabled = pika_image_undo_is_enabled (image);
}
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), enabled);
return return_vals;
}
static PikaValueArray *
image_undo_disable_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gboolean disabled = FALSE;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
#if 0
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in)
success = pika_plug_in_cleanup_undo_disable (plug_in, image);
#endif
if (success)
disabled = pika_image_undo_disable (image);
}
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), disabled);
return return_vals;
}
static PikaValueArray *
image_undo_enable_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gboolean enabled = FALSE;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
#if 0
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in)
success = pika_plug_in_cleanup_undo_enable (plug_in, image);
#endif
if (success)
enabled = pika_image_undo_enable (image);
}
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), enabled);
return return_vals;
}
static PikaValueArray *
image_undo_freeze_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gboolean frozen = FALSE;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
#if 0
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in)
success = pika_plug_in_cleanup_undo_freeze (plug_in, image);
#endif
if (success)
frozen = pika_image_undo_freeze (image);
}
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), frozen);
return return_vals;
}
static PikaValueArray *
image_undo_thaw_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gboolean thawed = FALSE;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
#if 0
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in)
success = pika_plug_in_cleanup_undo_thaw (plug_in, image);
#endif
if (success)
thawed = pika_image_undo_thaw (image);
}
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), thawed);
return return_vals;
}
void
register_image_undo_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-image-undo-group-start
*/
procedure = pika_procedure_new (image_undo_group_start_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-undo-group-start");
pika_procedure_set_static_help (procedure,
"Starts a group undo.",
"This function is used to start a group undo--necessary for logically combining two or more undo operations into a single operation. This call must be used in conjunction with a 'pika-image-undo-group-end' call.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The ID of the image in which to open an undo group",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-undo-group-end
*/
procedure = pika_procedure_new (image_undo_group_end_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-undo-group-end");
pika_procedure_set_static_help (procedure,
"Finish a group undo.",
"This function must be called once for each 'pika-image-undo-group-start' call that is made.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The ID of the image in which to close an undo group",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-undo-is-enabled
*/
procedure = pika_procedure_new (image_undo_is_enabled_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-undo-is-enabled");
pika_procedure_set_static_help (procedure,
"Check if the image's undo stack is enabled.",
"This procedure checks if the image's undo stack is currently enabled or disabled. This is useful when several plug-ins or scripts call each other and want to check if their caller has already used 'pika-image-undo-disable' or 'pika-image-undo-freeze'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Rapha\xc3\xabl Quinet <raphael@gimp.org>",
"Rapha\xc3\xabl Quinet",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("enabled",
"enabled",
"TRUE if undo is enabled for this image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-undo-disable
*/
procedure = pika_procedure_new (image_undo_disable_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-undo-disable");
pika_procedure_set_static_help (procedure,
"Disable the image's undo stack.",
"This procedure disables the image's undo stack, allowing subsequent operations to ignore their undo steps. This is generally called in conjunction with 'pika-image-undo-enable' to temporarily disable an image undo stack. This is advantageous because saving undo steps can be time and memory intensive.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("disabled",
"disabled",
"TRUE if the image undo has been disabled",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-undo-enable
*/
procedure = pika_procedure_new (image_undo_enable_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-undo-enable");
pika_procedure_set_static_help (procedure,
"Enable the image's undo stack.",
"This procedure enables the image's undo stack, allowing subsequent operations to store their undo steps. This is generally called in conjunction with 'pika-image-undo-disable' to temporarily disable an image undo stack.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("enabled",
"enabled",
"TRUE if the image undo has been enabled",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-undo-freeze
*/
procedure = pika_procedure_new (image_undo_freeze_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-undo-freeze");
pika_procedure_set_static_help (procedure,
"Freeze the image's undo stack.",
"This procedure freezes the image's undo stack, allowing subsequent operations to ignore their undo steps. This is generally called in conjunction with 'pika-image-undo-thaw' to temporarily disable an image undo stack. This is advantageous because saving undo steps can be time and memory intensive. 'pika-image-undo-freeze' / 'pika-image-undo-thaw' and 'pika-image-undo-disable' / 'pika-image-undo-enable' differ in that the former does not free up all undo steps when undo is thawed, so is more suited to interactive in-situ previews. It is important in this case that the image is back to the same state it was frozen in before thawing, else 'undo' behavior is undefined.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss",
"Adam D. Moss",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("frozen",
"frozen",
"TRUE if the image undo has been frozen",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-image-undo-thaw
*/
procedure = pika_procedure_new (image_undo_thaw_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-image-undo-thaw");
pika_procedure_set_static_help (procedure,
"Thaw the image's undo stack.",
"This procedure thaws the image's undo stack, allowing subsequent operations to store their undo steps. This is generally called in conjunction with 'pika-image-undo-freeze' to temporarily freeze an image undo stack. 'pika-image-undo-thaw' does NOT free the undo stack as 'pika-image-undo-enable' does, so is suited for situations where one wishes to leave the undo stack in the same state in which one found it despite non-destructively playing with the image in the meantime. An example would be in-situ plug-in previews. Balancing freezes and thaws and ensuring image consistency is the responsibility of the caller.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adam D. Moss",
"Adam D. Moss",
"1999");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("thawed",
"thawed",
"TRUE if the image undo has been thawed",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

98
app/pdb/internal-procs.c Normal file
View File

@ -0,0 +1,98 @@
/* 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 <glib-object.h>
#include "pdb-types.h"
#include "pikapdb.h"
#include "internal-procs.h"
/* 775 procedures registered total */
void
internal_procs_init (PikaPDB *pdb)
{
g_return_if_fail (PIKA_IS_PDB (pdb));
register_brush_procs (pdb);
register_brush_select_procs (pdb);
register_brushes_procs (pdb);
register_buffer_procs (pdb);
register_channel_procs (pdb);
register_context_procs (pdb);
register_debug_procs (pdb);
register_display_procs (pdb);
register_drawable_procs (pdb);
register_drawable_color_procs (pdb);
register_drawable_edit_procs (pdb);
register_dynamics_procs (pdb);
register_edit_procs (pdb);
register_file_procs (pdb);
register_floating_sel_procs (pdb);
register_font_procs (pdb);
register_font_select_procs (pdb);
register_fonts_procs (pdb);
register_pika_procs (pdb);
register_pikarc_procs (pdb);
register_gradient_procs (pdb);
register_gradient_select_procs (pdb);
register_gradients_procs (pdb);
register_help_procs (pdb);
register_image_procs (pdb);
register_image_color_profile_procs (pdb);
register_image_convert_procs (pdb);
register_image_grid_procs (pdb);
register_image_guides_procs (pdb);
register_image_sample_points_procs (pdb);
register_image_select_procs (pdb);
register_image_transform_procs (pdb);
register_image_undo_procs (pdb);
register_item_procs (pdb);
register_item_transform_procs (pdb);
register_layer_procs (pdb);
register_message_procs (pdb);
register_paint_tools_procs (pdb);
register_palette_procs (pdb);
register_palette_select_procs (pdb);
register_palettes_procs (pdb);
register_pattern_procs (pdb);
register_pattern_select_procs (pdb);
register_patterns_procs (pdb);
register_pdb_procs (pdb);
register_plug_in_procs (pdb);
register_plug_in_compat_procs (pdb);
register_progress_procs (pdb);
register_resource_procs (pdb);
register_selection_procs (pdb);
register_text_layer_procs (pdb);
register_text_tool_procs (pdb);
register_unit_procs (pdb);
register_vectors_procs (pdb);
}

86
app/pdb/internal-procs.h Normal file
View File

@ -0,0 +1,86 @@
/* 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. */
#ifndef __INTERNAL_PROCS_H__
#define __INTERNAL_PROCS_H__
void internal_procs_init (PikaPDB *pdb);
/* Forward declarations for registering PDB procs */
void register_brush_procs (PikaPDB *pdb);
void register_brush_select_procs (PikaPDB *pdb);
void register_brushes_procs (PikaPDB *pdb);
void register_buffer_procs (PikaPDB *pdb);
void register_channel_procs (PikaPDB *pdb);
void register_context_procs (PikaPDB *pdb);
void register_debug_procs (PikaPDB *pdb);
void register_display_procs (PikaPDB *pdb);
void register_drawable_procs (PikaPDB *pdb);
void register_drawable_color_procs (PikaPDB *pdb);
void register_drawable_edit_procs (PikaPDB *pdb);
void register_dynamics_procs (PikaPDB *pdb);
void register_edit_procs (PikaPDB *pdb);
void register_file_procs (PikaPDB *pdb);
void register_floating_sel_procs (PikaPDB *pdb);
void register_font_procs (PikaPDB *pdb);
void register_font_select_procs (PikaPDB *pdb);
void register_fonts_procs (PikaPDB *pdb);
void register_pika_procs (PikaPDB *pdb);
void register_pikarc_procs (PikaPDB *pdb);
void register_gradient_procs (PikaPDB *pdb);
void register_gradient_select_procs (PikaPDB *pdb);
void register_gradients_procs (PikaPDB *pdb);
void register_help_procs (PikaPDB *pdb);
void register_image_procs (PikaPDB *pdb);
void register_image_color_profile_procs (PikaPDB *pdb);
void register_image_convert_procs (PikaPDB *pdb);
void register_image_grid_procs (PikaPDB *pdb);
void register_image_guides_procs (PikaPDB *pdb);
void register_image_sample_points_procs (PikaPDB *pdb);
void register_image_select_procs (PikaPDB *pdb);
void register_image_transform_procs (PikaPDB *pdb);
void register_image_undo_procs (PikaPDB *pdb);
void register_item_procs (PikaPDB *pdb);
void register_item_transform_procs (PikaPDB *pdb);
void register_layer_procs (PikaPDB *pdb);
void register_message_procs (PikaPDB *pdb);
void register_paint_tools_procs (PikaPDB *pdb);
void register_palette_procs (PikaPDB *pdb);
void register_palette_select_procs (PikaPDB *pdb);
void register_palettes_procs (PikaPDB *pdb);
void register_pattern_procs (PikaPDB *pdb);
void register_pattern_select_procs (PikaPDB *pdb);
void register_patterns_procs (PikaPDB *pdb);
void register_pdb_procs (PikaPDB *pdb);
void register_plug_in_procs (PikaPDB *pdb);
void register_plug_in_compat_procs (PikaPDB *pdb);
void register_progress_procs (PikaPDB *pdb);
void register_resource_procs (PikaPDB *pdb);
void register_selection_procs (PikaPDB *pdb);
void register_text_layer_procs (PikaPDB *pdb);
void register_text_tool_procs (PikaPDB *pdb);
void register_unit_procs (PikaPDB *pdb);
void register_vectors_procs (PikaPDB *pdb);
#endif /* __INTERNAL_PROCS_H__ */

2002
app/pdb/item-cmds.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2380
app/pdb/layer-cmds.c Normal file

File diff suppressed because it is too large Load Diff

88
app/pdb/meson.build Normal file
View File

@ -0,0 +1,88 @@
libapppdb_sources = [
'pika-pdb-compat.c',
'pikapdb-query.c',
'pikapdb-utils.c',
'pikapdb.c',
'pikapdbcontext.c',
'pikapdberror.c',
'pikaprocedure.c',
]
libappinternalprocs_sources = [
'brush-cmds.c',
'brush-select-cmds.c',
'brushes-cmds.c',
'buffer-cmds.c',
'channel-cmds.c',
'context-cmds.c',
'debug-cmds.c',
'display-cmds.c',
'drawable-cmds.c',
'drawable-color-cmds.c',
'drawable-edit-cmds.c',
'dynamics-cmds.c',
'edit-cmds.c',
'file-cmds.c',
'floating-sel-cmds.c',
'font-cmds.c',
'font-select-cmds.c',
'fonts-cmds.c',
'pika-cmds.c',
'pikarc-cmds.c',
'gradient-cmds.c',
'gradient-select-cmds.c',
'gradients-cmds.c',
'help-cmds.c',
'image-cmds.c',
'image-color-profile-cmds.c',
'image-convert-cmds.c',
'image-grid-cmds.c',
'image-guides-cmds.c',
'image-sample-points-cmds.c',
'image-select-cmds.c',
'image-transform-cmds.c',
'image-undo-cmds.c',
'internal-procs.c',
'item-cmds.c',
'item-transform-cmds.c',
'layer-cmds.c',
'message-cmds.c',
'paint-tools-cmds.c',
'palette-cmds.c',
'palette-select-cmds.c',
'palettes-cmds.c',
'pattern-cmds.c',
'pattern-select-cmds.c',
'patterns-cmds.c',
'pdb-cmds.c',
'plug-in-cmds.c',
'plug-in-compat-cmds.c',
'progress-cmds.c',
'resource-cmds.c',
'selection-cmds.c',
'text-layer-cmds.c',
'text-tool-cmds.c',
'unit-cmds.c',
'vectors-cmds.c',
]
libapppdb = static_library('apppdb',
libapppdb_sources,
include_directories: [ rootInclude, rootAppInclude, ],
c_args: '-DG_LOG_DOMAIN="Pika-PDB"',
dependencies: [
cairo, gegl, gdk_pixbuf,
],
)
libappinternalprocs = static_library('appinternalprocs',
libappinternalprocs_sources,
include_directories: [ rootInclude, rootAppInclude, ],
c_args: '-DG_LOG_DOMAIN="Pika-PDB"',
dependencies: [
cairo, gegl, gdk_pixbuf, pangocairo,
],
sources: [
pdbgen
],
)

194
app/pdb/message-cmds.c Normal file
View File

@ -0,0 +1,194 @@
/* 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/pikaparamspecs.h"
#include "plug-in/pikaplugin.h"
#include "plug-in/pikapluginmanager.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
message_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *message;
message = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
const gchar *domain = NULL;
if (pika->plug_in_manager->current_plug_in)
domain = pika_plug_in_get_undo_desc (pika->plug_in_manager->current_plug_in);
pika_show_message (pika, G_OBJECT (progress), PIKA_MESSAGE_WARNING,
domain, message);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
message_get_handler_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gint handler = 0;
handler = pika->message_handler;
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_enum (pika_value_array_index (return_vals, 1), handler);
return return_vals;
}
static PikaValueArray *
message_set_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)
{
pika->message_handler = handler;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_message_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-message
*/
procedure = pika_procedure_new (message_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-message");
pika_procedure_set_static_help (procedure,
"Displays a dialog box with a message.",
"Displays a dialog box with a message. Useful for status or error reporting. The message must be in UTF-8 encoding.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Manish Singh",
"Manish Singh",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("message",
"message",
"Message to display in the dialog",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-message-get-handler
*/
procedure = pika_procedure_new (message_get_handler_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-message-get-handler");
pika_procedure_set_static_help (procedure,
"Returns the current state of where warning messages are displayed.",
"This procedure returns the way g_message warnings are displayed. They can be shown in a dialog box or printed on the console where pika was started.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Manish Singh",
"Manish Singh",
"1998");
pika_procedure_add_return_value (procedure,
g_param_spec_enum ("handler",
"handler",
"The current handler type",
PIKA_TYPE_MESSAGE_HANDLER_TYPE,
PIKA_MESSAGE_BOX,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-message-set-handler
*/
procedure = pika_procedure_new (message_set_handler_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-message-set-handler");
pika_procedure_set_static_help (procedure,
"Controls where warning messages are displayed.",
"This procedure controls how g_message warnings are displayed. They can be shown in a dialog box or printed on the console where pika was started.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Manish Singh",
"Manish Singh",
"1998");
pika_procedure_add_argument (procedure,
g_param_spec_enum ("handler",
"handler",
"The new handler type",
PIKA_TYPE_MESSAGE_HANDLER_TYPE,
PIKA_MESSAGE_BOX,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

1662
app/pdb/paint-tools-cmds.c Normal file

File diff suppressed because it is too large Load Diff

854
app/pdb/palette-cmds.c Normal file
View File

@ -0,0 +1,854 @@
/* 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 <cairo.h>
#include <string.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#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 <mitch@gimp.org>",
"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 <mitch@gimp.org>",
"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 <mitch@gimp.org>",
"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@gimp.org>",
"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@gimp.org>",
"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@gimp.org>",
"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 <mitch@gimp.org>",
"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 <mitch@gimp.org>",
"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 <mitch@gimp.org>",
"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 <mitch@gimp.org>",
"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 <mitch@gimp.org>",
"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 <mitch@gimp.org>",
"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);
}

View File

@ -0,0 +1,229 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
palettes_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *palette_callback;
const gchar *popup_title;
const gchar *initial_palette_name;
palette_callback = g_value_get_string (pika_value_array_index (args, 0));
popup_title = g_value_get_string (pika_value_array_index (args, 1));
initial_palette_name = g_value_get_string (pika_value_array_index (args, 2));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, palette_callback) ||
! pika_pdb_dialog_new (pika, context, progress,
pika_data_factory_get_container (pika->palette_factory),
popup_title, palette_callback, initial_palette_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
palettes_close_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *palette_callback;
palette_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, palette_callback) ||
! pika_pdb_dialog_close (pika, pika_data_factory_get_container (pika->palette_factory),
palette_callback))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
palettes_set_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *palette_callback;
const gchar *palette_name;
palette_callback = g_value_get_string (pika_value_array_index (args, 0));
palette_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, palette_callback) ||
! pika_pdb_dialog_set (pika, pika_data_factory_get_container (pika->palette_factory),
palette_callback, palette_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_palette_select_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-palettes-popup
*/
procedure = pika_procedure_new (palettes_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palettes-popup");
pika_procedure_set_static_help (procedure,
"Invokes the Pika palette selection dialog.",
"Opens a dialog letting a user choose a palette.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2002");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("palette-callback",
"palette callback",
"The callback PDB proc to call when user chooses a palette",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("popup-title",
"popup title",
"Title of the palette selection dialog",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("initial-palette-name",
"initial palette name",
"The name of the palette to set as the initial choice.",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palettes-close-popup
*/
procedure = pika_procedure_new (palettes_close_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palettes-close-popup");
pika_procedure_set_static_help (procedure,
"Close the palette selection dialog.",
"Closes an open palette selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2002");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("palette-callback",
"palette callback",
"The name of the callback registered for this pop-up",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palettes-set-popup
*/
procedure = pika_procedure_new (palettes_set_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palettes-set-popup");
pika_procedure_set_static_help (procedure,
"Sets the current palette in a palette selection dialog.",
"Sets the current palette in a palette selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2002");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("palette-callback",
"palette callback",
"The name of the callback registered for this pop-up",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("palette-name",
"palette name",
"The name of the palette to set as selected",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

145
app/pdb/palettes-cmds.c Normal file
View File

@ -0,0 +1,145 @@
/* 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/pikacontainer-filter.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 *
palettes_refresh_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
pika_data_factory_data_refresh (pika->palette_factory, context);
return pika_procedure_get_return_values (procedure, TRUE, NULL);
}
static PikaValueArray *
palettes_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 **palette_list = NULL;
filter = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
palette_list = pika_container_get_filtered_name_array (pika_data_factory_get_container (pika->palette_factory),
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), palette_list);
return return_vals;
}
void
register_palettes_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-palettes-refresh
*/
procedure = pika_procedure_new (palettes_refresh_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palettes-refresh");
pika_procedure_set_static_help (procedure,
"Refreshes current palettes. This function always succeeds.",
"This procedure retrieves all palettes currently in the user's palette path and updates the palette dialogs accordingly.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Adrian Likins <adrian@gimp.org>",
"Adrian Likins",
"1998");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-palettes-get-list
*/
procedure = pika_procedure_new (palettes_get_list_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-palettes-get-list");
pika_procedure_set_static_help (procedure,
"Retrieves a list of all of the available palettes",
"This procedure returns a complete listing of available palettes. Each name returned can be used as input to the command 'pika-context-set-palette'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Nathan Summers <rock@gimp.org>",
"Nathan Summers",
"2001");
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 ("palette-list",
"palette list",
"The list of palette names",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

297
app/pdb/pattern-cmds.c Normal file
View File

@ -0,0 +1,297 @@
/* 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/pikacontext.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "core/pikapattern.h"
#include "core/pikatempbuf.h"
#include "gegl/pika-babl-compat.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
pattern_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;
PikaPattern *pattern = NULL;
name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
pattern = PIKA_PATTERN (pika_pdb_get_resource (pika, PIKA_TYPE_PATTERN, name, PIKA_PDB_DATA_ACCESS_READ, error));
if (! pattern)
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), pattern);
return return_vals;
}
static PikaValueArray *
pattern_get_info_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaPattern *pattern;
gint width = 0;
gint height = 0;
gint bpp = 0;
pattern = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
const Babl *format;
format = pika_babl_compat_u8_format (
pika_temp_buf_get_format (pattern->mask));
width = pika_temp_buf_get_width (pattern->mask);
height = pika_temp_buf_get_height (pattern->mask);
bpp = babl_format_get_bytes_per_pixel (format);
}
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);
g_value_set_int (pika_value_array_index (return_vals, 2), height);
g_value_set_int (pika_value_array_index (return_vals, 3), bpp);
}
return return_vals;
}
static PikaValueArray *
pattern_get_pixels_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaPattern *pattern;
gint width = 0;
gint height = 0;
gint bpp = 0;
GBytes *color_bytes = NULL;
pattern = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
const Babl *format;
gpointer data;
format = pika_babl_compat_u8_format (
pika_temp_buf_get_format (pattern->mask));
data = pika_temp_buf_lock (pattern->mask, format, GEGL_ACCESS_READ);
width = pika_temp_buf_get_width (pattern->mask);
height = pika_temp_buf_get_height (pattern->mask);
bpp = babl_format_get_bytes_per_pixel (format);
color_bytes = g_bytes_new (data, pika_temp_buf_get_data_size (pattern->mask));
pika_temp_buf_unlock (pattern->mask, data);
}
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);
g_value_set_int (pika_value_array_index (return_vals, 2), height);
g_value_set_int (pika_value_array_index (return_vals, 3), bpp);
g_value_take_boxed (pika_value_array_index (return_vals, 4), color_bytes);
}
return return_vals;
}
void
register_pattern_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-pattern-get-by-name
*/
procedure = pika_procedure_new (pattern_get_by_name_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-pattern-get-by-name");
pika_procedure_set_static_help (procedure,
"Returns the pattern with the given name.",
"Returns the pattern with the given name.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("name",
"name",
"The name of the pattern",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_pattern ("pattern",
"pattern",
"The pattern",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-pattern-get-info
*/
procedure = pika_procedure_new (pattern_get_info_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-pattern-get-info");
pika_procedure_set_static_help (procedure,
"Gets information about the pattern.",
"Gets information about the pattern: the pattern extents (width and height) and bytes per pixel.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_pattern ("pattern",
"pattern",
"The pattern",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("width",
"width",
"The pattern width",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("height",
"height",
"The pattern height",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("bpp",
"bpp",
"The pattern bpp",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-pattern-get-pixels
*/
procedure = pika_procedure_new (pattern_get_pixels_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-pattern-get-pixels");
pika_procedure_set_static_help (procedure,
"Gets information about the pattern (including pixels).",
"Gets information about the pattern: the pattern extents (width and height), its bpp, and its pixel data. The pixel data is an array in C or a list in some languages.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_pattern ("pattern",
"pattern",
"The pattern",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("width",
"width",
"The pattern width",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("height",
"height",
"The pattern height",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("bpp",
"bpp",
"The pattern bpp",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("color-bytes",
"color bytes",
"The pattern data.",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View File

@ -0,0 +1,229 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
patterns_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *pattern_callback;
const gchar *popup_title;
const gchar *initial_pattern_name;
pattern_callback = g_value_get_string (pika_value_array_index (args, 0));
popup_title = g_value_get_string (pika_value_array_index (args, 1));
initial_pattern_name = g_value_get_string (pika_value_array_index (args, 2));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, pattern_callback) ||
! pika_pdb_dialog_new (pika, context, progress,
pika_data_factory_get_container (pika->pattern_factory),
popup_title, pattern_callback, initial_pattern_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
patterns_close_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *pattern_callback;
pattern_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, pattern_callback) ||
! pika_pdb_dialog_close (pika, pika_data_factory_get_container (pika->pattern_factory),
pattern_callback))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
patterns_set_popup_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *pattern_callback;
const gchar *pattern_name;
pattern_callback = g_value_get_string (pika_value_array_index (args, 0));
pattern_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
if (pika->no_interface ||
! pika_pdb_lookup_procedure (pika->pdb, pattern_callback) ||
! pika_pdb_dialog_set (pika, pika_data_factory_get_container (pika->pattern_factory),
pattern_callback, pattern_name,
NULL))
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_pattern_select_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-patterns-popup
*/
procedure = pika_procedure_new (patterns_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-patterns-popup");
pika_procedure_set_static_help (procedure,
"Invokes the Pika pattern selection.",
"Opens the pattern selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("pattern-callback",
"pattern callback",
"The callback PDB proc to call when the user chooses a pattern",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("popup-title",
"popup title",
"Title of the pattern selection dialog",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("initial-pattern-name",
"initial pattern name",
"The name of the pattern to set as the initial choice",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-patterns-close-popup
*/
procedure = pika_procedure_new (patterns_close_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-patterns-close-popup");
pika_procedure_set_static_help (procedure,
"Close the pattern selection dialog.",
"Closes an open pattern selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("pattern-callback",
"pattern callback",
"The name of the callback registered for this pop-up",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-patterns-set-popup
*/
procedure = pika_procedure_new (patterns_set_popup_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-patterns-set-popup");
pika_procedure_set_static_help (procedure,
"Sets the current pattern in a pattern selection dialog.",
"Sets the current pattern in a pattern selection dialog.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("pattern-callback",
"pattern callback",
"The name of the callback registered for this pop-up",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("pattern-name",
"pattern name",
"The name of the pattern to set as selected",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

146
app/pdb/patterns-cmds.c Normal file
View File

@ -0,0 +1,146 @@
/* 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/pikacontainer-filter.h"
#include "core/pikacontext.h"
#include "core/pikadatafactory.h"
#include "core/pikaparamspecs.h"
#include "core/pikapattern.h"
#include "core/pikatempbuf.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
patterns_refresh_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
pika_data_factory_data_refresh (pika->pattern_factory, context);
return pika_procedure_get_return_values (procedure, TRUE, NULL);
}
static PikaValueArray *
patterns_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 **pattern_list = NULL;
filter = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
pattern_list = pika_container_get_filtered_name_array (pika_data_factory_get_container (pika->pattern_factory),
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), pattern_list);
return return_vals;
}
void
register_patterns_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-patterns-refresh
*/
procedure = pika_procedure_new (patterns_refresh_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-patterns-refresh");
pika_procedure_set_static_help (procedure,
"Refresh current patterns. This function always succeeds.",
"This procedure retrieves all patterns currently in the user's pattern path and updates all pattern dialogs accordingly.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2002");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-patterns-get-list
*/
procedure = pika_procedure_new (patterns_get_list_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-patterns-get-list");
pika_procedure_set_static_help (procedure,
"Retrieve a complete listing of the available patterns.",
"This procedure returns a complete listing of available PIKA patterns. Each name returned can be used as input to the 'pika-context-set-pattern'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
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 ("pattern-list",
"pattern list",
"The list of pattern names",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

2292
app/pdb/pdb-cmds.c Normal file

File diff suppressed because it is too large Load Diff

58
app/pdb/pdb-types.h Normal file
View File

@ -0,0 +1,58 @@
/* 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 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/>.
*/
#ifndef __PDB_TYPES_H__
#define __PDB_TYPES_H__
#include "core/core-types.h"
typedef struct _PikaPDB PikaPDB;
typedef struct _PikaProcedure PikaProcedure;
typedef struct _PikaPlugInProcedure PikaPlugInProcedure;
typedef struct _PikaTemporaryProcedure PikaTemporaryProcedure;
typedef enum
{
PIKA_PDB_COMPAT_OFF,
PIKA_PDB_COMPAT_ON,
PIKA_PDB_COMPAT_WARN
} PikaPDBCompatMode;
typedef enum
{
PIKA_PDB_ITEM_CONTENT = 1 << 0,
PIKA_PDB_ITEM_POSITION = 1 << 1
} PikaPDBItemModify;
typedef enum
{
PIKA_PDB_DATA_ACCESS_READ = 0,
PIKA_PDB_DATA_ACCESS_WRITE = 1 << 0,
PIKA_PDB_DATA_ACCESS_RENAME = 1 << 1
} PikaPDBDataAccess;
#endif /* __PDB_TYPES_H__ */

437
app/pdb/pika-cmds.c Normal file
View File

@ -0,0 +1,437 @@
/* 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/pika-parasites.h"
#include "core/pika-utils.h"
#include "core/pika.h"
#include "core/pikaparamspecs.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
version_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gchar *version = NULL;
version = g_strdup (PIKA_VERSION);
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_take_string (pika_value_array_index (return_vals, 1), version);
return return_vals;
}
static PikaValueArray *
getpid_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gint pid = 0;
pid = pika_get_pid ();
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (pika_value_array_index (return_vals, 1), pid);
return return_vals;
}
static PikaValueArray *
quit_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
gboolean force;
force = g_value_get_boolean (pika_value_array_index (args, 0));
if (success)
{
pika_exit (pika, force);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
attach_parasite_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const PikaParasite *parasite;
parasite = g_value_get_boxed (pika_value_array_index (args, 0));
if (success)
{
if (pika_parasite_validate (pika, parasite, error))
pika_parasite_attach (pika, parasite);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
detach_parasite_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *name;
name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
pika_parasite_detach (pika, name);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
get_parasite_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *name;
PikaParasite *parasite = NULL;
name = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
parasite = pika_parasite_copy (pika_parasite_find (pika, name));
if (! parasite)
success = FALSE;
}
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), parasite);
return return_vals;
}
static PikaValueArray *
get_parasite_list_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
PikaValueArray *return_vals;
gchar **parasites = NULL;
parasites = pika_parasite_list (pika);
return_vals = pika_procedure_get_return_values (procedure, TRUE, NULL);
g_value_take_boxed (pika_value_array_index (return_vals, 1), parasites);
return return_vals;
}
static PikaValueArray *
temp_file_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *extension;
GFile *file = NULL;
extension = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
file = pika_get_temp_file (pika, extension);
}
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), file);
return return_vals;
}
void
register_pika_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-version
*/
procedure = pika_procedure_new (version_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-version");
pika_procedure_set_static_help (procedure,
"Returns the host PIKA version.",
"This procedure returns the version number of the currently running PIKA.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Manish Singh",
"Manish Singh",
"1999");
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("version",
"version",
"PIKA version number",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-getpid
*/
procedure = pika_procedure_new (getpid_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-getpid");
pika_procedure_set_static_help (procedure,
"Returns the PID of the host PIKA process.",
"This procedure returns the process ID of the currently running PIKA.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2005");
pika_procedure_add_return_value (procedure,
g_param_spec_int ("pid",
"pid",
"The PID",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-quit
*/
procedure = pika_procedure_new (quit_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-quit");
pika_procedure_set_static_help (procedure,
"Causes PIKA to exit gracefully.",
"If there are unsaved images in an interactive PIKA session, the user will be asked for confirmation. If force is TRUE, the application is quit without querying the user to save any dirty images.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("force",
"force",
"Force PIKA to quit without asking",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-attach-parasite
*/
procedure = pika_procedure_new (attach_parasite_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-attach-parasite");
pika_procedure_set_static_help (procedure,
"Add a global parasite.",
"This procedure attaches a global parasite. It has no return values.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Jay Cox",
"Jay Cox",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_parasite ("parasite",
"parasite",
"The parasite to attach",
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-detach-parasite
*/
procedure = pika_procedure_new (detach_parasite_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-detach-parasite");
pika_procedure_set_static_help (procedure,
"Removes a global parasite.",
"This procedure detaches a global parasite from. It has no return values.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Jay Cox",
"Jay Cox",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("name",
"name",
"The name of the parasite to detach.",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-get-parasite
*/
procedure = pika_procedure_new (get_parasite_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-get-parasite");
pika_procedure_set_static_help (procedure,
"Look up a global parasite.",
"Finds and returns the global parasite that was previously attached.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Jay Cox",
"Jay Cox",
"1998");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("name",
"name",
"The name of the parasite to find",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_parasite ("parasite",
"parasite",
"The found parasite",
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-get-parasite-list
*/
procedure = pika_procedure_new (get_parasite_list_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-get-parasite-list");
pika_procedure_set_static_help (procedure,
"List all parasites.",
"Returns a list of all currently attached global parasites.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Marc Lehmann",
"Marc Lehmann",
"1999");
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("parasites",
"parasites",
"The names of currently attached parasites",
G_TYPE_STRV,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-temp-file
*/
procedure = pika_procedure_new (temp_file_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-temp-file");
pika_procedure_set_static_help (procedure,
"Generates a unique temporary file.",
"Generates a unique file using the temp path supplied in the user's pikarc.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Josh MacDonald",
"Josh MacDonald",
"1997");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("extension",
"extension",
"The extension the file will have",
TRUE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_object ("file",
"file",
"The new temp file",
G_TYPE_FILE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

175
app/pdb/pika-pdb-compat.c Normal file
View File

@ -0,0 +1,175 @@
/* 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 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/>.
*/
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "pdb-types.h"
#include "pikapdb.h"
#include "pika-pdb-compat.h"
/* public functions */
void
pika_pdb_compat_procs_register (PikaPDB *pdb,
PikaPDBCompatMode compat_mode)
{
static const struct
{
const gchar *old_name;
const gchar *new_name;
}
compat_procs[] =
{
{ "pika-blend", "pika-edit-blend" },
{ "pika-brushes-list", "pika-brushes-get-list" },
{ "pika-bucket-fill", "pika-edit-bucket-fill" },
{ "pika-channel-delete", "pika-item-delete" },
{ "pika-channel-get-name", "pika-item-get-name" },
{ "pika-channel-get-tattoo", "pika-item-get-tattoo" },
{ "pika-channel-get-visible", "pika-item-get-visible" },
{ "pika-channel-set-name", "pika-item-set-name" },
{ "pika-channel-set-tattoo", "pika-item-set-tattoo" },
{ "pika-channel-set-visible", "pika-item-set-visible" },
{ "pika-color-picker", "pika-image-pick-color" },
{ "pika-convert-grayscale", "pika-image-convert-grayscale" },
{ "pika-convert-indexed", "pika-image-convert-indexed" },
{ "pika-convert-rgb", "pika-image-convert-rgb" },
{ "pika-crop", "pika-image-crop" },
{ "pika-drawable-bytes", "pika-drawable-bpp" },
{ "pika-drawable-image", "pika-drawable-get-image" },
{ "pika-image-floating-selection", "pika-image-get-floating-sel" },
{ "pika-layer-delete", "pika-item-delete" },
{ "pika-layer-get-name", "pika-item-get-name" },
{ "pika-layer-get-tattoo", "pika-item-get-tattoo" },
{ "pika-layer-get-visible", "pika-item-get-visible" },
{ "pika-layer-mask", "pika-layer-get-mask" },
{ "pika-layer-set-name", "pika-item-set-name" },
{ "pika-layer-set-tattoo", "pika-item-set-tattoo" },
{ "pika-layer-set-visible", "pika-item-set-visible" },
{ "pika-palette-refresh", "pika-palettes-refresh" },
{ "pika-patterns-list", "pika-patterns-get-list" },
{ "pika-temp-PDB-name", "pika-procedural-db-temp-name" },
{ "pika-undo-push-group-end", "pika-image-undo-group-end" },
{ "pika-undo-push-group-start", "pika-image-undo-group-start" },
/* deprecations since 2.0 */
{ "pika-brushes-get-opacity", "pika-context-get-opacity" },
{ "pika-brushes-get-paint-mode", "pika-context-get-paint-mode" },
{ "pika-brushes-set-brush", "pika-context-set-brush" },
{ "pika-brushes-set-opacity", "pika-context-set-opacity" },
{ "pika-brushes-set-paint-mode", "pika-context-set-paint-mode" },
{ "pika-channel-ops-duplicate", "pika-image-duplicate" },
{ "pika-channel-ops-offset", "pika-drawable-offset" },
{ "pika-gradients-get-active", "pika-context-get-gradient" },
{ "pika-gradients-get-gradient", "pika-context-get-gradient" },
{ "pika-gradients-set-active", "pika-context-set-gradient" },
{ "pika-gradients-set-gradient", "pika-context-set-gradient" },
{ "pika-image-get-cmap", "pika-image-get-colormap" },
{ "pika-image-set-cmap", "pika-image-set-colormap" },
{ "pika-palette-get-background", "pika-context-get-background" },
{ "pika-palette-get-foreground", "pika-context-get-foreground" },
{ "pika-palette-set-background", "pika-context-set-background" },
{ "pika-palette-set-default-colors", "pika-context-set-default-colors" },
{ "pika-palette-set-foreground", "pika-context-set-foreground" },
{ "pika-palette-swap-colors", "pika-context-swap-colors" },
{ "pika-palettes-set-palette", "pika-context-set-palette" },
{ "pika-patterns-set-pattern", "pika-context-set-pattern" },
{ "pika-selection-clear", "pika-selection-none" },
/* deprecations since 2.2 */
{ "pika-layer-get-preserve-trans", "pika-layer-get-lock-alpha" },
{ "pika-layer-set-preserve-trans", "pika-layer-set-lock-alpha" },
/* deprecations since 2.6 */
{ "pika-drawable-is-valid", "pika-item-is-valid" },
{ "pika-drawable-is-layer", "pika-item-is-layer" },
{ "pika-drawable-is-text-layer", "pika-item-is-text-layer" },
{ "pika-drawable-is-layer-mask", "pika-item-is-layer-mask" },
{ "pika-drawable-is-channel", "pika-item-is-channel" },
{ "pika-drawable-delete", "pika-item-delete" },
{ "pika-drawable-get-image", "pika-item-get-image" },
{ "pika-drawable-get-name", "pika-item-get-name" },
{ "pika-drawable-set-name", "pika-item-set-name" },
{ "pika-drawable-get-visible", "pika-item-get-visible" },
{ "pika-drawable-set-visible", "pika-item-set-visible" },
{ "pika-drawable-get-tattoo", "pika-item-get-tattoo" },
{ "pika-drawable-set-tattoo", "pika-item-set-tattoo" },
{ "pika-drawable-parasite-find", "pika-item-get-parasite" },
{ "pika-drawable-parasite-attach", "pika-item-attach-parasite" },
{ "pika-drawable-parasite-detach", "pika-item-detach-parasite" },
{ "pika-drawable-parasite-list", "pika-item-get-parasite-list" },
{ "pika-image-get-layer-position", "pika-image-get-item-position" },
{ "pika-image-raise-layer", "pika-image-raise-item" },
{ "pika-image-lower-layer", "pika-image-lower-item" },
{ "pika-image-raise-layer-to-top", "pika-image-raise-item-to-top" },
{ "pika-image-lower-layer-to-bottom", "pika-image-lower-item-to-bottom" },
{ "pika-image-get-channel-position", "pika-image-get-item-position" },
{ "pika-image-raise-channel", "pika-image-raise-item" },
{ "pika-image-lower-channel", "pika-image-lower-item" },
{ "pika-image-get-vectors-position", "pika-image-get-item-position" },
{ "pika-image-raise-vectors", "pika-image-raise-item" },
{ "pika-image-lower-vectors", "pika-image-lower-item" },
{ "pika-image-raise-vectors-to-top", "pika-image-raise-item-to-top" },
{ "pika-image-lower-vectors-to-bottom", "pika-image-lower-item-to-bottom" },
{ "pika-vectors-is-valid", "pika-item-is-valid" },
{ "pika-vectors-get-image", "pika-item-get-image" },
{ "pika-vectors-get-name", "pika-item-get-name" },
{ "pika-vectors-set-name", "pika-item-set-name" },
{ "pika-vectors-get-visible", "pika-item-get-visible" },
{ "pika-vectors-set-visible", "pika-item-set-visible" },
{ "pika-vectors-get-tattoo", "pika-item-get-tattoo" },
{ "pika-vectors-set-tattoo", "pika-item-set-tattoo" },
{ "pika-vectors-parasite-find", "pika-item-get-parasite" },
{ "pika-vectors-parasite-attach", "pika-item-attach-parasite" },
{ "pika-vectors-parasite-detach", "pika-item-detach-parasite" },
{ "pika-vectors-parasite-list", "pika-item-get-parasite-list" },
{ "pika-image-parasite-find", "pika-image-get-parasite" },
{ "pika-image-parasite-attach", "pika-image-attach-parasite" },
{ "pika-image-parasite-detach", "pika-image-detach-parasite" },
{ "pika-image-parasite-list", "pika-image-get-parasite-list" },
{ "pika-parasite-find", "pika-get-parasite" },
{ "pika-parasite-attach", "pika-attach-parasite" },
{ "pika-parasite-detach", "pika-detach-parasite" },
{ "pika-parasite-list", "pika-get-parasite-list" },
/* deprecations since 2.8 */
{ "pika-edit-paste-as-new", "pika-edit-paste-as-new-image" },
{ "pika-edit-named-paste-as-new", "pika-edit-named-paste-as-new-image" }
};
g_return_if_fail (PIKA_IS_PDB (pdb));
if (compat_mode != PIKA_PDB_COMPAT_OFF)
{
gint i;
for (i = 0; i < G_N_ELEMENTS (compat_procs); i++)
pika_pdb_register_compat_proc_name (pdb,
compat_procs[i].old_name,
compat_procs[i].new_name);
}
}

30
app/pdb/pika-pdb-compat.h Normal file
View File

@ -0,0 +1,30 @@
/* 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 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/>.
*/
#ifndef __PIKA_PDB_COMPAT_H__
#define __PIKA_PDB_COMPAT_H__
void pika_pdb_compat_procs_register (PikaPDB *pdb,
PikaPDBCompatMode compat_mode);
#endif /* __PIKA_PDB_COMPAT_H__ */

563
app/pdb/pikapdb-query.c Normal file
View File

@ -0,0 +1,563 @@
/* 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/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pikaparamspecs-desc.h"
#include "pikapdb.h"
#include "pikapdb-query.h"
#include "pikapdberror.h"
#include "pikaprocedure.h"
#include "pika-intl.h"
#define PDB_REGEX_FLAGS (G_REGEX_CASELESS | G_REGEX_OPTIMIZE)
#define COMPAT_BLURB "This procedure is deprecated! Use '%s' instead."
typedef struct _PDBDump PDBDump;
struct _PDBDump
{
PikaPDB *pdb;
GOutputStream *output;
GError *error;
gboolean dumping_compat;
};
typedef struct _PDBQuery PDBQuery;
struct _PDBQuery
{
PikaPDB *pdb;
GRegex *name_regex;
GRegex *blurb_regex;
GRegex *help_regex;
GRegex *authors_regex;
GRegex *copyright_regex;
GRegex *date_regex;
GRegex *proc_type_regex;
gchar **list_of_procs;
gboolean querying_compat;
};
typedef struct _PDBStrings PDBStrings;
struct _PDBStrings
{
gboolean compat;
gchar *blurb;
gchar *help;
gchar *authors;
gchar *copyright;
gchar *date;
};
/* local function prototypes */
static void pika_pdb_query_entry (gpointer key,
gpointer value,
gpointer user_data);
static void pika_pdb_print_entry (gpointer key,
gpointer value,
gpointer user_data);
static void pika_pdb_get_strings (PDBStrings *strings,
PikaProcedure *procedure,
gboolean compat);
static void pika_pdb_free_strings (PDBStrings *strings);
/* public functions */
gboolean
pika_pdb_dump (PikaPDB *pdb,
GFile *file,
GError **error)
{
PDBDump pdb_dump = { 0, };
g_return_val_if_fail (PIKA_IS_PDB (pdb), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
pdb_dump.pdb = pdb;
pdb_dump.output = G_OUTPUT_STREAM (g_file_replace (file,
NULL, FALSE,
G_FILE_CREATE_NONE,
NULL, error));
if (! pdb_dump.output)
return FALSE;
pdb_dump.dumping_compat = FALSE;
g_hash_table_foreach (pdb->procedures,
pika_pdb_print_entry,
&pdb_dump);
pdb_dump.dumping_compat = TRUE;
g_hash_table_foreach (pdb->compat_proc_names,
pika_pdb_print_entry,
&pdb_dump);
if (pdb_dump.error)
{
GCancellable *cancellable = g_cancellable_new ();
g_set_error (error, pdb_dump.error->domain, pdb_dump.error->code,
_("Writing PDB file '%s' failed: %s"),
pika_file_get_utf8_name (file), pdb_dump.error->message);
g_clear_error (&pdb_dump.error);
/* Cancel the overwrite initiated by g_file_replace(). */
g_cancellable_cancel (cancellable);
g_output_stream_close (pdb_dump.output, cancellable, NULL);
g_object_unref (cancellable);
g_object_unref (pdb_dump.output);
return FALSE;
}
g_object_unref (pdb_dump.output);
return TRUE;
}
gboolean
pika_pdb_query (PikaPDB *pdb,
const gchar *name,
const gchar *blurb,
const gchar *help,
const gchar *authors,
const gchar *copyright,
const gchar *date,
const gchar *proc_type,
gchar ***procs,
GError **error)
{
PDBQuery pdb_query = { 0, };
gboolean success = FALSE;
g_return_val_if_fail (PIKA_IS_PDB (pdb), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (blurb != NULL, FALSE);
g_return_val_if_fail (help != NULL, FALSE);
g_return_val_if_fail (authors != NULL, FALSE);
g_return_val_if_fail (copyright != NULL, FALSE);
g_return_val_if_fail (date != NULL, FALSE);
g_return_val_if_fail (proc_type != NULL, FALSE);
g_return_val_if_fail (procs != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
*procs = NULL;
pdb_query.name_regex = g_regex_new (name, PDB_REGEX_FLAGS, 0, error);
if (! pdb_query.name_regex)
goto cleanup;
pdb_query.blurb_regex = g_regex_new (blurb, PDB_REGEX_FLAGS, 0, error);
if (! pdb_query.blurb_regex)
goto cleanup;
pdb_query.help_regex = g_regex_new (help, PDB_REGEX_FLAGS, 0, error);
if (! pdb_query.help_regex)
goto cleanup;
pdb_query.authors_regex = g_regex_new (authors, PDB_REGEX_FLAGS, 0, error);
if (! pdb_query.authors_regex)
goto cleanup;
pdb_query.copyright_regex = g_regex_new (copyright, PDB_REGEX_FLAGS, 0, error);
if (! pdb_query.copyright_regex)
goto cleanup;
pdb_query.date_regex = g_regex_new (date, PDB_REGEX_FLAGS, 0, error);
if (! pdb_query.date_regex)
goto cleanup;
pdb_query.proc_type_regex = g_regex_new (proc_type, PDB_REGEX_FLAGS, 0, error);
if (! pdb_query.proc_type_regex)
goto cleanup;
success = TRUE;
pdb_query.pdb = pdb;
pdb_query.list_of_procs = g_new0 (gchar *, 1);
pdb_query.querying_compat = FALSE;
g_hash_table_foreach (pdb->procedures,
pika_pdb_query_entry, &pdb_query);
pdb_query.querying_compat = TRUE;
g_hash_table_foreach (pdb->compat_proc_names,
pika_pdb_query_entry, &pdb_query);
cleanup:
if (pdb_query.proc_type_regex)
g_regex_unref (pdb_query.proc_type_regex);
if (pdb_query.date_regex)
g_regex_unref (pdb_query.date_regex);
if (pdb_query.copyright_regex)
g_regex_unref (pdb_query.copyright_regex);
if (pdb_query.authors_regex)
g_regex_unref (pdb_query.authors_regex);
if (pdb_query.help_regex)
g_regex_unref (pdb_query.help_regex);
if (pdb_query.blurb_regex)
g_regex_unref (pdb_query.blurb_regex);
if (pdb_query.name_regex)
g_regex_unref (pdb_query.name_regex);
if (success)
{
*procs = pdb_query.list_of_procs;
}
return success;
}
/* private functions */
static gboolean
match_string (GRegex *regex,
const gchar *string)
{
if (! string)
string = "";
return g_regex_match (regex, string, 0, NULL);
}
static void
pika_pdb_query_entry (gpointer key,
gpointer value,
gpointer user_data)
{
PDBQuery *pdb_query = user_data;
GList *list;
PikaProcedure *procedure;
const gchar *proc_name;
PDBStrings strings;
GEnumClass *enum_class;
const PikaEnumDesc *type_desc;
proc_name = key;
if (pdb_query->querying_compat)
list = g_hash_table_lookup (pdb_query->pdb->procedures, value);
else
list = value;
if (! list)
return;
procedure = list->data;
pika_pdb_get_strings (&strings, procedure, pdb_query->querying_compat);
enum_class = g_type_class_ref (PIKA_TYPE_PDB_PROC_TYPE);
type_desc = pika_enum_get_desc (enum_class, procedure->proc_type);
g_type_class_unref (enum_class);
if (match_string (pdb_query->name_regex, proc_name) &&
match_string (pdb_query->blurb_regex, strings.blurb) &&
match_string (pdb_query->help_regex, strings.help) &&
match_string (pdb_query->authors_regex, strings.authors) &&
match_string (pdb_query->copyright_regex, strings.copyright) &&
match_string (pdb_query->date_regex, strings.date) &&
match_string (pdb_query->proc_type_regex, type_desc->value_desc))
{
guint num_procs = g_strv_length (pdb_query->list_of_procs);
pdb_query->list_of_procs = g_renew (gchar *, pdb_query->list_of_procs,
num_procs + 2);
pdb_query->list_of_procs[num_procs] = g_strdup (proc_name);
pdb_query->list_of_procs[num_procs + 1] = NULL;
}
pika_pdb_free_strings (&strings);
}
/* #define DEBUG_OUTPUT 1 */
static void
output_string (GString *dest,
const gchar *string)
{
#ifndef DEBUG_OUTPUT
g_string_append_printf (dest, "\"");
#endif
if (string)
while (*string)
{
switch (*string)
{
case '\\' : g_string_append_printf (dest, "\\\\"); break;
case '\"' : g_string_append_printf (dest, "\\\""); break;
case '{' : g_string_append_printf (dest, "@{"); break;
case '@' : g_string_append_printf (dest, "@@"); break;
case '}' : g_string_append_printf (dest, "@}"); break;
default:
g_string_append_printf (dest, "%c", *string);
}
string++;
}
#ifndef DEBUG_OUTPUT
g_string_append_printf (dest, "\"\n");
#endif
}
static void
pika_pdb_print_entry (gpointer key,
gpointer value,
gpointer user_data)
{
PDBDump *pdb_dump = user_data;
GOutputStream *output = pdb_dump->output;
const gchar *proc_name;
GList *list;
GEnumClass *proc_class;
GString *buf;
GString *string;
gint num = 0;
if (pdb_dump->error)
return;
proc_name = key;
if (pdb_dump->dumping_compat)
list = g_hash_table_lookup (pdb_dump->pdb->procedures, value);
else
list = value;
proc_class = g_type_class_ref (PIKA_TYPE_PDB_PROC_TYPE);
buf = g_string_new (NULL);
string = g_string_new (NULL);
for (; list; list = list->next)
{
PikaProcedure *procedure = list->data;
PDBStrings strings;
const PikaEnumDesc *type_desc;
gint i;
num++;
pika_pdb_get_strings (&strings, procedure, pdb_dump->dumping_compat);
#ifdef DEBUG_OUTPUT
g_string_append_printf (string, "(");
#else
g_string_append_printf (string, "(register-procedure ");
#endif
if (num != 1)
{
g_string_printf (buf, "%s <%d>", proc_name, num);
output_string (string, buf->str);
}
else
{
output_string (string, proc_name);
}
type_desc = pika_enum_get_desc (proc_class, procedure->proc_type);
#ifdef DEBUG_OUTPUT
g_string_append_printf (string, " (");
for (i = 0; i < procedure->num_args; i++)
{
GParamSpec *pspec = procedure->args[i];
if (i > 0)
g_string_append_printf (string, " ");
output_string (string, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
}
g_string_append_printf (string, ") (");
for (i = 0; i < procedure->num_values; i++)
{
GParamSpec *pspec = procedure->values[i];
if (i > 0)
g_string_append_printf (string, " ");
output_string (string, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
}
g_string_append_printf (string, "))\n");
#else /* ! DEBUG_OUTPUT */
g_string_append_printf (string, " ");
output_string (string, strings.blurb);
g_string_append_printf (string, " ");
output_string (string, strings.help);
g_string_append_printf (string, " ");
output_string (string, strings.authors);
g_string_append_printf (string, " ");
output_string (string, strings.copyright);
g_string_append_printf (string, " ");
output_string (string, strings.date);
g_string_append_printf (string, " ");
output_string (string, type_desc->value_desc);
g_string_append_printf (string, " (");
for (i = 0; i < procedure->num_args; i++)
{
GParamSpec *pspec = procedure->args[i];
gchar *desc = pika_param_spec_get_desc (pspec);
g_string_append_printf (string, "\n (\n");
g_string_append_printf (string, " ");
output_string (string, g_param_spec_get_name (pspec));
g_string_append_printf (string, " ");
output_string (string, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
g_string_append_printf (string, " ");
output_string (string, desc);
g_free (desc);
g_string_append_printf (string, " )");
}
g_string_append_printf (string, "\n )\n");
g_string_append_printf (string, " (");
for (i = 0; i < procedure->num_values; i++)
{
GParamSpec *pspec = procedure->values[i];
gchar *desc = pika_param_spec_get_desc (pspec);
g_string_append_printf (string, "\n (\n");
g_string_append_printf (string, " ");
output_string (string, g_param_spec_get_name (pspec));
g_string_append_printf (string, " ");
output_string (string, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
g_string_append_printf (string, " ");
output_string (string, desc);
g_free (desc);
g_string_append_printf (string, " )");
}
g_string_append_printf (string, "\n )");
g_string_append_printf (string, "\n)\n");
#endif /* DEBUG_OUTPUT */
pika_pdb_free_strings (&strings);
}
g_output_stream_write_all (output, string->str, string->len,
NULL, NULL, &pdb_dump->error);
g_string_free (string, TRUE);
g_string_free (buf, TRUE);
g_type_class_unref (proc_class);
}
static void
pika_pdb_get_strings (PDBStrings *strings,
PikaProcedure *procedure,
gboolean compat)
{
strings->compat = compat;
if (compat)
{
strings->blurb = g_strdup_printf (COMPAT_BLURB,
pika_object_get_name (procedure));
strings->help = g_strdup (strings->blurb);
strings->authors = NULL;
strings->copyright = NULL;
strings->date = NULL;
}
else
{
strings->blurb = procedure->blurb;
strings->help = procedure->help;
strings->authors = procedure->authors;
strings->copyright = procedure->copyright;
strings->date = procedure->date;
}
}
static void
pika_pdb_free_strings (PDBStrings *strings)
{
if (strings->compat)
{
g_free (strings->blurb);
g_free (strings->help);
}
}

41
app/pdb/pikapdb-query.h Normal file
View File

@ -0,0 +1,41 @@
/* 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/>.
*/
#ifndef __PIKA_PDB_QUERY_H__
#define __PIKA_PDB_QUERY_H__
gboolean pika_pdb_dump (PikaPDB *pdb,
GFile *file,
GError **error);
gboolean pika_pdb_query (PikaPDB *pdb,
const gchar *name,
const gchar *blurb,
const gchar *help,
const gchar *authors,
const gchar *copyright,
const gchar *date,
const gchar *proc_type,
gchar ***procs,
GError **error);
#endif /* __PIKA_PDB_QUERY_H__ */

833
app/pdb/pikapdb-utils.c Normal file
View File

@ -0,0 +1,833 @@
/* 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/>.
*/
#include "config.h"
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pika.h"
#include "core/pikabrush.h"
#include "core/pikabrushgenerated.h"
#include "core/pikachannel.h"
#include "core/pikacontainer.h"
#include "core/pikadatafactory.h"
#include "core/pikadrawable.h"
#include "core/pikadynamics.h"
#include "core/pikagradient.h"
#include "core/pikaimage.h"
#include "core/pikaimage-guides.h"
#include "core/pikaimage-sample-points.h"
#include "core/pikaitem.h"
#include "core/pikamybrush.h"
#include "core/pikapalette.h"
#include "core/pikapattern.h"
#include "text/pikatextlayer.h"
#include "text/pikafont.h"
#include "vectors/pikavectors.h"
#include "pikapdb-utils.h"
#include "pikapdberror.h"
#include "pika-intl.h"
typedef struct
{
const gchar *name;
const gchar *collection;
gboolean is_internal;
} SearchData;
static PikaResource * pika_pdb_get_data_factory_item (Pika *pika,
GType data_type,
const gchar *name,
const gchar *collection,
gboolean is_internal);
const gchar * pika_pdb_get_data_label (GType data_type);
static gboolean pika_pdb_search_in_data_container (PikaData *data,
SearchData *search_data);;
PikaDataFactory *
pika_pdb_get_data_factory (Pika *pika,
GType data_type)
{
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
g_return_val_if_fail (g_type_is_a (data_type, PIKA_TYPE_DATA), NULL);
if (g_type_is_a (data_type, PIKA_TYPE_BRUSH_GENERATED))
return pika->brush_factory;
else if (g_type_is_a (data_type, PIKA_TYPE_BRUSH))
return pika->brush_factory;
else if (g_type_is_a (data_type, PIKA_TYPE_PATTERN))
return pika->pattern_factory;
else if (g_type_is_a (data_type, PIKA_TYPE_GRADIENT))
return pika->gradient_factory;
else if (g_type_is_a (data_type, PIKA_TYPE_PALETTE))
return pika->palette_factory;
else if (g_type_is_a (data_type, PIKA_TYPE_FONT))
return pika->font_factory;
else if (g_type_is_a (data_type, PIKA_TYPE_DYNAMICS))
return pika->dynamics_factory;
else if (g_type_is_a (data_type, PIKA_TYPE_MYBRUSH))
return pika->mybrush_factory;
/* If we reach this, it means we forgot a data factory in our list! */
g_return_val_if_reached (NULL);
}
PikaResource *
pika_pdb_get_resource (Pika *pika,
GType data_type,
const gchar *name,
PikaPDBDataAccess access,
GError **error)
{
PikaResource *resource;
const gchar *label;
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
label = pika_pdb_get_data_label (data_type);
if (! name || ! strlen (name))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
/* TRANSLATOR: %s is a data label from the
* PDB-error-data-label context.
*/
C_("PDB-error-message", "%s name cannot be empty"),
g_type_name (data_type));
return NULL;
}
resource = pika_pdb_get_data_factory_item (pika, data_type, name, NULL, TRUE);
if (! resource)
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
/* TRANSLATOR: the first %s is a data label from the
* PDB-error-data-label context. The second %s is a data
* name.
*/
C_("PDB-error-message", "%s '%s' not found"), label, name);
}
else if ((access & PIKA_PDB_DATA_ACCESS_WRITE) &&
! pika_data_is_writable (PIKA_DATA (resource)))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
/* TRANSLATOR: the first %s is a data label from the
* PDB-error-data-label context. The second %s is a data
* name.
*/
C_("PDB-error-message", "%s '%s' is not editable"), label, name);
return NULL;
}
else if ((access & PIKA_PDB_DATA_ACCESS_RENAME) &&
! pika_viewable_is_name_editable (PIKA_VIEWABLE (resource)))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
/* TRANSLATOR: the first %s is a data label from the
* PDB-error-data-label context. The second %s is a data
* name.
*/
C_("PDB-error-message", "%s '%s' is not renamable"), label, name);
return NULL;
}
return resource;
}
PikaResource *
pika_pdb_get_resource_by_id (Pika *pika,
GType data_type,
const gchar *name,
const gchar *collection,
gboolean is_internal,
PikaPDBDataAccess access,
GError **error)
{
PikaResource *resource;
const gchar *label;
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
label = pika_pdb_get_data_label (data_type);
if (! name || ! strlen (name))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
/* TRANSLATOR: %s is a data label from the
* PDB-error-data-label context.
*/
C_("PDB-error-message", "%s name cannot be empty"),
g_type_name (data_type));
return NULL;
}
resource = pika_pdb_get_data_factory_item (pika, data_type, name, collection, is_internal);
if (! resource)
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
/* TRANSLATOR: the first %s is a data label from the
* PDB-error-data-label context. The second %s is a data
* name.
*/
C_("PDB-error-message", "%s '%s' not found"), label, name);
}
else if ((access & PIKA_PDB_DATA_ACCESS_WRITE) &&
! pika_data_is_writable (PIKA_DATA (resource)))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
/* TRANSLATOR: the first %s is a data label from the
* PDB-error-data-label context. The second %s is a data
* name.
*/
C_("PDB-error-message", "%s '%s' is not editable"), label, name);
return NULL;
}
else if ((access & PIKA_PDB_DATA_ACCESS_RENAME) &&
! pika_viewable_is_name_editable (PIKA_VIEWABLE (resource)))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
/* TRANSLATOR: the first %s is a data label from the
* PDB-error-data-label context. The second %s is a data
* name.
*/
C_("PDB-error-message", "%s '%s' is not renamable"), label, name);
return NULL;
}
return resource;
}
PikaBrush *
pika_pdb_get_generated_brush (Pika *pika,
const gchar *name,
PikaPDBDataAccess access,
GError **error)
{
PikaBrush *brush;
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
brush = PIKA_BRUSH (pika_pdb_get_resource (pika, PIKA_TYPE_BRUSH_GENERATED, name, access, error));
if (brush != NULL && ! PIKA_IS_BRUSH_GENERATED (brush))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Brush '%s' is not a generated brush"), name);
return NULL;
}
return brush;
}
PikaBuffer *
pika_pdb_get_buffer (Pika *pika,
const gchar *name,
GError **error)
{
PikaBuffer *buffer;
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (! name || ! strlen (name))
{
g_set_error_literal (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Invalid empty buffer name"));
return NULL;
}
buffer = (PikaBuffer *)
pika_container_get_child_by_name (pika->named_buffers, name);
if (! buffer)
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Named buffer '%s' not found"), name);
}
return buffer;
}
PikaPaintInfo *
pika_pdb_get_paint_info (Pika *pika,
const gchar *name,
GError **error)
{
PikaPaintInfo *paint_info;
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (! name || ! strlen (name))
{
g_set_error_literal (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Invalid empty paint method name"));
return NULL;
}
paint_info = (PikaPaintInfo *)
pika_container_get_child_by_name (pika->paint_info_list, name);
if (! paint_info)
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Paint method '%s' does not exist"), name);
}
return paint_info;
}
gboolean
pika_pdb_item_is_attached (PikaItem *item,
PikaImage *image,
PikaPDBItemModify modify,
GError **error)
{
g_return_val_if_fail (PIKA_IS_ITEM (item), FALSE);
g_return_val_if_fail (image == NULL || PIKA_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! pika_item_is_attached (item))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) cannot be used because it has not "
"been added to an image"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
if (image && image != pika_item_get_image (item))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) cannot be used because it is "
"attached to another image"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
return pika_pdb_item_is_modifiable (item, modify, error);
}
gboolean
pika_pdb_item_is_in_tree (PikaItem *item,
PikaImage *image,
PikaPDBItemModify modify,
GError **error)
{
g_return_val_if_fail (PIKA_IS_ITEM (item), FALSE);
g_return_val_if_fail (image == NULL || PIKA_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! pika_pdb_item_is_attached (item, image, modify, error))
return FALSE;
if (! pika_item_get_tree (item))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) cannot be used because it is not "
"a direct child of an item tree"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
return TRUE;
}
gboolean
pika_pdb_item_is_in_same_tree (PikaItem *item,
PikaItem *item2,
PikaImage *image,
GError **error)
{
g_return_val_if_fail (PIKA_IS_ITEM (item), FALSE);
g_return_val_if_fail (PIKA_IS_ITEM (item2), FALSE);
g_return_val_if_fail (image == NULL || PIKA_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! pika_pdb_item_is_in_tree (item, image, FALSE, error) ||
! pika_pdb_item_is_in_tree (item2, image, FALSE, error))
return FALSE;
if (pika_item_get_tree (item) != pika_item_get_tree (item2))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Items '%s' (%d) and '%s' (%d) cannot be used "
"because they are not part of the same item tree"),
pika_object_get_name (item),
pika_item_get_id (item),
pika_object_get_name (item2),
pika_item_get_id (item2));
return FALSE;
}
return TRUE;
}
gboolean
pika_pdb_item_is_not_ancestor (PikaItem *item,
PikaItem *not_descendant,
GError **error)
{
g_return_val_if_fail (PIKA_IS_ITEM (item), FALSE);
g_return_val_if_fail (PIKA_IS_ITEM (not_descendant), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (pika_viewable_is_ancestor (PIKA_VIEWABLE (item),
PIKA_VIEWABLE (not_descendant)))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) must not be an ancestor of "
"'%s' (%d)"),
pika_object_get_name (item),
pika_item_get_id (item),
pika_object_get_name (not_descendant),
pika_item_get_id (not_descendant));
return FALSE;
}
return TRUE;
}
gboolean
pika_pdb_item_is_floating (PikaItem *item,
PikaImage *dest_image,
GError **error)
{
g_return_val_if_fail (PIKA_IS_ITEM (item), FALSE);
g_return_val_if_fail (PIKA_IS_IMAGE (dest_image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! g_object_is_floating (item))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) has already been added to an image"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
else if (pika_item_get_image (item) != dest_image)
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Trying to add item '%s' (%d) to wrong image"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
return TRUE;
}
gboolean
pika_pdb_item_is_modifiable (PikaItem *item,
PikaPDBItemModify modify,
GError **error)
{
g_return_val_if_fail (PIKA_IS_ITEM (item), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* When a channel is position-locked, it is also implicitly
* content-locked because we translate channels by modifying their
* pixels.
*/
if ((modify & PIKA_PDB_ITEM_POSITION) && PIKA_IS_CHANNEL (item))
modify |= PIKA_PDB_ITEM_CONTENT;
if ((modify & PIKA_PDB_ITEM_CONTENT) && pika_item_is_content_locked (item, NULL))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) cannot be modified because its "
"contents are locked"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
if ((modify & PIKA_PDB_ITEM_POSITION) && pika_item_is_position_locked (item, NULL))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) cannot be modified because its "
"position and size are locked"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
return TRUE;
}
gboolean
pika_pdb_item_is_group (PikaItem *item,
GError **error)
{
g_return_val_if_fail (PIKA_IS_ITEM (item), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! pika_viewable_get_children (PIKA_VIEWABLE (item)))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) cannot be used because it is "
"not a group item"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
return TRUE;
}
gboolean
pika_pdb_item_is_not_group (PikaItem *item,
GError **error)
{
g_return_val_if_fail (PIKA_IS_ITEM (item), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (pika_viewable_get_children (PIKA_VIEWABLE (item)))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Item '%s' (%d) cannot be modified because it "
"is a group item"),
pika_object_get_name (item),
pika_item_get_id (item));
return FALSE;
}
return TRUE;
}
gboolean
pika_pdb_layer_is_text_layer (PikaLayer *layer,
PikaPDBItemModify modify,
GError **error)
{
g_return_val_if_fail (PIKA_IS_LAYER (layer), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! pika_item_is_text_layer (PIKA_ITEM (layer)))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Layer '%s' (%d) cannot be used because it is not "
"a text layer"),
pika_object_get_name (layer),
pika_item_get_id (PIKA_ITEM (layer)));
return FALSE;
}
return pika_pdb_item_is_attached (PIKA_ITEM (layer), NULL, modify, error);
}
static const gchar *
pika_pdb_enum_value_get_nick (GType enum_type,
gint value)
{
GEnumClass *enum_class;
GEnumValue *enum_value;
const gchar *nick;
enum_class = g_type_class_ref (enum_type);
enum_value = g_enum_get_value (enum_class, value);
nick = enum_value->value_nick;
g_type_class_unref (enum_class);
return nick;
}
gboolean
pika_pdb_image_is_base_type (PikaImage *image,
PikaImageBaseType type,
GError **error)
{
g_return_val_if_fail (PIKA_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (pika_image_get_base_type (image) == type)
return TRUE;
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) is of type '%s', "
"but an image of type '%s' is expected"),
pika_image_get_display_name (image),
pika_image_get_id (image),
pika_pdb_enum_value_get_nick (PIKA_TYPE_IMAGE_BASE_TYPE,
pika_image_get_base_type (image)),
pika_pdb_enum_value_get_nick (PIKA_TYPE_IMAGE_BASE_TYPE, type));
return FALSE;
}
gboolean
pika_pdb_image_is_not_base_type (PikaImage *image,
PikaImageBaseType type,
GError **error)
{
g_return_val_if_fail (PIKA_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (pika_image_get_base_type (image) != type)
return TRUE;
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) must not be of type '%s'"),
pika_image_get_display_name (image),
pika_image_get_id (image),
pika_pdb_enum_value_get_nick (PIKA_TYPE_IMAGE_BASE_TYPE, type));
return FALSE;
}
gboolean
pika_pdb_image_is_precision (PikaImage *image,
PikaPrecision precision,
GError **error)
{
g_return_val_if_fail (PIKA_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (pika_image_get_precision (image) == precision)
return TRUE;
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) has precision '%s', "
"but an image of precision '%s' is expected"),
pika_image_get_display_name (image),
pika_image_get_id (image),
pika_pdb_enum_value_get_nick (PIKA_TYPE_PRECISION,
pika_image_get_precision (image)),
pika_pdb_enum_value_get_nick (PIKA_TYPE_PRECISION, precision));
return FALSE;
}
gboolean
pika_pdb_image_is_not_precision (PikaImage *image,
PikaPrecision precision,
GError **error)
{
g_return_val_if_fail (PIKA_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (pika_image_get_precision (image) != precision)
return TRUE;
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) must not be of precision '%s'"),
pika_image_get_display_name (image),
pika_image_get_id (image),
pika_pdb_enum_value_get_nick (PIKA_TYPE_PRECISION, precision));
return FALSE;
}
PikaGuide *
pika_pdb_image_get_guide (PikaImage *image,
gint guide_id,
GError **error)
{
PikaGuide *guide;
g_return_val_if_fail (PIKA_IS_IMAGE (image), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
guide = pika_image_get_guide (image, guide_id);
if (guide)
return guide;
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) does not contain guide with ID %d"),
pika_image_get_display_name (image),
pika_image_get_id (image),
guide_id);
return NULL;
}
PikaSamplePoint *
pika_pdb_image_get_sample_point (PikaImage *image,
gint sample_point_id,
GError **error)
{
PikaSamplePoint *sample_point;
g_return_val_if_fail (PIKA_IS_IMAGE (image), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
sample_point = pika_image_get_sample_point (image, sample_point_id);
if (sample_point)
return sample_point;
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Image '%s' (%d) does not contain sample point with ID %d"),
pika_image_get_display_name (image),
pika_image_get_id (image),
sample_point_id);
return NULL;
}
PikaStroke *
pika_pdb_get_vectors_stroke (PikaVectors *vectors,
gint stroke_id,
PikaPDBItemModify modify,
GError **error)
{
PikaStroke *stroke = NULL;
g_return_val_if_fail (PIKA_IS_VECTORS (vectors), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (! pika_pdb_item_is_not_group (PIKA_ITEM (vectors), error))
return NULL;
if (! modify || pika_pdb_item_is_modifiable (PIKA_ITEM (vectors),
modify, error))
{
stroke = pika_vectors_stroke_get_by_id (vectors, stroke_id);
if (! stroke)
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Vectors object %d does not contain stroke with ID %d"),
pika_item_get_id (PIKA_ITEM (vectors)), stroke_id);
}
return stroke;
}
gboolean
pika_pdb_is_canonical_procedure (const gchar *procedure_name,
GError **error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! pika_is_canonical_identifier (procedure_name))
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Procedure name '%s' is not a canonical identifier"),
procedure_name);
return FALSE;
}
return TRUE;
}
/* Private functions. */
static PikaResource *
pika_pdb_get_data_factory_item (Pika *pika,
GType data_type,
const gchar *name,
const gchar *collection,
gboolean is_internal)
{
PikaDataFactory *factory;
PikaContainer *container;
PikaObject *resource;
factory = pika_pdb_get_data_factory (pika, data_type);
g_return_val_if_fail (PIKA_IS_DATA_FACTORY (factory), NULL);
container = pika_data_factory_get_container (factory);
if (collection == NULL)
{
resource = pika_container_get_child_by_name (container, name);
}
else
{
SearchData *data = g_new (SearchData, 1);
data->name = name;
data->collection = collection;
data->is_internal = is_internal;
resource = pika_container_search (container,
(PikaContainerSearchFunc) pika_pdb_search_in_data_container,
data);
g_free (data);
}
if (! resource)
resource = pika_container_get_child_by_name (pika_data_factory_get_container_obsolete (factory),
name);
if (! resource && ! strcmp (name, "Standard"))
resource = (PikaObject *) pika_data_factory_data_get_standard (factory,
pika_get_user_context (pika));
return (PikaResource *) resource;
}
const gchar *
pika_pdb_get_data_label (GType data_type)
{
g_return_val_if_fail (g_type_is_a (data_type, PIKA_TYPE_DATA), NULL);
if (g_type_is_a (data_type, PIKA_TYPE_BRUSH_GENERATED))
return C_("PDB-error-data-label", "Generated brush");
else if (g_type_is_a (data_type, PIKA_TYPE_BRUSH))
return C_("PDB-error-data-label", "Brush");
else if (g_type_is_a (data_type, PIKA_TYPE_PATTERN))
return C_("PDB-error-data-label", "Pattern");
else if (g_type_is_a (data_type, PIKA_TYPE_GRADIENT))
return C_("PDB-error-data-label", "Gradient");
else if (g_type_is_a (data_type, PIKA_TYPE_PALETTE))
return C_("PDB-error-data-label", "Palette");
else if (g_type_is_a (data_type, PIKA_TYPE_FONT))
return C_("PDB-error-data-label", "Font");
else if (g_type_is_a (data_type, PIKA_TYPE_DYNAMICS))
return C_("PDB-error-data-label", "Paint dynamics");
else if (g_type_is_a (data_type, PIKA_TYPE_MYBRUSH))
return C_("PDB-error-data-label", "MyPaint brush");
/* If we reach this, it means we forgot a data type in our list! */
g_return_val_if_reached (NULL);
}
static gboolean
pika_pdb_search_in_data_container (PikaData *data,
SearchData *search_data)
{
return pika_data_identify (data, search_data->name, search_data->collection, search_data->is_internal);
}

113
app/pdb/pikapdb-utils.h Normal file
View File

@ -0,0 +1,113 @@
/* 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/>.
*/
#ifndef __PIKA_PDB_UTILS_H__
#define __PIKA_PDB_UTILS_H__
PikaDataFactory * pika_pdb_get_data_factory (Pika *pika,
GType data_type);
PikaResource * pika_pdb_get_resource (Pika *pika,
GType data_type,
const gchar *name,
PikaPDBDataAccess access,
GError **error);
PikaResource * pika_pdb_get_resource_by_id (Pika *pika,
GType data_type,
const gchar *name,
const gchar *collection,
gboolean is_internal,
PikaPDBDataAccess access,
GError **error);
PikaBrush * pika_pdb_get_generated_brush (Pika *pika,
const gchar *name,
PikaPDBDataAccess access,
GError **error);
PikaBuffer * pika_pdb_get_buffer (Pika *pika,
const gchar *name,
GError **error);
PikaPaintInfo * pika_pdb_get_paint_info (Pika *pika,
const gchar *name,
GError **error);
gboolean pika_pdb_item_is_attached (PikaItem *item,
PikaImage *image,
PikaPDBItemModify modify,
GError **error);
gboolean pika_pdb_item_is_in_tree (PikaItem *item,
PikaImage *image,
PikaPDBItemModify modify,
GError **error);
gboolean pika_pdb_item_is_in_same_tree (PikaItem *item,
PikaItem *item2,
PikaImage *image,
GError **error);
gboolean pika_pdb_item_is_not_ancestor (PikaItem *item,
PikaItem *not_descendant,
GError **error);
gboolean pika_pdb_item_is_floating (PikaItem *item,
PikaImage *dest_image,
GError **error);
gboolean pika_pdb_item_is_modifiable (PikaItem *item,
PikaPDBItemModify modify,
GError **error);
gboolean pika_pdb_item_is_group (PikaItem *item,
GError **error);
gboolean pika_pdb_item_is_not_group (PikaItem *item,
GError **error);
gboolean pika_pdb_layer_is_text_layer (PikaLayer *layer,
PikaPDBItemModify modify,
GError **error);
gboolean pika_pdb_image_is_base_type (PikaImage *image,
PikaImageBaseType type,
GError **error);
gboolean pika_pdb_image_is_not_base_type (PikaImage *image,
PikaImageBaseType type,
GError **error);
gboolean pika_pdb_image_is_precision (PikaImage *image,
PikaPrecision precision,
GError **error);
gboolean pika_pdb_image_is_not_precision (PikaImage *image,
PikaPrecision precision,
GError **error);
PikaGuide * pika_pdb_image_get_guide (PikaImage *image,
gint guide_id,
GError **error);
PikaSamplePoint * pika_pdb_image_get_sample_point (PikaImage *image,
gint sample_point_id,
GError **error);
PikaStroke * pika_pdb_get_vectors_stroke (PikaVectors *vectors,
gint stroke_id,
PikaPDBItemModify modify,
GError **error);
gboolean pika_pdb_is_canonical_procedure (const gchar *procedure_name,
GError **error);
#endif /* __PIKA_PDB_UTILS_H__ */

579
app/pdb/pikapdb.c Normal file
View File

@ -0,0 +1,579 @@
/* 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 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/>.
*/
#include "config.h"
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <gobject/gvaluecollector.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pika.h"
#include "core/pikaitem.h"
#include "core/pika-memsize.h"
#include "core/pikacontext.h"
#include "core/pikaprogress.h"
#include "pikapdb.h"
#include "pikapdberror.h"
#include "pikaprocedure.h"
#include "pika-intl.h"
enum
{
REGISTER_PROCEDURE,
UNREGISTER_PROCEDURE,
LAST_SIGNAL
};
static void pika_pdb_finalize (GObject *object);
static gint64 pika_pdb_get_memsize (PikaObject *object,
gint64 *gui_size);
static void pika_pdb_real_register_procedure (PikaPDB *pdb,
PikaProcedure *procedure);
static void pika_pdb_real_unregister_procedure (PikaPDB *pdb,
PikaProcedure *procedure);
static void pika_pdb_entry_free (gpointer key,
gpointer value,
gpointer user_data);
static gint64 pika_pdb_entry_get_memsize (GList *procedures,
gint64 *gui_size);
G_DEFINE_TYPE (PikaPDB, pika_pdb, PIKA_TYPE_OBJECT)
#define parent_class pika_pdb_parent_class
static guint pika_pdb_signals[LAST_SIGNAL] = { 0 };
static void
pika_pdb_class_init (PikaPDBClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
PikaObjectClass *pika_object_class = PIKA_OBJECT_CLASS (klass);
pika_pdb_signals[REGISTER_PROCEDURE] =
g_signal_new ("register-procedure",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (PikaPDBClass, register_procedure),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
PIKA_TYPE_PROCEDURE);
pika_pdb_signals[UNREGISTER_PROCEDURE] =
g_signal_new ("unregister-procedure",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (PikaPDBClass, unregister_procedure),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
PIKA_TYPE_PROCEDURE);
object_class->finalize = pika_pdb_finalize;
pika_object_class->get_memsize = pika_pdb_get_memsize;
klass->register_procedure = pika_pdb_real_register_procedure;
klass->unregister_procedure = pika_pdb_real_unregister_procedure;
}
static void
pika_pdb_init (PikaPDB *pdb)
{
pdb->procedures = g_hash_table_new (g_str_hash, g_str_equal);
pdb->compat_proc_names = g_hash_table_new (g_str_hash, g_str_equal);
}
static void
pika_pdb_finalize (GObject *object)
{
PikaPDB *pdb = PIKA_PDB (object);
if (pdb->procedures)
{
g_hash_table_foreach (pdb->procedures, pika_pdb_entry_free, NULL);
g_hash_table_destroy (pdb->procedures);
pdb->procedures = NULL;
}
if (pdb->compat_proc_names)
{
g_hash_table_destroy (pdb->compat_proc_names);
pdb->compat_proc_names = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gint64
pika_pdb_get_memsize (PikaObject *object,
gint64 *gui_size)
{
PikaPDB *pdb = PIKA_PDB (object);
gint64 memsize = 0;
memsize += pika_g_hash_table_get_memsize_foreach (pdb->procedures,
(PikaMemsizeFunc)
pika_pdb_entry_get_memsize,
gui_size);
memsize += pika_g_hash_table_get_memsize (pdb->compat_proc_names, 0);
return memsize + PIKA_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
}
static void
pika_pdb_real_register_procedure (PikaPDB *pdb,
PikaProcedure *procedure)
{
const gchar *name;
GList *list;
name = pika_object_get_name (procedure);
list = g_hash_table_lookup (pdb->procedures, name);
g_hash_table_replace (pdb->procedures, (gpointer) name,
g_list_prepend (list, g_object_ref (procedure)));
}
static void
pika_pdb_real_unregister_procedure (PikaPDB *pdb,
PikaProcedure *procedure)
{
const gchar *name;
GList *list;
name = pika_object_get_name (procedure);
list = g_hash_table_lookup (pdb->procedures, name);
if (list)
{
list = g_list_remove (list, procedure);
if (list)
{
name = pika_object_get_name (list->data);
g_hash_table_replace (pdb->procedures, (gpointer) name, list);
}
else
{
g_hash_table_remove (pdb->procedures, name);
}
g_object_unref (procedure);
}
}
/* public functions */
PikaPDB *
pika_pdb_new (Pika *pika)
{
PikaPDB *pdb;
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
pdb = g_object_new (PIKA_TYPE_PDB,
"name", "pdb",
NULL);
pdb->pika = pika;
return pdb;
}
void
pika_pdb_register_procedure (PikaPDB *pdb,
PikaProcedure *procedure)
{
g_return_if_fail (PIKA_IS_PDB (pdb));
g_return_if_fail (PIKA_IS_PROCEDURE (procedure));
if (! procedure->deprecated ||
pdb->pika->pdb_compat_mode != PIKA_PDB_COMPAT_OFF)
{
g_signal_emit (pdb, pika_pdb_signals[REGISTER_PROCEDURE], 0,
procedure);
}
}
void
pika_pdb_unregister_procedure (PikaPDB *pdb,
PikaProcedure *procedure)
{
g_return_if_fail (PIKA_IS_PDB (pdb));
g_return_if_fail (PIKA_IS_PROCEDURE (procedure));
g_signal_emit (pdb, pika_pdb_signals[UNREGISTER_PROCEDURE], 0,
procedure);
}
PikaProcedure *
pika_pdb_lookup_procedure (PikaPDB *pdb,
const gchar *name)
{
GList *list;
g_return_val_if_fail (PIKA_IS_PDB (pdb), NULL);
g_return_val_if_fail (name != NULL, NULL);
list = g_hash_table_lookup (pdb->procedures, name);
if (list)
return list->data;
return NULL;
}
void
pika_pdb_register_compat_proc_name (PikaPDB *pdb,
const gchar *old_name,
const gchar *new_name)
{
g_return_if_fail (PIKA_IS_PDB (pdb));
g_return_if_fail (old_name != NULL);
g_return_if_fail (new_name != NULL);
g_hash_table_insert (pdb->compat_proc_names,
(gpointer) old_name,
(gpointer) new_name);
}
const gchar *
pika_pdb_lookup_compat_proc_name (PikaPDB *pdb,
const gchar *old_name)
{
g_return_val_if_fail (PIKA_IS_PDB (pdb), NULL);
g_return_val_if_fail (old_name != NULL, NULL);
return g_hash_table_lookup (pdb->compat_proc_names, old_name);
}
PikaValueArray *
pika_pdb_execute_procedure_by_name_args (PikaPDB *pdb,
PikaContext *context,
PikaProgress *progress,
GError **error,
const gchar *name,
PikaValueArray *args)
{
PikaValueArray *return_vals = NULL;
GList *list;
g_return_val_if_fail (PIKA_IS_PDB (pdb), NULL);
g_return_val_if_fail (PIKA_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || PIKA_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
list = g_hash_table_lookup (pdb->procedures, name);
if (list == NULL)
{
GError *pdb_error = g_error_new (PIKA_PDB_ERROR,
PIKA_PDB_ERROR_PROCEDURE_NOT_FOUND,
_("Procedure '%s' not found"), name);
return_vals = pika_procedure_get_return_values (NULL, FALSE, pdb_error);
g_propagate_error (error, pdb_error);
return return_vals;
}
g_return_val_if_fail (args != NULL, NULL);
for (; list; list = g_list_next (list))
{
PikaProcedure *procedure = list->data;
g_return_val_if_fail (PIKA_IS_PROCEDURE (procedure), NULL);
return_vals = pika_procedure_execute (procedure,
pdb->pika, context, progress,
args, error);
if (g_value_get_enum (pika_value_array_index (return_vals, 0)) ==
PIKA_PDB_PASS_THROUGH)
{
/* If the return value is PIKA_PDB_PASS_THROUGH and there is
* a next procedure in the list, destroy the return values
* and run the next procedure.
*/
if (g_list_next (list))
{
pika_value_array_unref (return_vals);
g_clear_error (error);
}
}
else
{
/* No PIKA_PDB_PASS_THROUGH, break out of the list of
* procedures and return the current return values.
*/
break;
}
}
return return_vals;
}
PikaValueArray *
pika_pdb_execute_procedure_by_name (PikaPDB *pdb,
PikaContext *context,
PikaProgress *progress,
GError **error,
const gchar *name,
...)
{
PikaProcedure *procedure;
PikaValueArray *args;
PikaValueArray *return_vals;
va_list va_args;
GType prev_value_type = G_TYPE_NONE;
gint prev_int_value = 0;
gint i;
g_return_val_if_fail (PIKA_IS_PDB (pdb), NULL);
g_return_val_if_fail (PIKA_IS_CONTEXT (context), NULL);
g_return_val_if_fail (progress == NULL || PIKA_IS_PROGRESS (progress), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
procedure = pika_pdb_lookup_procedure (pdb, name);
if (! procedure)
{
GError *pdb_error = g_error_new (PIKA_PDB_ERROR,
PIKA_PDB_ERROR_PROCEDURE_NOT_FOUND,
_("Procedure '%s' not found"), name);
return_vals = pika_procedure_get_return_values (NULL, FALSE, pdb_error);
g_propagate_error (error, pdb_error);
return return_vals;
}
args = pika_procedure_get_arguments (procedure);
va_start (va_args, name);
for (i = 0; i < procedure->num_args; i++)
{
GValue *value;
GType arg_type;
GType value_type;
gchar *error_msg = NULL;
arg_type = va_arg (va_args, GType);
if (arg_type == G_TYPE_NONE)
break;
value = pika_value_array_index (args, i);
value_type = G_VALUE_TYPE (value);
/* G_TYPE_INT is widely abused for enums and booleans in
* old plug-ins, silently copy stuff into integers when enums
* and booleans are passed
*/
if (arg_type != value_type
&&
value_type == G_TYPE_INT
&&
(arg_type == G_TYPE_BOOLEAN ||
g_type_is_a (arg_type, G_TYPE_ENUM)))
{
arg_type = value_type;
}
if (arg_type != value_type)
{
GError *pdb_error;
const gchar *expected = g_type_name (value_type);
const gchar *got = g_type_name (arg_type);
pika_value_array_unref (args);
pdb_error = g_error_new (PIKA_PDB_ERROR,
PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Procedure '%s' has been called with a "
"wrong type for argument #%d. "
"Expected %s, got %s."),
pika_object_get_name (procedure),
i + 1, expected, got);
return_vals = pika_procedure_get_return_values (procedure,
FALSE, pdb_error);
g_propagate_error (error, pdb_error);
va_end (va_args);
return return_vals;
}
if (PIKA_VALUE_HOLDS_INT32_ARRAY (value) ||
PIKA_VALUE_HOLDS_FLOAT_ARRAY (value) ||
PIKA_VALUE_HOLDS_RGB_ARRAY (value) ||
PIKA_VALUE_HOLDS_OBJECT_ARRAY (value))
{
/* Array arguments don't have their size information when they
* are set by core code, in C array form.
* By convention, the previous argument has to be the array
* size argument.
*/
g_return_val_if_fail (prev_value_type == G_TYPE_INT && prev_int_value >= 0, NULL);
if (PIKA_VALUE_HOLDS_INT32_ARRAY (value))
pika_value_set_int32_array (value,
(const gint32 *) va_arg (va_args, gpointer),
prev_int_value);
else if (PIKA_VALUE_HOLDS_FLOAT_ARRAY (value))
pika_value_set_float_array (value,
(const gdouble *) va_arg (va_args, gpointer),
prev_int_value);
else if (PIKA_VALUE_HOLDS_RGB_ARRAY (value))
pika_value_set_rgb_array (value,
(const PikaRGB *) va_arg (va_args, gpointer),
prev_int_value);
else if (PIKA_VALUE_HOLDS_OBJECT_ARRAY (value))
pika_value_set_object_array (value, PIKA_TYPE_ITEM,
va_arg (va_args, gpointer),
prev_int_value);
}
else
{
G_VALUE_COLLECT (value, va_args, G_VALUE_NOCOPY_CONTENTS, &error_msg);
}
if (error_msg)
{
GError *pdb_error = g_error_new_literal (PIKA_PDB_ERROR,
PIKA_PDB_ERROR_INTERNAL_ERROR,
error_msg);
g_warning ("%s: %s", G_STRFUNC, error_msg);
g_free (error_msg);
pika_value_array_unref (args);
return_vals = pika_procedure_get_return_values (procedure,
FALSE, pdb_error);
g_propagate_error (error, pdb_error);
va_end (va_args);
return return_vals;
}
prev_value_type = value_type;
if (prev_value_type == G_TYPE_INT)
prev_int_value = g_value_get_int (value);
}
va_end (va_args);
return_vals = pika_pdb_execute_procedure_by_name_args (pdb, context,
progress, error,
name, args);
pika_value_array_unref (args);
return return_vals;
}
/**
* pika_pdb_get_deprecated_procedures:
* @pdb:
*
* Returns: A new #GList with the deprecated procedures. Free with
* g_list_free().
**/
GList *
pika_pdb_get_deprecated_procedures (PikaPDB *pdb)
{
GList *result = NULL;
GList *procs;
GList *iter;
g_return_val_if_fail (PIKA_IS_PDB (pdb), NULL);
procs = g_hash_table_get_values (pdb->procedures);
for (iter = procs;
iter;
iter = g_list_next (iter))
{
GList *proc_list = iter->data;
/* Only care about the first procedure in the list */
PikaProcedure *procedure = PIKA_PROCEDURE (proc_list->data);
if (procedure->deprecated)
result = g_list_prepend (result, procedure);
}
result = g_list_sort (result, (GCompareFunc) pika_procedure_name_compare);
g_list_free (procs);
return result;
}
/* private functions */
static void
pika_pdb_entry_free (gpointer key,
gpointer value,
gpointer user_data)
{
if (value)
g_list_free_full (value, (GDestroyNotify) g_object_unref);
}
static gint64
pika_pdb_entry_get_memsize (GList *procedures,
gint64 *gui_size)
{
return pika_g_list_get_memsize_foreach (procedures,
(PikaMemsizeFunc)
pika_object_get_memsize,
gui_size);
}

94
app/pdb/pikapdb.h Normal file
View File

@ -0,0 +1,94 @@
/* 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 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/>.
*/
#ifndef __PIKA_PDB_H__
#define __PIKA_PDB_H__
#include "core/pikaobject.h"
#define PIKA_TYPE_PDB (pika_pdb_get_type ())
#define PIKA_PDB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_PDB, PikaPDB))
#define PIKA_PDB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_PDB, PikaPDBClass))
#define PIKA_IS_PDB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_PDB))
#define PIKA_IS_PDB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_PDB))
#define PIKA_PDB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_PDB, PikaPDBClass))
typedef struct _PikaPDBClass PikaPDBClass;
struct _PikaPDB
{
PikaObject parent_instance;
Pika *pika;
GHashTable *procedures;
GHashTable *compat_proc_names;
};
struct _PikaPDBClass
{
PikaObjectClass parent_class;
void (* register_procedure) (PikaPDB *pdb,
PikaProcedure *procedure);
void (* unregister_procedure) (PikaPDB *pdb,
PikaProcedure *procedure);
};
GType pika_pdb_get_type (void) G_GNUC_CONST;
PikaPDB * pika_pdb_new (Pika *pika);
void pika_pdb_register_procedure (PikaPDB *pdb,
PikaProcedure *procedure);
void pika_pdb_unregister_procedure (PikaPDB *pdb,
PikaProcedure *procedure);
PikaProcedure * pika_pdb_lookup_procedure (PikaPDB *pdb,
const gchar *name);
void pika_pdb_register_compat_proc_name (PikaPDB *pdb,
const gchar *old_name,
const gchar *new_name);
const gchar * pika_pdb_lookup_compat_proc_name (PikaPDB *pdb,
const gchar *old_name);
PikaValueArray * pika_pdb_execute_procedure_by_name_args (PikaPDB *pdb,
PikaContext *context,
PikaProgress *progress,
GError **error,
const gchar *name,
PikaValueArray *args);
PikaValueArray * pika_pdb_execute_procedure_by_name (PikaPDB *pdb,
PikaContext *context,
PikaProgress *progress,
GError **error,
const gchar *name,
...);
GList * pika_pdb_get_deprecated_procedures (PikaPDB *pdb);
#endif /* __PIKA_PDB_H__ */

564
app/pdb/pikapdbcontext.c Normal file
View File

@ -0,0 +1,564 @@
/* 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-1999 Spencer Kimball and Peter Mattis
*
* pikapdbcontext.c
*
* 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/>.
*/
#include "config.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "pdb-types.h"
#include "config/pikacoreconfig.h"
#include "core/pika.h"
#include "core/pikalist.h"
#include "core/pikapaintinfo.h"
#include "core/pikastrokeoptions.h"
#include "paint/pikabrushcore.h"
#include "paint/pikapaintoptions.h"
#include "pikapdbcontext.h"
#include "pika-intl.h"
enum
{
PROP_0,
PROP_ANTIALIAS,
PROP_FEATHER,
PROP_FEATHER_RADIUS_X,
PROP_FEATHER_RADIUS_Y,
PROP_SAMPLE_MERGED,
PROP_SAMPLE_CRITERION,
PROP_SAMPLE_THRESHOLD,
PROP_SAMPLE_TRANSPARENT,
PROP_DIAGONAL_NEIGHBORS,
PROP_INTERPOLATION,
PROP_TRANSFORM_DIRECTION,
PROP_TRANSFORM_RESIZE,
PROP_DISTANCE_METRIC
};
static void pika_pdb_context_iface_init (PikaConfigInterface *iface);
static void pika_pdb_context_constructed (GObject *object);
static void pika_pdb_context_finalize (GObject *object);
static void pika_pdb_context_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_pdb_context_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void pika_pdb_context_reset (PikaConfig *config);
G_DEFINE_TYPE_WITH_CODE (PikaPDBContext, pika_pdb_context, PIKA_TYPE_CONTEXT,
G_IMPLEMENT_INTERFACE (PIKA_TYPE_CONFIG,
pika_pdb_context_iface_init))
#define parent_class pika_pdb_context_parent_class
static PikaConfigInterface *parent_config_iface = NULL;
static void
pika_pdb_context_class_init (PikaPDBContextClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = pika_pdb_context_constructed;
object_class->finalize = pika_pdb_context_finalize;
object_class->set_property = pika_pdb_context_set_property;
object_class->get_property = pika_pdb_context_get_property;
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
"antialias",
_("Antialiasing"),
_("Smooth edges"),
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_FEATHER,
"feather",
_("Feather"),
NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_DOUBLE (object_class, PROP_FEATHER_RADIUS_X,
"feather-radius-x",
_("Feather radius X"),
NULL,
0.0, 1000.0, 10.0,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_DOUBLE (object_class, PROP_FEATHER_RADIUS_Y,
"feather-radius-y",
_("Feather radius Y"),
NULL,
0.0, 1000.0, 10.0,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
"sample-merged",
_("Sample merged"),
NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_SAMPLE_CRITERION,
"sample-criterion",
_("Sample criterion"),
NULL,
PIKA_TYPE_SELECT_CRITERION,
PIKA_SELECT_CRITERION_COMPOSITE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_DOUBLE (object_class, PROP_SAMPLE_THRESHOLD,
"sample-threshold",
_("Sample threshold"),
NULL,
0.0, 1.0, 0.0,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SAMPLE_TRANSPARENT,
"sample-transparent",
_("Sample transparent"),
NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DIAGONAL_NEIGHBORS,
"diagonal-neighbors",
_("Diagonal neighbors"),
NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_INTERPOLATION,
"interpolation",
_("Interpolation"),
NULL,
PIKA_TYPE_INTERPOLATION_TYPE,
PIKA_INTERPOLATION_CUBIC,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_TRANSFORM_DIRECTION,
"transform-direction",
_("Transform direction"),
NULL,
PIKA_TYPE_TRANSFORM_DIRECTION,
PIKA_TRANSFORM_FORWARD,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_TRANSFORM_RESIZE,
"transform-resize",
_("Transform resize"),
NULL,
PIKA_TYPE_TRANSFORM_RESIZE,
PIKA_TRANSFORM_RESIZE_ADJUST,
PIKA_PARAM_STATIC_STRINGS);
/* Legacy blend used "manhattan" metric to compute distance.
* API needs to stay compatible, hence the default value for this
* property.
* Nevertheless Euclidean distance since to render better; for PIKA 3
* API, we might therefore want to change the defaults to
* GEGL_DISTANCE_METRIC_EUCLIDEAN. FIXME.
*/
PIKA_CONFIG_PROP_ENUM (object_class, PROP_DISTANCE_METRIC,
"distance-metric",
_("Distance metric"),
NULL,
GEGL_TYPE_DISTANCE_METRIC,
GEGL_DISTANCE_METRIC_MANHATTAN,
PIKA_PARAM_STATIC_STRINGS);
}
static void
pika_pdb_context_iface_init (PikaConfigInterface *iface)
{
parent_config_iface = g_type_interface_peek_parent (iface);
if (! parent_config_iface)
parent_config_iface = g_type_default_interface_peek (PIKA_TYPE_CONFIG);
iface->reset = pika_pdb_context_reset;
}
static void
pika_pdb_context_init (PikaPDBContext *context)
{
context->paint_options_list = pika_list_new (PIKA_TYPE_PAINT_OPTIONS,
FALSE);
}
static void
pika_pdb_context_constructed (GObject *object)
{
PikaPDBContext *context = PIKA_PDB_CONTEXT (object);
PikaInterpolationType interpolation;
gint threshold;
GParamSpec *pspec;
G_OBJECT_CLASS (parent_class)->constructed (object);
context->stroke_options = pika_stroke_options_new (PIKA_CONTEXT (context)->pika,
PIKA_CONTEXT (context),
TRUE);
/* keep the stroke options in sync with the context */
pika_context_define_properties (PIKA_CONTEXT (context->stroke_options),
PIKA_CONTEXT_PROP_MASK_ALL, FALSE);
pika_context_set_parent (PIKA_CONTEXT (context->stroke_options),
PIKA_CONTEXT (context));
/* preserve the traditional PDB default */
g_object_set (context->stroke_options,
"method", PIKA_STROKE_PAINT_METHOD,
NULL);
g_object_bind_property (G_OBJECT (context), "antialias",
G_OBJECT (context->stroke_options), "antialias",
G_BINDING_SYNC_CREATE);
/* get default interpolation from pikarc */
interpolation = PIKA_CONTEXT (object)->pika->config->interpolation_type;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
"interpolation");
if (pspec)
G_PARAM_SPEC_ENUM (pspec)->default_value = interpolation;
g_object_set (object, "interpolation", interpolation, NULL);
/* get default threshold from pikarc */
threshold = PIKA_CONTEXT (object)->pika->config->default_threshold;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
"sample-threshold");
if (pspec)
G_PARAM_SPEC_DOUBLE (pspec)->default_value = threshold / 255.0;
g_object_set (object, "sample-threshold", threshold / 255.0, NULL);
}
static void
pika_pdb_context_finalize (GObject *object)
{
PikaPDBContext *context = PIKA_PDB_CONTEXT (object);
g_clear_object (&context->paint_options_list);
g_clear_object (&context->stroke_options);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pika_pdb_context_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaPDBContext *options = PIKA_PDB_CONTEXT (object);
switch (property_id)
{
case PROP_ANTIALIAS:
options->antialias = g_value_get_boolean (value);
break;
case PROP_FEATHER:
options->feather = g_value_get_boolean (value);
break;
case PROP_FEATHER_RADIUS_X:
options->feather_radius_x = g_value_get_double (value);
break;
case PROP_FEATHER_RADIUS_Y:
options->feather_radius_y = g_value_get_double (value);
break;
case PROP_SAMPLE_MERGED:
options->sample_merged = g_value_get_boolean (value);
break;
case PROP_SAMPLE_CRITERION:
options->sample_criterion = g_value_get_enum (value);
break;
case PROP_SAMPLE_THRESHOLD:
options->sample_threshold = g_value_get_double (value);
break;
case PROP_SAMPLE_TRANSPARENT:
options->sample_transparent = g_value_get_boolean (value);
break;
case PROP_DIAGONAL_NEIGHBORS:
options->diagonal_neighbors = g_value_get_boolean (value);
break;
case PROP_INTERPOLATION:
options->interpolation = g_value_get_enum (value);
break;
case PROP_TRANSFORM_DIRECTION:
options->transform_direction = g_value_get_enum (value);
break;
case PROP_TRANSFORM_RESIZE:
options->transform_resize = g_value_get_enum (value);
break;
case PROP_DISTANCE_METRIC:
options->distance_metric = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_pdb_context_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaPDBContext *options = PIKA_PDB_CONTEXT (object);
switch (property_id)
{
case PROP_ANTIALIAS:
g_value_set_boolean (value, options->antialias);
break;
case PROP_FEATHER:
g_value_set_boolean (value, options->feather);
break;
case PROP_FEATHER_RADIUS_X:
g_value_set_double (value, options->feather_radius_x);
break;
case PROP_FEATHER_RADIUS_Y:
g_value_set_double (value, options->feather_radius_y);
break;
case PROP_SAMPLE_MERGED:
g_value_set_boolean (value, options->sample_merged);
break;
case PROP_SAMPLE_CRITERION:
g_value_set_enum (value, options->sample_criterion);
break;
case PROP_SAMPLE_THRESHOLD:
g_value_set_double (value, options->sample_threshold);
break;
case PROP_SAMPLE_TRANSPARENT:
g_value_set_boolean (value, options->sample_transparent);
break;
case PROP_DIAGONAL_NEIGHBORS:
g_value_set_boolean (value, options->diagonal_neighbors);
break;
case PROP_INTERPOLATION:
g_value_set_enum (value, options->interpolation);
break;
case PROP_TRANSFORM_DIRECTION:
g_value_set_enum (value, options->transform_direction);
break;
case PROP_TRANSFORM_RESIZE:
g_value_set_enum (value, options->transform_resize);
break;
case PROP_DISTANCE_METRIC:
g_value_set_enum (value, options->distance_metric);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_pdb_context_reset (PikaConfig *config)
{
PikaPDBContext *context = PIKA_PDB_CONTEXT (config);
GList *list;
for (list = PIKA_LIST (context->paint_options_list)->queue->head;
list;
list = g_list_next (list))
{
pika_config_reset (list->data);
}
pika_config_reset (PIKA_CONFIG (context->stroke_options));
/* preserve the traditional PDB default */
g_object_set (context->stroke_options,
"method", PIKA_STROKE_PAINT_METHOD,
NULL);
parent_config_iface->reset (config);
g_object_notify (G_OBJECT (context), "antialias");
}
PikaContext *
pika_pdb_context_new (Pika *pika,
PikaContext *parent,
gboolean set_parent)
{
PikaPDBContext *context;
GList *list;
g_return_val_if_fail (PIKA_IS_PIKA (pika), NULL);
g_return_val_if_fail (PIKA_IS_CONTEXT (parent), NULL);
context = g_object_new (PIKA_TYPE_PDB_CONTEXT,
"pika", pika,
"name", "PDB Context",
NULL);
if (set_parent)
{
pika_context_define_properties (PIKA_CONTEXT (context),
PIKA_CONTEXT_PROP_MASK_ALL, FALSE);
pika_context_set_parent (PIKA_CONTEXT (context), parent);
for (list = pika_get_paint_info_iter (pika);
list;
list = g_list_next (list))
{
PikaPaintInfo *info = list->data;
pika_container_add (context->paint_options_list,
PIKA_OBJECT (info->paint_options));
}
}
else
{
for (list = PIKA_LIST (PIKA_PDB_CONTEXT (parent)->paint_options_list)->queue->head;
list;
list = g_list_next (list))
{
PikaPaintOptions *options = pika_config_duplicate (list->data);
pika_container_add (context->paint_options_list,
PIKA_OBJECT (options));
g_object_unref (options);
}
pika_config_copy (PIKA_CONFIG (PIKA_PDB_CONTEXT (parent)->stroke_options),
PIKA_CONFIG (context->stroke_options),
0);
}
/* copy the context properties last, they might have been
* overwritten by the above copying of stroke options, which have
* the pdb context as parent
*/
pika_config_sync (G_OBJECT (parent), G_OBJECT (context), 0);
/* Reset the proper init name after syncing. */
g_object_set (G_OBJECT (context),
"name", "PDB Context",
NULL);
return PIKA_CONTEXT (context);
}
PikaContainer *
pika_pdb_context_get_paint_options_list (PikaPDBContext *context)
{
g_return_val_if_fail (PIKA_IS_PDB_CONTEXT (context), NULL);
return context->paint_options_list;
}
PikaPaintOptions *
pika_pdb_context_get_paint_options (PikaPDBContext *context,
const gchar *name)
{
g_return_val_if_fail (PIKA_IS_PDB_CONTEXT (context), NULL);
if (! name)
name = pika_object_get_name (pika_context_get_paint_info (PIKA_CONTEXT (context)));
return (PikaPaintOptions *)
pika_container_get_child_by_name (context->paint_options_list, name);
}
GList *
pika_pdb_context_get_brush_options (PikaPDBContext *context)
{
GList *brush_options = NULL;
GList *list;
g_return_val_if_fail (PIKA_IS_PDB_CONTEXT (context), NULL);
for (list = PIKA_LIST (context->paint_options_list)->queue->head;
list;
list = g_list_next (list))
{
PikaPaintOptions *options = list->data;
if (g_type_is_a (options->paint_info->paint_type, PIKA_TYPE_BRUSH_CORE))
brush_options = g_list_prepend (brush_options, options);
}
return g_list_reverse (brush_options);
}
PikaStrokeOptions *
pika_pdb_context_get_stroke_options (PikaPDBContext *context)
{
g_return_val_if_fail (PIKA_IS_PDB_CONTEXT (context), NULL);
return context->stroke_options;
}

87
app/pdb/pikapdbcontext.h Normal file
View File

@ -0,0 +1,87 @@
/* 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-1999 Spencer Kimball and Peter Mattis
*
* pikapdbcontext.h
*
* 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/>.
*/
#ifndef __PIKA_PDB_CONTEXT_H__
#define __PIKA_PDB_CONTEXT_H__
#include "core/pikacontext.h"
#define PIKA_TYPE_PDB_CONTEXT (pika_pdb_context_get_type ())
#define PIKA_PDB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_PDB_CONTEXT, PikaPDBContext))
#define PIKA_PDB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_PDB_CONTEXT, PikaPDBContextClass))
#define PIKA_IS_PDB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_PDB_CONTEXT))
#define PIKA_IS_PDB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_PDB_CONTEXT))
#define PIKA_PDB_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_PDB_CONTEXT, PikaPDBContextClass))
typedef struct _PikaPDBContext PikaPDBContext;
typedef struct _PikaPDBContextClass PikaPDBContextClass;
struct _PikaPDBContext
{
PikaContext parent_instance;
gboolean antialias;
gboolean feather;
gdouble feather_radius_x;
gdouble feather_radius_y;
gboolean sample_merged;
PikaSelectCriterion sample_criterion;
gdouble sample_threshold;
gboolean sample_transparent;
gboolean diagonal_neighbors;
PikaInterpolationType interpolation;
PikaTransformDirection transform_direction;
PikaTransformResize transform_resize;
PikaContainer *paint_options_list;
PikaStrokeOptions *stroke_options;
GeglDistanceMetric distance_metric;
};
struct _PikaPDBContextClass
{
PikaContextClass parent_class;
};
GType pika_pdb_context_get_type (void) G_GNUC_CONST;
PikaContext * pika_pdb_context_new (Pika *pika,
PikaContext *parent,
gboolean set_parent);
PikaContainer * pika_pdb_context_get_paint_options_list
(PikaPDBContext *context);
PikaPaintOptions * pika_pdb_context_get_paint_options (PikaPDBContext *context,
const gchar *name);
GList * pika_pdb_context_get_brush_options (PikaPDBContext *context);
PikaStrokeOptions * pika_pdb_context_get_stroke_options (PikaPDBContext *context);
#endif /* __PIKA_PDB_CONTEXT_H__ */

40
app/pdb/pikapdberror.c Normal file
View File

@ -0,0 +1,40 @@
/* 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 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/>.
*/
#include "config.h"
#include <glib-object.h>
#include "pikapdberror.h"
/**
* pika_pdb_error_quark:
*
* This function is never called directly. Use PIKA_PDB_ERROR() instead.
*
* Returns: the #GQuark that defines the PikaPlugIn error domain.
**/
GQuark
pika_pdb_error_quark (void)
{
return g_quark_from_static_string ("pika-pdb-error-quark");
}

42
app/pdb/pikapdberror.h Normal file
View File

@ -0,0 +1,42 @@
/* 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 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/>.
*/
#ifndef __PIKA_PDB_ERROR_H__
#define __PIKA_PDB_ERROR_H__
typedef enum
{
PIKA_PDB_ERROR_FAILED, /* generic error condition */
PIKA_PDB_ERROR_CANCELLED,
PIKA_PDB_ERROR_PROCEDURE_NOT_FOUND,
PIKA_PDB_ERROR_INVALID_ARGUMENT,
PIKA_PDB_ERROR_INVALID_RETURN_VALUE,
PIKA_PDB_ERROR_INTERNAL_ERROR
} PikaPdbErrorCode;
#define PIKA_PDB_ERROR (pika_pdb_error_quark ())
GQuark pika_pdb_error_quark (void) G_GNUC_CONST;
#endif /* __PIKA_PDB_ERROR_H__ */

1056
app/pdb/pikaprocedure.c Normal file

File diff suppressed because it is too large Load Diff

178
app/pdb/pikaprocedure.h Normal file
View File

@ -0,0 +1,178 @@
/* 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 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/>.
*/
#ifndef __PIKA_PROCEDURE_H__
#define __PIKA_PROCEDURE_H__
#include "core/pikaviewable.h"
typedef PikaValueArray * (* PikaMarshalFunc) (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error);
#define PIKA_TYPE_PROCEDURE (pika_procedure_get_type ())
#define PIKA_PROCEDURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_PROCEDURE, PikaProcedure))
#define PIKA_PROCEDURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_PROCEDURE, PikaProcedureClass))
#define PIKA_IS_PROCEDURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_PROCEDURE))
#define PIKA_IS_PROCEDURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_PROCEDURE))
#define PIKA_PROCEDURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_PROCEDURE, PikaProcedureClass))
typedef struct _PikaProcedureClass PikaProcedureClass;
struct _PikaProcedure
{
PikaViewable parent_instance;
PikaPDBProcType proc_type; /* Type of procedure */
gboolean static_help; /* Are the strings allocated? */
gchar *blurb; /* Short procedure description */
gchar *help; /* Detailed help instructions */
gchar *help_id; /* Help ID */
gboolean static_attribution;
gchar *authors; /* Authors field */
gchar *copyright; /* Copyright field */
gchar *date; /* Date field */
gchar *deprecated; /* Replacement if deprecated */
gchar *label; /* Cached label string */
gint32 num_args; /* Number of procedure arguments */
GParamSpec **args; /* Array of procedure arguments */
gint32 num_values; /* Number of return values */
GParamSpec **values; /* Array of return values */
PikaMarshalFunc marshal_func; /* Marshaller for internal procs */
};
struct _PikaProcedureClass
{
PikaViewableClass parent_class;
const gchar * (* get_label) (PikaProcedure *procedure);
const gchar * (* get_menu_label) (PikaProcedure *procedure);
const gchar * (* get_blurb) (PikaProcedure *procedure);
const gchar * (* get_help_id) (PikaProcedure *procedure);
gboolean (* get_sensitive) (PikaProcedure *procedure,
PikaObject *object,
const gchar **reason);
PikaValueArray * (* execute) (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
PikaValueArray *args,
GError **error);
void (* execute_async) (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
PikaValueArray *args,
PikaDisplay *display);
};
GType pika_procedure_get_type (void) G_GNUC_CONST;
PikaProcedure * pika_procedure_new (PikaMarshalFunc marshal_func);
void pika_procedure_set_help (PikaProcedure *procedure,
const gchar *blurb,
const gchar *help,
const gchar *help_id);
void pika_procedure_set_static_help (PikaProcedure *procedure,
const gchar *blurb,
const gchar *help,
const gchar *help_id);
void pika_procedure_take_help (PikaProcedure *procedure,
gchar *blurb,
gchar *help,
gchar *help_id);
void pika_procedure_set_attribution (PikaProcedure *procedure,
const gchar *authors,
const gchar *copyright,
const gchar *date);
void pika_procedure_set_static_attribution
(PikaProcedure *procedure,
const gchar *authors,
const gchar *copyright,
const gchar *date);
void pika_procedure_take_attribution (PikaProcedure *procedure,
gchar *authors,
gchar *copyright,
gchar *date);
void pika_procedure_set_deprecated (PikaProcedure *procedure,
const gchar *deprecated);
const gchar * pika_procedure_get_label (PikaProcedure *procedure);
const gchar * pika_procedure_get_menu_label (PikaProcedure *procedure);
const gchar * pika_procedure_get_blurb (PikaProcedure *procedure);
const gchar * pika_procedure_get_help (PikaProcedure *procedure);
const gchar * pika_procedure_get_help_id (PikaProcedure *procedure);
gboolean pika_procedure_get_sensitive (PikaProcedure *procedure,
PikaObject *object,
const gchar **reason);
void pika_procedure_add_argument (PikaProcedure *procedure,
GParamSpec *pspec);
void pika_procedure_add_return_value (PikaProcedure *procedure,
GParamSpec *pspec);
PikaValueArray * pika_procedure_get_arguments (PikaProcedure *procedure);
PikaValueArray * pika_procedure_get_return_values (PikaProcedure *procedure,
gboolean success,
const GError *error);
PikaProcedure * pika_procedure_create_override (PikaProcedure *procedure,
PikaMarshalFunc new_marshal_func);
PikaValueArray * pika_procedure_execute (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
PikaValueArray *args,
GError **error);
void pika_procedure_execute_async (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
PikaValueArray *args,
PikaDisplay *display,
GError **error);
gint pika_procedure_name_compare (PikaProcedure *proc1,
PikaProcedure *proc2);
#endif /* __PIKA_PROCEDURE_H__ */

412
app/pdb/pikarc-cmds.c Normal file
View File

@ -0,0 +1,412 @@
/* 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);
}

385
app/pdb/plug-in-cmds.c Normal file
View File

@ -0,0 +1,385 @@
/* 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);
}

File diff suppressed because it is too large Load Diff

508
app/pdb/progress-cmds.c Normal file
View File

@ -0,0 +1,508 @@
/* 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 "pdb-types.h"
#include "core/pika.h"
#include "core/pikaparamspecs.h"
#include "plug-in/pikaplugin-progress.h"
#include "plug-in/pikaplugin.h"
#include "plug-in/pikapluginmanager.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
progress_init_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *message;
PikaDisplay *gdisplay;
message = g_value_get_string (pika_value_array_index (args, 0));
gdisplay = 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->open)
{
if (! pika->no_interface)
pika_plug_in_progress_start (plug_in, message, gdisplay);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_update_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
gdouble percentage;
percentage = g_value_get_double (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
pika_plug_in_progress_set_value (plug_in, percentage);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_pulse_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
pika_plug_in_progress_pulse (plug_in);
}
else
success = FALSE;
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_set_text_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *message;
message = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
pika_plug_in_progress_set_text (plug_in, message);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_end_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
PikaPlugInProcFrame *proc_frame = pika_plug_in_get_proc_frame (plug_in);
pika_plug_in_progress_end (plug_in, proc_frame);
}
else
success = FALSE;
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_get_window_handle_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint window = 0;
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
window = pika_plug_in_progress_get_window_id (plug_in);
}
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), window);
return return_vals;
}
static PikaValueArray *
progress_install_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *progress_callback;
progress_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = pika_plug_in_progress_install (plug_in, progress_callback);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_uninstall_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *progress_callback;
progress_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = pika_plug_in_progress_uninstall (plug_in, progress_callback);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_cancel_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *progress_callback;
progress_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = pika_plug_in_progress_cancel (plug_in, progress_callback);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_progress_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-progress-init
*/
procedure = pika_procedure_new (progress_init_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-init");
pika_procedure_set_static_help (procedure,
"Initializes the progress bar for the current plug-in.",
"Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("message",
"message",
"Message to use in the progress dialog",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_display ("gdisplay",
"gdisplay",
"PikaDisplay to update progressbar in, or %NULL for a separate window",
TRUE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-update
*/
procedure = pika_procedure_new (progress_update_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-update");
pika_procedure_set_static_help (procedure,
"Updates the progress bar for the current plug-in.",
"Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
g_param_spec_double ("percentage",
"percentage",
"Percentage of progress completed which must be between 0.0 and 1.0",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-pulse
*/
procedure = pika_procedure_new (progress_pulse_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-pulse");
pika_procedure_set_static_help (procedure,
"Pulses the progress bar for the current plug-in.",
"Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in. Use this function instead of 'pika-progress-update' if you cannot tell how much progress has been made. This usually causes the the progress bar to enter \"activity mode\", where a block bounces back and forth.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-set-text
*/
procedure = pika_procedure_new (progress_set_text_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-set-text");
pika_procedure_set_static_help (procedure,
"Changes the text in the progress bar for the current plug-in.",
"This function changes the text in the progress bar for the current plug-in. Unlike 'pika-progress-init' it does not change the displayed value.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("message",
"message",
"Message to use in the progress dialog",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-end
*/
procedure = pika_procedure_new (progress_end_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-end");
pika_procedure_set_static_help (procedure,
"Ends the progress bar for the current plug-in.",
"Ends the progress display for the current plug-in. Most plug-ins don't need to call this, they just exit when the work is done. It is only valid to call this procedure from a plug-in.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2007");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-get-window-handle
*/
procedure = pika_procedure_new (progress_get_window_handle_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-get-window-handle");
pika_procedure_set_static_help (procedure,
"Returns the native window ID of the toplevel window this plug-in's progress is displayed in.",
"This function returns the native window ID of the toplevel window this plug-in\'s progress is displayed in.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_return_value (procedure,
g_param_spec_int ("window",
"window",
"The progress bar's toplevel window",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-install
*/
procedure = pika_procedure_new (progress_install_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-install");
pika_procedure_set_static_help (procedure,
"Installs a progress callback for the current plug-in.",
"This function installs a temporary PDB procedure which will handle all progress calls made by this plug-in and any procedure it calls. Calling this function multiple times simply replaces the old progress callbacks.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("progress-callback",
"progress callback",
"The callback PDB proc to call",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-uninstall
*/
procedure = pika_procedure_new (progress_uninstall_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-uninstall");
pika_procedure_set_static_help (procedure,
"Uninstalls the progress callback for the current plug-in.",
"This function uninstalls any progress callback installed with 'pika-progress-install' before.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("progress-callback",
"progress callback",
"The name of the callback registered for this progress",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-cancel
*/
procedure = pika_procedure_new (progress_cancel_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-cancel");
pika_procedure_set_static_help (procedure,
"Cancels a running progress.",
"This function cancels the currently running progress.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("progress-callback",
"progress callback",
"The name of the callback registered for this progress",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

959
app/pdb/resource-cmds.c Normal file
View File

@ -0,0 +1,959 @@
/* 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 "pdb-types.h"
#include "core/pikabrush.h"
#include "core/pikadatafactory.h"
#include "core/pikagradient.h"
#include "core/pikapalette.h"
#include "core/pikaparamspecs.h"
#include "core/pikapattern.h"
#include "core/pikaresource.h"
#include "text/pikafont.h"
#include "pikapdb.h"
#include "pikapdberror.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
resource_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 *type_name;
const gchar *resource_name;
PikaResource *resource = NULL;
type_name = g_value_get_string (pika_value_array_index (args, 0));
resource_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
resource = pika_pdb_get_resource (pika, g_type_from_name (type_name), resource_name,
PIKA_PDB_DATA_ACCESS_READ, error);
if (! resource)
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), resource);
return return_vals;
}
static PikaValueArray *
resource_get_by_identifiers_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *type_name;
const gchar *resource_name;
const gchar *collection;
gboolean is_internal;
PikaResource *resource = NULL;
type_name = g_value_get_string (pika_value_array_index (args, 0));
resource_name = g_value_get_string (pika_value_array_index (args, 1));
collection = g_value_get_string (pika_value_array_index (args, 2));
is_internal = g_value_get_boolean (pika_value_array_index (args, 3));
if (success)
{
resource = pika_pdb_get_resource_by_id (pika, g_type_from_name (type_name),
resource_name, collection, is_internal,
PIKA_PDB_DATA_ACCESS_READ, error);
if (! resource)
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), resource);
return return_vals;
}
static PikaValueArray *
resource_id_is_valid_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint resource_id;
gboolean valid = FALSE;
resource_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
PikaData *data = pika_data_get_by_id (resource_id);
valid = PIKA_IS_DATA (data);
}
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), valid);
return return_vals;
}
static PikaValueArray *
resource_id_is_brush_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint resource_id;
gboolean brush = FALSE;
resource_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
PikaData *data = pika_data_get_by_id (resource_id);
brush = PIKA_IS_BRUSH (data);
}
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), brush);
return return_vals;
}
static PikaValueArray *
resource_id_is_pattern_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint resource_id;
gboolean pattern = FALSE;
resource_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
PikaData *data = pika_data_get_by_id (resource_id);
pattern = PIKA_IS_PATTERN (data);
}
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), pattern);
return return_vals;
}
static PikaValueArray *
resource_id_is_gradient_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint resource_id;
gboolean gradient = FALSE;
resource_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
PikaData *data = pika_data_get_by_id (resource_id);
gradient = PIKA_IS_GRADIENT (data);
}
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), gradient);
return return_vals;
}
static PikaValueArray *
resource_id_is_palette_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint resource_id;
gboolean palette = FALSE;
resource_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
PikaData *data = pika_data_get_by_id (resource_id);
palette = PIKA_IS_PALETTE (data);
}
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), palette);
return return_vals;
}
static PikaValueArray *
resource_id_is_font_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint resource_id;
gboolean font = FALSE;
resource_id = g_value_get_int (pika_value_array_index (args, 0));
if (success)
{
PikaData *data = pika_data_get_by_id (resource_id);
font = PIKA_IS_FONT (data);
}
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), font);
return return_vals;
}
static PikaValueArray *
resource_get_name_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaResource *resource;
gchar *name = NULL;
resource = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
name = g_strdup (pika_object_get_name (PIKA_OBJECT (resource)));
}
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), name);
return return_vals;
}
static PikaValueArray *
resource_get_identifiers_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaResource *resource;
gboolean is_internal = FALSE;
gchar *name = NULL;
gchar *collection_id = NULL;
resource = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_data_get_identifiers (PIKA_DATA (resource), &name, &collection_id, &is_internal);
}
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), is_internal);
g_value_take_string (pika_value_array_index (return_vals, 2), name);
g_value_take_string (pika_value_array_index (return_vals, 3), collection_id);
}
return return_vals;
}
static PikaValueArray *
resource_is_editable_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaResource *resource;
gboolean editable = FALSE;
resource = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
editable = pika_data_is_writable (PIKA_DATA (resource));
}
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), editable);
return return_vals;
}
static PikaValueArray *
resource_duplicate_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaResource *resource;
PikaResource *resource_copy = NULL;
resource = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaDataFactory *factory;
factory = pika_pdb_get_data_factory (pika, G_TYPE_FROM_INSTANCE (resource));
resource_copy = (PikaResource *)
pika_data_factory_data_duplicate (factory, PIKA_DATA (resource));
if (! resource_copy)
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), resource_copy);
return return_vals;
}
static PikaValueArray *
resource_rename_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaResource *resource;
const gchar *new_name;
resource = g_value_get_object (pika_value_array_index (args, 0));
new_name = g_value_get_string (pika_value_array_index (args, 1));
if (success)
{
if (pika_viewable_is_name_editable (PIKA_VIEWABLE (resource)))
{
pika_object_set_name (PIKA_OBJECT (resource), new_name);
}
else
{
g_set_error (error, PIKA_PDB_ERROR, PIKA_PDB_ERROR_INVALID_ARGUMENT,
_("Resource '%s' is not renamable"),
pika_object_get_name (PIKA_OBJECT (resource)));
success = FALSE;
}
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
resource_delete_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaResource *resource;
resource = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
PikaDataFactory *factory;
factory = pika_pdb_get_data_factory (pika, G_TYPE_FROM_INSTANCE (resource));
if (pika_data_is_deletable (PIKA_DATA (resource)))
success = pika_data_factory_data_delete (factory, PIKA_DATA (resource),
TRUE, error);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_resource_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-resource-get-by-name
*/
procedure = pika_procedure_new (resource_get_by_name_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-get-by-name");
pika_procedure_set_static_help (procedure,
"Returns a resource with the given name.",
"Returns a resource with the given name.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("type-name",
"type name",
"The name of the resource type",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("resource-name",
"resource name",
"The name of the resource",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_resource ("resource",
"resource",
"The resource",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-get-by-identifiers
*/
procedure = pika_procedure_new (resource_get_by_identifiers_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-get-by-identifiers");
pika_procedure_set_static_help (procedure,
"Returns the resource contained in a given file with a given name.",
"Returns a resource specifically stored in a given file path, under a given name (a single path may be a collection containing several resources).",
NULL);
pika_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("type-name",
"type name",
"The name of the resource type",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("resource-name",
"resource name",
"The name of the resource",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("collection",
"collection",
"The collection identifier",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("is-internal",
"is internal",
"Whether this is the identifier for internal data",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_resource ("resource",
"resource",
"The resource",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-id-is-valid
*/
procedure = pika_procedure_new (resource_id_is_valid_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-id-is-valid");
pika_procedure_set_static_help (procedure,
"Returns TRUE if the resource ID is valid.",
"This procedure checks if the given resource ID is valid and refers to an existing resource.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
g_param_spec_int ("resource-id",
"resource id",
"The resource ID to check",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("valid",
"valid",
"Whether the resource ID is valid",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-id-is-brush
*/
procedure = pika_procedure_new (resource_id_is_brush_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-id-is-brush");
pika_procedure_set_static_help (procedure,
"Returns whether the resource ID is a brush.",
"This procedure returns TRUE if the specified resource ID is a brush.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
g_param_spec_int ("resource-id",
"resource id",
"The resource ID",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("brush",
"brush",
"TRUE if the resource ID is a brush, FALSE otherwise",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-id-is-pattern
*/
procedure = pika_procedure_new (resource_id_is_pattern_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-id-is-pattern");
pika_procedure_set_static_help (procedure,
"Returns whether the resource ID is a pattern.",
"This procedure returns TRUE if the specified resource ID is a pattern.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
g_param_spec_int ("resource-id",
"resource id",
"The resource ID",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("pattern",
"pattern",
"TRUE if the resource ID is a pattern, FALSE otherwise",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-id-is-gradient
*/
procedure = pika_procedure_new (resource_id_is_gradient_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-id-is-gradient");
pika_procedure_set_static_help (procedure,
"Returns whether the resource ID is a gradient.",
"This procedure returns TRUE if the specified resource ID is a gradient.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
g_param_spec_int ("resource-id",
"resource id",
"The resource ID",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("gradient",
"gradient",
"TRUE if the resource ID is a gradient, FALSE otherwise",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-id-is-palette
*/
procedure = pika_procedure_new (resource_id_is_palette_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-id-is-palette");
pika_procedure_set_static_help (procedure,
"Returns whether the resource ID is a palette.",
"This procedure returns TRUE if the specified resource ID is a palette.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
g_param_spec_int ("resource-id",
"resource id",
"The resource ID",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("palette",
"palette",
"TRUE if the resource ID is a palette, FALSE otherwise",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-id-is-font
*/
procedure = pika_procedure_new (resource_id_is_font_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-id-is-font");
pika_procedure_set_static_help (procedure,
"Returns whether the resource ID is a font.",
"This procedure returns TRUE if the specified resource ID is a font.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
g_param_spec_int ("resource-id",
"resource id",
"The resource ID",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("font",
"font",
"TRUE if the resource ID is a font, FALSE otherwise",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-get-name
*/
procedure = pika_procedure_new (resource_get_name_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-get-name");
pika_procedure_set_static_help (procedure,
"Returns the resource's name.",
"This procedure returns the resource's name.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_resource ("resource",
"resource",
"The resource",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("name",
"name",
"The resource's name",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-get-identifiers
*/
procedure = pika_procedure_new (resource_get_identifiers_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-get-identifiers");
pika_procedure_set_static_help (procedure,
"Returns a triplet identifying the resource.",
"This procedure returns 2 strings and a boolean. The first string is the resource name, similar to what you would obtain calling 'pika-resource-get-name'. The second is an opaque identifier for the collection this resource belongs to.\n"
"Note: as far as PIKA is concerned, a collection of resource usually corresponds to a single file on disk (which may or may not contain several resources). Therefore the identifier may be derived from the local file path. Nevertheless you should not use this string as such as this is not guaranteed to be always the case. You should consider it as an opaque identifier only to be used again through _'pika-resource-get-by-identifier'.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_resource ("resource",
"resource",
"The resource",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("is-internal",
"is internal",
"Whether this is the identifier for internal data",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("name",
"name",
"The resource's name",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_string ("collection-id",
"collection id",
"The resource's collection identifier",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-is-editable
*/
procedure = pika_procedure_new (resource_is_editable_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-is-editable");
pika_procedure_set_static_help (procedure,
"Whether the resource can be edited.",
"Returns TRUE if you have permission to change the resource.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_resource ("resource",
"resource",
"The resource",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("editable",
"editable",
"TRUE if the resource can be edited",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-duplicate
*/
procedure = pika_procedure_new (resource_duplicate_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-duplicate");
pika_procedure_set_static_help (procedure,
"Duplicates a resource.",
"Returns a copy having a different, unique ID.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_resource ("resource",
"resource",
"The resource",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_resource ("resource-copy",
"resource copy",
"A copy of the resource.",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-rename
*/
procedure = pika_procedure_new (resource_rename_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-rename");
pika_procedure_set_static_help (procedure,
"Renames a resource. When the name is in use, renames to a unique name.",
"Renames a resource. When the proposed name is already used, PIKA generates a unique name.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_resource ("resource",
"resource",
"The resource",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("new-name",
"new name",
"The proposed new name of the resource",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-resource-delete
*/
procedure = pika_procedure_new (resource_delete_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-resource-delete");
pika_procedure_set_static_help (procedure,
"Deletes a resource.",
"Deletes a resource. Returns an error if the resource is not deletable. Deletes the resource's data. You should not use the resource afterwards.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2023");
pika_procedure_add_argument (procedure,
pika_param_spec_resource ("resource",
"resource",
"The resource",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

992
app/pdb/selection-cmds.c Normal file
View File

@ -0,0 +1,992 @@
/* 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 "libpikamath/pikamath.h"
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pikachannel.h"
#include "core/pikaimage.h"
#include "core/pikalayer.h"
#include "core/pikaparamspecs.h"
#include "core/pikapickable.h"
#include "core/pikaselection.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
#include "pika-intl.h"
static PikaValueArray *
selection_bounds_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gboolean non_empty = FALSE;
gint x1 = 0;
gint y1 = 0;
gint x2 = 0;
gint y2 = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
gint x, y, w, h;
non_empty = pika_item_bounds (PIKA_ITEM (pika_image_get_mask (image)),
&x, &y, &w, &h);
x1 = x;
y1 = y;
x2 = x + w;
y2 = y + h;
}
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), non_empty);
g_value_set_int (pika_value_array_index (return_vals, 2), x1);
g_value_set_int (pika_value_array_index (return_vals, 3), y1);
g_value_set_int (pika_value_array_index (return_vals, 4), x2);
g_value_set_int (pika_value_array_index (return_vals, 5), y2);
}
return return_vals;
}
static PikaValueArray *
selection_value_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gint x;
gint y;
gint value = 0;
image = g_value_get_object (pika_value_array_index (args, 0));
x = g_value_get_int (pika_value_array_index (args, 1));
y = g_value_get_int (pika_value_array_index (args, 2));
if (success)
{
gdouble val;
val= pika_pickable_get_opacity_at (PIKA_PICKABLE (pika_image_get_mask (image)),
x, y);
value = ROUND (CLAMP (val, 0.0, 1.0) * 255.0);
}
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), value);
return return_vals;
}
static PikaValueArray *
selection_is_empty_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
gboolean is_empty = FALSE;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
is_empty = pika_channel_is_empty (pika_image_get_mask (image));
}
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), is_empty);
return return_vals;
}
static PikaValueArray *
selection_translate_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint offx;
gint offy;
image = g_value_get_object (pika_value_array_index (args, 0));
offx = g_value_get_int (pika_value_array_index (args, 1));
offy = g_value_get_int (pika_value_array_index (args, 2));
if (success)
{
pika_item_translate (PIKA_ITEM (pika_image_get_mask (image)),
offx, offy, TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_float_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
gint num_drawables;
const PikaItem **drawables;
gint offx;
gint offy;
PikaLayer *layer = NULL;
num_drawables = g_value_get_int (pika_value_array_index (args, 0));
drawables = (const PikaItem **) pika_value_get_object_array (pika_value_array_index (args, 1));
offx = g_value_get_int (pika_value_array_index (args, 2));
offy = g_value_get_int (pika_value_array_index (args, 3));
if (success)
{
PikaImage *image = NULL;
gint i;
if (num_drawables < 1)
{
success = FALSE;
}
else
{
for (i = 0; i < num_drawables; i++)
{
if (! pika_pdb_item_is_attached (PIKA_ITEM (drawables[i]), NULL,
PIKA_PDB_ITEM_CONTENT, error) ||
pika_pdb_item_is_group (PIKA_ITEM (drawables[i]), error) ||
(image && image != pika_item_get_image (PIKA_ITEM (drawables[i]))))
{
success = FALSE;
break;
}
else
{
image = pika_item_get_image (PIKA_ITEM (drawables[i]));
}
}
}
if (success)
{
GList *drawable_list = NULL;
for (i = 0; i < num_drawables; i++)
drawable_list = g_list_prepend (drawable_list, (gpointer) drawables[i]);
layer = pika_selection_float (PIKA_SELECTION (pika_image_get_mask (image)),
drawable_list, context, TRUE, offx, offy,
error);
g_list_free (drawable_list);
if (! layer)
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), layer);
return return_vals;
}
static PikaValueArray *
selection_invert_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_channel_invert (pika_image_get_mask (image), TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_sharpen_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_channel_sharpen (pika_image_get_mask (image), TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_all_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_channel_all (pika_image_get_mask (image), TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_none_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_channel_clear (pika_image_get_mask (image), NULL, TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_feather_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gdouble radius;
image = g_value_get_object (pika_value_array_index (args, 0));
radius = g_value_get_double (pika_value_array_index (args, 1));
if (success)
{
/* FIXME: "edge-lock" hardcoded to TRUE */
pika_channel_feather (pika_image_get_mask (image),
radius, radius, TRUE, TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_border_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint radius;
image = g_value_get_object (pika_value_array_index (args, 0));
radius = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
/* FIXME: "style" and "edge-lock" hardcoded to SMOOTH and TRUE, respectively. */
pika_channel_border (pika_image_get_mask (image),
radius, radius,
PIKA_CHANNEL_BORDER_STYLE_SMOOTH,
TRUE, TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_grow_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint steps;
image = g_value_get_object (pika_value_array_index (args, 0));
steps = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
pika_channel_grow (pika_image_get_mask (image),
steps, steps, TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_shrink_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
gint steps;
image = g_value_get_object (pika_value_array_index (args, 0));
steps = g_value_get_int (pika_value_array_index (args, 1));
if (success)
{
pika_channel_shrink (pika_image_get_mask (image),
steps, steps, FALSE, TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_flood_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaImage *image;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
pika_channel_flood (pika_image_get_mask (image), TRUE);
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
selection_save_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
PikaChannel *channel = NULL;
image = g_value_get_object (pika_value_array_index (args, 0));
if (success)
{
channel = PIKA_CHANNEL (pika_item_duplicate (PIKA_ITEM (pika_image_get_mask (image)),
PIKA_TYPE_CHANNEL));
if (channel)
{
/* saved selections are not visible by default */
pika_item_set_visible (PIKA_ITEM (channel), FALSE, FALSE);
pika_image_add_channel (image, channel,
PIKA_IMAGE_ACTIVE_PARENT, -1, TRUE);
}
else
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), channel);
return return_vals;
}
void
register_selection_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-selection-bounds
*/
procedure = pika_procedure_new (selection_bounds_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-bounds");
pika_procedure_set_static_help (procedure,
"Find the bounding box of the current selection.",
"This procedure returns whether there is a selection for the specified image. If there is one, the upper left and lower right corners of the bounding box are returned. These coordinates are relative to the image. Please note that the pixel specified by the lower right coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("non-empty",
"non empty",
"TRUE if there is a selection",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("x1",
"x1",
"x coordinate of upper left corner of selection bounds",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("y1",
"y1",
"y coordinate of upper left corner of selection bounds",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("x2",
"x2",
"x coordinate of lower right corner of selection bounds",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("y2",
"y2",
"y coordinate of lower right corner of selection bounds",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-value
*/
procedure = pika_procedure_new (selection_value_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-value");
pika_procedure_set_static_help (procedure,
"Find the value of the selection at the specified coordinates.",
"This procedure returns the value of the selection at the specified coordinates. If the coordinates lie out of bounds, 0 is returned.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("x",
"x",
"x coordinate of value",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("y",
"y",
"y coordinate of value",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("value",
"value",
"Value of the selection",
0, 255, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-is-empty
*/
procedure = pika_procedure_new (selection_is_empty_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-is-empty");
pika_procedure_set_static_help (procedure,
"Determine whether the selection is empty.",
"This procedure returns TRUE if the selection for the specified image is empty.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_boolean ("is-empty",
"is empty",
"Is the selection empty?",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-translate
*/
procedure = pika_procedure_new (selection_translate_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-translate");
pika_procedure_set_static_help (procedure,
"Translate the selection by the specified offsets.",
"This procedure actually translates the selection for the specified image by the specified offsets. Regions that are translated from beyond the bounds of the image are set to empty. Valid regions of the selection which are translated beyond the bounds of the image because of this call are lost.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offx",
"offx",
"x offset for translation",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offy",
"offy",
"y offset for translation",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-float
*/
procedure = pika_procedure_new (selection_float_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-float");
pika_procedure_set_static_help (procedure,
"Float the selection from the specified drawable with initial offsets as specified.",
"This procedure determines the region of the specified drawable that lies beneath the current selection. The region is then cut from the drawable and the resulting data is made into a new layer which is instantiated as a floating selection. The offsets allow initial positioning of the new floating selection.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
g_param_spec_int ("num-drawables",
"num drawables",
"The number of drawables",
1, G_MAXINT32, 1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_object_array ("drawables",
"drawables",
"The drawables from which to float selection",
PIKA_TYPE_ITEM,
PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offx",
"offx",
"x offset for translation",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("offy",
"offy",
"y offset for translation",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_layer ("layer",
"layer",
"The floated layer",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-invert
*/
procedure = pika_procedure_new (selection_invert_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-invert");
pika_procedure_set_static_help (procedure,
"Invert the selection mask.",
"This procedure inverts the selection mask. For every pixel in the selection channel, its new value is calculated as (255 - old-value).",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-sharpen
*/
procedure = pika_procedure_new (selection_sharpen_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-sharpen");
pika_procedure_set_static_help (procedure,
"Sharpen the selection mask.",
"This procedure sharpens the selection mask. For every pixel in the selection channel, if the value is > 127, the new pixel is assigned a value of 255. This removes any \"anti-aliasing\" that might exist in the selection mask's boundary.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-all
*/
procedure = pika_procedure_new (selection_all_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-all");
pika_procedure_set_static_help (procedure,
"Select all of the image.",
"This procedure sets the selection mask to completely encompass the image. Every pixel in the selection channel is set to 255.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-none
*/
procedure = pika_procedure_new (selection_none_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-none");
pika_procedure_set_static_help (procedure,
"Deselect the entire image.",
"This procedure deselects the entire image. Every pixel in the selection channel is set to 0.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-feather
*/
procedure = pika_procedure_new (selection_feather_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-feather");
pika_procedure_set_static_help (procedure,
"Feather the image's selection",
"This procedure feathers the selection. Feathering is implemented using a gaussian blur.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("radius",
"radius",
"Radius of feather (in pixels)",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-border
*/
procedure = pika_procedure_new (selection_border_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-border");
pika_procedure_set_static_help (procedure,
"Border the image's selection",
"This procedure borders the selection. Bordering creates a new selection which is defined along the boundary of the previous selection at every point within the specified radius.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("radius",
"radius",
"Radius of border (in pixels)",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-grow
*/
procedure = pika_procedure_new (selection_grow_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-grow");
pika_procedure_set_static_help (procedure,
"Grow the image's selection",
"This procedure grows the selection. Growing involves expanding the boundary in all directions by the specified pixel amount.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("steps",
"steps",
"Steps of grow (in pixels)",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-shrink
*/
procedure = pika_procedure_new (selection_shrink_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-shrink");
pika_procedure_set_static_help (procedure,
"Shrink the image's selection",
"This procedure shrinks the selection. Shrinking involves trimming the existing selection boundary on all sides by the specified number of pixels.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("steps",
"steps",
"Steps of shrink (in pixels)",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-flood
*/
procedure = pika_procedure_new (selection_flood_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-flood");
pika_procedure_set_static_help (procedure,
"Remove holes from the image's selection",
"This procedure removes holes from the selection, that can come from selecting a patchy area with the Fuzzy Select Tool. In technical terms this procedure floods the selection. See the Algorithms page in the developer wiki for details.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Ell",
"Ell",
"2016");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-selection-save
*/
procedure = pika_procedure_new (selection_save_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-selection-save");
pika_procedure_set_static_help (procedure,
"Copy the selection mask to a new channel.",
"This procedure copies the selection mask and stores the content in a new channel. The new channel is automatically inserted into the image's list of channels.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_channel ("channel",
"channel",
"The new channel",
FALSE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

1939
app/pdb/text-layer-cmds.c Normal file

File diff suppressed because it is too large Load Diff

316
app/pdb/text-tool-cmds.c Normal file
View File

@ -0,0 +1,316 @@
/* 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/pikadrawable.h"
#include "core/pikaimage.h"
#include "core/pikalayer.h"
#include "core/pikaparamspecs.h"
#include "text/pikatext-compat.h"
#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
text_fontname_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
PikaImage *image;
PikaDrawable *drawable;
gdouble x;
gdouble y;
const gchar *text;
gint border;
gboolean antialias;
gdouble size;
const gchar *fontname;
PikaLayer *text_layer = NULL;
image = g_value_get_object (pika_value_array_index (args, 0));
drawable = g_value_get_object (pika_value_array_index (args, 1));
x = g_value_get_double (pika_value_array_index (args, 2));
y = g_value_get_double (pika_value_array_index (args, 3));
text = g_value_get_string (pika_value_array_index (args, 4));
border = g_value_get_int (pika_value_array_index (args, 5));
antialias = g_value_get_boolean (pika_value_array_index (args, 6));
size = g_value_get_double (pika_value_array_index (args, 7));
fontname = g_value_get_string (pika_value_array_index (args, 9));
if (success)
{
if (drawable &&
(! pika_pdb_item_is_attached (PIKA_ITEM (drawable), image,
PIKA_PDB_ITEM_CONTENT, error) ||
! pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error)))
success = FALSE;
if (success)
{
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
text_layer = text_render (image, drawable, context,
x, y, real_fontname, text,
border, antialias);
g_free (real_fontname);
}
}
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), text_layer);
return return_vals;
}
static PikaValueArray *
text_get_extents_fontname_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
const gchar *text;
gdouble size;
const gchar *fontname;
gint width = 0;
gint height = 0;
gint ascent = 0;
gint descent = 0;
text = g_value_get_string (pika_value_array_index (args, 0));
size = g_value_get_double (pika_value_array_index (args, 1));
fontname = g_value_get_string (pika_value_array_index (args, 3));
if (success)
{
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
success = text_get_extents (pika,
real_fontname, text,
&width, &height,
&ascent, &descent);
g_free (real_fontname);
}
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);
g_value_set_int (pika_value_array_index (return_vals, 2), height);
g_value_set_int (pika_value_array_index (return_vals, 3), ascent);
g_value_set_int (pika_value_array_index (return_vals, 4), descent);
}
return return_vals;
}
void
register_text_tool_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-text-fontname
*/
procedure = pika_procedure_new (text_fontname_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-text-fontname");
pika_procedure_set_static_help (procedure,
"Add text at the specified location as a floating selection or a new layer.",
"This tool requires a fontname matching an installed PangoFT2 font. You can specify the fontsize in units of pixels or points, and the appropriate metric is specified using the size_type argument. The x and y parameters together control the placement of the new text by specifying the upper left corner of the text bounding box. If the specified drawable parameter is valid, the text will be created as a floating selection attached to the drawable. If the drawable parameter is not valid (%NULL), the text will appear as a new layer. Finally, a border can be specified around the final rendered text. The border is measured in pixels. Parameter size-type is not used and is currently ignored. If you need to display a font in points, divide the size in points by 72.0 and multiply it by the image's vertical resolution.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Martin Edlman & Sven Neumann",
"Spencer Kimball & Peter Mattis",
"1998- 2001");
pika_procedure_add_argument (procedure,
pika_param_spec_image ("image",
"image",
"The image",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_drawable ("drawable",
"drawable",
"The affected drawable: (%NULL for a new text layer)",
TRUE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("x",
"x",
"The x coordinate for the left of the text bounding box",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("y",
"y",
"The y coordinate for the top of the text bounding box",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("text",
"text",
"The text to generate (in UTF-8 encoding)",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_int ("border",
"border",
"The size of the border",
-1, G_MAXINT32, -1,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_boolean ("antialias",
"antialias",
"Antialiasing",
FALSE,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("size",
"size",
"The size of text in either pixels or points",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("size-type",
"size type",
"The units of specified size",
PIKA_TYPE_SIZE_TYPE,
PIKA_PIXELS,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("fontname",
"fontname",
"The name of the font",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
pika_param_spec_layer ("text-layer",
"text layer",
"The new text layer or %NULL if no layer was created.",
TRUE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-text-get-extents-fontname
*/
procedure = pika_procedure_new (text_get_extents_fontname_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-text-get-extents-fontname");
pika_procedure_set_static_help (procedure,
"Get extents of the bounding box for the specified text.",
"This tool returns the width and height of a bounding box for the specified text string with the specified font information. Ascent and descent for the specified font are returned as well. Parameter size-type is not used and is currently ignored. If you need to display a font in points, divide the size in points by 72.0 and multiply it by the vertical resolution of the image you are taking into account.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Martin Edlman & Sven Neumann",
"Spencer Kimball & Peter Mattis",
"1998- 2001");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("text",
"text",
"The text to generate (in UTF-8 encoding)",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_double ("size",
"size",
"The size of text in either pixels or points",
0, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
g_param_spec_enum ("size-type",
"size type",
"The units of specified size",
PIKA_TYPE_SIZE_TYPE,
PIKA_PIXELS,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_string ("fontname",
"fontname",
"The name of the font",
FALSE, FALSE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("width",
"width",
"The width of the specified font",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("height",
"height",
"The height of the specified font",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("ascent",
"ascent",
"The ascent of the specified font",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_procedure_add_return_value (procedure,
g_param_spec_int ("descent",
"descent",
"The descent of the specified font",
G_MININT32, G_MAXINT32, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

788
app/pdb/unit-cmds.c Normal file
View File

@ -0,0 +1,788 @@
/* 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);
}

2505
app/pdb/vectors-cmds.c Normal file

File diff suppressed because it is too large Load Diff