app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpgpparams-body.c
|
2019-07-31 06:12:36 +08:00
|
|
|
* Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
*
|
|
|
|
* This library is free software: you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* this file is included by both
|
|
|
|
*
|
|
|
|
* libgimp/gimpgpparams.c
|
|
|
|
* app/plug-in/gimpgpparams.c
|
|
|
|
*/
|
|
|
|
|
2024-09-06 19:38:43 +08:00
|
|
|
static GimpImage * get_image_by_id (gpointer gimp,
|
|
|
|
gint id);
|
|
|
|
static GimpItem * get_item_by_id (gpointer gimp,
|
|
|
|
gint id);
|
|
|
|
static GimpDisplay * get_display_by_id (gpointer gimp,
|
|
|
|
gint id);
|
|
|
|
static GObject * get_resource_by_id (gint id);
|
|
|
|
static gint get_resource_id (GObject *resource);
|
|
|
|
static GimpUnit * get_unit_by_id (gpointer gimp,
|
|
|
|
gint id);
|
|
|
|
|
|
|
|
|
2019-09-04 16:41:19 +08:00
|
|
|
GParamSpec *
|
2019-09-05 22:07:15 +08:00
|
|
|
_gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
|
2019-09-04 16:41:19 +08:00
|
|
|
{
|
|
|
|
const gchar *name = param_def->name;
|
|
|
|
const gchar *nick = param_def->nick;
|
|
|
|
const gchar *blurb = param_def->blurb;
|
|
|
|
GParamFlags flags = param_def->flags;
|
|
|
|
|
|
|
|
flags &= ~G_PARAM_STATIC_STRINGS;
|
|
|
|
|
|
|
|
switch (param_def->param_def_type)
|
|
|
|
{
|
|
|
|
case GP_PARAM_DEF_TYPE_DEFAULT:
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamInt32Array"))
|
|
|
|
return gimp_param_spec_int32_array (name, nick, blurb, flags);
|
|
|
|
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GimpParamDoubleArray"))
|
|
|
|
return gimp_param_spec_double_array (name, nick, blurb, flags);
|
2019-09-04 16:41:19 +08:00
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamParasite"))
|
|
|
|
return gimp_param_spec_parasite (name, nick, blurb, flags);
|
2019-09-12 03:40:17 +08:00
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GParamParam"))
|
|
|
|
return g_param_spec_param (name, nick, blurb,
|
|
|
|
g_type_from_name (param_def->value_type_name),
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GParamObject") &&
|
|
|
|
! strcmp (param_def->value_type_name, "GFile"))
|
|
|
|
return g_param_spec_object (name, nick, blurb, G_TYPE_FILE, flags);
|
2021-04-20 20:10:37 +08:00
|
|
|
|
2020-12-24 04:15:43 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GParamBoxed") &&
|
|
|
|
! strcmp (param_def->value_type_name, "GStrv"))
|
|
|
|
return g_param_spec_boxed (name, nick, blurb, G_TYPE_STRV, flags);
|
|
|
|
|
2023-05-24 05:37:46 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GParamBoxed") &&
|
|
|
|
! strcmp (param_def->value_type_name, "GBytes"))
|
|
|
|
return g_param_spec_boxed (name, nick, blurb, G_TYPE_BYTES, flags);
|
|
|
|
|
2024-02-28 05:31:15 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GParamBoxed") &&
|
|
|
|
! strcmp (param_def->value_type_name, "GimpColorArray"))
|
|
|
|
return g_param_spec_boxed (name, nick, blurb, GIMP_TYPE_COLOR_ARRAY, flags);
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GParamBoxed") &&
|
|
|
|
! strcmp (param_def->value_type_name, "GimpBablFormat"))
|
|
|
|
return g_param_spec_boxed (name, nick, blurb, GIMP_TYPE_BABL_FORMAT, flags);
|
|
|
|
|
2019-09-04 16:41:19 +08:00
|
|
|
break;
|
|
|
|
|
2023-08-03 05:55:33 +08:00
|
|
|
case GP_PARAM_DEF_TYPE_CHOICE:
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamChoice"))
|
|
|
|
{
|
|
|
|
return gimp_param_spec_choice (name, nick, blurb,
|
|
|
|
g_object_ref (param_def->meta.m_choice.choice),
|
|
|
|
param_def->meta.m_choice.default_val,
|
|
|
|
flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2019-09-04 16:41:19 +08:00
|
|
|
case GP_PARAM_DEF_TYPE_INT:
|
|
|
|
if (! strcmp (param_def->type_name, "GParamInt"))
|
|
|
|
return g_param_spec_int (name, nick, blurb,
|
|
|
|
param_def->meta.m_int.min_val,
|
|
|
|
param_def->meta.m_int.max_val,
|
|
|
|
param_def->meta.m_int.default_val,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GParamUInt"))
|
|
|
|
return g_param_spec_uint (name, nick, blurb,
|
|
|
|
param_def->meta.m_int.min_val,
|
|
|
|
param_def->meta.m_int.max_val,
|
|
|
|
param_def->meta.m_int.default_val,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GParamUChar"))
|
|
|
|
return g_param_spec_uchar (name, nick, blurb,
|
|
|
|
param_def->meta.m_int.min_val,
|
|
|
|
param_def->meta.m_int.max_val,
|
|
|
|
param_def->meta.m_int.default_val,
|
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_UNIT:
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamUnit"))
|
|
|
|
return gimp_param_spec_unit (name, nick, blurb,
|
|
|
|
param_def->meta.m_unit.allow_pixels,
|
|
|
|
param_def->meta.m_unit.allow_percent,
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
gimp_unit_get_by_id (param_def->meta.m_unit.default_val),
|
2019-09-04 16:41:19 +08:00
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_ENUM:
|
|
|
|
if (! strcmp (param_def->type_name, "GParamEnum"))
|
|
|
|
return g_param_spec_enum (name, nick, blurb,
|
2019-09-12 03:40:17 +08:00
|
|
|
g_type_from_name (param_def->value_type_name),
|
2019-09-04 16:41:19 +08:00
|
|
|
param_def->meta.m_enum.default_val,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamEnum"))
|
|
|
|
/* FIXME GimpParamEnum */
|
|
|
|
return g_param_spec_enum (name, nick, blurb,
|
2019-09-12 03:40:17 +08:00
|
|
|
g_type_from_name (param_def->value_type_name),
|
2019-09-04 16:41:19 +08:00
|
|
|
param_def->meta.m_enum.default_val,
|
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_BOOLEAN:
|
|
|
|
if (! strcmp (param_def->type_name, "GParamBoolean"))
|
|
|
|
return g_param_spec_boolean (name, nick, blurb,
|
|
|
|
param_def->meta.m_boolean.default_val,
|
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
case GP_PARAM_DEF_TYPE_DOUBLE:
|
2019-09-04 16:41:19 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GParamDouble"))
|
|
|
|
return g_param_spec_double (name, nick, blurb,
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
param_def->meta.m_double.min_val,
|
|
|
|
param_def->meta.m_double.max_val,
|
|
|
|
param_def->meta.m_double.default_val,
|
2019-09-04 16:41:19 +08:00
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_STRING:
|
|
|
|
if (! strcmp (param_def->type_name, "GParamString"))
|
|
|
|
return g_param_spec_string (name, nick, blurb,
|
|
|
|
param_def->meta.m_string.default_val,
|
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
|
2024-02-13 23:07:24 +08:00
|
|
|
case GP_PARAM_DEF_TYPE_GEGL_COLOR:
|
2024-04-20 05:02:29 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GeglParamColor") ||
|
|
|
|
! strcmp (param_def->type_name, "GimpParamColor"))
|
2024-02-13 23:07:24 +08:00
|
|
|
{
|
|
|
|
GeglColor *default_color = NULL;
|
|
|
|
|
|
|
|
if (param_def->meta.m_gegl_color.default_val)
|
|
|
|
{
|
|
|
|
GPParamColor *default_val = param_def->meta.m_gegl_color.default_val;
|
|
|
|
const Babl *format = NULL;
|
|
|
|
const Babl *space = NULL;
|
|
|
|
gint bpp;
|
|
|
|
|
|
|
|
default_color = gegl_color_new ("black");
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
if (default_val->format.profile_data)
|
2024-02-13 23:07:24 +08:00
|
|
|
{
|
|
|
|
GimpColorProfile *profile;
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
profile = gimp_color_profile_new_from_icc_profile (default_val->format.profile_data,
|
|
|
|
default_val->format.profile_size,
|
2024-02-13 23:07:24 +08:00
|
|
|
NULL);
|
|
|
|
if (profile)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
space = gimp_color_profile_get_space (profile,
|
|
|
|
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (! space)
|
|
|
|
{
|
|
|
|
g_printerr ("%s: failed to create Babl space from profile: %s\n",
|
|
|
|
G_STRFUNC, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
g_object_unref (profile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
format = babl_format_with_space (default_val->format.encoding, space);
|
2024-02-13 23:07:24 +08:00
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
|
|
|
|
|
|
|
if (bpp != default_val->size)
|
|
|
|
g_printerr ("%s: encoding \"%s\" expects %d bpp but data size is %d bpp.\n",
|
2024-09-21 03:55:21 +08:00
|
|
|
G_STRFUNC, default_val->format.encoding, bpp, default_val->size);
|
2024-02-13 23:07:24 +08:00
|
|
|
else
|
|
|
|
gegl_color_set_pixel (default_color, format, default_val->data);
|
|
|
|
}
|
|
|
|
|
2024-04-20 05:02:29 +08:00
|
|
|
return gimp_param_spec_color (name, nick, blurb,
|
|
|
|
param_def->meta.m_gegl_color.has_alpha,
|
|
|
|
default_color, flags);
|
2024-02-13 23:07:24 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2019-09-04 16:41:19 +08:00
|
|
|
case GP_PARAM_DEF_TYPE_ID:
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamDisplay"))
|
|
|
|
return gimp_param_spec_display (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamImage"))
|
|
|
|
return gimp_param_spec_image (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamItem"))
|
|
|
|
return gimp_param_spec_item (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamDrawable"))
|
|
|
|
return gimp_param_spec_drawable (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamLayer"))
|
|
|
|
return gimp_param_spec_layer (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
2023-06-08 19:18:14 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GimpParamTextLayer"))
|
|
|
|
return gimp_param_spec_text_layer (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
app, libgimp, pdb, plug-ins: new GimpGroupLayer class in libgimp.
Also:
- renaming gimp_layer_group_new() to gimp_group_layer_new() in order to keep the
same name as in core code (i.e. GimpGroupLayer, not GimpLayerGroup).
- renaming gimp_image_merge_layer_group() to gimp_group_layer_merge()
- new functions: gimp_procedure_add_group_layer_argument(),
gimp_procedure_add_group_layer_aux_argument() and
gimp_procedure_add_group_layer_return_value().
This can be tested, e.g. in Python with these calls:
```py
i = Gimp.get_images()[0]
g = Gimp.GroupLayer.new(i, "hello")
i.insert_layer(g, None, 1)
g2 = Gimp.GroupLayer.new(i, "world")
i.insert_layer(g2, g, 1)
g.merge()
```
This was work started long ago, stored in an old stash which I finally
finish now! :-)
2024-07-06 23:24:11 +08:00
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamGroupLayer"))
|
|
|
|
return gimp_param_spec_group_layer (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
2023-06-08 19:18:14 +08:00
|
|
|
|
2019-09-04 16:41:19 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GimpParamChannel"))
|
|
|
|
return gimp_param_spec_channel (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamLayerMask"))
|
|
|
|
return gimp_param_spec_layer_mask (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamSelection"))
|
|
|
|
return gimp_param_spec_selection (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
2024-07-12 14:16:25 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GimpParamPath"))
|
|
|
|
return gimp_param_spec_path (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
2019-09-04 16:41:19 +08:00
|
|
|
break;
|
|
|
|
|
2019-09-05 17:39:13 +08:00
|
|
|
case GP_PARAM_DEF_TYPE_ID_ARRAY:
|
2024-10-24 00:48:29 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GimpParamCoreObjectArray"))
|
|
|
|
return gimp_param_spec_core_object_array (name, nick, blurb,
|
|
|
|
g_type_from_name (param_def->meta.m_id_array.type_name),
|
|
|
|
flags);
|
2024-09-06 19:38:43 +08:00
|
|
|
break;
|
2024-05-07 02:38:12 +08:00
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamExportOptions"))
|
|
|
|
{
|
2024-11-02 02:13:02 +08:00
|
|
|
return gimp_param_spec_export_options (name, nick, blurb, flags);
|
2024-05-07 02:38:12 +08:00
|
|
|
}
|
2019-09-04 16:41:19 +08:00
|
|
|
break;
|
2024-09-06 19:38:43 +08:00
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_RESOURCE:
|
|
|
|
if (g_type_from_name (param_def->type_name) != 0 &&
|
|
|
|
g_type_is_a (g_type_from_name (param_def->type_name), GIMP_TYPE_PARAM_RESOURCE))
|
|
|
|
return gimp_param_spec_resource (name, nick, blurb, g_type_from_name (param_def->type_name),
|
|
|
|
param_def->meta.m_resource.none_ok,
|
|
|
|
param_def->meta.m_resource.default_to_context ?
|
|
|
|
NULL : GIMP_RESOURCE (get_resource_by_id (param_def->meta.m_resource.default_resource_id)),
|
|
|
|
param_def->meta.m_resource.default_to_context,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
break;
|
2019-09-04 16:41:19 +08:00
|
|
|
}
|
|
|
|
|
2023-05-31 22:12:04 +08:00
|
|
|
g_warning ("%s: GParamSpec type unsupported '%s'", G_STRFUNC,
|
|
|
|
param_def->type_name);
|
2019-09-04 16:41:19 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
void
|
|
|
|
_gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
|
|
|
GPParamDef *param_def)
|
|
|
|
{
|
2019-09-12 03:40:17 +08:00
|
|
|
GType pspec_type = G_PARAM_SPEC_TYPE (pspec);
|
|
|
|
GType value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-09-12 03:40:17 +08:00
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_DEFAULT;
|
|
|
|
param_def->type_name = (gchar *) g_type_name (pspec_type);
|
|
|
|
param_def->value_type_name = (gchar *) g_type_name (value_type);
|
|
|
|
param_def->name = (gchar *) g_param_spec_get_name (pspec);
|
|
|
|
param_def->nick = (gchar *) g_param_spec_get_nick (pspec);
|
|
|
|
param_def->blurb = (gchar *) g_param_spec_get_blurb (pspec);
|
|
|
|
param_def->flags = pspec->flags;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-15 20:17:17 +08:00
|
|
|
if (pspec_type == G_TYPE_PARAM_INT)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
|
|
|
GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
|
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_INT;
|
|
|
|
|
|
|
|
param_def->meta.m_int.min_val = ispec->minimum;
|
|
|
|
param_def->meta.m_int.max_val = ispec->maximum;
|
|
|
|
param_def->meta.m_int.default_val = ispec->default_value;
|
|
|
|
}
|
2019-08-15 19:34:11 +08:00
|
|
|
else if (pspec_type == G_TYPE_PARAM_UINT)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
|
|
|
GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
|
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_INT;
|
|
|
|
|
2019-08-15 19:34:11 +08:00
|
|
|
param_def->meta.m_int.min_val = uspec->minimum;
|
|
|
|
param_def->meta.m_int.max_val = uspec->maximum;
|
|
|
|
param_def->meta.m_int.default_val = uspec->default_value;
|
|
|
|
}
|
|
|
|
else if (pspec_type == G_TYPE_PARAM_UCHAR)
|
|
|
|
{
|
|
|
|
GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
|
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_INT;
|
|
|
|
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
param_def->meta.m_int.min_val = uspec->minimum;
|
|
|
|
param_def->meta.m_int.max_val = uspec->maximum;
|
|
|
|
param_def->meta.m_int.default_val = uspec->default_value;
|
|
|
|
}
|
2019-07-30 21:04:06 +08:00
|
|
|
else if (pspec_type == GIMP_TYPE_PARAM_UNIT)
|
|
|
|
{
|
|
|
|
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_UNIT;
|
|
|
|
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
param_def->meta.m_unit.allow_pixels = uspec->allow_pixel;
|
2019-07-30 21:04:06 +08:00
|
|
|
param_def->meta.m_unit.allow_percent = uspec->allow_percent;
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
param_def->meta.m_unit.default_val = gimp_unit_get_id (uspec->default_value);
|
2019-07-30 21:04:06 +08:00
|
|
|
}
|
2019-08-05 20:14:32 +08:00
|
|
|
else if (G_IS_PARAM_SPEC_ENUM (pspec))
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-09-12 03:40:17 +08:00
|
|
|
GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_ENUM;
|
|
|
|
|
2019-08-04 23:20:02 +08:00
|
|
|
param_def->meta.m_enum.default_val = espec->default_value;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
}
|
|
|
|
else if (pspec_type == G_TYPE_PARAM_BOOLEAN)
|
|
|
|
{
|
|
|
|
GParamSpecBoolean *bspec = G_PARAM_SPEC_BOOLEAN (pspec);
|
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_BOOLEAN;
|
|
|
|
|
|
|
|
param_def->meta.m_boolean.default_val = bspec->default_value;
|
|
|
|
}
|
|
|
|
else if (pspec_type == G_TYPE_PARAM_DOUBLE)
|
|
|
|
{
|
|
|
|
GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
|
|
|
|
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_DOUBLE;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
param_def->meta.m_double.min_val = dspec->minimum;
|
|
|
|
param_def->meta.m_double.max_val = dspec->maximum;
|
|
|
|
param_def->meta.m_double.default_val = dspec->default_value;
|
2024-11-02 05:52:02 +08:00
|
|
|
}
|
|
|
|
/* Must be before G_IS_PARAM_SPEC_STRING() because it's a parent. */
|
|
|
|
else if (pspec_type == GIMP_TYPE_PARAM_CHOICE)
|
|
|
|
{
|
|
|
|
GimpParamSpecChoice *cspec = GIMP_PARAM_SPEC_CHOICE (pspec);
|
|
|
|
GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
|
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_CHOICE;
|
|
|
|
|
|
|
|
param_def->meta.m_choice.default_val = sspec->default_value;
|
|
|
|
param_def->meta.m_choice.choice = cspec->choice;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
}
|
2019-08-19 18:54:52 +08:00
|
|
|
else if (G_IS_PARAM_SPEC_STRING (pspec))
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-08-02 21:55:52 +08:00
|
|
|
GParamSpecString *gsspec = G_PARAM_SPEC_STRING (pspec);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-28 00:08:58 +08:00
|
|
|
if (! strcmp (param_def->type_name, "GimpParamString"))
|
|
|
|
param_def->type_name = "GParamString";
|
2019-08-19 18:54:52 +08:00
|
|
|
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_STRING;
|
|
|
|
|
2019-08-19 18:54:52 +08:00
|
|
|
param_def->meta.m_string.default_val = gsspec->default_value;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
}
|
2024-04-20 00:54:53 +08:00
|
|
|
else if (GEGL_IS_PARAM_SPEC_COLOR (pspec) ||
|
2024-04-20 05:02:29 +08:00
|
|
|
GIMP_IS_PARAM_SPEC_COLOR (pspec) ||
|
2024-04-20 00:54:53 +08:00
|
|
|
(pspec_type == G_TYPE_PARAM_OBJECT && value_type == GEGL_TYPE_COLOR))
|
2024-02-13 23:07:24 +08:00
|
|
|
{
|
|
|
|
GPParamColor *default_val = NULL;
|
|
|
|
GeglColor *default_color;
|
|
|
|
|
2024-04-19 20:34:22 +08:00
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_GEGL_COLOR;
|
2024-04-20 05:02:29 +08:00
|
|
|
param_def->meta.m_gegl_color.has_alpha = TRUE;
|
2024-02-13 23:07:24 +08:00
|
|
|
|
2024-04-20 00:54:53 +08:00
|
|
|
if (GEGL_IS_PARAM_SPEC_COLOR (pspec))
|
|
|
|
{
|
|
|
|
default_color = gegl_param_spec_color_get_default (pspec);
|
|
|
|
}
|
2024-04-20 05:02:29 +08:00
|
|
|
else if (GIMP_IS_PARAM_SPEC_COLOR (pspec))
|
|
|
|
{
|
app, libgimp*, pdb: new GimpParamSpecObject abstract spec type.
This abstract spec type is basically a GParamSpecObject with a default
value. It will be used by various object spec with default values, such
as GimpParamSpecColor, GimpParamSpecUnit and all GimpParamSpecResource
subtypes. Also it has a duplicate() class method so that every spec type
can implement the proper way to duplicate itself.
This fixes the fact that in gimp_config_param_spec_duplicate(), all
unknown object spec types (because they are implemented in libgimp,
which is invisible to libgimpconfig) are just copied as
GParamSpecObject, hence losing default values and other parameters.
As a second enhancement, it also makes it easier to detect the object
spec types for which we have default value support in
gimp_config_reset_properties().
As a side fix, gimp_param_spec_color() now just always duplicates the
passed default color, making it hence much easier to avoid bugs when
reusing a GeglColor.
2024-09-03 05:38:13 +08:00
|
|
|
default_color = GEGL_COLOR (gimp_param_spec_object_get_default (pspec));
|
2024-04-20 05:02:29 +08:00
|
|
|
param_def->meta.m_gegl_color.has_alpha = gimp_param_spec_color_has_alpha (pspec);
|
|
|
|
}
|
2024-04-20 00:54:53 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const GValue *value = g_param_spec_get_default_value (pspec);
|
|
|
|
|
|
|
|
default_color = g_value_get_object (value);
|
|
|
|
param_def->type_name = "GeglParamColor";
|
|
|
|
}
|
2024-04-20 05:02:29 +08:00
|
|
|
|
2024-02-13 23:07:24 +08:00
|
|
|
if (default_color != NULL)
|
|
|
|
{
|
|
|
|
const Babl *format;
|
|
|
|
|
|
|
|
format = gegl_color_get_format (default_color);
|
|
|
|
default_val = g_new0 (GPParamColor, 1);
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
default_val->size = babl_format_get_bytes_per_pixel (format);
|
|
|
|
default_val->format.encoding = (gchar *) g_strdup (babl_format_get_encoding (format));
|
2024-02-13 23:07:24 +08:00
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
default_val->format.profile_data = NULL;
|
|
|
|
default_val->format.profile_size = 0;
|
2024-02-13 23:07:24 +08:00
|
|
|
if (babl_format_get_space (format) != babl_space ("sRGB"))
|
|
|
|
{
|
|
|
|
const char *icc;
|
|
|
|
int icc_length;
|
|
|
|
|
|
|
|
icc = babl_space_get_icc (babl_format_get_space (format), &icc_length);
|
|
|
|
|
|
|
|
if (icc_length > 0)
|
|
|
|
{
|
2024-09-21 03:55:21 +08:00
|
|
|
default_val->format.profile_data = g_new0 (guint8, icc_length);
|
|
|
|
memcpy (default_val->format.profile_data, icc, icc_length);
|
2024-02-13 23:07:24 +08:00
|
|
|
}
|
2024-09-21 03:55:21 +08:00
|
|
|
default_val->format.profile_size = icc_length;
|
2024-02-13 23:07:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
param_def->meta.m_gegl_color.default_val = default_val;
|
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
else if (pspec_type == GIMP_TYPE_PARAM_IMAGE)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-08-29 17:25:35 +08:00
|
|
|
GimpParamSpecImage *ispec = GIMP_PARAM_SPEC_IMAGE (pspec);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
|
|
|
|
|
|
|
|
param_def->meta.m_id.none_ok = ispec->none_ok;
|
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
else if (GIMP_IS_PARAM_SPEC_ITEM (pspec))
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-08-29 17:25:35 +08:00
|
|
|
GimpParamSpecItem *ispec = GIMP_PARAM_SPEC_ITEM (pspec);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
|
|
|
|
|
|
|
|
param_def->meta.m_id.none_ok = ispec->none_ok;
|
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
else if (pspec_type == GIMP_TYPE_PARAM_DISPLAY)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-08-29 17:25:35 +08:00
|
|
|
GimpParamSpecDisplay *ispec = GIMP_PARAM_SPEC_DISPLAY (pspec);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
|
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
param_def->meta.m_id.none_ok = ispec->none_ok;
|
|
|
|
}
|
2023-08-17 02:48:32 +08:00
|
|
|
else if (GIMP_IS_PARAM_SPEC_RESOURCE (pspec))
|
2022-09-06 07:28:35 +08:00
|
|
|
{
|
2024-09-06 19:38:43 +08:00
|
|
|
GimpParamSpecResource *rspec = GIMP_PARAM_SPEC_RESOURCE (pspec);
|
|
|
|
GObject *default_value = NULL;
|
2022-09-06 07:28:35 +08:00
|
|
|
|
2024-09-06 19:38:43 +08:00
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_RESOURCE;
|
2022-09-06 07:28:35 +08:00
|
|
|
|
2024-09-06 19:38:43 +08:00
|
|
|
if (gimp_param_spec_object_has_default (pspec))
|
|
|
|
default_value = gimp_param_spec_object_get_default (pspec);
|
|
|
|
|
|
|
|
param_def->meta.m_resource.none_ok = rspec->none_ok;
|
|
|
|
param_def->meta.m_resource.default_to_context = rspec->default_to_context;
|
|
|
|
if (default_value != NULL && ! rspec->default_to_context)
|
|
|
|
param_def->meta.m_resource.default_resource_id = get_resource_id (default_value);
|
|
|
|
else
|
|
|
|
param_def->meta.m_resource.default_resource_id = 0;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
}
|
2024-10-22 03:59:26 +08:00
|
|
|
else if (GIMP_IS_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec))
|
|
|
|
{
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID_ARRAY;
|
|
|
|
|
|
|
|
param_def->meta.m_id_array.type_name =
|
|
|
|
(gchar *) g_type_name (GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec)->object_type);
|
|
|
|
}
|
2024-05-07 02:38:12 +08:00
|
|
|
else if (pspec_type == GIMP_TYPE_PARAM_EXPORT_OPTIONS)
|
|
|
|
{
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_EXPORT_OPTIONS;
|
|
|
|
}
|
2019-09-12 03:40:17 +08:00
|
|
|
else if (pspec_type == G_TYPE_PARAM_OBJECT &&
|
2024-04-20 00:54:53 +08:00
|
|
|
value_type != G_TYPE_FILE &&
|
|
|
|
value_type != GEGL_TYPE_COLOR)
|
2019-08-05 20:14:32 +08:00
|
|
|
{
|
2019-08-30 05:37:37 +08:00
|
|
|
const gchar *type_name = NULL;
|
|
|
|
|
2019-09-04 20:27:18 +08:00
|
|
|
if (g_type_is_a (value_type, GIMP_TYPE_DISPLAY))
|
2019-08-30 05:37:37 +08:00
|
|
|
{
|
2019-09-04 20:27:18 +08:00
|
|
|
/* g_type_is_a() because the core has a GimpDisplay subclasses */
|
2019-08-30 05:37:37 +08:00
|
|
|
type_name = "GimpParamDisplay";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_IMAGE)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamImage";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_ITEM)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamItem";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_DRAWABLE)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamDrawable";
|
|
|
|
}
|
2024-07-08 04:17:44 +08:00
|
|
|
else if (value_type == GIMP_TYPE_LAYER)
|
2019-08-30 05:37:37 +08:00
|
|
|
{
|
|
|
|
type_name = "GimpParamLayer";
|
|
|
|
}
|
2024-07-08 04:17:44 +08:00
|
|
|
else if (value_type == GIMP_TYPE_TEXT_LAYER)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamTextLayer";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_GROUP_LAYER)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamGroupLayer";
|
|
|
|
}
|
2019-08-30 05:37:37 +08:00
|
|
|
else if (value_type == GIMP_TYPE_CHANNEL)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamChannel";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_LAYER_MASK)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamLayerMask";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_SELECTION)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamSelection";
|
|
|
|
}
|
2024-07-12 14:16:25 +08:00
|
|
|
else if (value_type == GIMP_TYPE_PATH)
|
2019-08-30 05:37:37 +08:00
|
|
|
{
|
2024-07-12 14:16:25 +08:00
|
|
|
type_name = "GimpParamPath";
|
2019-08-30 05:37:37 +08:00
|
|
|
}
|
2023-08-17 02:48:32 +08:00
|
|
|
else if (value_type == GIMP_TYPE_RESOURCE)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamResource";
|
|
|
|
}
|
2022-09-06 07:28:35 +08:00
|
|
|
else if (value_type == GIMP_TYPE_BRUSH)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamBrush";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_FONT)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamFont";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_GRADIENT)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamGradient";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_PALETTE)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamPalette";
|
|
|
|
}
|
|
|
|
else if (value_type == GIMP_TYPE_PATTERN)
|
|
|
|
{
|
|
|
|
type_name = "GimpParamPattern";
|
|
|
|
}
|
2019-08-30 05:37:37 +08:00
|
|
|
|
|
|
|
if (type_name)
|
|
|
|
{
|
|
|
|
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
|
|
|
|
param_def->type_name = (gchar *) type_name;
|
|
|
|
param_def->meta.m_id.none_ok = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-06 07:28:35 +08:00
|
|
|
g_warning ("%s: GParamSpecObject for unsupported type '%s:%s'",
|
2023-05-31 22:12:04 +08:00
|
|
|
G_STRFUNC,
|
|
|
|
param_def->type_name, param_def->value_type_name);
|
2019-08-30 05:37:37 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
}
|
2019-08-13 18:34:09 +08:00
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
static GimpImage *
|
|
|
|
get_image_by_id (gpointer gimp,
|
|
|
|
gint id)
|
|
|
|
{
|
|
|
|
#ifdef LIBGIMP_COMPILATION
|
|
|
|
return gimp_image_get_by_id (id);
|
|
|
|
#else
|
|
|
|
return gimp_image_get_by_id (gimp, id);
|
|
|
|
#endif
|
|
|
|
}
|
2019-08-24 05:31:19 +08:00
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
static GimpItem *
|
|
|
|
get_item_by_id (gpointer gimp,
|
|
|
|
gint id)
|
|
|
|
{
|
|
|
|
#ifdef LIBGIMP_COMPILATION
|
|
|
|
return gimp_item_get_by_id (id);
|
|
|
|
#else
|
|
|
|
return gimp_item_get_by_id (gimp, id);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-04 20:27:18 +08:00
|
|
|
static GimpDisplay *
|
2019-08-29 17:25:35 +08:00
|
|
|
get_display_by_id (gpointer gimp,
|
|
|
|
gint id)
|
|
|
|
{
|
|
|
|
#ifdef LIBGIMP_COMPILATION
|
2019-09-04 20:27:18 +08:00
|
|
|
return gimp_display_get_by_id (id);
|
2019-08-29 17:25:35 +08:00
|
|
|
#else
|
2019-09-04 20:27:18 +08:00
|
|
|
return gimp_display_get_by_id (gimp, id);
|
2019-08-29 17:25:35 +08:00
|
|
|
#endif
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
}
|
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
static GObject *
|
2023-05-31 22:12:04 +08:00
|
|
|
get_resource_by_id (gint id)
|
2022-09-06 07:28:35 +08:00
|
|
|
{
|
|
|
|
#ifdef LIBGIMP_COMPILATION
|
2023-05-31 22:12:04 +08:00
|
|
|
return (GObject *) gimp_resource_get_by_id (id);
|
2022-09-06 07:28:35 +08:00
|
|
|
#else
|
2023-05-31 22:12:04 +08:00
|
|
|
return (GObject *) gimp_data_get_by_id (id);
|
2022-09-06 07:28:35 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-05-31 22:12:04 +08:00
|
|
|
static gint
|
2022-09-06 07:28:35 +08:00
|
|
|
get_resource_id (GObject *resource)
|
|
|
|
{
|
|
|
|
#ifdef LIBGIMP_COMPILATION
|
2023-05-31 22:12:04 +08:00
|
|
|
return gimp_resource_get_id (GIMP_RESOURCE (resource));
|
2022-09-06 07:28:35 +08:00
|
|
|
#else
|
2023-05-31 22:12:04 +08:00
|
|
|
return gimp_data_get_id (GIMP_DATA (resource));
|
2022-09-06 07:28:35 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
static GimpUnit *
|
|
|
|
get_unit_by_id (gpointer gimp,
|
|
|
|
gint id)
|
|
|
|
{
|
|
|
|
return gimp_unit_get_by_id (id);
|
|
|
|
}
|
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
|
2023-05-31 22:12:04 +08:00
|
|
|
/* Deserialize a gp_param (from the wire) to an instance of object or
|
|
|
|
* primitive type.
|
|
|
|
*
|
2022-09-06 07:28:35 +08:00
|
|
|
* This is used on both the core and plugin (libgimp) side,
|
|
|
|
* each having its own class definitions for a same named class.
|
|
|
|
* Thus this creates different objects, depending on which side it is.
|
|
|
|
* See the conditionally compiled constructors/fetchers above.
|
|
|
|
*/
|
2019-09-05 22:07:15 +08:00
|
|
|
static void
|
|
|
|
gimp_gp_param_to_value (gpointer gimp,
|
|
|
|
const GPParam *param,
|
|
|
|
GType type,
|
2023-10-20 05:34:47 +08:00
|
|
|
GParamSpec *pspec,
|
2019-09-06 02:17:22 +08:00
|
|
|
GValue *value)
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (param != NULL);
|
|
|
|
g_return_if_fail (value != NULL);
|
2024-07-18 03:46:06 +08:00
|
|
|
/* pspec is nullable. */
|
2019-08-05 06:58:44 +08:00
|
|
|
|
2024-07-18 03:46:06 +08:00
|
|
|
/* See also changing of types by caller. */
|
2022-09-06 07:28:35 +08:00
|
|
|
if (type == G_TYPE_NONE || type == G_TYPE_INVALID)
|
|
|
|
{
|
|
|
|
type = g_type_from_name (param->type_name);
|
|
|
|
if (type == 0)
|
2023-05-31 22:12:04 +08:00
|
|
|
{
|
|
|
|
if (! strcmp (param->type_name, "GimpResource"))
|
|
|
|
type = g_type_from_name ("GimpData");
|
|
|
|
else if (! strcmp (param->type_name, "GimpData"))
|
|
|
|
type = g_type_from_name ("GimpResource");
|
|
|
|
else
|
|
|
|
g_critical ("%s: type name %s is not registered", G_STRFUNC,
|
|
|
|
param->type_name);
|
|
|
|
}
|
2022-09-06 07:28:35 +08:00
|
|
|
}
|
|
|
|
/* assert type is not G_TYPE_NONE and type is not G_TYPE_INVALID. */
|
2019-08-05 06:58:44 +08:00
|
|
|
|
|
|
|
g_value_init (value, type);
|
|
|
|
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
if (type == G_TYPE_INT)
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
|
|
|
g_value_set_int (value, param->data.d_int);
|
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_UINT (value))
|
|
|
|
{
|
|
|
|
g_value_set_uint (value, param->data.d_int);
|
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_ENUM (value))
|
|
|
|
{
|
|
|
|
g_value_set_enum (value, param->data.d_int);
|
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_BOOLEAN (value))
|
|
|
|
{
|
|
|
|
g_value_set_boolean (value, param->data.d_int ? TRUE : FALSE);
|
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_DOUBLE (value))
|
|
|
|
{
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
g_value_set_double (value, param->data.d_double);
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_STRING (value))
|
|
|
|
{
|
2019-09-06 02:17:22 +08:00
|
|
|
g_value_set_string (value, param->data.d_string);
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
2020-12-24 04:15:43 +08:00
|
|
|
else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
|
|
|
|
{
|
|
|
|
g_value_set_boxed (value, param->data.d_strv);
|
|
|
|
}
|
2023-05-24 05:37:46 +08:00
|
|
|
else if (G_VALUE_HOLDS (value, G_TYPE_BYTES))
|
|
|
|
{
|
|
|
|
g_value_set_boxed (value, param->data.d_bytes);
|
|
|
|
}
|
2023-08-03 04:53:56 +08:00
|
|
|
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_FILE))
|
2019-09-12 03:40:17 +08:00
|
|
|
{
|
|
|
|
g_value_take_object (value, (param->data.d_string ?
|
|
|
|
g_file_new_for_uri (param->data.d_string) :
|
|
|
|
NULL));
|
|
|
|
}
|
2024-09-21 03:55:21 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_BABL_FORMAT (value))
|
|
|
|
{
|
|
|
|
const Babl *format = NULL;
|
|
|
|
const Babl *space = NULL;
|
|
|
|
const gchar *encoding;
|
|
|
|
GimpColorProfile *profile;
|
|
|
|
|
|
|
|
encoding = param->data.d_format.encoding;
|
|
|
|
profile = gimp_color_profile_new_from_icc_profile (param->data.d_format.profile_data,
|
|
|
|
param->data.d_format.profile_size,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (profile)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
space = gimp_color_profile_get_space (profile,
|
|
|
|
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (! space)
|
|
|
|
{
|
|
|
|
g_printerr ("%s: failed to create Babl space from profile: %s\n",
|
|
|
|
G_STRFUNC, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
g_object_unref (profile);
|
|
|
|
}
|
|
|
|
|
|
|
|
format = babl_format_with_space (encoding, space);
|
|
|
|
|
|
|
|
g_value_set_boxed (value, format);
|
|
|
|
}
|
2023-11-04 04:26:51 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_COLOR (value))
|
|
|
|
{
|
|
|
|
GeglColor *color;
|
|
|
|
const Babl *format = NULL;
|
|
|
|
const Babl *space = NULL;
|
|
|
|
const gchar *encoding;
|
|
|
|
GimpColorProfile *profile;
|
|
|
|
gint bpp;
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
encoding = param->data.d_gegl_color.format.encoding;
|
|
|
|
profile = gimp_color_profile_new_from_icc_profile (param->data.d_gegl_color.format.profile_data,
|
|
|
|
param->data.d_gegl_color.format.profile_size,
|
2023-11-04 04:26:51 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (profile)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
space = gimp_color_profile_get_space (profile,
|
|
|
|
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (! space)
|
|
|
|
{
|
|
|
|
g_printerr ("%s: failed to create Babl space from profile: %s\n",
|
|
|
|
G_STRFUNC, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
g_object_unref (profile);
|
|
|
|
}
|
2024-06-24 00:09:38 +08:00
|
|
|
|
2023-11-04 04:26:51 +08:00
|
|
|
format = babl_format_with_space (encoding, space);
|
|
|
|
color = gegl_color_new ("black");
|
|
|
|
|
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
|
|
|
if (bpp != param->data.d_gegl_color.size)
|
|
|
|
g_printerr ("%s: encoding \"%s\" expects %d bpp but data size is %d bpp.\n",
|
|
|
|
G_STRFUNC, encoding, bpp, param->data.d_gegl_color.size);
|
|
|
|
else
|
|
|
|
gegl_color_set_pixel (color, format, param->data.d_gegl_color.data);
|
|
|
|
|
|
|
|
g_value_take_object (value, color);
|
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_PARASITE (value))
|
|
|
|
{
|
2019-09-06 02:17:22 +08:00
|
|
|
g_value_set_boxed (value, ¶m->data.d_parasite);
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_INT32_ARRAY (value))
|
|
|
|
{
|
2019-09-06 02:17:22 +08:00
|
|
|
gimp_value_set_int32_array (value,
|
|
|
|
(gint32 *) param->data.d_array.data,
|
|
|
|
param->data.d_array.size /
|
|
|
|
sizeof (gint32));
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_DOUBLE_ARRAY (value))
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
gimp_value_set_double_array (value,
|
2019-09-06 02:17:22 +08:00
|
|
|
(const gdouble *)
|
|
|
|
param->data.d_array.data,
|
|
|
|
param->data.d_array.size /
|
|
|
|
sizeof (gdouble));
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
2023-12-27 00:07:19 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_COLOR_ARRAY (value))
|
|
|
|
{
|
|
|
|
GeglColor **colors;
|
|
|
|
|
|
|
|
colors = g_new0 (GeglColor *, param->data.d_color_array.size + 1);
|
|
|
|
|
|
|
|
for (gint i = 0; i < param->data.d_color_array.size; i++)
|
|
|
|
{
|
|
|
|
GeglColor *color;
|
|
|
|
const Babl *format = NULL;
|
|
|
|
const Babl *space = NULL;
|
|
|
|
GimpColorProfile *profile = NULL;
|
|
|
|
const gchar *encoding;
|
|
|
|
gint bpp;
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
encoding = param->data.d_color_array.colors[i].format.encoding;
|
|
|
|
if (param->data.d_color_array.colors[i].format.profile_size > 0)
|
|
|
|
profile = gimp_color_profile_new_from_icc_profile (param->data.d_color_array.colors[i].format.profile_data,
|
|
|
|
param->data.d_color_array.colors[i].format.profile_size,
|
2023-12-27 00:07:19 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (profile)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
space = gimp_color_profile_get_space (profile,
|
|
|
|
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (! space)
|
|
|
|
{
|
|
|
|
g_printerr ("%s: failed to create Babl space from profile: %s\n",
|
|
|
|
G_STRFUNC, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
g_object_unref (profile);
|
|
|
|
}
|
|
|
|
format = babl_format_with_space (encoding, space);
|
|
|
|
color = gegl_color_new ("black");
|
|
|
|
|
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
|
|
|
if (bpp != param->data.d_color_array.colors[i].size)
|
|
|
|
g_printerr ("%s: encoding \"%s\" expects %d bpp but data size is %d bpp.\n",
|
|
|
|
G_STRFUNC, encoding, bpp, param->data.d_color_array.colors[i].size);
|
|
|
|
else
|
|
|
|
gegl_color_set_pixel (color, format, param->data.d_color_array.colors[i].data);
|
|
|
|
|
|
|
|
colors[i] = color;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_take_boxed (value, colors);
|
|
|
|
}
|
2024-10-22 03:59:26 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_CORE_OBJECT_ARRAY (value))
|
|
|
|
{
|
|
|
|
GType object_type = G_TYPE_INVALID;
|
|
|
|
GObject **objects;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (param->data.d_id_array.type_name != NULL)
|
|
|
|
{
|
|
|
|
/* An empty array from a NULL has an arbitrary type_name set earlier. */
|
|
|
|
object_type = g_type_from_name (param->data.d_id_array.type_name);
|
|
|
|
}
|
|
|
|
else if (pspec != NULL)
|
|
|
|
{
|
|
|
|
object_type = GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec)->object_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param->data.d_id_array.size > 1 && ! g_type_is_a (object_type, G_TYPE_OBJECT))
|
|
|
|
{
|
|
|
|
g_warning ("%s: GimpCoreObjectArray of unknown type.", G_STRFUNC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* size might be zero. */
|
|
|
|
|
|
|
|
objects = g_new0 (GObject *, param->data.d_id_array.size + 1);
|
|
|
|
|
|
|
|
for (i = 0; i < param->data.d_id_array.size; i++)
|
|
|
|
{
|
|
|
|
gint id = param->data.d_id_array.data[i];
|
|
|
|
|
|
|
|
if (object_type == GIMP_TYPE_IMAGE)
|
|
|
|
{
|
|
|
|
objects[i] = (GObject *) get_image_by_id (gimp, id);
|
|
|
|
}
|
|
|
|
else if (g_type_is_a (object_type, GIMP_TYPE_ITEM))
|
|
|
|
{
|
|
|
|
objects[i] = (GObject *) get_item_by_id (gimp, id);
|
|
|
|
}
|
|
|
|
else if (g_type_is_a (object_type, GIMP_TYPE_DISPLAY))
|
|
|
|
{
|
|
|
|
objects[i] = (GObject *) get_display_by_id (gimp, id);
|
|
|
|
}
|
|
|
|
else if (g_type_is_a (object_type, GIMP_TYPE_RESOURCE))
|
|
|
|
{
|
|
|
|
objects[i] = (GObject *) get_resource_by_id (id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Even when size is zero, set gvalue to an empty GimpObjectArray object,
|
|
|
|
* having a valid but possibly arbitrary type of its elements.
|
|
|
|
*/
|
|
|
|
g_value_set_boxed (value, objects);
|
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_IMAGE (value))
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
2019-08-29 17:25:35 +08:00
|
|
|
g_value_set_object (value, get_image_by_id (gimp, param->data.d_int));
|
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_ITEM (value))
|
|
|
|
{
|
|
|
|
g_value_set_object (value, get_item_by_id (gimp, param->data.d_int));
|
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_DISPLAY (value))
|
|
|
|
{
|
|
|
|
g_value_set_object (value, get_display_by_id (gimp, param->data.d_int));
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
2022-09-06 07:28:35 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_RESOURCE (value))
|
|
|
|
{
|
2023-05-31 22:12:04 +08:00
|
|
|
g_value_set_object (value, get_resource_by_id (param->data.d_int));
|
2022-09-06 07:28:35 +08:00
|
|
|
}
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_UNIT (value))
|
|
|
|
{
|
|
|
|
g_value_set_object (value, get_unit_by_id (gimp, param->data.d_int));
|
|
|
|
}
|
2024-05-07 02:38:12 +08:00
|
|
|
else if (g_type_is_a (G_VALUE_TYPE (value), GIMP_TYPE_EXPORT_OPTIONS))
|
|
|
|
{
|
app, libgimp*, pdb, plug-ins: review and enhance MR !1549.
- Fix annotations for gimp_export_options_get_image() to make it
actually introspectable with the GimpImage being both input and
output. Even though the logic doesn't change much (the input image may
be overriden or not), it doesn't matter for introspection because
images are handled centrally by libgimp and therefore must not be
freed. Actually deleting the image from the central list of images
though remains a manual action depending on code logic, not some
automatic action to be handled by binding engines.
- Add G_GNUC_WARN_UNUSED_RESULT to gimp_export_options_get_image()
because ignoring the returned value is rarely a good idea (as you
usually want to delete the image).
- Remove gimp_export_options_new(): we don't need this constructor
because at this point, the best is to tell plug-in developers to just
pass NULL everywhere. This leaves us free to create a more useful
default constructor if needed, in the future. Main description for
GimpExportOptions has also been updated to say this.
- Add a data_destroy callback for the user data passed in
gimp_export_procedure_set_capabilities().
- Fixing annotations of 'export_options' object from pdb/pdb.pl: input
args would actually be (nullable) and would not transfer ownership
(calling code must still free the object). Return value's ownership on
the other hand is fully transfered.
- Add C and Python unit testing for GimpExportOptions and
gimp_export_options_get_image() in particular.
- Fix or improve various details.
Note that I have also considered for a long time changing the signature
of gimp_export_options_get_image() to return a boolean indicating
whether `image` had been replaced (hence needed deletion) or not. This
also meant getting rid of the GimpExportReturn enum. Right now it would
work because there are no third case, but I was considering the future
possibility that for instance we got some impossible conversion for some
future capability. I'm not sure it would ever happen; and for sure, this
is not desirable because it implies an export failure a bit late in the
workflow. But just in case, let's keep the enum return value. It does
not even make the using code that much more complicated (well just a
value comparison instead of a simple boolean test).
2024-08-17 21:06:27 +08:00
|
|
|
GimpExportOptions *options;
|
2024-05-07 02:38:12 +08:00
|
|
|
|
2024-11-02 02:13:02 +08:00
|
|
|
/* Recreating the same options when it'll have settings. The
|
|
|
|
* "capabilities" property doesn't need to be recreated. It is
|
|
|
|
* managed by the GimpExportProcedure code.
|
|
|
|
*/
|
|
|
|
options = g_object_new (GIMP_TYPE_EXPORT_OPTIONS, NULL);
|
2024-05-07 02:38:12 +08:00
|
|
|
|
|
|
|
g_value_set_object (value, options);
|
|
|
|
|
|
|
|
g_object_unref (options);
|
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
else if (G_VALUE_HOLDS_PARAM (value))
|
|
|
|
{
|
|
|
|
GParamSpec *pspec =
|
2019-09-05 22:07:15 +08:00
|
|
|
_gimp_gp_param_def_to_param_spec (¶m->data.d_param_def);
|
2019-08-05 06:58:44 +08:00
|
|
|
|
|
|
|
g_value_take_param (value, pspec);
|
|
|
|
}
|
2022-09-06 07:28:35 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: unsupported deserialization to GValue of type '%s'\n",
|
|
|
|
G_STRFUNC, param->type_name);
|
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
|
|
|
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
GimpValueArray *
|
2019-08-07 06:02:29 +08:00
|
|
|
_gimp_gp_params_to_value_array (gpointer gimp,
|
|
|
|
GParamSpec **pspecs,
|
|
|
|
gint n_pspecs,
|
|
|
|
const GPParam *params,
|
|
|
|
gint n_params,
|
2019-09-06 02:17:22 +08:00
|
|
|
gboolean return_values)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
|
|
|
GimpValueArray *args;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail ((params != NULL && n_params > 0) ||
|
|
|
|
(params == NULL && n_params == 0), NULL);
|
|
|
|
|
|
|
|
args = gimp_value_array_new (n_params);
|
|
|
|
|
|
|
|
for (i = 0; i < n_params; i++)
|
|
|
|
{
|
2023-10-20 05:34:47 +08:00
|
|
|
GParamSpec *pspec = NULL;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
GType type;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
|
|
|
/* first get the GType from the passed GPParam */
|
|
|
|
type = g_type_from_name (params[i].type_name);
|
|
|
|
|
|
|
|
/* then try to try to be more specific by looking at the param
|
|
|
|
* spec (return values have one additional value (the status),
|
|
|
|
* skip that, it's not in the array of param specs)
|
|
|
|
*/
|
|
|
|
if (i > 0 || ! return_values)
|
|
|
|
{
|
|
|
|
gint pspec_index = i;
|
|
|
|
|
|
|
|
if (return_values)
|
|
|
|
pspec_index--;
|
|
|
|
|
|
|
|
/* are there param specs left? */
|
|
|
|
if (pspec_index < n_pspecs)
|
|
|
|
{
|
|
|
|
GType pspec_type = G_PARAM_SPEC_VALUE_TYPE (pspecs[pspec_index]);
|
|
|
|
|
2023-10-20 05:34:47 +08:00
|
|
|
pspec = pspecs[pspec_index];
|
|
|
|
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
if (type != pspec_type)
|
|
|
|
{
|
|
|
|
if (g_type_is_a (pspec_type, type))
|
|
|
|
{
|
|
|
|
/* if the param spec's GType is more specific
|
|
|
|
* than the one from the GPParam, use the param
|
|
|
|
* spec's GType.
|
|
|
|
*/
|
|
|
|
type = pspec_type;
|
|
|
|
}
|
2019-08-15 20:04:56 +08:00
|
|
|
else if (type == G_TYPE_INT)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
|
|
|
if (g_type_is_a (pspec_type, G_TYPE_ENUM))
|
|
|
|
{
|
|
|
|
/* if the param spec's type is enum, but an
|
2019-08-15 20:04:56 +08:00
|
|
|
* int was passed, use the enum type.
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
*/
|
|
|
|
type = pspec_type;
|
|
|
|
}
|
|
|
|
else if (g_type_is_a (pspec_type, G_TYPE_BOOLEAN))
|
|
|
|
{
|
|
|
|
/* if the param spec's type is boolean, but
|
2019-08-15 20:04:56 +08:00
|
|
|
* an int was passed, use the boolean
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
* type.
|
|
|
|
*/
|
|
|
|
type = pspec_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-20 05:34:47 +08:00
|
|
|
gimp_gp_param_to_value (gimp, ¶ms[i], type, pspec, &value);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
|
|
|
gimp_value_array_append (args, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
2019-09-05 22:07:15 +08:00
|
|
|
static void
|
|
|
|
gimp_value_to_gp_param (const GValue *value,
|
|
|
|
GPParam *param,
|
|
|
|
gboolean full_copy)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-08-05 06:58:44 +08:00
|
|
|
GType type;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
g_return_if_fail (value != NULL);
|
|
|
|
g_return_if_fail (param != NULL);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-24 05:31:19 +08:00
|
|
|
type = G_VALUE_TYPE (value);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
param->param_type = -1;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
if (full_copy)
|
|
|
|
param->type_name = g_strdup (g_type_name (type));
|
|
|
|
else
|
|
|
|
param->type_name = (gchar *) g_type_name (type);
|
|
|
|
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
if (type == G_TYPE_INT)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-08-05 06:58:44 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
|
|
|
|
|
|
|
param->data.d_int = g_value_get_int (value);
|
|
|
|
}
|
2019-08-15 19:34:11 +08:00
|
|
|
else if (type == G_TYPE_UINT)
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
|
|
|
|
|
|
|
param->data.d_int = g_value_get_uint (value);
|
|
|
|
}
|
2019-08-15 19:34:11 +08:00
|
|
|
else if (type == G_TYPE_UCHAR)
|
|
|
|
{
|
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
|
|
|
|
|
|
|
param->data.d_int = g_value_get_uchar (value);
|
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
else if (G_VALUE_HOLDS_ENUM (value))
|
|
|
|
{
|
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
|
|
|
|
|
|
|
param->data.d_int = g_value_get_enum (value);
|
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_BOOLEAN (value))
|
|
|
|
{
|
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
|
|
|
|
|
|
|
param->data.d_int = g_value_get_boolean (value);
|
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_DOUBLE (value))
|
|
|
|
{
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_DOUBLE;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
param->data.d_double = g_value_get_double (value);
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_STRING (value))
|
|
|
|
{
|
|
|
|
param->param_type = GP_PARAM_TYPE_STRING;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
|
|
|
if (full_copy)
|
2019-08-05 06:58:44 +08:00
|
|
|
param->data.d_string = g_value_dup_string (value);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
else
|
2019-08-05 06:58:44 +08:00
|
|
|
param->data.d_string = (gchar *) g_value_get_string (value);
|
|
|
|
}
|
2023-08-03 04:53:56 +08:00
|
|
|
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_FILE))
|
2019-09-12 03:40:17 +08:00
|
|
|
{
|
|
|
|
GFile *file = g_value_get_object (value);
|
|
|
|
|
|
|
|
param->param_type = GP_PARAM_TYPE_FILE;
|
|
|
|
|
|
|
|
param->data.d_string = file ? g_file_get_uri (file) : NULL;
|
|
|
|
}
|
2024-09-21 03:55:21 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_BABL_FORMAT (value))
|
|
|
|
{
|
|
|
|
const Babl *format;
|
|
|
|
int icc_length = 0;
|
|
|
|
|
|
|
|
param->param_type = GP_PARAM_TYPE_BABL_FORMAT;
|
|
|
|
|
|
|
|
format = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
/* TODO: For indexed colors, we'll convert to R'G'B'(A) u8 as that
|
|
|
|
* is currently what we support. As indexed format support improves,
|
|
|
|
* we'll want to make this space and encoding agnostic. */
|
|
|
|
if (babl_format_is_palette (format))
|
|
|
|
{
|
|
|
|
const Babl *indexed_format = NULL;
|
|
|
|
gint bpp;
|
|
|
|
|
|
|
|
g_warning ("%s: GValue of type '%s' holds an indexed format. "
|
|
|
|
"This is unsupported and replaced with \"R'G'B' u8\".",
|
|
|
|
G_STRFUNC, param->type_name);
|
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
|
|
|
if (bpp == 1)
|
|
|
|
indexed_format = babl_format_with_space ("R'G'B' u8",
|
|
|
|
babl_format_get_space (format));
|
|
|
|
else if (bpp == 2)
|
|
|
|
indexed_format = babl_format_with_space ("R'G'B'A u8",
|
|
|
|
babl_format_get_space (format));
|
|
|
|
|
|
|
|
/* TODO: This is to notify us in the future when indexed image can have more than
|
|
|
|
* 256 colors - we'll need to update encoding support accordingly */
|
|
|
|
g_return_if_fail (indexed_format != NULL);
|
|
|
|
|
|
|
|
format = indexed_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
param->data.d_format.encoding = (gchar *) babl_format_get_encoding (format);
|
|
|
|
param->data.d_format.profile_data = (guint8 *) babl_space_get_icc (babl_format_get_space (format),
|
|
|
|
&icc_length);
|
|
|
|
param->data.d_format.profile_size = icc_length;
|
|
|
|
}
|
2023-11-04 04:26:51 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_COLOR (value))
|
|
|
|
{
|
|
|
|
GeglColor *color;
|
|
|
|
const Babl *format;
|
|
|
|
int icc_length = 0;
|
|
|
|
|
|
|
|
param->param_type = GP_PARAM_TYPE_GEGL_COLOR;
|
|
|
|
|
|
|
|
color = g_value_get_object (value);
|
|
|
|
format = gegl_color_get_format (color);
|
|
|
|
|
2024-06-24 00:09:38 +08:00
|
|
|
/* TODO: For indexed colors, we'll convert to R'G'B'(A) u8 as that
|
|
|
|
* is currently what we support. As indexed format support improves,
|
|
|
|
* we'll want to make this space and encoding agnostic. */
|
|
|
|
if (babl_format_is_palette (format))
|
|
|
|
{
|
|
|
|
const Babl *indexed_format = NULL;
|
|
|
|
gint bpp;
|
|
|
|
|
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
|
|
|
if (bpp == 1)
|
|
|
|
indexed_format = babl_format_with_space ("R'G'B' u8",
|
|
|
|
babl_format_get_space (format));
|
|
|
|
else if (bpp == 2)
|
|
|
|
indexed_format = babl_format_with_space ("R'G'B'A u8",
|
|
|
|
babl_format_get_space (format));
|
|
|
|
|
|
|
|
/* TODO: This is to notify us in the future when indexed image can have more than
|
|
|
|
* 256 colors - we'll need to update encoding support accordingly */
|
|
|
|
g_return_if_fail (indexed_format != NULL);
|
|
|
|
|
|
|
|
format = indexed_format;
|
|
|
|
}
|
|
|
|
|
2023-11-04 04:26:51 +08:00
|
|
|
param->data.d_gegl_color.size = babl_format_get_bytes_per_pixel (format);
|
|
|
|
gegl_color_get_pixel (color, format, ¶m->data.d_gegl_color.data);
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
param->data.d_gegl_color.format.encoding = (gchar *) babl_format_get_encoding (format);
|
|
|
|
param->data.d_gegl_color.format.profile_data = (guint8 *) babl_space_get_icc (babl_format_get_space (format),
|
|
|
|
&icc_length);
|
|
|
|
param->data.d_gegl_color.format.profile_size = icc_length;
|
2023-11-04 04:26:51 +08:00
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_PARASITE (value))
|
|
|
|
{
|
|
|
|
GimpParasite *parasite = (full_copy ?
|
|
|
|
g_value_dup_boxed (value) :
|
|
|
|
g_value_get_boxed (value));
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_PARASITE;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
if (parasite)
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-08-05 06:58:44 +08:00
|
|
|
param->data.d_parasite.name = parasite->name;
|
|
|
|
param->data.d_parasite.flags = parasite->flags;
|
|
|
|
param->data.d_parasite.size = parasite->size;
|
|
|
|
param->data.d_parasite.data = parasite->data;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
if (full_copy)
|
|
|
|
{
|
|
|
|
parasite->name = NULL;
|
|
|
|
parasite->flags = 0;
|
|
|
|
parasite->size = 0;
|
|
|
|
parasite->data = NULL;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
gimp_parasite_free (parasite);
|
|
|
|
}
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
else
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
{
|
2019-08-05 06:58:44 +08:00
|
|
|
param->data.d_parasite.name = NULL;
|
|
|
|
param->data.d_parasite.flags = 0;
|
|
|
|
param->data.d_parasite.size = 0;
|
|
|
|
param->data.d_parasite.data = NULL;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_INT32_ARRAY (value) ||
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
GIMP_VALUE_HOLDS_DOUBLE_ARRAY (value))
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
|
|
|
GimpArray *array = g_value_get_boxed (value);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2020-01-06 23:16:18 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_ARRAY;
|
|
|
|
|
2019-08-14 04:52:19 +08:00
|
|
|
if (array)
|
|
|
|
{
|
|
|
|
param->data.d_array.size = array->length;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-14 04:52:19 +08:00
|
|
|
if (full_copy)
|
2021-08-26 23:18:32 +08:00
|
|
|
param->data.d_array.data = g_memdup2 (array->data,
|
|
|
|
array->length);
|
2019-08-14 04:52:19 +08:00
|
|
|
else
|
|
|
|
param->data.d_array.data = array->data;
|
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
else
|
2019-08-14 04:52:19 +08:00
|
|
|
{
|
2020-01-06 23:16:18 +08:00
|
|
|
param->data.d_array.size = 0;
|
2019-08-14 04:52:19 +08:00
|
|
|
param->data.d_array.data = NULL;
|
|
|
|
}
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
2023-12-27 00:07:19 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_COLOR_ARRAY (value))
|
|
|
|
{
|
|
|
|
GeglColor **colors = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
param->param_type = GP_PARAM_TYPE_COLOR_ARRAY;
|
|
|
|
|
|
|
|
if (colors != NULL)
|
|
|
|
{
|
|
|
|
param->data.d_color_array.size = gimp_color_array_get_length (colors);
|
|
|
|
param->data.d_color_array.colors = g_new0 (GPParamColor,
|
|
|
|
param->data.d_color_array.size);
|
|
|
|
for (gint i = 0; i < param->data.d_color_array.size; i++)
|
|
|
|
{
|
|
|
|
const Babl *format;
|
|
|
|
int icc_length = 0;
|
|
|
|
|
|
|
|
format = gegl_color_get_format (colors[i]);
|
|
|
|
|
|
|
|
param->data.d_color_array.colors[i].size = babl_format_get_bytes_per_pixel (format);
|
|
|
|
gegl_color_get_pixel (colors[i], format, ¶m->data.d_color_array.colors[i].data);
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
param->data.d_color_array.colors[i].format.encoding = (gchar *) babl_format_get_encoding (format);
|
2023-12-27 00:07:19 +08:00
|
|
|
|
|
|
|
if (babl_format_get_space (format) != babl_space ("sRGB"))
|
2024-09-21 03:55:21 +08:00
|
|
|
param->data.d_color_array.colors[i].format.profile_data = (guint8 *) babl_space_get_icc (babl_format_get_space (format),
|
|
|
|
&icc_length);
|
|
|
|
param->data.d_gegl_color.format.profile_size = icc_length;
|
2023-12-27 00:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
param->data.d_color_array.size = 0;
|
|
|
|
param->data.d_color_array.colors = NULL;
|
|
|
|
}
|
|
|
|
}
|
2023-05-24 05:37:46 +08:00
|
|
|
else if (G_VALUE_HOLDS (value, G_TYPE_BYTES))
|
|
|
|
{
|
|
|
|
GBytes *bytes = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
param->param_type = GP_PARAM_TYPE_BYTES;
|
|
|
|
|
|
|
|
if (bytes != NULL)
|
|
|
|
{
|
|
|
|
if (full_copy)
|
|
|
|
param->data.d_bytes = g_bytes_new (g_bytes_get_data (bytes, NULL),
|
|
|
|
g_bytes_get_size (bytes));
|
|
|
|
else
|
|
|
|
param->data.d_bytes = g_bytes_new_static (g_bytes_get_data (bytes, NULL),
|
|
|
|
g_bytes_get_size (bytes));
|
|
|
|
}
|
|
|
|
}
|
2020-12-24 04:15:43 +08:00
|
|
|
else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
2022-05-25 05:52:15 +08:00
|
|
|
gchar **array = g_value_get_boxed (value);
|
2020-01-06 23:16:18 +08:00
|
|
|
|
2020-12-24 04:15:43 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_STRV;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2020-12-24 04:15:43 +08:00
|
|
|
if (full_copy)
|
|
|
|
param->data.d_strv = g_strdupv (array);
|
2019-08-05 06:58:44 +08:00
|
|
|
else
|
2020-12-24 04:15:43 +08:00
|
|
|
param->data.d_strv = array;
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
2024-10-22 03:59:26 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_CORE_OBJECT_ARRAY (value))
|
|
|
|
{
|
|
|
|
GObject **array = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
param->param_type = GP_PARAM_TYPE_ID_ARRAY;
|
|
|
|
param->data.d_id_array.type_name = NULL;
|
|
|
|
|
|
|
|
if (array && array[0])
|
|
|
|
{
|
|
|
|
GType element_type = G_TYPE_NONE;
|
|
|
|
gsize array_length;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; array[i] != NULL; i++)
|
|
|
|
{
|
|
|
|
if (element_type != G_TYPE_NONE)
|
|
|
|
{
|
|
|
|
if (! g_type_is_a (G_TYPE_FROM_INSTANCE (array[i]), element_type))
|
|
|
|
{
|
|
|
|
g_warning ("%s: GimpCoreObjectArray with element type %s holds unsupported element of type '%s'", G_STRFUNC,
|
|
|
|
g_type_name (element_type), g_type_name (G_TYPE_FROM_INSTANCE (array[i])));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GIMP_IS_IMAGE (array[i]))
|
|
|
|
{
|
|
|
|
element_type = GIMP_TYPE_IMAGE;
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_ITEM (array[i]))
|
|
|
|
{
|
|
|
|
element_type = GIMP_TYPE_ITEM;
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_DISPLAY (array[i]))
|
|
|
|
{
|
|
|
|
element_type = GIMP_TYPE_DISPLAY;
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_RESOURCE (array[i]))
|
|
|
|
{
|
|
|
|
element_type = GIMP_TYPE_RESOURCE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: GimpCoreObjectArray holds unsupported type '%s'", G_STRFUNC,
|
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (array[i])));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
array_length = i;
|
|
|
|
param->data.d_id_array.size = array_length;
|
|
|
|
|
|
|
|
if (array_length > 0)
|
|
|
|
{
|
|
|
|
if (full_copy)
|
|
|
|
param->data.d_id_array.type_name = g_strdup (g_type_name (element_type));
|
|
|
|
else
|
|
|
|
param->data.d_id_array.type_name = (gchar *) g_type_name (element_type);
|
|
|
|
|
|
|
|
/* must be free'd also for full_copy == FALSE */
|
|
|
|
param->data.d_id_array.data = g_new (gint32, array_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < array_length; i++)
|
|
|
|
{
|
|
|
|
if (GIMP_IS_IMAGE (array[i]))
|
|
|
|
{
|
|
|
|
param->data.d_id_array.data[i] =
|
|
|
|
gimp_image_get_id (GIMP_IMAGE (array[i]));
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_ITEM (array[i]))
|
|
|
|
{
|
|
|
|
param->data.d_id_array.data[i] =
|
|
|
|
gimp_item_get_id (GIMP_ITEM (array[i]));
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_DISPLAY (array[i]))
|
|
|
|
{
|
|
|
|
param->data.d_id_array.data[i] =
|
|
|
|
gimp_display_get_id (GIMP_DISPLAY (array[i]));
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_RESOURCE (array[i]))
|
|
|
|
{
|
|
|
|
param->data.d_id_array.data[i] = get_resource_id (array[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
param->data.d_id_array.data[i] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* GValue intended to hold an array of objects is NULL.
|
|
|
|
* For convenience, we allow this, meaning empty.
|
|
|
|
*/
|
|
|
|
param->data.d_id_array.size = 0;
|
|
|
|
param->data.d_id_array.data = NULL;
|
|
|
|
}
|
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_IMAGE (value))
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
2019-08-29 17:25:35 +08:00
|
|
|
GimpImage *image = g_value_get_object (value);
|
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
param->data.d_int = image ? gimp_image_get_id (image) : -1;
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_ITEM (value))
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
2019-08-29 17:25:35 +08:00
|
|
|
GimpItem *item = g_value_get_object (value);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
|
|
|
|
|
|
|
param->data.d_int = item ? gimp_item_get_id (item) : -1;
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_DISPLAY (value))
|
2019-08-14 20:56:28 +08:00
|
|
|
{
|
2019-09-04 20:27:18 +08:00
|
|
|
GimpDisplay *display = g_value_get_object (value);
|
2019-08-24 05:31:19 +08:00
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
2019-08-24 05:31:19 +08:00
|
|
|
|
2019-09-04 20:27:18 +08:00
|
|
|
param->data.d_int = display ? gimp_display_get_id (display) : -1;
|
2019-08-29 17:25:35 +08:00
|
|
|
}
|
2022-09-06 07:28:35 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_RESOURCE (value))
|
|
|
|
{
|
|
|
|
GObject *resource = g_value_get_object (value);
|
|
|
|
|
2023-05-31 22:12:04 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
2023-01-15 02:06:03 +08:00
|
|
|
|
2023-05-31 22:12:04 +08:00
|
|
|
param->data.d_int = resource ? get_resource_id (resource) : -1;
|
2022-09-06 07:28:35 +08:00
|
|
|
}
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
else if (GIMP_VALUE_HOLDS_UNIT (value))
|
|
|
|
{
|
|
|
|
GimpUnit *unit = g_value_get_object (value);
|
|
|
|
|
|
|
|
param->param_type = GP_PARAM_TYPE_INT;
|
|
|
|
|
|
|
|
param->data.d_int = unit ? gimp_unit_get_id (unit) : -1;
|
|
|
|
}
|
2024-05-07 02:38:12 +08:00
|
|
|
else if (g_type_is_a (G_VALUE_TYPE (value), GIMP_TYPE_EXPORT_OPTIONS))
|
|
|
|
{
|
2024-11-02 02:13:02 +08:00
|
|
|
param->param_type = GP_PARAM_TYPE_EXPORT_OPTIONS;
|
2024-05-07 02:38:12 +08:00
|
|
|
}
|
2019-08-29 17:25:35 +08:00
|
|
|
else if (G_VALUE_HOLDS_PARAM (value))
|
|
|
|
{
|
|
|
|
param->param_type = GP_PARAM_TYPE_PARAM_DEF;
|
2019-08-24 05:31:19 +08:00
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
_gimp_param_spec_to_gp_param_def (g_value_get_param (value),
|
|
|
|
¶m->data.d_param_def);
|
2019-08-14 20:56:28 +08:00
|
|
|
}
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
if (param->param_type == -1)
|
2022-09-06 07:28:35 +08:00
|
|
|
g_warning ("%s: GValue holds unsupported type '%s'", G_STRFUNC, param->type_name);
|
2019-08-05 06:58:44 +08:00
|
|
|
}
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
GPParam *
|
2019-08-07 06:02:29 +08:00
|
|
|
_gimp_value_array_to_gp_params (const GimpValueArray *args,
|
|
|
|
gboolean full_copy)
|
2019-08-05 06:58:44 +08:00
|
|
|
{
|
|
|
|
GPParam *params;
|
|
|
|
gint length;
|
|
|
|
gint i;
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
g_return_val_if_fail (args != NULL, NULL);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
length = gimp_value_array_length (args);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
params = g_new0 (GPParam, length);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-08-05 06:58:44 +08:00
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
GValue *value = gimp_value_array_index (args, i);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
|
2019-09-05 22:07:15 +08:00
|
|
|
gimp_value_to_gp_param (value, ¶ms[i], full_copy);
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return params;
|
|
|
|
}
|
2019-09-06 02:59:57 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
_gimp_gp_params_free (GPParam *params,
|
|
|
|
gint n_params,
|
|
|
|
gboolean full_copy)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < n_params; i++)
|
|
|
|
{
|
|
|
|
if (full_copy)
|
|
|
|
g_free (params[i].type_name);
|
|
|
|
|
|
|
|
switch (params[i].param_type)
|
|
|
|
{
|
|
|
|
case GP_PARAM_TYPE_INT:
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
case GP_PARAM_TYPE_DOUBLE:
|
2019-09-06 02:59:57 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_TYPE_STRING:
|
|
|
|
if (full_copy)
|
|
|
|
g_free (params[i].data.d_string);
|
|
|
|
break;
|
|
|
|
|
2019-09-12 03:40:17 +08:00
|
|
|
case GP_PARAM_TYPE_FILE:
|
|
|
|
/* always free the uri */
|
|
|
|
g_free (params[i].data.d_string);
|
|
|
|
break;
|
|
|
|
|
2024-09-21 03:55:21 +08:00
|
|
|
case GP_PARAM_TYPE_BABL_FORMAT:
|
2023-11-04 04:26:51 +08:00
|
|
|
case GP_PARAM_TYPE_GEGL_COLOR:
|
|
|
|
break;
|
|
|
|
|
2023-12-27 00:07:19 +08:00
|
|
|
case GP_PARAM_TYPE_COLOR_ARRAY:
|
|
|
|
g_free (params[i].data.d_color_array.colors);
|
|
|
|
break;
|
|
|
|
|
2019-09-06 02:59:57 +08:00
|
|
|
case GP_PARAM_TYPE_ARRAY:
|
|
|
|
if (full_copy)
|
|
|
|
g_free (params[i].data.d_array.data);
|
|
|
|
break;
|
|
|
|
|
2020-12-24 04:15:43 +08:00
|
|
|
case GP_PARAM_TYPE_STRV:
|
|
|
|
if (full_copy)
|
|
|
|
g_strfreev (params[i].data.d_strv);
|
2019-09-06 02:59:57 +08:00
|
|
|
break;
|
|
|
|
|
2023-05-24 05:37:46 +08:00
|
|
|
case GP_PARAM_TYPE_BYTES:
|
|
|
|
g_bytes_unref (params[i].data.d_bytes);
|
|
|
|
break;
|
|
|
|
|
2019-09-06 02:59:57 +08:00
|
|
|
case GP_PARAM_TYPE_ID_ARRAY:
|
|
|
|
if (full_copy)
|
|
|
|
g_free (params[i].data.d_id_array.type_name);
|
|
|
|
|
|
|
|
/* always free the array */
|
|
|
|
g_free (params[i].data.d_id_array.data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_TYPE_PARASITE:
|
|
|
|
if (full_copy)
|
2019-09-06 23:24:33 +08:00
|
|
|
{
|
|
|
|
g_free (params[i].data.d_parasite.name);
|
|
|
|
g_free (params[i].data.d_parasite.data);
|
|
|
|
}
|
2019-09-06 02:59:57 +08:00
|
|
|
break;
|
|
|
|
|
2024-05-07 02:38:12 +08:00
|
|
|
case GP_PARAM_TYPE_EXPORT_OPTIONS:
|
|
|
|
break;
|
|
|
|
|
2019-09-06 02:59:57 +08:00
|
|
|
case GP_PARAM_TYPE_PARAM_DEF:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (params);
|
|
|
|
}
|