app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
information needed for constructing all GParamSpecs we use, don't
use GimpPDBArgType in GPProcInstall but an enum private to the wire
protocol plus the GParamSpec's GType name. Bump the wire protocol
version.
- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
take care of converting between GPParamDef and GParamSpec. They
share code as far as possible.
- Change pluginrc writing and parsing to re-use GPParamDef and the
utility functions from gimpgpparamspecs.
- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
the entire core uses proper GParamSpecs from the wire protocol now,
the whole file will follow down the drain once we use a GValue
representation on the wire too.
- In gimp_plug_in_handle_proc_install(), change the "run-mode"
parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
already an enum). and change all places in app/ to treat it as an
enum value.
- plug-ins: fix cml-explorer to register correctly, a typo in
"run-mode" was never noticed until now.
- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
between old-style wire communication and using GParamSpec and
GValue, it contains some functions that are subject to change or
even removal in the next steps.
- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
able to actually install procedures the new way.
- plug-ins: change goat-exercise to completely use the new GimpPlugIn
and GimpProcedure API, look here to see how plug-ins will look in
the future, of course subject to change until this is finished.
- Next: changing GPParam to transmit all information about a GValue.
2019-07-27 16:37:55 +02:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
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 01:56:58 +02:00
|
|
|
* gimpgpparams.c
|
2019-07-31 00:12:36 +02:00
|
|
|
* Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
|
app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
information needed for constructing all GParamSpecs we use, don't
use GimpPDBArgType in GPProcInstall but an enum private to the wire
protocol plus the GParamSpec's GType name. Bump the wire protocol
version.
- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
take care of converting between GPParamDef and GParamSpec. They
share code as far as possible.
- Change pluginrc writing and parsing to re-use GPParamDef and the
utility functions from gimpgpparamspecs.
- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
the entire core uses proper GParamSpecs from the wire protocol now,
the whole file will follow down the drain once we use a GValue
representation on the wire too.
- In gimp_plug_in_handle_proc_install(), change the "run-mode"
parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
already an enum). and change all places in app/ to treat it as an
enum value.
- plug-ins: fix cml-explorer to register correctly, a typo in
"run-mode" was never noticed until now.
- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
between old-style wire communication and using GParamSpec and
GValue, it contains some functions that are subject to change or
even removal in the next steps.
- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
able to actually install procedures the new way.
- plug-ins: change goat-exercise to completely use the new GimpPlugIn
and GimpProcedure API, look here to see how plug-ins will look in
the future, of course subject to change until this is finished.
- Next: changing GPParam to transmit all information about a GValue.
2019-07-27 16:37:55 +02: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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <cairo.h>
|
|
|
|
#include <gio/gio.h>
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
|
|
#include <gegl.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpbase/gimpprotocol.h"
|
|
|
|
|
|
|
|
#include "gimp.h"
|
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 01:56:58 +02:00
|
|
|
#include "gimpgpparams.h"
|
app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
information needed for constructing all GParamSpecs we use, don't
use GimpPDBArgType in GPProcInstall but an enum private to the wire
protocol plus the GParamSpec's GType name. Bump the wire protocol
version.
- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
take care of converting between GPParamDef and GParamSpec. They
share code as far as possible.
- Change pluginrc writing and parsing to re-use GPParamDef and the
utility functions from gimpgpparamspecs.
- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
the entire core uses proper GParamSpecs from the wire protocol now,
the whole file will follow down the drain once we use a GValue
representation on the wire too.
- In gimp_plug_in_handle_proc_install(), change the "run-mode"
parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
already an enum). and change all places in app/ to treat it as an
enum value.
- plug-ins: fix cml-explorer to register correctly, a typo in
"run-mode" was never noticed until now.
- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
between old-style wire communication and using GParamSpec and
GValue, it contains some functions that are subject to change or
even removal in the next steps.
- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
able to actually install procedures the new way.
- plug-ins: change goat-exercise to completely use the new GimpPlugIn
and GimpProcedure API, look here to see how plug-ins will look in
the future, of course subject to change until this is finished.
- Next: changing GPParam to transmit all information about a GValue.
2019-07-27 16:37:55 +02:00
|
|
|
|
|
|
|
|
2019-07-31 00:12:36 +02:00
|
|
|
/* include the implementation, they are shared between app/ and
|
|
|
|
* libgimp/ but need different headers.
|
app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
information needed for constructing all GParamSpecs we use, don't
use GimpPDBArgType in GPProcInstall but an enum private to the wire
protocol plus the GParamSpec's GType name. Bump the wire protocol
version.
- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
take care of converting between GPParamDef and GParamSpec. They
share code as far as possible.
- Change pluginrc writing and parsing to re-use GPParamDef and the
utility functions from gimpgpparamspecs.
- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
the entire core uses proper GParamSpecs from the wire protocol now,
the whole file will follow down the drain once we use a GValue
representation on the wire too.
- In gimp_plug_in_handle_proc_install(), change the "run-mode"
parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
already an enum). and change all places in app/ to treat it as an
enum value.
- plug-ins: fix cml-explorer to register correctly, a typo in
"run-mode" was never noticed until now.
- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
between old-style wire communication and using GParamSpec and
GValue, it contains some functions that are subject to change or
even removal in the next steps.
- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
able to actually install procedures the new way.
- plug-ins: change goat-exercise to completely use the new GimpPlugIn
and GimpProcedure API, look here to see how plug-ins will look in
the future, of course subject to change until this is finished.
- Next: changing GPParam to transmit all information about a GValue.
2019-07-27 16:37:55 +02: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 01:56:58 +02:00
|
|
|
#include "gimpgpparams-body.c"
|
2019-08-05 00:58:44 +02:00
|
|
|
|
|
|
|
GParamSpec *
|
2019-08-07 00:02:29 +02:00
|
|
|
_gimp_gp_param_def_to_param_spec (gpointer gimp,
|
|
|
|
const GPParamDef *param_def)
|
2019-08-05 00:58:44 +02:00
|
|
|
{
|
|
|
|
const gchar *name = param_def->name;
|
|
|
|
const gchar *nick = param_def->nick;
|
|
|
|
const gchar *blurb = param_def->blurb;
|
2019-08-19 12:54:52 +02:00
|
|
|
GParamFlags flags = param_def->flags;
|
|
|
|
|
|
|
|
flags &= ~G_PARAM_STATIC_STRINGS;
|
2019-08-05 00:58:44 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamInt16Array"))
|
|
|
|
return gimp_param_spec_int16_array (name, nick, blurb, flags);
|
|
|
|
|
2019-08-15 15:04:34 +02:00
|
|
|
if (! strcmp (param_def->type_name, "GimpParamUInt8Array"))
|
|
|
|
return gimp_param_spec_uint8_array (name, nick, blurb, flags);
|
2019-08-05 00:58:44 +02:00
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamFloatArray"))
|
|
|
|
return gimp_param_spec_float_array (name, nick, blurb, flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamStringArray"))
|
|
|
|
return gimp_param_spec_string_array (name, nick, blurb, flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamRGBArray"))
|
|
|
|
return gimp_param_spec_rgb_array (name, nick, blurb, flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamParasite"))
|
|
|
|
return gimp_param_spec_parasite (name, nick, blurb, flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-08-05 12:46:25 +02:00
|
|
|
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);
|
|
|
|
|
2019-08-15 13:34:11 +02:00
|
|
|
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);
|
2019-08-05 00:58:44 +02:00
|
|
|
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,
|
|
|
|
param_def->meta.m_unit.default_val,
|
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_ENUM:
|
|
|
|
if (! strcmp (param_def->type_name, "GParamEnum"))
|
|
|
|
return g_param_spec_enum (name, nick, blurb,
|
|
|
|
g_type_from_name (param_def->meta.m_enum.type_name),
|
|
|
|
param_def->meta.m_enum.default_val,
|
|
|
|
flags);
|
2019-08-05 14:14:32 +02:00
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamEnum"))
|
|
|
|
/* FIXME GimpParamEnum */
|
|
|
|
return g_param_spec_enum (name, nick, blurb,
|
|
|
|
g_type_from_name (param_def->meta.m_enum.type_name),
|
|
|
|
param_def->meta.m_enum.default_val,
|
|
|
|
flags);
|
2019-08-05 00:58:44 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_FLOAT:
|
|
|
|
if (! strcmp (param_def->type_name, "GParamDouble"))
|
|
|
|
return g_param_spec_double (name, nick, blurb,
|
|
|
|
param_def->meta.m_float.min_val,
|
|
|
|
param_def->meta.m_float.max_val,
|
|
|
|
param_def->meta.m_float.default_val,
|
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_STRING:
|
2019-08-19 12:54:52 +02:00
|
|
|
if (! strcmp (param_def->type_name, "GParamString"))
|
|
|
|
return g_param_spec_string (name, nick, blurb,
|
|
|
|
param_def->meta.m_string.default_val,
|
|
|
|
flags);
|
2019-08-05 00:58:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_COLOR:
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamRGB"))
|
|
|
|
return gimp_param_spec_rgb (name, nick, blurb,
|
|
|
|
param_def->meta.m_color.has_alpha,
|
|
|
|
¶m_def->meta.m_color.default_val,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_ID:
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamDisplayID"))
|
|
|
|
return gimp_param_spec_display_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamImageID"))
|
|
|
|
return gimp_param_spec_image_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamItemID"))
|
|
|
|
return gimp_param_spec_item_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamDrawableID"))
|
|
|
|
return gimp_param_spec_drawable_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamLayerID"))
|
|
|
|
return gimp_param_spec_layer_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamChannelID"))
|
|
|
|
return gimp_param_spec_channel_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamLayerMaskID"))
|
|
|
|
return gimp_param_spec_layer_mask_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamSelectionID"))
|
|
|
|
return gimp_param_spec_selection_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
if (! strcmp (param_def->type_name, "GimpParamVectorsID"))
|
|
|
|
return gimp_param_spec_vectors_id (name, nick, blurb,
|
|
|
|
param_def->meta.m_id.none_ok,
|
|
|
|
flags);
|
|
|
|
break;
|
2019-08-05 14:14:32 +02:00
|
|
|
|
|
|
|
case GP_PARAM_DEF_TYPE_PARAM_DEF:
|
|
|
|
if (! strcmp (param_def->type_name, "GParamParam"))
|
|
|
|
return g_param_spec_param (name, nick, blurb,
|
|
|
|
g_type_from_name (param_def->meta.m_param_def.type_name),
|
|
|
|
flags);
|
|
|
|
break;
|
2019-08-05 00:58:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
g_printerr ("%s: GParamSpec type '%s' is not handled\n",
|
|
|
|
G_STRFUNC, param_def->type_name);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|