Commit bb6436cb authored by Michael Natterer's avatar Michael Natterer 😴

libgimp: deprecate and rename the global pararasite functions

just as it was done for items and images. Remove the "parasite" PDB
group completely.
parent db6f3dfe
......@@ -69,7 +69,6 @@ libappinternal_procs_a_SOURCES = \
palette-cmds.c \
palette-select-cmds.c \
palettes-cmds.c \
parasite-cmds.c \
paths-cmds.c \
pattern-cmds.c \
pattern-select-cmds.c \
......
......@@ -26,6 +26,7 @@
#include "pdb-types.h"
#include "base/base-utils.h"
#include "core/gimp-parasites.h"
#include "core/gimp.h"
#include "core/gimpparamspecs.h"
......@@ -94,6 +95,104 @@ quit_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
attach_parasite_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
const GimpParasite *parasite;
parasite = g_value_get_boxed (&args->values[0]);
if (success)
{
gimp_parasite_attach (gimp, parasite);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
detach_parasite_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *name;
name = g_value_get_string (&args->values[0]);
if (success)
{
gimp_parasite_detach (gimp, name);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
get_parasite_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
const gchar *name;
GimpParasite *parasite = NULL;
name = g_value_get_string (&args->values[0]);
if (success)
{
parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name));
if (! parasite)
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_boxed (&return_vals->values[1], parasite);
return return_vals;
}
static GValueArray *
get_parasite_list_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 num_parasites = 0;
gchar **parasites = NULL;
parasites = gimp_parasite_list (gimp, &num_parasites);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (&return_vals->values[1], num_parasites);
gimp_value_take_stringarray (&return_vals->values[2], parasites, num_parasites);
return return_vals;
}
void
register_gimp_procs (GimpPDB *pdb)
{
......@@ -168,4 +267,107 @@ register_gimp_procs (GimpPDB *pdb)
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-attach-parasite
*/
procedure = gimp_procedure_new (attach_parasite_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-attach-parasite");
gimp_procedure_set_static_strings (procedure,
"gimp-attach-parasite",
"Add a global parasite.",
"This procedure attaches a global parasite. It has no return values.",
"Jay Cox",
"Jay Cox",
"1998",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_parasite ("parasite",
"parasite",
"The parasite to attach",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-detach-parasite
*/
procedure = gimp_procedure_new (detach_parasite_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-detach-parasite");
gimp_procedure_set_static_strings (procedure,
"gimp-detach-parasite",
"Removes a global parasite.",
"This procedure detaches a global parasite from. It has no return values.",
"Jay Cox",
"Jay Cox",
"1998",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The name of the parasite to detach.",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-get-parasite
*/
procedure = gimp_procedure_new (get_parasite_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-get-parasite");
gimp_procedure_set_static_strings (procedure,
"gimp-get-parasite",
"Look up a global parasite.",
"Finds and returns the global parasite that was previously attached.",
"Jay Cox",
"Jay Cox",
"1998",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The name of the parasite to find",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_parasite ("parasite",
"parasite",
"The found parasite",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-get-parasite-list
*/
procedure = gimp_procedure_new (get_parasite_list_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-get-parasite-list");
gimp_procedure_set_static_strings (procedure,
"gimp-get-parasite-list",
"List all parasites.",
"Returns a list of all currently attached global parasites.",
"Marc Lehmann",
"Marc Lehmann",
"1999",
NULL);
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("num-parasites",
"num parasites",
"The number of attached parasites",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_string_array ("parasites",
"parasites",
"The names of currently attached parasites",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}
......@@ -475,7 +475,11 @@ gimp_pdb_compat_procs_register (GimpPDB *pdb,
{ "gimp-image-parasite-find", "gimp-image-get-parasite" },
{ "gimp-image-parasite-attach", "gimp-image-attach-parasite" },
{ "gimp-image-parasite-detach", "gimp-image-detach-parasite" },
{ "gimp-image-parasite-list", "gimp-image-get-parasite-list" }
{ "gimp-image-parasite-list", "gimp-image-get-parasite-list" },
{ "gimp-parasite-find", "gimp-get-parasite" },
{ "gimp-parasite-attach", "gimp-attach-parasite" },
{ "gimp-parasite-detach", "gimp-detach-parasite" },
{ "gimp-parasite-list", "gimp-get-parasite-list" }
};
g_return_if_fail (GIMP_IS_PDB (pdb));
......
......@@ -69,7 +69,6 @@ internal_procs_init (GimpPDB *pdb)
register_palette_procs (pdb);
register_palette_select_procs (pdb);
register_palettes_procs (pdb);
register_parasite_procs (pdb);
register_paths_procs (pdb);
register_pattern_procs (pdb);
register_pattern_select_procs (pdb);
......
......@@ -58,7 +58,6 @@ void register_paint_tools_procs (GimpPDB *pdb);
void register_palette_procs (GimpPDB *pdb);
void register_palette_select_procs (GimpPDB *pdb);
void register_palettes_procs (GimpPDB *pdb);
void register_parasite_procs (GimpPDB *pdb);
void register_paths_procs (GimpPDB *pdb);
void register_pattern_procs (GimpPDB *pdb);
void register_pattern_select_procs (GimpPDB *pdb);
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl. */
#include "config.h"
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "pdb-types.h"
#include "core/gimp-parasites.h"
#include "core/gimpparamspecs.h"
#include "gimppdb.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
static GValueArray *
parasite_find_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
const gchar *name;
GimpParasite *parasite = NULL;
name = g_value_get_string (&args->values[0]);
if (success)
{
parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name));
if (! parasite)
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_boxed (&return_vals->values[1], parasite);
return return_vals;
}
static GValueArray *
parasite_attach_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
const GimpParasite *parasite;
parasite = g_value_get_boxed (&args->values[0]);
if (success)
{
gimp_parasite_attach (gimp, parasite);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
parasite_detach_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *name;
name = g_value_get_string (&args->values[0]);
if (success)
{
gimp_parasite_detach (gimp, name);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
parasite_list_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 num_parasites = 0;
gchar **parasites = NULL;
parasites = gimp_parasite_list (gimp, &num_parasites);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (&return_vals->values[1], num_parasites);
gimp_value_take_stringarray (&return_vals->values[2], parasites, num_parasites);
return return_vals;
}
void
register_parasite_procs (GimpPDB *pdb)
{
GimpProcedure *procedure;
/*
* gimp-parasite-find
*/
procedure = gimp_procedure_new (parasite_find_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-parasite-find");
gimp_procedure_set_static_strings (procedure,
"gimp-parasite-find",
"Look up a global parasite.",
"Finds and returns the global parasite that was previously attached.",
"Jay Cox",
"Jay Cox",
"1998",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The name of the parasite to find",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_parasite ("parasite",
"parasite",
"The found parasite",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-parasite-attach
*/
procedure = gimp_procedure_new (parasite_attach_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-parasite-attach");
gimp_procedure_set_static_strings (procedure,
"gimp-parasite-attach",
"Add a global parasite.",
"This procedure attaches a global parasite. It has no return values.",
"Jay Cox",
"Jay Cox",
"1998",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_parasite ("parasite",
"parasite",
"The parasite to attach",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-parasite-detach
*/
procedure = gimp_procedure_new (parasite_detach_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-parasite-detach");
gimp_procedure_set_static_strings (procedure,
"gimp-parasite-detach",
"Removes a global parasite.",
"This procedure detaches a global parasite from. It has no return values.",
"Jay Cox",
"Jay Cox",
"1998",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The name of the parasite to detach.",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-parasite-list
*/
procedure = gimp_procedure_new (parasite_list_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-parasite-list");
gimp_procedure_set_static_strings (procedure,
"gimp-parasite-list",
"List all parasites.",
"Returns a list of all currently attached global parasites.",
"Marc Lehmann",
"Marc Lehmann",
"1999",
NULL);
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("num-parasites",
"num parasites",
"The number of attached parasites",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_string_array ("parasites",
"parasites",
"The names of currently attached parasites",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}
......@@ -102,7 +102,6 @@ PDB_WRAPPERS_C = \
gimppalette_pdb.c \
gimppalettes_pdb.c \
gimppaletteselect_pdb.c \
gimpparasite_pdb.c \
gimppaths_pdb.c \
gimppattern_pdb.c \
gimppatterns_pdb.c \
......@@ -155,7 +154,6 @@ PDB_WRAPPERS_H = \
gimppalette_pdb.h \
gimppalettes_pdb.h \
gimppaletteselect_pdb.h \
gimpparasite_pdb.h \
gimppaths_pdb.h \
gimppattern_pdb.h \
gimppatterns_pdb.h \
......
......@@ -1504,6 +1504,66 @@ gimp_extension_process (guint timeout)
#endif
}
/**
* gimp_parasite_find:
* @name: The name of the parasite to find.
*
* Deprecated: Use gimp_get_parasite() instead.
*
* Returns: The found parasite.
**/
GimpParasite *
gimp_parasite_find (const gchar *name)
{
return gimp_get_parasite (name);
}
/**
* gimp_parasite_attach:
* @parasite: The parasite to attach.
*
* Deprecated: Use gimp_attach_parasite() instead.
*
* Returns: TRUE on success.
**/
gboolean
gimp_parasite_attach (const GimpParasite *parasite)
{
return gimp_attach_parasite (parasite);
}
/**
* gimp_parasite_detach:
* @name: The name of the parasite to detach.
*
* Deprecated: Use gimp_detach_parasite() instead.
*
* Returns: TRUE on success.
**/
gboolean
gimp_parasite_detach (const gchar *name)
{
return gimp_parasite_detach (name);
}
/**
* gimp_parasite_list:
* @num_parasites: The number of attached parasites.
* @parasites: The names of currently attached parasites.
*
* Deprecated: Use gimp_get_parasite_list() instead.
*
* Returns: TRUE on success.
**/
gboolean
gimp_parasite_list (gint *num_parasites,
gchar ***parasites)
{
*parasites = gimp_get_parasite_list (num_parasites);
return *parasites != NULL;
}
/**
* gimp_attach_new_parasite:
* @name: the name of the #GimpParasite to create and attach.
......
......@@ -333,10 +333,15 @@ const gchar * gimp_get_progname (void) G_GNUC_CONST;
gboolean gimp_install_cmap (void) G_GNUC_CONST;
gint gimp_min_colors (void) G_GNUC_CONST;
gboolean gimp_attach_new_parasite (const gchar *name,
gint flags,
gint size,
gconstpointer data);
GimpParasite * gimp_parasite_find (const gchar *name);
gboolean gimp_parasite_attach (const GimpParasite *parasite);
gboolean gimp_parasite_detach (const gchar *name);
gboolean gimp_parasite_list (gint *num_parasites,
gchar ***parasites);
gboolean gimp_attach_new_parasite (const gchar *name,
gint flags,
gint size,
gconstpointer data);
#endif /* GIMP_DISABLE_DEPRECATED */
......
......@@ -92,3 +92,137 @@ gimp_getpid (void)
return pid;
}
/**
* gimp_attach_parasite:
* @parasite: The parasite to attach.
*
* Add a global parasite.
*
* This procedure attaches a global parasite. It has no return values.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_attach_parasite (const GimpParasite *parasite)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-attach-parasite",
&nreturn_vals,
GIMP_PDB_PARASITE, parasite,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_detach_parasite:
* @name: The name of the parasite to detach.
*
* Removes a global parasite.
*
* This procedure detaches a global parasite from. It has no return
* values.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_detach_parasite (const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-detach-parasite",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_get_parasite:
* @name: The name of the parasite to find.
*
* Look up a global parasite.
*
* Finds and returns the global parasite that was previously attached.
*
* Returns: The found parasite.
*
* Since: GIMP 2.8
**/
GimpParasite *
gimp_get_parasite (const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpParasite *parasite = NULL;
return_vals = gimp_run_procedure ("gimp-get-parasite",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
parasite = gimp_parasite_copy (&return_vals[1].data.d_parasite);
gimp_destroy_params (return_vals, nreturn_vals);
return parasite;
}
/**
* gimp_get_parasite_list:
* @num_parasites: The number of attached parasites.
*
* List all parasites.
*
* Returns a list of all currently attached global parasites.
*
* Returns: The names of currently attached parasites.
*
* Since: GIMP 2.8
**/
gchar **
gimp_get_parasite_list (gint *num_parasites)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar **parasites = NULL;
gint i;
return_vals = gimp_run_procedure ("gimp-get-parasite-list",
&nreturn_vals,
GIMP_PDB_END);
*num_parasites = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_parasites = return_vals[1].data.d_int32;
parasites = g_new (gchar *, *num_parasites);
for (i = 0; i < *num_parasites; i++)
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
}
gimp_destroy_params (return_vals, nreturn_vals);
return parasites;
}
......@@ -28,8 +28,12 @@ G_BEGIN_DECLS