2019-07-26 08:05:11 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2019-07-31 06:12:36 +08:00
|
|
|
* gimpprocedure.c
|
|
|
|
* Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2019-07-26 08:05:11 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
#include <gobject/gvaluecollector.h>
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
#include "gimp.h"
|
2019-08-07 05:06:15 +08:00
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
#include "libgimpbase/gimpprotocol.h"
|
|
|
|
#include "libgimpbase/gimpwire.h"
|
|
|
|
|
|
|
|
#include "gimpgpparams.h"
|
2019-08-06 18:17:27 +08:00
|
|
|
#include "gimppdb-private.h"
|
2019-08-11 02:25:37 +08:00
|
|
|
#include "gimpplugin-private.h"
|
2019-09-08 21:53:37 +08:00
|
|
|
#include "gimppdb_pdb.h"
|
2023-10-15 22:34:11 +08:00
|
|
|
#include "gimpplugin-private.h"
|
2019-08-11 02:25:37 +08:00
|
|
|
#include "gimpplugin_pdb.h"
|
2019-08-23 23:18:17 +08:00
|
|
|
#include "gimpprocedure-private.h"
|
2019-09-27 01:06:17 +08:00
|
|
|
#include "gimpprocedureconfig-private.h"
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
#include "libgimp-intl.h"
|
|
|
|
|
|
|
|
|
2024-04-24 22:02:08 +08:00
|
|
|
/**
|
|
|
|
* GimpProcedure:
|
|
|
|
*
|
|
|
|
* Procedures are registered functions which can be run across GIMP ecosystem.
|
|
|
|
* They can be created by plug-ins and can then run by the core application
|
|
|
|
* when called from menus (or through other interaction depending on specific
|
|
|
|
* procedure subclasses).
|
|
|
|
*
|
|
|
|
* A plug-in can also run procedures created by the core, but also the ones
|
|
|
|
* created by other plug-ins (see [class@PDB]).
|
|
|
|
**/
|
|
|
|
|
2019-08-06 18:17:27 +08:00
|
|
|
enum
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2019-08-06 18:17:27 +08:00
|
|
|
PROP_0,
|
|
|
|
PROP_PLUG_IN,
|
|
|
|
PROP_NAME,
|
|
|
|
PROP_PROCEDURE_TYPE,
|
|
|
|
N_PROPS
|
|
|
|
};
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
typedef struct _GimpProcedurePrivate
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2019-08-06 05:01:25 +08:00
|
|
|
GimpPlugIn *plug_in;
|
|
|
|
|
|
|
|
gchar *name;
|
|
|
|
GimpPDBProcType proc_type;
|
|
|
|
|
|
|
|
gchar *image_types;
|
2019-07-31 03:02:58 +08:00
|
|
|
|
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 22:37:55 +08:00
|
|
|
gchar *menu_label;
|
2019-08-06 05:01:25 +08:00
|
|
|
GList *menu_paths;
|
|
|
|
|
2019-08-18 20:04:45 +08:00
|
|
|
GimpIconType icon_type;
|
|
|
|
gpointer icon_data;
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
gchar *blurb;
|
|
|
|
gchar *help;
|
2019-07-26 08:05:11 +08:00
|
|
|
gchar *help_id;
|
2019-08-06 05:01:25 +08:00
|
|
|
|
|
|
|
gchar *authors;
|
|
|
|
gchar *copyright;
|
|
|
|
gchar *date;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2021-04-02 05:49:11 +08:00
|
|
|
gint sensitivity_mask;
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
gint32 n_args;
|
|
|
|
GParamSpec **args;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2019-09-24 18:39:02 +08:00
|
|
|
gint32 n_aux_args;
|
|
|
|
GParamSpec **aux_args;
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
gint32 n_values;
|
|
|
|
GParamSpec **values;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
GimpRunFunc run_func;
|
2019-08-02 04:45:49 +08:00
|
|
|
gpointer run_data;
|
|
|
|
GDestroyNotify run_data_destroy;
|
2019-08-13 01:06:13 +08:00
|
|
|
|
|
|
|
gboolean installed;
|
2019-08-23 23:18:17 +08:00
|
|
|
|
|
|
|
GHashTable *displays;
|
|
|
|
GHashTable *images;
|
|
|
|
GHashTable *items;
|
2023-05-31 22:12:04 +08:00
|
|
|
GHashTable *resources;
|
2024-07-10 21:03:15 +08:00
|
|
|
} GimpProcedurePrivate;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
|
2023-10-19 00:43:08 +08:00
|
|
|
static void gimp_procedure_constructed (GObject *object);
|
|
|
|
static void gimp_procedure_finalize (GObject *object);
|
|
|
|
static void gimp_procedure_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_procedure_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
static void gimp_procedure_real_install (GimpProcedure *procedure);
|
|
|
|
static void gimp_procedure_real_uninstall (GimpProcedure *procedure);
|
|
|
|
static GimpValueArray * gimp_procedure_real_run (GimpProcedure *procedure,
|
|
|
|
const GimpValueArray *args);
|
|
|
|
static GimpProcedureConfig * gimp_procedure_real_create_config (GimpProcedure *procedure,
|
|
|
|
GParamSpec **args,
|
|
|
|
gint n_args);
|
|
|
|
|
2024-05-02 03:47:55 +08:00
|
|
|
static GimpProcedureConfig *
|
|
|
|
gimp_procedure_create_config_with_prefix (GimpProcedure *procedure,
|
|
|
|
const gchar *prefix,
|
|
|
|
GParamSpec **args,
|
|
|
|
gint n_args);
|
|
|
|
|
2023-10-19 00:43:08 +08:00
|
|
|
static GimpValueArray * gimp_procedure_new_arguments (GimpProcedure *procedure);
|
|
|
|
static gboolean gimp_procedure_validate_args (GimpProcedure *procedure,
|
|
|
|
GParamSpec **param_specs,
|
|
|
|
gint n_param_specs,
|
|
|
|
GimpValueArray *args,
|
|
|
|
gboolean return_vals,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
static void gimp_procedure_set_icon (GimpProcedure *procedure,
|
|
|
|
GimpIconType icon_type,
|
|
|
|
gconstpointer icon_data);
|
2019-08-09 06:05:49 +08:00
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpProcedure, gimp_procedure, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
#define parent_class gimp_procedure_parent_class
|
|
|
|
|
2019-08-06 18:17:27 +08:00
|
|
|
static GParamSpec *props[N_PROPS] = { NULL, };
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_procedure_class_init (GimpProcedureClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2019-08-06 18:17:27 +08:00
|
|
|
object_class->constructed = gimp_procedure_constructed;
|
|
|
|
object_class->finalize = gimp_procedure_finalize;
|
|
|
|
object_class->set_property = gimp_procedure_set_property;
|
|
|
|
object_class->get_property = gimp_procedure_get_property;
|
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
klass->install = gimp_procedure_real_install;
|
|
|
|
klass->uninstall = gimp_procedure_real_uninstall;
|
2019-08-06 18:17:27 +08:00
|
|
|
klass->run = gimp_procedure_real_run;
|
2019-09-20 18:31:11 +08:00
|
|
|
klass->create_config = gimp_procedure_real_create_config;
|
2019-08-06 18:17:27 +08:00
|
|
|
|
|
|
|
props[PROP_PLUG_IN] =
|
|
|
|
g_param_spec_object ("plug-in",
|
|
|
|
"Plug-In",
|
|
|
|
"The GimpPlugIn of this plug-in process",
|
|
|
|
GIMP_TYPE_PLUG_IN,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
props[PROP_NAME] =
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
"Name",
|
|
|
|
"The procedure's name",
|
|
|
|
NULL,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
props[PROP_PROCEDURE_TYPE] =
|
|
|
|
g_param_spec_enum ("procedure-type",
|
|
|
|
"Procedure type",
|
|
|
|
"The procedure's type",
|
|
|
|
GIMP_TYPE_PDB_PROC_TYPE,
|
2019-08-30 18:52:28 +08:00
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
2019-08-06 18:17:27 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, N_PROPS, props);
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_procedure_init (GimpProcedure *procedure)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-06 18:17:27 +08:00
|
|
|
static void
|
|
|
|
gimp_procedure_constructed (GObject *object)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (object);
|
|
|
|
GimpProcedurePrivate *priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-06 18:17:27 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_assert (GIMP_IS_PLUG_IN (priv->plug_in));
|
|
|
|
g_assert (priv->name != NULL);
|
2019-08-06 18:17:27 +08:00
|
|
|
}
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
static void
|
|
|
|
gimp_procedure_finalize (GObject *object)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (object);
|
|
|
|
GimpProcedurePrivate *priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
gint i;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->run_data_destroy)
|
|
|
|
priv->run_data_destroy (priv->run_data);
|
2019-08-02 04:45:49 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_clear_object (&priv->plug_in);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_clear_pointer (&priv->name, g_free);
|
|
|
|
g_clear_pointer (&priv->image_types, g_free);
|
|
|
|
g_clear_pointer (&priv->menu_label, g_free);
|
|
|
|
g_clear_pointer (&priv->blurb, g_free);
|
|
|
|
g_clear_pointer (&priv->help, g_free);
|
|
|
|
g_clear_pointer (&priv->help_id, g_free);
|
|
|
|
g_clear_pointer (&priv->authors, g_free);
|
|
|
|
g_clear_pointer (&priv->copyright, g_free);
|
|
|
|
g_clear_pointer (&priv->date, g_free);
|
2019-07-31 01:21:57 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_list_free_full (priv->menu_paths, g_free);
|
|
|
|
priv->menu_paths = NULL;
|
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 22:37:55 +08:00
|
|
|
|
2019-08-09 06:05:49 +08:00
|
|
|
gimp_procedure_set_icon (procedure, GIMP_ICON_TYPE_ICON_NAME, NULL);
|
2019-08-06 05:01:25 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->args)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
for (i = 0; i < priv->n_args; i++)
|
|
|
|
g_param_spec_unref (priv->args[i]);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_clear_pointer (&priv->args, g_free);
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->aux_args)
|
2019-09-24 18:39:02 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
for (i = 0; i < priv->n_aux_args; i++)
|
|
|
|
g_param_spec_unref (priv->aux_args[i]);
|
2019-09-24 18:39:02 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_clear_pointer (&priv->aux_args, g_free);
|
2019-09-24 18:39:02 +08:00
|
|
|
}
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->values)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
for (i = 0; i < priv->n_values; i++)
|
|
|
|
g_param_spec_unref (priv->values[i]);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_clear_pointer (&priv->values, g_free);
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
_gimp_procedure_destroy_proxies (procedure);
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2019-08-06 18:17:27 +08:00
|
|
|
static void
|
|
|
|
gimp_procedure_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (object);
|
|
|
|
GimpProcedurePrivate *priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-06 18:17:27 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_PLUG_IN:
|
2024-07-10 21:03:15 +08:00
|
|
|
g_set_object (&priv->plug_in, g_value_get_object (value));
|
2019-08-06 18:17:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_NAME:
|
2024-07-10 21:03:15 +08:00
|
|
|
g_free (priv->name);
|
|
|
|
priv->name = g_value_dup_string (value);
|
2019-08-06 18:17:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_PROCEDURE_TYPE:
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->proc_type = g_value_get_enum (value);
|
2019-08-06 18:17:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_procedure_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (object);
|
|
|
|
GimpProcedurePrivate *priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-06 18:17:27 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_PLUG_IN:
|
2024-07-10 21:03:15 +08:00
|
|
|
g_value_set_object (value, priv->plug_in);
|
2019-08-06 18:17:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_NAME:
|
2024-07-10 21:03:15 +08:00
|
|
|
g_value_set_string (value, priv->name);
|
2019-08-06 18:17:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_PROCEDURE_TYPE:
|
2024-07-10 21:03:15 +08:00
|
|
|
g_value_set_enum (value, priv->proc_type);
|
2019-08-06 18:17:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
static void
|
2019-09-08 22:22:32 +08:00
|
|
|
gimp_procedure_install_icon (GimpProcedure *procedure)
|
2019-08-11 02:25:37 +08:00
|
|
|
{
|
2019-09-08 22:22:32 +08:00
|
|
|
GimpIconType icon_type;
|
|
|
|
guint8 *icon_data = NULL;
|
|
|
|
gsize icon_data_length = 0;
|
2023-05-24 05:37:46 +08:00
|
|
|
GBytes *icon_bytes = NULL;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
icon_type = gimp_procedure_get_icon_type (procedure);
|
|
|
|
|
|
|
|
switch (icon_type)
|
|
|
|
{
|
|
|
|
case GIMP_ICON_TYPE_ICON_NAME:
|
|
|
|
{
|
|
|
|
icon_data = (guint8 *) gimp_procedure_get_icon_name (procedure);
|
|
|
|
if (icon_data)
|
2023-05-24 05:37:46 +08:00
|
|
|
icon_bytes = g_bytes_new_static (icon_data,
|
|
|
|
strlen ((gchar *) icon_data) + 1);
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ICON_TYPE_PIXBUF:
|
|
|
|
{
|
|
|
|
GdkPixbuf *pixbuf = gimp_procedure_get_icon_pixbuf (procedure);
|
|
|
|
|
|
|
|
if (pixbuf)
|
2023-05-24 05:37:46 +08:00
|
|
|
{
|
2023-05-26 05:19:58 +08:00
|
|
|
if (gdk_pixbuf_save_to_buffer (pixbuf,
|
|
|
|
(gchar **) &icon_data, &icon_data_length,
|
|
|
|
"png", NULL, NULL))
|
|
|
|
icon_bytes = g_bytes_new_take (icon_data, icon_data_length);
|
2023-05-24 05:37:46 +08:00
|
|
|
}
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ICON_TYPE_IMAGE_FILE:
|
|
|
|
{
|
|
|
|
GFile *file = gimp_procedure_get_icon_file (procedure);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
icon_data = (guchar *) g_file_get_uri (file);
|
|
|
|
icon_data_length = strlen ((gchar *) icon_data) + 1;
|
2023-05-24 05:37:46 +08:00
|
|
|
icon_bytes = g_bytes_new_take (icon_data, icon_data_length);
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-05-26 05:19:58 +08:00
|
|
|
if (icon_bytes)
|
2019-09-08 22:22:32 +08:00
|
|
|
_gimp_pdb_set_proc_icon (gimp_procedure_get_name (procedure),
|
2023-05-24 05:37:46 +08:00
|
|
|
icon_type, icon_bytes);
|
2023-05-26 06:30:47 +08:00
|
|
|
g_bytes_unref (icon_bytes);
|
2019-09-08 22:22:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_procedure_real_install (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GParamSpec **args;
|
|
|
|
GParamSpec **return_vals;
|
|
|
|
gint n_args = 0;
|
|
|
|
gint n_return_vals = 0;
|
|
|
|
GList *list;
|
|
|
|
GimpPlugIn *plug_in;
|
|
|
|
GPProcInstall proc_install;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-09-08 22:22:32 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_return_if_fail (priv->installed == FALSE);
|
2019-09-08 22:22:32 +08:00
|
|
|
|
|
|
|
args = gimp_procedure_get_arguments (procedure, &n_args);
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, &n_return_vals);
|
|
|
|
|
2019-09-09 07:00:54 +08:00
|
|
|
proc_install.name = (gchar *) gimp_procedure_get_name (procedure);
|
|
|
|
proc_install.type = gimp_procedure_get_proc_type (procedure);
|
|
|
|
proc_install.n_params = n_args;
|
|
|
|
proc_install.n_return_vals = n_return_vals;
|
|
|
|
proc_install.params = g_new0 (GPParamDef, n_args);
|
|
|
|
proc_install.return_vals = g_new0 (GPParamDef, n_return_vals);
|
2019-09-08 22:22:32 +08:00
|
|
|
|
|
|
|
for (i = 0; i < n_args; i++)
|
|
|
|
{
|
|
|
|
_gimp_param_spec_to_gp_param_def (args[i],
|
|
|
|
&proc_install.params[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n_return_vals; i++)
|
|
|
|
{
|
|
|
|
_gimp_param_spec_to_gp_param_def (return_vals[i],
|
|
|
|
&proc_install.return_vals[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
plug_in = gimp_procedure_get_plug_in (procedure);
|
|
|
|
|
|
|
|
if (! gp_proc_install_write (_gimp_plug_in_get_write_channel (plug_in),
|
|
|
|
&proc_install, plug_in))
|
|
|
|
gimp_quit ();
|
2019-08-11 02:25:37 +08:00
|
|
|
|
|
|
|
g_free (proc_install.params);
|
|
|
|
g_free (proc_install.return_vals);
|
|
|
|
|
2019-09-08 22:22:32 +08:00
|
|
|
gimp_procedure_install_icon (procedure);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->image_types)
|
2019-09-09 06:36:24 +08:00
|
|
|
{
|
|
|
|
_gimp_pdb_set_proc_image_types (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->image_types);
|
2019-09-09 06:36:24 +08:00
|
|
|
}
|
2019-09-08 22:54:08 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->menu_label)
|
2019-09-09 06:36:24 +08:00
|
|
|
{
|
|
|
|
_gimp_pdb_set_proc_menu_label (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->menu_label);
|
2019-09-09 06:36:24 +08:00
|
|
|
}
|
2019-09-08 23:30:54 +08:00
|
|
|
|
2021-04-02 05:49:11 +08:00
|
|
|
_gimp_pdb_set_proc_sensitivity_mask (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->sensitivity_mask);
|
2021-04-02 05:49:11 +08:00
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
for (list = gimp_procedure_get_menu_paths (procedure);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2019-09-08 21:53:37 +08:00
|
|
|
_gimp_pdb_add_proc_menu_path (gimp_procedure_get_name (procedure),
|
|
|
|
list->data);
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
2019-08-13 01:06:13 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->blurb ||
|
|
|
|
priv->help ||
|
|
|
|
priv->help_id)
|
2019-09-09 06:36:24 +08:00
|
|
|
{
|
|
|
|
_gimp_pdb_set_proc_documentation (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->blurb,
|
|
|
|
priv->help,
|
|
|
|
priv->help_id);
|
2019-09-09 06:36:24 +08:00
|
|
|
}
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->authors ||
|
|
|
|
priv->copyright ||
|
|
|
|
priv->date)
|
2019-09-09 06:36:24 +08:00
|
|
|
{
|
|
|
|
_gimp_pdb_set_proc_attribution (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->authors,
|
|
|
|
priv->copyright,
|
|
|
|
priv->date);
|
2019-09-09 06:36:24 +08:00
|
|
|
}
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->installed = TRUE;
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_procedure_real_uninstall (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
GimpPlugIn *plug_in;
|
|
|
|
GPProcUninstall proc_uninstall;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_return_if_fail (priv->installed == TRUE);
|
2019-08-13 01:06:13 +08:00
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
proc_uninstall.name = (gchar *) gimp_procedure_get_name (procedure);
|
|
|
|
|
|
|
|
plug_in = gimp_procedure_get_plug_in (procedure);
|
|
|
|
|
|
|
|
if (! gp_proc_uninstall_write (_gimp_plug_in_get_write_channel (plug_in),
|
|
|
|
&proc_uninstall, plug_in))
|
|
|
|
gimp_quit ();
|
2019-08-13 01:06:13 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->installed = FALSE;
|
2019-08-11 02:25:37 +08:00
|
|
|
}
|
|
|
|
|
2019-08-06 18:17:27 +08:00
|
|
|
static GimpValueArray *
|
|
|
|
gimp_procedure_real_run (GimpProcedure *procedure,
|
|
|
|
const GimpValueArray *args)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
GimpPlugIn *plug_in;
|
|
|
|
GimpProcedureConfig *config;
|
|
|
|
GimpImage *image = NULL;
|
|
|
|
GimpRunMode run_mode = GIMP_RUN_NONINTERACTIVE;
|
|
|
|
GimpValueArray *retvals;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR;
|
2023-06-17 00:34:53 +08:00
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > 0 &&
|
|
|
|
G_VALUE_HOLDS_ENUM (gimp_value_array_index (args, 0)))
|
2023-06-12 23:56:06 +08:00
|
|
|
{
|
2023-06-17 00:34:53 +08:00
|
|
|
run_mode = GIMP_VALUES_GET_ENUM (args, 0);
|
|
|
|
|
|
|
|
if (gimp_value_array_length (args) > 1 &&
|
|
|
|
GIMP_VALUE_HOLDS_IMAGE (gimp_value_array_index (args, 1)))
|
|
|
|
image = GIMP_VALUES_GET_IMAGE (args, 1);
|
2023-06-12 23:56:06 +08:00
|
|
|
}
|
2023-06-17 00:34:53 +08:00
|
|
|
|
2024-05-02 03:47:55 +08:00
|
|
|
config = _gimp_procedure_create_run_config (procedure);
|
2023-10-15 23:01:47 +08:00
|
|
|
_gimp_procedure_config_begin_run (config, image, run_mode, args);
|
2023-06-17 00:34:53 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
retvals = priv->run_func (procedure, config, priv->run_data);
|
|
|
|
|
2023-06-17 00:34:53 +08:00
|
|
|
if (retvals != NULL &&
|
|
|
|
gimp_value_array_length (retvals) > 0 &&
|
|
|
|
G_VALUE_HOLDS_ENUM (gimp_value_array_index (retvals, 0)))
|
|
|
|
status = GIMP_VALUES_GET_ENUM (retvals, 0);
|
|
|
|
|
2023-10-15 23:01:47 +08:00
|
|
|
_gimp_procedure_config_end_run (config, status);
|
2023-07-18 05:31:26 +08:00
|
|
|
|
|
|
|
/* This is debug printing to help plug-in developers figure out best
|
|
|
|
* practices.
|
|
|
|
*/
|
2023-10-15 22:34:11 +08:00
|
|
|
plug_in = gimp_procedure_get_plug_in (procedure);
|
|
|
|
if (G_OBJECT (config)->ref_count > 1 &&
|
|
|
|
_gimp_plug_in_manage_memory_manually (plug_in))
|
2023-07-18 05:31:26 +08:00
|
|
|
g_printerr ("%s: ERROR: the GimpProcedureConfig object was refed "
|
|
|
|
"by plug-in, it MUST NOT do that!\n", G_STRFUNC);
|
|
|
|
|
2023-06-17 00:34:53 +08:00
|
|
|
g_object_unref (config);
|
|
|
|
|
|
|
|
return retvals;
|
2019-08-06 18:17:27 +08:00
|
|
|
}
|
|
|
|
|
2019-09-20 18:31:11 +08:00
|
|
|
static GimpProcedureConfig *
|
|
|
|
gimp_procedure_real_create_config (GimpProcedure *procedure,
|
|
|
|
GParamSpec **args,
|
|
|
|
gint n_args)
|
2024-05-02 03:47:55 +08:00
|
|
|
{
|
|
|
|
return gimp_procedure_create_config_with_prefix (procedure,
|
|
|
|
"GimpProcedureConfigRun",
|
|
|
|
args, n_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpProcedureConfig *
|
|
|
|
gimp_procedure_create_config_with_prefix (GimpProcedure *procedure,
|
|
|
|
const gchar *prefix,
|
|
|
|
GParamSpec **args,
|
|
|
|
gint n_args)
|
2019-09-20 18:31:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
gchar *type_name;
|
|
|
|
GType type;
|
2019-09-20 18:31:11 +08:00
|
|
|
|
2024-05-02 03:47:55 +08:00
|
|
|
type_name = g_strdup_printf ("%s-%s", prefix,
|
2019-09-20 18:31:11 +08:00
|
|
|
gimp_procedure_get_name (procedure));
|
|
|
|
|
|
|
|
type = g_type_from_name (type_name);
|
|
|
|
|
|
|
|
if (! type)
|
2019-09-24 18:39:02 +08:00
|
|
|
{
|
|
|
|
GParamSpec **config_args;
|
|
|
|
gint n_config_args;
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
n_config_args = n_args + priv->n_aux_args;
|
2019-09-24 18:39:02 +08:00
|
|
|
|
|
|
|
config_args = g_new0 (GParamSpec *, n_config_args);
|
|
|
|
|
|
|
|
memcpy (config_args,
|
|
|
|
args,
|
|
|
|
n_args * sizeof (GParamSpec *));
|
|
|
|
memcpy (config_args + n_args,
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->aux_args,
|
|
|
|
priv->n_aux_args * sizeof (GParamSpec *));
|
2019-09-24 18:39:02 +08:00
|
|
|
|
|
|
|
type = gimp_config_type_register (GIMP_TYPE_PROCEDURE_CONFIG,
|
|
|
|
type_name,
|
|
|
|
config_args, n_config_args);
|
|
|
|
|
|
|
|
g_free (config_args);
|
|
|
|
}
|
2019-09-20 18:31:11 +08:00
|
|
|
|
|
|
|
g_free (type_name);
|
|
|
|
|
|
|
|
return g_object_new (type,
|
|
|
|
"procedure", procedure,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2019-08-01 17:57:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_new:
|
|
|
|
* @plug_in: a #GimpPlugIn.
|
|
|
|
* @name: the new procedure's name.
|
|
|
|
* @proc_type: the new procedure's #GimpPDBProcType.
|
2019-08-02 04:45:49 +08:00
|
|
|
* @run_func: the run function for the new procedure.
|
|
|
|
* @run_data: user data passed to @run_func.
|
2019-08-02 08:30:07 +08:00
|
|
|
* @run_data_destroy: (nullable): free function for @run_data, or %NULL.
|
2019-08-01 17:57:17 +08:00
|
|
|
*
|
|
|
|
* Creates a new procedure named @name which will call @run_func when
|
|
|
|
* invoked.
|
|
|
|
*
|
2019-08-02 05:09:01 +08:00
|
|
|
* The @name parameter is mandatory and should be unique, or it will
|
|
|
|
* overwrite an already existing procedure (overwrite procedures only
|
|
|
|
* if you know what you're doing).
|
|
|
|
*
|
2019-08-30 18:52:28 +08:00
|
|
|
* @proc_type should be %GIMP_PDB_PROC_TYPE_PLUGIN for "normal" plug-ins.
|
2019-08-02 05:24:49 +08:00
|
|
|
*
|
2019-08-30 18:52:28 +08:00
|
|
|
* Using %GIMP_PDB_PROC_TYPE_EXTENSION means that the plug-in will add
|
|
|
|
* temporary procedures. Therefore, the GIMP core will wait until the
|
|
|
|
* %GIMP_PDB_PROC_TYPE_EXTENSION procedure has called
|
2021-11-29 02:36:07 +08:00
|
|
|
* [method@Procedure.extension_ready], which means that the procedure
|
2019-08-02 07:32:16 +08:00
|
|
|
* has done its initialization, installed its temporary procedures and
|
|
|
|
* is ready to run.
|
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* *Not calling [method@Procedure.extension_ready] from a
|
2019-08-30 18:52:28 +08:00
|
|
|
* %GIMP_PDB_PROC_TYPE_EXTENSION procedure will cause the GIMP core to
|
2021-11-29 02:36:07 +08:00
|
|
|
* lock up.*
|
2019-08-02 07:32:16 +08:00
|
|
|
*
|
2019-08-30 18:52:28 +08:00
|
|
|
* Additionally, a %GIMP_PDB_PROC_TYPE_EXTENSION procedure with no
|
|
|
|
* arguments added is an "automatic" extension that will be
|
|
|
|
* automatically started on each GIMP startup.
|
2019-08-02 05:24:49 +08:00
|
|
|
*
|
2019-08-30 18:52:28 +08:00
|
|
|
* %GIMP_PDB_PROC_TYPE_TEMPORARY must be used for temporary procedures
|
|
|
|
* that are created during a plug-ins lifetime. They must be added to
|
2021-11-29 02:36:07 +08:00
|
|
|
* the #GimpPlugIn using [method@PlugIn.add_temp_procedure].
|
2019-08-02 05:09:01 +08:00
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* @run_func is called via [method@Procedure.run].
|
2019-08-02 05:46:25 +08:00
|
|
|
*
|
2019-08-30 18:52:28 +08:00
|
|
|
* For %GIMP_PDB_PROC_TYPE_PLUGIN and %GIMP_PDB_PROC_TYPE_EXTENSION
|
|
|
|
* procedures the call of @run_func is basically the lifetime of the
|
|
|
|
* plug-in.
|
2019-08-02 05:46:25 +08:00
|
|
|
*
|
2019-08-01 17:57:17 +08:00
|
|
|
* Returns: a new #GimpProcedure.
|
2019-08-06 05:33:49 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
2019-08-01 17:57:17 +08:00
|
|
|
**/
|
2019-08-10 18:32:25 +08:00
|
|
|
GimpProcedure *
|
2023-06-17 00:34:53 +08:00
|
|
|
gimp_procedure_new (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name,
|
|
|
|
GimpPDBProcType proc_type,
|
|
|
|
GimpRunFunc run_func,
|
|
|
|
gpointer run_data,
|
|
|
|
GDestroyNotify run_data_destroy)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedure *procedure;
|
|
|
|
GimpProcedurePrivate *priv;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2019-07-31 03:02:58 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
|
2019-08-06 05:22:39 +08:00
|
|
|
g_return_val_if_fail (gimp_is_canonical_identifier (name), NULL);
|
2019-08-30 18:52:28 +08:00
|
|
|
g_return_val_if_fail (proc_type != GIMP_PDB_PROC_TYPE_INTERNAL, NULL);
|
2019-07-26 08:05:11 +08:00
|
|
|
g_return_val_if_fail (run_func != NULL, NULL);
|
|
|
|
|
2019-08-06 18:17:27 +08:00
|
|
|
procedure = g_object_new (GIMP_TYPE_PROCEDURE,
|
|
|
|
"plug-in", plug_in,
|
|
|
|
"name", name,
|
|
|
|
"procedure-type", proc_type,
|
|
|
|
NULL);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
priv->run_func = run_func;
|
|
|
|
priv->run_data = run_data;
|
|
|
|
priv->run_data_destroy = run_data_destroy;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
return procedure;
|
|
|
|
}
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_plug_in:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* Returns: (transfer none): The #GimpPlugIn given in [ctor@Procedure.new].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2019-07-31 03:02:58 +08:00
|
|
|
GimpPlugIn *
|
|
|
|
gimp_procedure_get_plug_in (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-07-31 03:02:58 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->plug_in;
|
2019-07-31 03:02:58 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_name:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* Returns: The procedure's name given in [ctor@Procedure.new].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2019-08-02 05:46:25 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_procedure_get_name (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-02 05:46:25 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->name;
|
2019-08-02 05:46:25 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_proc_type:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* Returns: The procedure's type given in [ctor@Procedure.new].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2019-07-31 03:02:58 +08:00
|
|
|
GimpPDBProcType
|
|
|
|
gimp_procedure_get_proc_type (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-30 18:52:28 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure),
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN);
|
2019-07-31 03:02:58 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->proc_type;
|
2019-07-31 03:02:58 +08:00
|
|
|
}
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_set_image_types:
|
2019-08-10 17:08:06 +08:00
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
* @image_types: The image types this procedure can operate on.
|
2019-08-06 05:01:25 +08:00
|
|
|
*
|
|
|
|
* This is a comma separated list of image types, or actually drawable
|
|
|
|
* types, that this procedure can deal with. Wildcards are possible
|
|
|
|
* here, so you could say "RGB*" instead of "RGB, RGBA" or "*" for all
|
|
|
|
* image types.
|
|
|
|
*
|
|
|
|
* Supported types are "RGB", "GRAY", "INDEXED" and their variants
|
|
|
|
* with alpha.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_procedure_set_image_types (GimpProcedure *procedure,
|
|
|
|
const gchar *image_types)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-09-08 22:54:08 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_free (priv->image_types);
|
|
|
|
priv->image_types = g_strdup (image_types);
|
|
|
|
|
|
|
|
if (priv->installed)
|
2019-09-08 22:54:08 +08:00
|
|
|
_gimp_pdb_set_proc_image_types (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->image_types);
|
2019-08-06 05:01:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_get_image_types:
|
2019-08-10 17:08:06 +08:00
|
|
|
* @procedure: A #GimpProcedure.
|
2019-08-06 05:01:25 +08:00
|
|
|
*
|
2019-08-10 17:08:06 +08:00
|
|
|
* This function retrieves the list of image types the procedure can
|
2019-08-06 05:01:25 +08:00
|
|
|
* operate on. See gimp_procedure_set_image_types().
|
|
|
|
*
|
|
|
|
* Returns: The image types.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
const gchar *
|
|
|
|
gimp_procedure_get_image_types (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->image_types;
|
2019-08-06 05:01:25 +08:00
|
|
|
}
|
|
|
|
|
2021-04-02 05:49:11 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_set_sensitivity_mask:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
* @sensitivity_mask: A binary mask of #GimpProcedureSensitivityMask.
|
|
|
|
*
|
|
|
|
* Sets the case when @procedure is supposed to be sensitive or not.
|
|
|
|
* Note that it will be used by the core to determine whether to show a
|
|
|
|
* procedure as sensitive (hence forbid running it otherwise), yet it
|
|
|
|
* will not forbid thid-party plug-ins for instance to run manually your
|
|
|
|
* registered procedure. Therefore you should still handle non-supported
|
|
|
|
* cases appropriately by returning with %GIMP_PDB_EXECUTION_ERROR and a
|
|
|
|
* suitable error message.
|
|
|
|
*
|
|
|
|
* Similarly third-party plug-ins should verify they are allowed to call
|
2021-11-29 02:36:07 +08:00
|
|
|
* a procedure with [method@Procedure.get_sensitivity_mask] when running
|
2021-04-02 05:49:11 +08:00
|
|
|
* with dynamic contents.
|
|
|
|
*
|
|
|
|
* Note that by default, a procedure works on an image with a single
|
|
|
|
* drawable selected. Hence not setting the mask, setting it with 0 or
|
|
|
|
* setting it with a mask of %GIMP_PROCEDURE_SENSITIVE_DRAWABLE only are
|
|
|
|
* equivalent.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_procedure_set_sensitivity_mask (GimpProcedure *procedure,
|
|
|
|
gint sensitivity_mask)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
gboolean success = TRUE;
|
2021-04-30 05:53:35 +08:00
|
|
|
|
2021-04-02 05:49:11 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
2021-04-30 05:53:35 +08:00
|
|
|
if (GIMP_PROCEDURE_GET_CLASS (procedure)->set_sensitivity)
|
|
|
|
success = GIMP_PROCEDURE_GET_CLASS (procedure)->set_sensitivity (procedure,
|
|
|
|
sensitivity_mask);
|
2021-04-02 05:49:11 +08:00
|
|
|
|
2021-04-30 05:53:35 +08:00
|
|
|
if (success)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->sensitivity_mask = sensitivity_mask;
|
2021-04-30 05:53:35 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->installed)
|
2021-04-30 05:53:35 +08:00
|
|
|
_gimp_pdb_set_proc_sensitivity_mask (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->sensitivity_mask);
|
2021-04-30 05:53:35 +08:00
|
|
|
}
|
2021-04-02 05:49:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_get_sensitivity_mask:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Returns: The procedure's sensitivity mask given in
|
2021-11-29 02:36:07 +08:00
|
|
|
* [method@Procedure.set_sensitivity_mask].
|
2021-04-02 05:49:11 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
gimp_procedure_get_sensitivity_mask (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2021-04-02 05:49:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), 0);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->sensitivity_mask;
|
2021-04-02 05:49:11 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:56:00 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_set_menu_label:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
* @menu_label: The @procedure's menu label.
|
|
|
|
*
|
|
|
|
* Sets the label to use for the @procedure's menu entry, The
|
|
|
|
* location(s) where to register in the menu hierarchy is chosen using
|
|
|
|
* gimp_procedure_add_menu_path().
|
|
|
|
*
|
2023-07-22 22:17:24 +08:00
|
|
|
* Plug-ins are responsible for their own translations. You are expected to send
|
|
|
|
* localized strings to GIMP if your plug-in is internationalized.
|
2019-08-02 06:56:00 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2019-07-26 08:05:11 +08:00
|
|
|
void
|
2019-08-02 06:56:00 +08:00
|
|
|
gimp_procedure_set_menu_label (GimpProcedure *procedure,
|
|
|
|
const gchar *menu_label)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
2019-09-08 23:30:54 +08:00
|
|
|
g_return_if_fail (menu_label != NULL && strlen (menu_label));
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
g_clear_pointer (&priv->menu_label, g_free);
|
|
|
|
priv->menu_label = g_strdup (menu_label);
|
2019-09-08 23:30:54 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->installed)
|
2019-09-08 23:30:54 +08:00
|
|
|
_gimp_pdb_set_proc_menu_label (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->menu_label);
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_menu_label:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Returns: The procedure's menu label given in
|
2019-08-02 08:30:07 +08:00
|
|
|
* gimp_procedure_set_menu_label().
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2019-07-26 08:05:11 +08:00
|
|
|
const gchar *
|
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 22:37:55 +08:00
|
|
|
gimp_procedure_get_menu_label (GimpProcedure *procedure)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->menu_label;
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_add_menu_path:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
* @menu_path: The @procedure's additional menu path.
|
|
|
|
*
|
2019-08-20 08:52:05 +08:00
|
|
|
* Adds a menu path to the procedure. Only procedures which have a menu
|
2019-08-06 05:01:25 +08:00
|
|
|
* label can add a menu path.
|
|
|
|
*
|
2022-10-26 06:39:40 +08:00
|
|
|
* Menu paths are untranslated paths to known menus and submenus with the
|
|
|
|
* syntax `<Prefix>/Path/To/Submenu`, for example `<Image>/Layer/Transform`.
|
|
|
|
* GIMP will localize these.
|
|
|
|
* Nevertheless you should localize unknown parts of the path. For instance, say
|
|
|
|
* you want to create procedure to create customized layers and add a `Create`
|
|
|
|
* submenu which you want to localize from your plug-in with gettext. You could
|
|
|
|
* call:
|
|
|
|
*
|
2023-07-14 23:02:19 +08:00
|
|
|
* ```C
|
|
|
|
* path = g_build_path ("/", "<Image>/Layer", _("Create"), NULL);
|
|
|
|
* gimp_procedure_add_menu_path (procedure, path);
|
|
|
|
* g_free (path);
|
2022-10-26 06:39:40 +08:00
|
|
|
* ```
|
2019-08-06 05:01:25 +08:00
|
|
|
*
|
|
|
|
* See also: gimp_plug_in_add_menu_branch().
|
|
|
|
*
|
2023-07-14 23:02:19 +08:00
|
|
|
* GIMP menus also have a concept of named section. For instance, say you are
|
|
|
|
* creating a plug-in which you want to show next to the "Export", "Export As"
|
|
|
|
* plug-ins in the File menu. You would add it to the menu path "File/[Export]".
|
|
|
|
* If you actually wanted to create a submenu called "[Export]" (with square
|
|
|
|
* brackets), double the brackets: "File/[[Export]]"
|
|
|
|
*
|
|
|
|
* See also: https://gitlab.gnome.org/GNOME/gimp/-/blob/master/menus/image-menu.ui.in.in
|
|
|
|
*
|
|
|
|
* This function will place your procedure to the bottom of the selected path or
|
|
|
|
* section. Order is not assured relatively to other plug-ins.
|
|
|
|
*
|
2019-08-06 05:01:25 +08:00
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_procedure_add_menu_path (GimpProcedure *procedure,
|
|
|
|
const gchar *menu_path)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
g_return_if_fail (menu_path != NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-13 01:06:13 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
g_return_if_fail (priv->menu_label != NULL);
|
|
|
|
|
|
|
|
priv->menu_paths = g_list_append (priv->menu_paths, g_strdup (menu_path));
|
|
|
|
|
|
|
|
if (priv->installed)
|
2019-09-08 21:53:37 +08:00
|
|
|
_gimp_pdb_add_proc_menu_path (gimp_procedure_get_name (procedure),
|
|
|
|
menu_path);
|
2019-08-06 05:01:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_get_menu_paths:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none) (element-type gchar*): the @procedure's
|
|
|
|
* menu paths as added with gimp_procedure_add_menu_path().
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GList *
|
|
|
|
gimp_procedure_get_menu_paths (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-06 05:01:25 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->menu_paths;
|
2019-08-06 05:01:25 +08:00
|
|
|
}
|
|
|
|
|
2019-08-18 20:04:45 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_set_icon_name:
|
|
|
|
* @procedure: a #GimpProcedure.
|
|
|
|
* @icon_name: (nullable): an icon name.
|
|
|
|
*
|
|
|
|
* Sets the icon for @procedure to the icon referenced by @icon_name.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_procedure_set_icon_name (GimpProcedure *procedure,
|
|
|
|
const gchar *icon_name)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
|
|
|
|
gimp_procedure_set_icon (procedure,
|
|
|
|
GIMP_ICON_TYPE_ICON_NAME,
|
|
|
|
icon_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_set_icon_pixbuf:
|
|
|
|
* @procedure: a #GimpProcedure.
|
|
|
|
* @pixbuf: (nullable): a #GdkPixbuf.
|
|
|
|
*
|
|
|
|
* Sets the icon for @procedure to @pixbuf.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_procedure_set_icon_pixbuf (GimpProcedure *procedure,
|
|
|
|
GdkPixbuf *pixbuf)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
|
|
|
|
|
|
|
|
gimp_procedure_set_icon (procedure,
|
|
|
|
GIMP_ICON_TYPE_PIXBUF,
|
|
|
|
pixbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_set_icon_file:
|
|
|
|
* @procedure: a #GimpProcedure.
|
|
|
|
* @file: (nullable): a #GFile pointing to an image file.
|
|
|
|
*
|
|
|
|
* Sets the icon for @procedure to the contents of an image file.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_procedure_set_icon_file (GimpProcedure *procedure,
|
|
|
|
GFile *file)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
|
|
|
|
|
|
|
gimp_procedure_set_icon (procedure,
|
|
|
|
GIMP_ICON_TYPE_IMAGE_FILE,
|
|
|
|
file);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_get_icon_type:
|
|
|
|
* @procedure: a #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Gets the type of data set as @procedure's icon. Depending on the
|
|
|
|
* result, you can call the relevant specific function, such as
|
2021-11-29 02:36:07 +08:00
|
|
|
* [method@Procedure.get_icon_name].
|
2019-08-18 20:04:45 +08:00
|
|
|
*
|
|
|
|
* Returns: the #GimpIconType of @procedure's icon.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
GimpIconType
|
|
|
|
gimp_procedure_get_icon_type (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-18 20:04:45 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), -1);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->icon_type;
|
2019-08-18 20:04:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_get_icon_name:
|
|
|
|
* @procedure: a #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Gets the name of the icon if one was set for @procedure.
|
|
|
|
*
|
|
|
|
* Returns: (nullable): the icon name or %NULL if no icon name was set.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
const gchar *
|
|
|
|
gimp_procedure_get_icon_name (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-18 20:04:45 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
if (priv->icon_type == GIMP_ICON_TYPE_ICON_NAME)
|
|
|
|
return (const gchar *) priv->icon_data;
|
2019-08-18 20:04:45 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_get_icon_file:
|
|
|
|
* @procedure: a #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Gets the file of the icon if one was set for @procedure.
|
|
|
|
*
|
|
|
|
* Returns: (nullable) (transfer none): the icon #GFile or %NULL if no
|
|
|
|
* file was set.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
GFile *
|
|
|
|
gimp_procedure_get_icon_file (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-18 20:04:45 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
if (priv->icon_type == GIMP_ICON_TYPE_IMAGE_FILE)
|
|
|
|
return (GFile *) priv->icon_data;
|
2019-08-18 20:04:45 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_get_icon_pixbuf:
|
|
|
|
* @procedure: a #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Gets the #GdkPixbuf of the icon if an icon was set this way for
|
|
|
|
* @procedure.
|
|
|
|
*
|
|
|
|
* Returns: (nullable) (transfer none): the icon pixbuf or %NULL if no
|
|
|
|
* icon name was set.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
GdkPixbuf *
|
|
|
|
gimp_procedure_get_icon_pixbuf (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-18 20:04:45 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
if (priv->icon_type == GIMP_ICON_TYPE_PIXBUF)
|
|
|
|
return (GdkPixbuf *) priv->icon_data;
|
2019-08-18 20:04:45 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-08-02 06:56:00 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_set_documentation:
|
2023-07-28 04:59:51 +08:00
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
* @blurb: The @procedure's blurb.
|
|
|
|
* @help: (nullable): The @procedure's help text.
|
|
|
|
* @help_id: (nullable): The @procedure's help ID.
|
2019-08-02 06:56:00 +08:00
|
|
|
*
|
2023-07-28 04:59:51 +08:00
|
|
|
* Sets various documentation strings on @procedure:
|
2019-08-02 06:56:00 +08:00
|
|
|
*
|
2023-07-28 04:59:51 +08:00
|
|
|
* * @blurb is used for instance as the @procedure's tooltip when represented in
|
|
|
|
* the UI such as a menu entry.
|
|
|
|
* * @help is a free-form text that's meant as additional documentation for
|
|
|
|
* developers of scripts and plug-ins. If the @blurb and the argument names
|
|
|
|
* and descriptions are enough for a quite self-explanatory procedure, you may
|
|
|
|
* set @help to %NULL, rather than setting an uninformative @help (avoid
|
|
|
|
* setting the same text as @blurb or redundant information).
|
2019-08-02 06:56:00 +08:00
|
|
|
*
|
2023-07-28 04:59:51 +08:00
|
|
|
* Plug-ins are responsible for their own translations. You are expected to send
|
|
|
|
* localized strings of @blurb and @help to GIMP if your plug-in is
|
|
|
|
* internationalized.
|
2019-08-02 06:56:00 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_procedure_set_documentation (GimpProcedure *procedure,
|
|
|
|
const gchar *blurb,
|
|
|
|
const gchar *help,
|
|
|
|
const gchar *help_id)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-02 06:56:00 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
g_clear_pointer (&priv->blurb, g_free);
|
|
|
|
g_clear_pointer (&priv->help, g_free);
|
|
|
|
g_clear_pointer (&priv->help_id, g_free);
|
2019-08-02 06:56:00 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->blurb = g_strdup (blurb);
|
|
|
|
priv->help = g_strdup (help);
|
|
|
|
priv->help_id = g_strdup (help_id);
|
2019-09-09 06:36:24 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->installed)
|
2019-09-09 06:36:24 +08:00
|
|
|
_gimp_pdb_set_proc_documentation (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->blurb,
|
|
|
|
priv->help,
|
|
|
|
priv->help_id);
|
2019-08-02 06:56:00 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_blurb:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
2019-08-02 08:30:07 +08:00
|
|
|
* Returns: The procedure's blurb given in
|
2021-11-29 02:36:07 +08:00
|
|
|
* [method@Procedure.set_documentation].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2019-07-26 08:05:11 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_procedure_get_blurb (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-07-26 08:05:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->blurb;
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_help:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Returns: The procedure's help text given in
|
2021-11-29 02:36:07 +08:00
|
|
|
* [method@Procedure.set_documentation].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
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 22:37:55 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_procedure_get_help (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
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 22:37:55 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->help;
|
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 22:37:55 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_help_id:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Returns: The procedure's help ID given in
|
2021-11-29 02:36:07 +08:00
|
|
|
* [method@Procedure.set_documentation].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2019-07-26 08:05:11 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_procedure_get_help_id (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-07-26 08:05:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->help_id;
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_set_attribution:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
* @authors: The @procedure's author(s).
|
|
|
|
* @copyright: The @procedure's copyright.
|
2019-08-02 08:30:07 +08:00
|
|
|
* @date: The @procedure's date (written or published).
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Sets various attribution strings on @procedure.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_procedure_set_attribution (GimpProcedure *procedure,
|
|
|
|
const gchar *authors,
|
|
|
|
const gchar *copyright,
|
|
|
|
const gchar *date)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-08-02 06:35:17 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
g_free (priv->authors);
|
|
|
|
g_free (priv->copyright);
|
|
|
|
g_free (priv->date);
|
2019-08-02 06:35:17 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->authors = g_strdup (authors);
|
|
|
|
priv->copyright = g_strdup (copyright);
|
|
|
|
priv->date = g_strdup (date);
|
2019-09-09 06:36:24 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->installed)
|
2019-09-09 06:36:24 +08:00
|
|
|
_gimp_pdb_set_proc_attribution (gimp_procedure_get_name (procedure),
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->authors,
|
|
|
|
priv->copyright,
|
|
|
|
priv->date);
|
2019-08-02 06:35:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-08-10 18:32:25 +08:00
|
|
|
* gimp_procedure_get_authors:
|
2019-08-02 06:35:17 +08:00
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* Returns: The procedure's authors given in [method@Procedure.set_attribution].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
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 22:37:55 +08:00
|
|
|
const gchar *
|
2019-08-02 06:35:17 +08:00
|
|
|
gimp_procedure_get_authors (GimpProcedure *procedure)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
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 22:37:55 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->authors;
|
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 22:37:55 +08:00
|
|
|
}
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_copyright:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Returns: The procedure's copyright given in
|
2021-11-29 02:36:07 +08:00
|
|
|
* [method@Procedure.set_attribution].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
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 22:37:55 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_procedure_get_copyright (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-07-26 08:05:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->copyright;
|
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 22:37:55 +08:00
|
|
|
}
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_date:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* Returns: The procedure's date given in [method@Procedure.set_attribution].
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
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 22:37:55 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_procedure_get_date (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
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 22:37:55 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
return priv->date;
|
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 22:37:55 +08:00
|
|
|
}
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2019-08-01 17:57:17 +08:00
|
|
|
/**
|
2024-07-06 04:29:35 +08:00
|
|
|
* _gimp_procedure_add_argument:
|
2019-08-01 17:57:17 +08:00
|
|
|
* @procedure: the #GimpProcedure.
|
2021-10-13 00:45:50 +08:00
|
|
|
* @pspec: (transfer floating): the argument specification.
|
2019-08-01 17:57:17 +08:00
|
|
|
*
|
|
|
|
* Add a new argument to @procedure according to @pspec specifications.
|
2024-07-06 04:29:35 +08:00
|
|
|
* The arguments will be ordered according to the calls order.
|
2019-08-06 05:33:49 +08:00
|
|
|
*
|
2021-10-13 00:45:50 +08:00
|
|
|
* If @pspec is floating, ownership will be taken over by @procedure,
|
2021-11-29 02:36:07 +08:00
|
|
|
* allowing to pass directly `g*_param_spec_*()` calls as arguments.
|
2021-10-13 00:45:50 +08:00
|
|
|
*
|
|
|
|
* Returns: (transfer none): the same @pspec or %NULL in case of error.
|
2020-06-12 18:15:22 +08:00
|
|
|
*
|
2019-08-06 05:33:49 +08:00
|
|
|
* Since: 3.0
|
2019-08-02 06:35:17 +08:00
|
|
|
**/
|
2020-06-12 18:15:22 +08:00
|
|
|
GParamSpec *
|
2024-07-06 04:29:35 +08:00
|
|
|
_gimp_procedure_add_argument (GimpProcedure *procedure,
|
|
|
|
GParamSpec *pspec)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2020-06-12 18:15:22 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
|
|
|
|
g_return_val_if_fail (gimp_is_canonical_identifier (pspec->name), NULL);
|
2019-09-03 00:53:30 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
2019-10-12 18:49:32 +08:00
|
|
|
if (gimp_procedure_find_argument (procedure, pspec->name))
|
|
|
|
{
|
|
|
|
g_warning ("Argument with name '%s' already exists on procedure '%s'",
|
|
|
|
pspec->name,
|
|
|
|
gimp_procedure_get_name (procedure));
|
2021-08-27 23:54:33 +08:00
|
|
|
g_param_spec_sink (pspec);
|
2021-10-13 00:45:50 +08:00
|
|
|
return NULL;
|
2019-10-12 18:49:32 +08:00
|
|
|
}
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2019-10-12 18:49:32 +08:00
|
|
|
if (gimp_procedure_find_aux_argument (procedure, pspec->name))
|
|
|
|
{
|
|
|
|
g_warning ("Auxiliary argument with name '%s' already exists "
|
|
|
|
"on procedure '%s'",
|
|
|
|
pspec->name,
|
|
|
|
gimp_procedure_get_name (procedure));
|
2021-08-27 23:54:33 +08:00
|
|
|
g_param_spec_sink (pspec);
|
2021-10-13 00:45:50 +08:00
|
|
|
return NULL;
|
2019-10-12 18:49:32 +08:00
|
|
|
}
|
2019-09-24 18:39:02 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->args = g_renew (GParamSpec *, priv->args,
|
|
|
|
priv->n_args + 1);
|
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 22:37:55 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->args[priv->n_args] = pspec;
|
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 22:37:55 +08:00
|
|
|
|
|
|
|
g_param_spec_ref_sink (pspec);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->n_args++;
|
2020-06-12 18:15:22 +08:00
|
|
|
|
|
|
|
return pspec;
|
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 22:37:55 +08:00
|
|
|
}
|
|
|
|
|
2019-09-24 18:39:02 +08:00
|
|
|
/**
|
2024-07-06 04:29:35 +08:00
|
|
|
* _gimp_procedure_add_aux_argument:
|
2019-09-24 18:39:02 +08:00
|
|
|
* @procedure: the #GimpProcedure.
|
|
|
|
* @pspec: (transfer full): the argument specification.
|
|
|
|
*
|
|
|
|
* Add a new auxiliary argument to @procedure according to @pspec
|
|
|
|
* specifications.
|
|
|
|
*
|
|
|
|
* Auxiliary arguments are not passed to the @procedure in run() and
|
|
|
|
* are not known to the PDB. They are however members of the
|
|
|
|
* #GimpProcedureConfig created by gimp_procedure_create_config() and
|
|
|
|
* can be used to persistently store whatever last used values the
|
|
|
|
* @procedure wants to remember across invocations
|
|
|
|
*
|
2020-06-12 18:15:22 +08:00
|
|
|
* Returns: (transfer none): the same @pspec.
|
|
|
|
*
|
2019-09-24 18:39:02 +08:00
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2020-06-12 18:15:22 +08:00
|
|
|
GParamSpec *
|
2024-07-06 04:29:35 +08:00
|
|
|
_gimp_procedure_add_aux_argument (GimpProcedure *procedure,
|
|
|
|
GParamSpec *pspec)
|
2019-09-24 18:39:02 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2020-06-12 18:15:22 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), pspec);
|
|
|
|
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), pspec);
|
|
|
|
g_return_val_if_fail (gimp_is_canonical_identifier (pspec->name), pspec);
|
2019-09-24 18:39:02 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
2019-10-12 18:49:32 +08:00
|
|
|
if (gimp_procedure_find_argument (procedure, pspec->name))
|
|
|
|
{
|
|
|
|
g_warning ("Argument with name '%s' already exists on procedure '%s'",
|
|
|
|
pspec->name,
|
|
|
|
gimp_procedure_get_name (procedure));
|
2020-06-12 18:15:22 +08:00
|
|
|
return pspec;
|
2019-10-12 18:49:32 +08:00
|
|
|
}
|
2019-09-24 18:39:02 +08:00
|
|
|
|
2019-10-12 18:49:32 +08:00
|
|
|
if (gimp_procedure_find_aux_argument (procedure, pspec->name))
|
|
|
|
{
|
|
|
|
g_warning ("Auxiliary argument with name '%s' already exists "
|
|
|
|
"on procedure '%s'",
|
|
|
|
pspec->name,
|
|
|
|
gimp_procedure_get_name (procedure));
|
2020-06-12 18:15:22 +08:00
|
|
|
return pspec;
|
2019-10-12 18:49:32 +08:00
|
|
|
}
|
2019-09-24 18:39:02 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->aux_args = g_renew (GParamSpec *, priv->aux_args,
|
|
|
|
priv->n_aux_args + 1);
|
2019-09-24 18:39:02 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->aux_args[priv->n_aux_args] = pspec;
|
2019-09-24 18:39:02 +08:00
|
|
|
|
|
|
|
g_param_spec_ref_sink (pspec);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->n_aux_args++;
|
2020-06-12 18:15:22 +08:00
|
|
|
|
|
|
|
return pspec;
|
2019-09-24 18:39:02 +08:00
|
|
|
}
|
|
|
|
|
2019-08-01 17:57:17 +08:00
|
|
|
/**
|
2024-07-06 04:29:35 +08:00
|
|
|
* _gimp_procedure_add_return_value:
|
2019-08-01 17:57:17 +08:00
|
|
|
* @procedure: the #GimpProcedure.
|
2019-08-01 18:58:39 +08:00
|
|
|
* @pspec: (transfer full): the return value specification.
|
2019-08-01 17:57:17 +08:00
|
|
|
*
|
|
|
|
* Add a new return value to @procedure according to @pspec
|
2019-08-02 20:57:42 +08:00
|
|
|
* specifications.
|
|
|
|
*
|
2024-07-06 04:29:35 +08:00
|
|
|
* The returned values will be ordered according to the calls order.
|
2019-08-06 05:33:49 +08:00
|
|
|
*
|
2020-06-12 18:15:22 +08:00
|
|
|
* Returns: (transfer none): the same @pspec.
|
|
|
|
*
|
2019-08-06 05:33:49 +08:00
|
|
|
* Since: 3.0
|
2019-08-02 06:35:17 +08:00
|
|
|
**/
|
2020-06-12 18:15:22 +08:00
|
|
|
GParamSpec *
|
2024-07-06 04:29:35 +08:00
|
|
|
_gimp_procedure_add_return_value (GimpProcedure *procedure,
|
|
|
|
GParamSpec *pspec)
|
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 22:37:55 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2020-06-12 18:15:22 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), pspec);
|
|
|
|
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), pspec);
|
|
|
|
g_return_val_if_fail (gimp_is_canonical_identifier (pspec->name), pspec);
|
2019-09-03 00:53:30 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
2019-10-12 18:49:32 +08:00
|
|
|
if (gimp_procedure_find_return_value (procedure, pspec->name))
|
|
|
|
{
|
|
|
|
g_warning ("Return value with name '%s' already exists on procedure '%s'",
|
|
|
|
pspec->name,
|
|
|
|
gimp_procedure_get_name (procedure));
|
2020-06-12 18:15:22 +08:00
|
|
|
return pspec;
|
2019-10-12 18:49:32 +08:00
|
|
|
}
|
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 22:37:55 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->values = g_renew (GParamSpec *, priv->values,
|
|
|
|
priv->n_values + 1);
|
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 22:37:55 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->values[priv->n_values] = pspec;
|
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 22:37:55 +08:00
|
|
|
|
|
|
|
g_param_spec_ref_sink (pspec);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->n_values++;
|
2020-06-12 18:15:22 +08:00
|
|
|
|
|
|
|
return pspec;
|
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 22:37:55 +08:00
|
|
|
}
|
|
|
|
|
2019-10-12 18:49:32 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_find_argument:
|
|
|
|
* @procedure: A #GimpProcedure
|
|
|
|
* @name: An argument name
|
|
|
|
*
|
|
|
|
* Searches the @procedure's arguments for a #GParamSpec called @name.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The @procedure's argument with @name if it
|
|
|
|
* exists, or %NULL otherwise.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GParamSpec *
|
|
|
|
gimp_procedure_find_argument (GimpProcedure *procedure,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
gint i;
|
2019-10-12 18:49:32 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
for (i = 0; i < priv->n_args; i++)
|
|
|
|
if (! strcmp (name, priv->args[i]->name))
|
|
|
|
return priv->args[i];
|
2019-10-12 18:49:32 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_find_aux_argument:
|
|
|
|
* @procedure: A #GimpProcedure
|
|
|
|
* @name: An auxiliary argument name
|
|
|
|
*
|
|
|
|
* Searches the @procedure's auxiliary arguments for a #GParamSpec
|
|
|
|
* called @name.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The @procedure's auxiliary argument with
|
|
|
|
* @name if it exists, or %NULL otherwise.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GParamSpec *
|
|
|
|
gimp_procedure_find_aux_argument (GimpProcedure *procedure,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-10-12 18:49:32 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
for (i = 0; i < priv->n_aux_args; i++)
|
|
|
|
if (! strcmp (name, priv->aux_args[i]->name))
|
|
|
|
return priv->aux_args[i];
|
2019-10-12 18:49:32 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_find_return_value:
|
|
|
|
* @procedure: A #GimpProcedure
|
|
|
|
* @name: A return value name
|
|
|
|
*
|
|
|
|
* Searches the @procedure's return values for a #GParamSpec called
|
|
|
|
* @name.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The @procedure's return values with @name
|
|
|
|
* if it exists, or %NULL otherwise.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GParamSpec *
|
|
|
|
gimp_procedure_find_return_value (GimpProcedure *procedure,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
2019-10-12 18:49:32 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
for (i = 0; i < priv->n_values; i++)
|
|
|
|
if (! strcmp (name, priv->values[i]->name))
|
|
|
|
return priv->values[i];
|
2019-10-12 18:49:32 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_arguments:
|
|
|
|
* @procedure: A #GimpProcedure.
|
2019-08-02 09:21:59 +08:00
|
|
|
* @n_arguments: (out): Returns the number of arguments.
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
2019-08-02 09:21:59 +08:00
|
|
|
* Returns: (transfer none) (array length=n_arguments): An array
|
2024-07-06 04:29:35 +08:00
|
|
|
* of @GParamSpec in the order they were added in.
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
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 22:37:55 +08:00
|
|
|
GParamSpec **
|
|
|
|
gimp_procedure_get_arguments (GimpProcedure *procedure,
|
|
|
|
gint *n_arguments)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
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 22:37:55 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (n_arguments != NULL, NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
*n_arguments = priv->n_args;
|
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 22:37:55 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
return priv->args;
|
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 22:37:55 +08:00
|
|
|
}
|
|
|
|
|
2019-09-24 18:39:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_aux_arguments:
|
|
|
|
* @procedure: A #GimpProcedure.
|
|
|
|
* @n_arguments: (out): Returns the number of auxiliary arguments.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none) (array length=n_arguments): An array
|
2024-07-06 04:29:35 +08:00
|
|
|
* of @GParamSpec in the order they were added in.
|
2019-09-24 18:39:02 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GParamSpec **
|
|
|
|
gimp_procedure_get_aux_arguments (GimpProcedure *procedure,
|
|
|
|
gint *n_arguments)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-09-24 18:39:02 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (n_arguments != NULL, NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
*n_arguments = priv->n_aux_args;
|
2019-09-24 18:39:02 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
return priv->aux_args;
|
2019-09-24 18:39:02 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 06:35:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_get_return_values:
|
|
|
|
* @procedure: A #GimpProcedure.
|
2019-08-02 09:21:59 +08:00
|
|
|
* @n_return_values: (out): Returns the number of return values.
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
2019-08-02 09:21:59 +08:00
|
|
|
* Returns: (transfer none) (array length=n_return_values): An array
|
2024-07-06 04:29:35 +08:00
|
|
|
* of @GParamSpec in the order they were added in.
|
2019-08-02 06:35:17 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
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 22:37:55 +08:00
|
|
|
GParamSpec **
|
|
|
|
gimp_procedure_get_return_values (GimpProcedure *procedure,
|
|
|
|
gint *n_return_values)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
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 22:37:55 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (n_return_values != NULL, NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
*n_return_values = priv->n_values;
|
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 22:37:55 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
return priv->values;
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
2020-06-16 04:55:58 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_set_argument_sync:
|
|
|
|
* @procedure: a #GimpProcedure.
|
|
|
|
* @arg_name: the name of one of @procedure's arguments or auxiliary arguments.
|
|
|
|
* @sync: how to sync the argument or auxiliary argument.
|
|
|
|
*
|
2023-10-15 23:01:47 +08:00
|
|
|
* When the procedure's run() function exits, a #GimpProcedure's arguments
|
|
|
|
* or auxiliary arguments can be automatically synced with a #GimpParasite of
|
|
|
|
* the #GimpImage the procedure is running on.
|
2020-06-16 04:55:58 +08:00
|
|
|
*
|
|
|
|
* In order to enable this, set @sync to %GIMP_ARGUMENT_SYNC_PARASITE.
|
|
|
|
*
|
|
|
|
* Currently, it is possible to sync a string argument of type
|
|
|
|
* #GParamSpecString with an image parasite of the same name, for
|
|
|
|
* example the "gimp-comment" parasite in file save procedures.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_procedure_set_argument_sync (GimpProcedure *procedure,
|
|
|
|
const gchar *arg_name,
|
|
|
|
GimpArgumentSync sync)
|
|
|
|
{
|
|
|
|
GParamSpec *pspec;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
g_return_if_fail (arg_name != NULL);
|
|
|
|
|
|
|
|
pspec = gimp_procedure_find_argument (procedure, arg_name);
|
|
|
|
|
|
|
|
if (! pspec)
|
|
|
|
pspec = gimp_procedure_find_aux_argument (procedure, arg_name);
|
|
|
|
|
|
|
|
g_return_if_fail (pspec != NULL);
|
|
|
|
|
|
|
|
switch (sync)
|
|
|
|
{
|
|
|
|
case GIMP_ARGUMENT_SYNC_NONE:
|
|
|
|
gegl_param_spec_set_property_key (pspec, "gimp-argument-sync", NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ARGUMENT_SYNC_PARASITE:
|
|
|
|
gegl_param_spec_set_property_key (pspec, "gimp-argument-sync", "parasite");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_get_argument_sync:
|
|
|
|
* @procedure: a #GimpProcedure
|
|
|
|
* @arg_name: the name of one of @procedure's arguments or auxiliary arguments
|
|
|
|
*
|
|
|
|
* Returns: The #GimpArgumentSync value set with
|
|
|
|
* gimp_procedure_set_argument_sync():
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GimpArgumentSync
|
|
|
|
gimp_procedure_get_argument_sync (GimpProcedure *procedure,
|
|
|
|
const gchar *arg_name)
|
|
|
|
{
|
|
|
|
GParamSpec *pspec;
|
|
|
|
GimpArgumentSync sync = GIMP_ARGUMENT_SYNC_NONE;
|
|
|
|
const gchar *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), GIMP_ARGUMENT_SYNC_NONE);
|
|
|
|
g_return_val_if_fail (arg_name != NULL, GIMP_ARGUMENT_SYNC_NONE);
|
|
|
|
|
|
|
|
pspec = gimp_procedure_find_argument (procedure, arg_name);
|
|
|
|
|
|
|
|
if (! pspec)
|
|
|
|
pspec = gimp_procedure_find_aux_argument (procedure, arg_name);
|
|
|
|
|
|
|
|
g_return_val_if_fail (pspec != NULL, GIMP_ARGUMENT_SYNC_NONE);
|
|
|
|
|
|
|
|
value = gegl_param_spec_get_property_key (pspec, "gimp-argument-sync");
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
if (! strcmp (value, "parasite"))
|
|
|
|
sync = GIMP_ARGUMENT_SYNC_PARASITE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sync;
|
|
|
|
}
|
|
|
|
|
2019-08-01 17:57:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_new_return_values:
|
2021-11-29 02:36:07 +08:00
|
|
|
* @procedure: the procedure.
|
2019-08-01 18:58:39 +08:00
|
|
|
* @status: the success status of the procedure run.
|
2019-08-01 22:00:36 +08:00
|
|
|
* @error: (in) (nullable) (transfer full):
|
|
|
|
* an optional #GError. This parameter should be set if
|
|
|
|
* @status is either #GIMP_PDB_EXECUTION_ERROR or
|
2019-08-01 18:58:39 +08:00
|
|
|
* #GIMP_PDB_CALLING_ERROR.
|
2019-08-01 17:57:17 +08:00
|
|
|
*
|
2024-07-06 04:29:35 +08:00
|
|
|
* Format the expected return values from procedures.
|
2019-08-01 17:57:17 +08:00
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* Returns: (transfer full): the expected #GimpValueArray as could be returned
|
|
|
|
* by a [callback@RunFunc].
|
2019-08-06 05:33:49 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
2019-08-02 06:35:17 +08:00
|
|
|
**/
|
2019-07-26 08:05:11 +08:00
|
|
|
GimpValueArray *
|
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 22:37:55 +08:00
|
|
|
gimp_procedure_new_return_values (GimpProcedure *procedure,
|
|
|
|
GimpPDBStatusType status,
|
2019-08-01 22:00:36 +08:00
|
|
|
GError *error)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GimpValueArray *args;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
gint i;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
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 22:37:55 +08:00
|
|
|
g_return_val_if_fail (status != GIMP_PDB_PASS_THROUGH, NULL);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
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 22:37:55 +08:00
|
|
|
switch (status)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
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 22:37:55 +08:00
|
|
|
case GIMP_PDB_SUCCESS:
|
|
|
|
case GIMP_PDB_CANCEL:
|
2019-08-07 01:10:04 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
args = gimp_value_array_new (priv->n_values + 1);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
g_value_init (&value, GIMP_TYPE_PDB_STATUS_TYPE);
|
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 22:37:55 +08:00
|
|
|
g_value_set_enum (&value, status);
|
2019-07-26 08:05:11 +08:00
|
|
|
gimp_value_array_append (args, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
for (i = 0; i < priv->n_values; i++)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GParamSpec *pspec = priv->values[i];
|
2019-08-02 06:39:22 +08:00
|
|
|
|
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
|
|
g_param_value_set_default (pspec, &value);
|
2019-07-26 08:05:11 +08:00
|
|
|
gimp_value_array_append (args, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
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 22:37:55 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PDB_EXECUTION_ERROR:
|
|
|
|
case GIMP_PDB_CALLING_ERROR:
|
2019-07-26 08:05:11 +08:00
|
|
|
args = gimp_value_array_new ((error && error->message) ? 2 : 1);
|
|
|
|
|
|
|
|
g_value_init (&value, GIMP_TYPE_PDB_STATUS_TYPE);
|
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 22:37:55 +08:00
|
|
|
g_value_set_enum (&value, status);
|
2019-07-26 08:05:11 +08:00
|
|
|
gimp_value_array_append (args, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
if (error && error->message)
|
|
|
|
{
|
|
|
|
g_value_init (&value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (&value, error->message);
|
|
|
|
gimp_value_array_append (args, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
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 22:37:55 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_return_val_if_reached (NULL);
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
2019-08-07 01:10:04 +08:00
|
|
|
|
2019-08-01 22:00:36 +08:00
|
|
|
g_clear_error (&error);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
2019-08-02 05:46:25 +08:00
|
|
|
/**
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
* gimp_procedure_run: (skip)
|
2024-06-11 18:34:15 +08:00
|
|
|
* @procedure: the [class@Gimp.Procedure] to run.
|
2023-12-08 20:18:03 +08:00
|
|
|
* @first_arg_name: the name of an argument of @procedure or %NULL to
|
|
|
|
* run @procedure with default arguments.
|
|
|
|
* @...: the value of @first_arg_name and any more argument
|
|
|
|
* names and values as needed.
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
*
|
|
|
|
* Runs the procedure named @procedure_name with arguments given as
|
|
|
|
* list of `(name, value)` pairs, terminated by %NULL.
|
|
|
|
*
|
|
|
|
* The order of arguments does not matter and if any argument is missing, its
|
|
|
|
* default value will be used. The value type must correspond to the argument
|
|
|
|
* type as registered for @procedure_name.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the return values for the procedure call.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
GimpValueArray *
|
|
|
|
gimp_procedure_run (GimpProcedure *procedure,
|
|
|
|
const gchar *first_arg_name,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
GimpValueArray *return_values;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
|
|
|
va_start (args, first_arg_name);
|
|
|
|
|
|
|
|
return_values = gimp_procedure_run_valist (procedure, first_arg_name, args);
|
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
return return_values;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_run_valist: (skip)
|
2024-06-11 18:34:15 +08:00
|
|
|
* @procedure: the [class@Gimp.Procedure] to run.
|
2023-12-08 20:18:03 +08:00
|
|
|
* @first_arg_name: the name of an argument of @procedure or %NULL to
|
|
|
|
* run @procedure with default arguments.
|
|
|
|
* @args the value of @first_arg_name and any more argument
|
|
|
|
* names and values as needed.
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
*
|
|
|
|
* Runs @procedure with arguments names and values, given in the order as passed
|
|
|
|
* to [method@Procedure.run].
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the return values for the procedure call.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
GimpValueArray *
|
|
|
|
gimp_procedure_run_valist (GimpProcedure *procedure,
|
|
|
|
const gchar *first_arg_name,
|
|
|
|
va_list args)
|
|
|
|
{
|
|
|
|
GimpValueArray *return_values;
|
|
|
|
GimpProcedureConfig *config;
|
|
|
|
const gchar *arg_name;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
|
|
|
config = gimp_procedure_create_config (procedure);
|
|
|
|
arg_name = first_arg_name;
|
|
|
|
|
|
|
|
while (arg_name != NULL)
|
|
|
|
{
|
|
|
|
GParamSpec *pspec;
|
|
|
|
gchar *error = NULL;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config), arg_name);
|
|
|
|
|
|
|
|
if (pspec == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("%s: %s has no property named '%s'",
|
|
|
|
G_STRFUNC,
|
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (config)),
|
|
|
|
arg_name);
|
|
|
|
g_clear_object (&config);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init (&value, pspec->value_type);
|
|
|
|
G_VALUE_COLLECT (&value, args, G_VALUE_NOCOPY_CONTENTS, &error);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("%s: %s", G_STRFUNC, error);
|
|
|
|
g_free (error);
|
|
|
|
g_clear_object (&config);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_property (G_OBJECT (config), arg_name, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
arg_name = va_arg (args, const gchar *);
|
|
|
|
}
|
|
|
|
|
|
|
|
return_values = gimp_procedure_run_config (procedure, config);
|
|
|
|
g_clear_object (&config);
|
|
|
|
|
|
|
|
return return_values;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_procedure_run_config: (rename-to gimp_procedure_run)
|
2024-06-11 18:34:15 +08:00
|
|
|
* @procedure: the [class@Gimp.Procedure] to run.
|
2024-02-29 23:33:32 +08:00
|
|
|
* @config: (nullable): the @procedure's arguments.
|
2019-08-02 05:46:25 +08:00
|
|
|
*
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
* Runs @procedure, calling the run_func given in [ctor@Procedure.new].
|
2019-08-02 05:46:25 +08:00
|
|
|
*
|
2023-12-08 20:18:03 +08:00
|
|
|
* Create @config at default values with
|
|
|
|
* [method@Gimp.Procedure.create_config] then set any argument you wish
|
|
|
|
* to change from defaults with [method@GObject.Object.set].
|
|
|
|
*
|
2024-02-29 23:33:32 +08:00
|
|
|
* If @config is %NULL, the default arguments of @procedure will be used.
|
|
|
|
*
|
2019-08-02 09:21:59 +08:00
|
|
|
* Returns: (transfer full): The @procedure's return values.
|
2019-08-02 05:46:25 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
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 22:37:55 +08:00
|
|
|
GimpValueArray *
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
gimp_procedure_run_config (GimpProcedure *procedure,
|
|
|
|
GimpProcedureConfig *config)
|
|
|
|
{
|
|
|
|
GimpValueArray *return_vals;
|
|
|
|
GimpValueArray *args;
|
2024-02-29 23:33:32 +08:00
|
|
|
gboolean free_config = FALSE;
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
2024-02-29 23:33:32 +08:00
|
|
|
g_return_val_if_fail (config == NULL || GIMP_IS_PROCEDURE_CONFIG (config), NULL);
|
|
|
|
g_return_val_if_fail (config == NULL || gimp_procedure_config_get_procedure (config) == procedure, NULL);
|
|
|
|
|
|
|
|
if (config == NULL)
|
|
|
|
{
|
|
|
|
config = gimp_procedure_create_config (procedure);
|
|
|
|
free_config = TRUE;
|
|
|
|
}
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
|
|
|
|
args = gimp_procedure_new_arguments (procedure);
|
|
|
|
_gimp_procedure_config_get_values (config, args);
|
|
|
|
|
|
|
|
return_vals = _gimp_procedure_run_array (procedure, args);
|
|
|
|
|
|
|
|
gimp_value_array_unref (args);
|
|
|
|
|
2024-02-29 23:33:32 +08:00
|
|
|
if (free_config)
|
|
|
|
g_object_unref (config);
|
|
|
|
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
2024-05-02 03:47:55 +08:00
|
|
|
/**
|
|
|
|
* _gimp_procedure_create_run_config:
|
|
|
|
* @procedure: A #GimpProcedure
|
|
|
|
*
|
|
|
|
* Create a #GimpConfig with properties that match @procedure's arguments, to be
|
|
|
|
* used in the run() method for @procedure.
|
|
|
|
*
|
|
|
|
* This is an internal function to be used only by libgimp code.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): The new #GimpConfig.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GimpProcedureConfig *
|
|
|
|
_gimp_procedure_create_run_config (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2024-05-02 03:47:55 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
2024-05-02 03:47:55 +08:00
|
|
|
return GIMP_PROCEDURE_GET_CLASS (procedure)->create_config (procedure,
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->args,
|
|
|
|
priv->n_args);
|
2024-05-02 03:47:55 +08:00
|
|
|
}
|
|
|
|
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 23:11:20 +08:00
|
|
|
GimpValueArray *
|
|
|
|
_gimp_procedure_run_array (GimpProcedure *procedure,
|
|
|
|
GimpValueArray *args)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GimpValueArray *return_vals;
|
|
|
|
GError *error = NULL;
|
|
|
|
gint i;
|
2019-07-26 08:05:11 +08:00
|
|
|
|
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 22:37:55 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (args != NULL, NULL);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
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 22:37:55 +08:00
|
|
|
if (! gimp_procedure_validate_args (procedure,
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->args,
|
|
|
|
priv->n_args,
|
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 22:37:55 +08:00
|
|
|
args, FALSE, &error))
|
|
|
|
{
|
|
|
|
return_vals = gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_CALLING_ERROR,
|
|
|
|
error);
|
|
|
|
return return_vals;
|
|
|
|
}
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2019-08-03 22:56:31 +08:00
|
|
|
/* add missing args with default values */
|
2024-07-10 21:03:15 +08:00
|
|
|
if (gimp_value_array_length (args) < priv->n_args)
|
2019-08-03 22:56:31 +08:00
|
|
|
{
|
2019-09-27 01:06:17 +08:00
|
|
|
GimpProcedureConfig *config;
|
|
|
|
GObjectClass *config_class = NULL;
|
|
|
|
GimpValueArray *complete;
|
|
|
|
|
|
|
|
/* if saved defaults exist, they override GParamSpec */
|
2024-05-02 03:47:55 +08:00
|
|
|
config = _gimp_procedure_create_run_config (procedure);
|
2023-10-16 05:20:44 +08:00
|
|
|
if (gimp_procedure_config_load_default (config, NULL))
|
2019-09-27 01:06:17 +08:00
|
|
|
config_class = G_OBJECT_GET_CLASS (config);
|
|
|
|
else
|
|
|
|
g_clear_object (&config);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
complete = gimp_value_array_new (priv->n_args);
|
2019-08-03 22:56:31 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
for (i = 0; i < priv->n_args; i++)
|
2019-08-07 06:02:29 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GParamSpec *pspec = priv->args[i];
|
2019-08-07 06:02:29 +08:00
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
2019-08-03 22:56:31 +08:00
|
|
|
|
2019-08-07 06:02:29 +08:00
|
|
|
if (i < gimp_value_array_length (args))
|
|
|
|
{
|
|
|
|
GValue *orig = gimp_value_array_index (args, i);
|
|
|
|
|
|
|
|
g_value_copy (orig, &value);
|
|
|
|
}
|
2019-09-27 01:06:17 +08:00
|
|
|
else if (config &&
|
|
|
|
g_object_class_find_property (config_class, pspec->name))
|
|
|
|
{
|
|
|
|
g_object_get_property (G_OBJECT (config), pspec->name,
|
|
|
|
&value);
|
|
|
|
}
|
2019-08-07 06:02:29 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_param_value_set_default (pspec, &value);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_value_array_append (complete, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
2019-09-27 01:06:17 +08:00
|
|
|
g_clear_object (&config);
|
|
|
|
|
2019-08-07 06:02:29 +08:00
|
|
|
/* call the procedure */
|
|
|
|
return_vals = GIMP_PROCEDURE_GET_CLASS (procedure)->run (procedure,
|
|
|
|
complete);
|
|
|
|
gimp_value_array_unref (complete);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* call the procedure */
|
|
|
|
return_vals = GIMP_PROCEDURE_GET_CLASS (procedure)->run (procedure,
|
|
|
|
args);
|
|
|
|
}
|
2019-07-26 08:05:11 +08:00
|
|
|
|
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 22:37:55 +08:00
|
|
|
if (! return_vals)
|
|
|
|
{
|
|
|
|
g_warning ("%s: no return values, shouldn't happen", G_STRFUNC);
|
2019-07-26 08:05:11 +08:00
|
|
|
|
2019-08-29 22:25:14 +08:00
|
|
|
error = g_error_new (0, 0,
|
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 22:37:55 +08:00
|
|
|
_("Procedure '%s' returned no return values"),
|
|
|
|
gimp_procedure_get_name (procedure));
|
2019-07-26 08:05:11 +08:00
|
|
|
|
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 22:37:55 +08:00
|
|
|
return_vals = gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_EXECUTION_ERROR,
|
|
|
|
error);
|
|
|
|
}
|
2019-07-26 08:05:11 +08:00
|
|
|
|
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 22:37:55 +08:00
|
|
|
return return_vals;
|
2019-07-26 08:05:11 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 05:24:49 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_extension_ready:
|
2019-08-10 17:08:06 +08:00
|
|
|
* @procedure: A #GimpProcedure
|
2019-08-02 05:24:49 +08:00
|
|
|
*
|
|
|
|
* Notify the main GIMP application that the extension has been
|
|
|
|
* properly initialized and is ready to run.
|
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* This function _must_ be called from every procedure's [callback@RunFunc]
|
|
|
|
* that was created as #GIMP_PDB_PROC_TYPE_EXTENSION.
|
2019-08-02 05:24:49 +08:00
|
|
|
*
|
|
|
|
* Subsequently, extensions can process temporary procedure run
|
2021-11-29 02:36:07 +08:00
|
|
|
* requests using either [method@PlugIn.extension_enable] or
|
|
|
|
* [method@PlugIn.extension_process].
|
2019-08-02 05:24:49 +08:00
|
|
|
*
|
2021-11-29 02:36:07 +08:00
|
|
|
* See also: [ctor@Procedure.new].
|
2019-08-02 05:24:49 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_procedure_extension_ready (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GimpPlugIn *plug_in;
|
2019-08-11 02:25:37 +08:00
|
|
|
|
2019-08-02 05:24:49 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
2024-07-10 21:03:15 +08:00
|
|
|
|
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
g_return_if_fail (priv->proc_type == GIMP_PDB_PROC_TYPE_EXTENSION);
|
2019-08-02 05:24:49 +08:00
|
|
|
|
2019-08-11 02:25:37 +08:00
|
|
|
plug_in = gimp_procedure_get_plug_in (procedure);
|
|
|
|
|
|
|
|
if (! gp_extension_ack_write (_gimp_plug_in_get_write_channel (plug_in),
|
|
|
|
plug_in))
|
|
|
|
gimp_quit ();
|
2019-08-02 05:24:49 +08:00
|
|
|
}
|
|
|
|
|
2019-09-20 18:31:11 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_create_config:
|
|
|
|
* @procedure: A #GimpProcedure
|
|
|
|
*
|
2024-05-02 03:47:55 +08:00
|
|
|
* Create a #GimpConfig with properties that match @procedure's arguments, to be
|
|
|
|
* used in [method@Procedure.run_config] method.
|
2019-09-20 18:31:11 +08:00
|
|
|
*
|
|
|
|
* Returns: (transfer full): The new #GimpConfig.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GimpProcedureConfig *
|
|
|
|
gimp_procedure_create_config (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-09-20 18:31:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
2024-05-02 03:47:55 +08:00
|
|
|
return gimp_procedure_create_config_with_prefix (procedure,
|
|
|
|
"GimpProcedureConfig",
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->args,
|
|
|
|
priv->n_args);
|
2019-09-20 18:31:11 +08:00
|
|
|
}
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2023-10-19 00:43:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedure_new_arguments:
|
|
|
|
* @procedure: the #GimpProcedure.
|
|
|
|
*
|
|
|
|
* Format the expected argument values of procedures, in the order as
|
|
|
|
* added with [method@Procedure.add_argument].
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the expected #GimpValueArray which could be given as
|
|
|
|
* arguments to run @procedure, with all values set to
|
|
|
|
* defaults. Free with gimp_value_array_unref().
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
static GimpValueArray *
|
|
|
|
gimp_procedure_new_arguments (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GimpValueArray *args;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
gint i;
|
2023-10-19 00:43:08 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
args = gimp_value_array_new (priv->n_args);
|
2023-10-19 00:43:08 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
for (i = 0; i < priv->n_args; i++)
|
2023-10-19 00:43:08 +08:00
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GParamSpec *pspec = priv->args[i];
|
2023-10-19 00:43:08 +08:00
|
|
|
|
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
|
|
g_param_value_set_default (pspec, &value);
|
|
|
|
gimp_value_array_append (args, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
static gboolean
|
2019-08-13 18:34:09 +08:00
|
|
|
gimp_procedure_validate_args (GimpProcedure *procedure,
|
|
|
|
GParamSpec **param_specs,
|
|
|
|
gint n_param_specs,
|
|
|
|
GimpValueArray *args,
|
|
|
|
gboolean return_vals,
|
|
|
|
GError **error)
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < MIN (gimp_value_array_length (args), n_param_specs); i++)
|
|
|
|
{
|
|
|
|
GValue *arg = gimp_value_array_index (args, i);
|
|
|
|
GParamSpec *pspec = param_specs[i];
|
|
|
|
GType arg_type = G_VALUE_TYPE (arg);
|
|
|
|
GType spec_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
|
|
|
|
2021-04-21 06:00:32 +08:00
|
|
|
if (! g_type_is_a (arg_type, spec_type))
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
|
|
|
if (return_vals)
|
|
|
|
{
|
|
|
|
g_set_error (error,
|
|
|
|
GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
|
|
|
|
_("Procedure '%s' returned a wrong value type "
|
|
|
|
"for return value '%s' (#%d). "
|
|
|
|
"Expected %s, got %s."),
|
|
|
|
gimp_procedure_get_name (procedure),
|
|
|
|
g_param_spec_get_name (pspec),
|
|
|
|
i + 1, g_type_name (spec_type),
|
|
|
|
g_type_name (arg_type));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_set_error (error,
|
|
|
|
GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
|
|
|
_("Procedure '%s' has been called with a "
|
|
|
|
"wrong value type for argument '%s' (#%d). "
|
|
|
|
"Expected %s, got %s."),
|
|
|
|
gimp_procedure_get_name (procedure),
|
|
|
|
g_param_spec_get_name (pspec),
|
|
|
|
i + 1, g_type_name (spec_type),
|
|
|
|
g_type_name (arg_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-08-13 19:37:52 +08:00
|
|
|
else if (! (pspec->flags & GIMP_PARAM_NO_VALIDATE))
|
2019-07-26 08:05:11 +08:00
|
|
|
{
|
|
|
|
GValue string_value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
g_value_init (&string_value, G_TYPE_STRING);
|
|
|
|
|
|
|
|
if (g_value_type_transformable (arg_type, G_TYPE_STRING))
|
|
|
|
g_value_transform (arg, &string_value);
|
|
|
|
else
|
|
|
|
g_value_set_static_string (&string_value,
|
|
|
|
"<not transformable to string>");
|
|
|
|
|
|
|
|
if (g_param_value_validate (pspec, arg))
|
|
|
|
{
|
|
|
|
const gchar *value = g_value_get_string (&string_value);
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
value = "(null)";
|
|
|
|
|
|
|
|
if (return_vals)
|
|
|
|
{
|
|
|
|
g_set_error (error,
|
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
|
|
|
|
_("Procedure '%s' returned "
|
|
|
|
"'%s' as return value '%s' "
|
|
|
|
"(#%d, type %s). "
|
|
|
|
"This value is out of range."),
|
|
|
|
gimp_procedure_get_name (procedure),
|
|
|
|
value,
|
|
|
|
g_param_spec_get_name (pspec),
|
|
|
|
i + 1, g_type_name (spec_type));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_set_error (error,
|
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
|
|
|
_("Procedure '%s' has been called with "
|
|
|
|
"value '%s' for argument '%s' "
|
|
|
|
"(#%d, type %s). "
|
|
|
|
"This value is out of range."),
|
|
|
|
gimp_procedure_get_name (procedure),
|
|
|
|
value,
|
|
|
|
g_param_spec_get_name (pspec),
|
|
|
|
i + 1, g_type_name (spec_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&string_value);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-08-19 19:11:02 +08:00
|
|
|
/* UTT-8 validate all strings */
|
2019-08-20 07:46:56 +08:00
|
|
|
if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING ||
|
2020-12-24 04:15:43 +08:00
|
|
|
(G_PARAM_SPEC_TYPE (pspec) == G_TYPE_BOXED &&
|
|
|
|
G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_STRV))
|
2019-08-19 19:11:02 +08:00
|
|
|
{
|
2019-08-20 07:46:56 +08:00
|
|
|
gboolean valid = TRUE;
|
2019-08-19 19:11:02 +08:00
|
|
|
|
2019-08-20 07:46:56 +08:00
|
|
|
if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING)
|
|
|
|
{
|
|
|
|
const gchar *string = g_value_get_string (arg);
|
|
|
|
|
|
|
|
if (string)
|
|
|
|
valid = g_utf8_validate (string, -1, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-25 05:52:15 +08:00
|
|
|
const gchar **strings = g_value_get_boxed (arg);
|
2019-08-20 07:46:56 +08:00
|
|
|
|
2022-05-25 05:52:15 +08:00
|
|
|
for (const gchar **sp = strings; sp && *sp && valid; sp++)
|
|
|
|
valid = g_utf8_validate (*sp, -1, NULL);
|
2019-08-20 07:46:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! valid)
|
2019-08-19 19:11:02 +08:00
|
|
|
{
|
|
|
|
if (return_vals)
|
|
|
|
{
|
|
|
|
g_set_error (error,
|
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
|
|
|
|
_("Procedure '%s' returned an "
|
|
|
|
"invalid UTF-8 string for argument '%s'."),
|
|
|
|
gimp_procedure_get_name (procedure),
|
|
|
|
g_param_spec_get_name (pspec));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_set_error (error,
|
|
|
|
GIMP_PDB_ERROR,
|
|
|
|
GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
|
|
|
_("Procedure '%s' has been called with an "
|
|
|
|
"invalid UTF-8 string for argument '%s'."),
|
|
|
|
gimp_procedure_get_name (procedure),
|
|
|
|
g_param_spec_get_name (pspec));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&string_value);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-26 08:05:11 +08:00
|
|
|
g_value_unset (&string_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-08-09 06:05:49 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_procedure_set_icon (GimpProcedure *procedure,
|
|
|
|
GimpIconType icon_type,
|
|
|
|
gconstpointer icon_data)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-09 06:05:49 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
if (icon_data == priv->icon_data)
|
2019-08-09 06:05:49 +08:00
|
|
|
return;
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
switch (priv->icon_type)
|
2019-08-09 06:05:49 +08:00
|
|
|
{
|
|
|
|
case GIMP_ICON_TYPE_ICON_NAME:
|
2024-07-10 21:03:15 +08:00
|
|
|
g_clear_pointer (&priv->icon_data, g_free);
|
2019-08-09 06:05:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ICON_TYPE_PIXBUF:
|
|
|
|
case GIMP_ICON_TYPE_IMAGE_FILE:
|
2024-07-10 21:03:15 +08:00
|
|
|
g_clear_object (&priv->icon_data);
|
2019-08-09 06:05:49 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->icon_type = icon_type;
|
2019-08-09 06:05:49 +08:00
|
|
|
|
|
|
|
switch (icon_type)
|
|
|
|
{
|
|
|
|
case GIMP_ICON_TYPE_ICON_NAME:
|
2024-07-10 21:03:15 +08:00
|
|
|
priv->icon_data = g_strdup (icon_data);
|
2019-08-09 06:05:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ICON_TYPE_PIXBUF:
|
|
|
|
case GIMP_ICON_TYPE_IMAGE_FILE:
|
2024-07-10 21:03:15 +08:00
|
|
|
g_set_object (&priv->icon_data, (GObject *) icon_data);
|
2019-08-09 06:05:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_return_if_reached ();
|
|
|
|
}
|
2019-09-08 22:22:32 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
if (priv->installed)
|
2019-09-08 22:22:32 +08:00
|
|
|
gimp_procedure_install_icon (procedure);
|
2019-08-09 06:05:49 +08:00
|
|
|
}
|
2019-08-23 23:18:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* internal functions */
|
|
|
|
|
|
|
|
GimpDisplay *
|
|
|
|
_gimp_procedure_get_display (GimpProcedure *procedure,
|
|
|
|
gint32 display_id)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GimpDisplay *display = NULL;
|
2019-08-23 23:18:17 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
2019-08-29 17:25:35 +08:00
|
|
|
g_return_val_if_fail (gimp_display_id_is_valid (display_id), NULL);
|
2019-08-23 23:18:17 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (! priv->displays))
|
|
|
|
priv->displays =
|
2019-08-23 23:18:17 +08:00
|
|
|
g_hash_table_new_full (g_direct_hash,
|
|
|
|
g_direct_equal,
|
|
|
|
NULL,
|
|
|
|
(GDestroyNotify) g_object_unref);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
display = g_hash_table_lookup (priv->displays,
|
2019-08-23 23:18:17 +08:00
|
|
|
GINT_TO_POINTER (display_id));
|
|
|
|
|
|
|
|
if (! display)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
display = _gimp_plug_in_get_display (priv->plug_in,
|
2019-08-23 23:18:17 +08:00
|
|
|
display_id);
|
|
|
|
|
|
|
|
if (display)
|
2024-07-10 21:03:15 +08:00
|
|
|
g_hash_table_insert (priv->displays,
|
2019-08-23 23:18:17 +08:00
|
|
|
GINT_TO_POINTER (display_id),
|
|
|
|
g_object_ref (display));
|
|
|
|
}
|
|
|
|
|
|
|
|
return display;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpImage *
|
|
|
|
_gimp_procedure_get_image (GimpProcedure *procedure,
|
|
|
|
gint32 image_id)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GimpImage *image = NULL;
|
2019-08-23 23:18:17 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
2019-08-29 17:25:35 +08:00
|
|
|
g_return_val_if_fail (gimp_image_id_is_valid (image_id), NULL);
|
2019-08-23 23:18:17 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (! priv->images))
|
|
|
|
priv->images =
|
2019-08-23 23:18:17 +08:00
|
|
|
g_hash_table_new_full (g_direct_hash,
|
|
|
|
g_direct_equal,
|
|
|
|
NULL,
|
|
|
|
(GDestroyNotify) g_object_unref);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
image = g_hash_table_lookup (priv->images,
|
2019-08-23 23:18:17 +08:00
|
|
|
GINT_TO_POINTER (image_id));
|
|
|
|
|
|
|
|
if (! image)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
image = _gimp_plug_in_get_image (priv->plug_in,
|
2019-08-23 23:18:17 +08:00
|
|
|
image_id);
|
|
|
|
|
|
|
|
if (image)
|
2024-07-10 21:03:15 +08:00
|
|
|
g_hash_table_insert (priv->images,
|
2019-08-23 23:18:17 +08:00
|
|
|
GINT_TO_POINTER (image_id),
|
|
|
|
g_object_ref (image));
|
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpItem *
|
|
|
|
_gimp_procedure_get_item (GimpProcedure *procedure,
|
|
|
|
gint32 item_id)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GimpItem *item = NULL;
|
2019-08-23 23:18:17 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
2019-08-29 17:25:35 +08:00
|
|
|
g_return_val_if_fail (gimp_item_id_is_valid (item_id), NULL);
|
2019-08-23 23:18:17 +08:00
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (! priv->items))
|
|
|
|
priv->items =
|
2019-08-23 23:18:17 +08:00
|
|
|
g_hash_table_new_full (g_direct_hash,
|
|
|
|
g_direct_equal,
|
|
|
|
NULL,
|
|
|
|
(GDestroyNotify) g_object_unref);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
item = g_hash_table_lookup (priv->items,
|
2019-08-23 23:18:17 +08:00
|
|
|
GINT_TO_POINTER (item_id));
|
|
|
|
|
|
|
|
if (! item)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
item = _gimp_plug_in_get_item (priv->plug_in,
|
2019-08-23 23:18:17 +08:00
|
|
|
item_id);
|
|
|
|
|
|
|
|
if (item)
|
2024-07-10 21:03:15 +08:00
|
|
|
g_hash_table_insert (priv->items,
|
2019-08-23 23:18:17 +08:00
|
|
|
GINT_TO_POINTER (item_id),
|
|
|
|
g_object_ref (item));
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2023-05-31 22:12:04 +08:00
|
|
|
GimpResource *
|
|
|
|
_gimp_procedure_get_resource (GimpProcedure *procedure,
|
|
|
|
gint32 resource_id)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
GimpResource *resource = NULL;
|
2023-05-31 22:12:04 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
|
|
|
g_return_val_if_fail (gimp_resource_id_is_valid (resource_id), NULL);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (! priv->resources))
|
|
|
|
priv->resources =
|
2023-05-31 22:12:04 +08:00
|
|
|
g_hash_table_new_full (g_direct_hash,
|
|
|
|
g_direct_equal,
|
|
|
|
NULL,
|
|
|
|
(GDestroyNotify) g_object_unref);
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
resource = g_hash_table_lookup (priv->resources,
|
2023-05-31 22:12:04 +08:00
|
|
|
GINT_TO_POINTER (resource_id));
|
|
|
|
|
|
|
|
if (! resource)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
resource = _gimp_plug_in_get_resource (priv->plug_in,
|
2023-05-31 22:12:04 +08:00
|
|
|
resource_id);
|
|
|
|
|
|
|
|
if (resource)
|
2024-07-10 21:03:15 +08:00
|
|
|
g_hash_table_insert (priv->resources,
|
2023-05-31 22:12:04 +08:00
|
|
|
GINT_TO_POINTER (resource_id),
|
|
|
|
g_object_ref (resource));
|
|
|
|
}
|
|
|
|
|
|
|
|
return resource;
|
|
|
|
}
|
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
void
|
|
|
|
_gimp_procedure_destroy_proxies (GimpProcedure *procedure)
|
|
|
|
{
|
2024-07-10 21:03:15 +08:00
|
|
|
GimpProcedurePrivate *priv;
|
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
|
|
|
|
2024-07-10 21:03:15 +08:00
|
|
|
priv = gimp_procedure_get_instance_private (procedure);
|
|
|
|
|
|
|
|
g_clear_pointer (&priv->displays, g_hash_table_unref);
|
|
|
|
g_clear_pointer (&priv->images, g_hash_table_unref);
|
|
|
|
g_clear_pointer (&priv->items, g_hash_table_unref);
|
|
|
|
g_clear_pointer (&priv->resources, g_hash_table_unref);
|
2019-08-23 23:18:17 +08:00
|
|
|
}
|