Much like for images and items. Change the PDB to transmit IDs instead of names for brush, pattern etc. and refactor a whole lot of libgimp code to deal with it. modified: libgimp/gimpplugin-private.h
470 lines
19 KiB
C
470 lines
19 KiB
C
/* GIMP - The GNU Image Manipulation Program
|
|
* 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 "libgimpbase/gimpbase.h"
|
|
|
|
#include "pdb-types.h"
|
|
|
|
#include "core/gimpbrush.h"
|
|
#include "core/gimpgradient.h"
|
|
#include "core/gimppalette.h"
|
|
#include "core/gimpparamspecs.h"
|
|
#include "core/gimppattern.h"
|
|
#include "core/gimpresource.h"
|
|
#include "text/gimpfont.h"
|
|
|
|
#include "gimppdb.h"
|
|
#include "gimpprocedure.h"
|
|
#include "internal-procs.h"
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
static GimpValueArray *
|
|
resource_id_is_valid_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GimpValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpValueArray *return_vals;
|
|
gint resource_id;
|
|
gboolean valid = FALSE;
|
|
|
|
resource_id = g_value_get_int (gimp_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
GimpData *data = gimp_data_get_by_id (resource_id);
|
|
|
|
valid = GIMP_IS_DATA (data);
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (gimp_value_array_index (return_vals, 1), valid);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GimpValueArray *
|
|
resource_id_is_brush_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GimpValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpValueArray *return_vals;
|
|
gint resource_id;
|
|
gboolean brush = FALSE;
|
|
|
|
resource_id = g_value_get_int (gimp_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
GimpData *data = gimp_data_get_by_id (resource_id);
|
|
|
|
brush = GIMP_IS_BRUSH (data);
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (gimp_value_array_index (return_vals, 1), brush);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GimpValueArray *
|
|
resource_id_is_pattern_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GimpValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpValueArray *return_vals;
|
|
gint resource_id;
|
|
gboolean pattern = FALSE;
|
|
|
|
resource_id = g_value_get_int (gimp_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
GimpData *data = gimp_data_get_by_id (resource_id);
|
|
|
|
pattern = GIMP_IS_PATTERN (data);
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (gimp_value_array_index (return_vals, 1), pattern);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GimpValueArray *
|
|
resource_id_is_gradient_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GimpValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpValueArray *return_vals;
|
|
gint resource_id;
|
|
gboolean gradient = FALSE;
|
|
|
|
resource_id = g_value_get_int (gimp_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
GimpData *data = gimp_data_get_by_id (resource_id);
|
|
|
|
gradient = GIMP_IS_GRADIENT (data);
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (gimp_value_array_index (return_vals, 1), gradient);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GimpValueArray *
|
|
resource_id_is_palette_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GimpValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpValueArray *return_vals;
|
|
gint resource_id;
|
|
gboolean palette = FALSE;
|
|
|
|
resource_id = g_value_get_int (gimp_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
GimpData *data = gimp_data_get_by_id (resource_id);
|
|
|
|
palette = GIMP_IS_PALETTE (data);
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (gimp_value_array_index (return_vals, 1), palette);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GimpValueArray *
|
|
resource_id_is_font_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GimpValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpValueArray *return_vals;
|
|
gint resource_id;
|
|
gboolean font = FALSE;
|
|
|
|
resource_id = g_value_get_int (gimp_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
GimpData *data = gimp_data_get_by_id (resource_id);
|
|
|
|
font = GIMP_IS_FONT (data);
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (gimp_value_array_index (return_vals, 1), font);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static GimpValueArray *
|
|
resource_get_name_invoker (GimpProcedure *procedure,
|
|
Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
const GimpValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpValueArray *return_vals;
|
|
GimpResource *resource;
|
|
gchar *name = NULL;
|
|
|
|
resource = g_value_get_object (gimp_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (resource)));
|
|
}
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_take_string (gimp_value_array_index (return_vals, 1), name);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
void
|
|
register_resource_procs (GimpPDB *pdb)
|
|
{
|
|
GimpProcedure *procedure;
|
|
|
|
/*
|
|
* gimp-resource-id-is-valid
|
|
*/
|
|
procedure = gimp_procedure_new (resource_id_is_valid_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
"gimp-resource-id-is-valid");
|
|
gimp_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);
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2023");
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_int ("resource-id",
|
|
"resource id",
|
|
"The resource ID to check",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("valid",
|
|
"valid",
|
|
"Whether the resource ID is valid",
|
|
FALSE,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-resource-id-is-brush
|
|
*/
|
|
procedure = gimp_procedure_new (resource_id_is_brush_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
"gimp-resource-id-is-brush");
|
|
gimp_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);
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2023");
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_int ("resource-id",
|
|
"resource id",
|
|
"The resource ID",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("brush",
|
|
"brush",
|
|
"TRUE if the resource ID is a brush, FALSE otherwise",
|
|
FALSE,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-resource-id-is-pattern
|
|
*/
|
|
procedure = gimp_procedure_new (resource_id_is_pattern_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
"gimp-resource-id-is-pattern");
|
|
gimp_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);
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2023");
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_int ("resource-id",
|
|
"resource id",
|
|
"The resource ID",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("pattern",
|
|
"pattern",
|
|
"TRUE if the resource ID is a pattern, FALSE otherwise",
|
|
FALSE,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-resource-id-is-gradient
|
|
*/
|
|
procedure = gimp_procedure_new (resource_id_is_gradient_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
"gimp-resource-id-is-gradient");
|
|
gimp_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);
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2023");
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_int ("resource-id",
|
|
"resource id",
|
|
"The resource ID",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("gradient",
|
|
"gradient",
|
|
"TRUE if the resource ID is a gradient, FALSE otherwise",
|
|
FALSE,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-resource-id-is-palette
|
|
*/
|
|
procedure = gimp_procedure_new (resource_id_is_palette_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
"gimp-resource-id-is-palette");
|
|
gimp_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);
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2023");
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_int ("resource-id",
|
|
"resource id",
|
|
"The resource ID",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("palette",
|
|
"palette",
|
|
"TRUE if the resource ID is a palette, FALSE otherwise",
|
|
FALSE,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-resource-id-is-font
|
|
*/
|
|
procedure = gimp_procedure_new (resource_id_is_font_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
"gimp-resource-id-is-font");
|
|
gimp_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);
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2023");
|
|
gimp_procedure_add_argument (procedure,
|
|
g_param_spec_int ("resource-id",
|
|
"resource id",
|
|
"The resource ID",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("font",
|
|
"font",
|
|
"TRUE if the resource ID is a font, FALSE otherwise",
|
|
FALSE,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* gimp-resource-get-name
|
|
*/
|
|
procedure = gimp_procedure_new (resource_get_name_invoker);
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
"gimp-resource-get-name");
|
|
gimp_procedure_set_static_help (procedure,
|
|
"Returns the resource's name.",
|
|
"This procedure returns the resource's name.",
|
|
NULL);
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2023");
|
|
gimp_procedure_add_argument (procedure,
|
|
gimp_param_spec_resource ("resource",
|
|
"resource",
|
|
"The resource",
|
|
FALSE,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_procedure_add_return_value (procedure,
|
|
gimp_param_spec_string ("name",
|
|
"name",
|
|
"The resource's name",
|
|
FALSE, FALSE, FALSE,
|
|
NULL,
|
|
GIMP_PARAM_READWRITE));
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
}
|