diff --git a/app/pdb/Makefile.am b/app/pdb/Makefile.am index eb86f143a5..dbbf1adbcd 100644 --- a/app/pdb/Makefile.am +++ b/app/pdb/Makefile.am @@ -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 \ diff --git a/app/pdb/gimp-cmds.c b/app/pdb/gimp-cmds.c index ce91ab17cc..8dda7d741f 100644 --- a/app/pdb/gimp-cmds.c +++ b/app/pdb/gimp-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); } diff --git a/app/pdb/gimp-pdb-compat.c b/app/pdb/gimp-pdb-compat.c index c0f5db7ce0..8a99b89304 100644 --- a/app/pdb/gimp-pdb-compat.c +++ b/app/pdb/gimp-pdb-compat.c @@ -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)); diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c index 4f2713cb9b..a16da7549f 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -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); diff --git a/app/pdb/internal-procs.h b/app/pdb/internal-procs.h index a8b3a27e66..95c4b1e75c 100644 --- a/app/pdb/internal-procs.h +++ b/app/pdb/internal-procs.h @@ -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); diff --git a/app/pdb/parasite-cmds.c b/app/pdb/parasite-cmds.c deleted file mode 100644 index 4c7f44c7b1..0000000000 --- a/app/pdb/parasite-cmds.c +++ /dev/null @@ -1,241 +0,0 @@ -/* 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 . - */ - -/* NOTE: This file is auto-generated by pdbgen.pl. */ - -#include "config.h" - -#include - -#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); -} diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am index a2abe6c3e1..659ecf0d7a 100644 --- a/libgimp/Makefile.am +++ b/libgimp/Makefile.am @@ -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 \ diff --git a/libgimp/gimp.c b/libgimp/gimp.c index b0fbb4b90c..ac2682ba45 100644 --- a/libgimp/gimp.c +++ b/libgimp/gimp.c @@ -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. diff --git a/libgimp/gimp.h b/libgimp/gimp.h index 407f4a31be..c6bb484281 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -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 */ diff --git a/libgimp/gimp_pdb.c b/libgimp/gimp_pdb.c index 9ade3676f2..7d89eb0abf 100644 --- a/libgimp/gimp_pdb.c +++ b/libgimp/gimp_pdb.c @@ -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; +} diff --git a/libgimp/gimp_pdb.h b/libgimp/gimp_pdb.h index 6b71a87151..b45eacd35a 100644 --- a/libgimp/gimp_pdb.h +++ b/libgimp/gimp_pdb.h @@ -28,8 +28,12 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gchar* gimp_version (void); -gint gimp_getpid (void); +gchar* gimp_version (void); +gint gimp_getpid (void); +gboolean gimp_attach_parasite (const GimpParasite *parasite); +gboolean gimp_detach_parasite (const gchar *name); +GimpParasite* gimp_get_parasite (const gchar *name); +gchar** gimp_get_parasite_list (gint *num_parasites); G_END_DECLS diff --git a/libgimp/gimp_pdb_headers.h b/libgimp/gimp_pdb_headers.h index a747d21989..62c3dc0945 100644 --- a/libgimp/gimp_pdb_headers.h +++ b/libgimp/gimp_pdb_headers.h @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include diff --git a/libgimp/gimpparasite_pdb.c b/libgimp/gimpparasite_pdb.c deleted file mode 100644 index 26359c6aac..0000000000 --- a/libgimp/gimpparasite_pdb.c +++ /dev/null @@ -1,166 +0,0 @@ -/* LIBGIMP - The GIMP Library - * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball - * - * gimpparasite_pdb.c - * - * This library is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -/* NOTE: This file is auto-generated by pdbgen.pl */ - -#include "config.h" - -#include "gimp.h" - - -/** - * SECTION: gimpparasite - * @title: gimpparasite - * @short_description: Operations related to parasites. - * - * Operations related to parasites. - **/ - - -/** - * gimp_parasite_find: - * @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. - **/ -GimpParasite * -gimp_parasite_find (const gchar *name) -{ - GimpParam *return_vals; - gint nreturn_vals; - GimpParasite *parasite = NULL; - - return_vals = gimp_run_procedure ("gimp-parasite-find", - &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_parasite_attach: - * @parasite: The parasite to attach. - * - * Add a global parasite. - * - * This procedure attaches a global parasite. It has no return values. - * - * Returns: TRUE on success. - **/ -gboolean -gimp_parasite_attach (const GimpParasite *parasite) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp-parasite-attach", - &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_parasite_detach: - * @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. - **/ -gboolean -gimp_parasite_detach (const gchar *name) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp-parasite-detach", - &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_parasite_list: - * @num_parasites: The number of attached parasites. - * @parasites: The names of currently attached parasites. - * - * List all parasites. - * - * Returns a list of all currently attached global parasites. - * - * Returns: TRUE on success. - **/ -gboolean -gimp_parasite_list (gint *num_parasites, - gchar ***parasites) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - gint i; - - return_vals = gimp_run_procedure ("gimp-parasite-list", - &nreturn_vals, - GIMP_PDB_END); - - *num_parasites = 0; - *parasites = NULL; - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - if (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 success; -} diff --git a/libgimp/gimpparasite_pdb.h b/libgimp/gimpparasite_pdb.h deleted file mode 100644 index 5dfe3c43dc..0000000000 --- a/libgimp/gimpparasite_pdb.h +++ /dev/null @@ -1,40 +0,0 @@ -/* LIBGIMP - The GIMP Library - * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball - * - * gimpparasite_pdb.h - * - * This library is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -/* NOTE: This file is auto-generated by pdbgen.pl */ - -#ifndef __GIMP_PARASITE_PDB_H__ -#define __GIMP_PARASITE_PDB_H__ - -G_BEGIN_DECLS - -/* For information look into the C source or the html documentation */ - - -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); - - -G_END_DECLS - -#endif /* __GIMP_PARASITE_PDB_H__ */ diff --git a/plug-ins/common/file-dicom.c b/plug-ins/common/file-dicom.c index de437898e5..82d0975e42 100644 --- a/plug-ins/common/file-dicom.c +++ b/plug-ins/common/file-dicom.c @@ -549,7 +549,7 @@ load_image (const gchar *filename, GimpParasite *parasite; gchar pname[255]; - /* all elements are retrievable using gimp_parasite_list() */ + /* all elements are retrievable using gimp_get_parasite_list() */ g_snprintf (pname, sizeof (pname), "dcm/%04x-%04x-%s", group_word, element_word, value_rep); if ((parasite = gimp_parasite_new (pname, diff --git a/plug-ins/common/file-png.c b/plug-ins/common/file-png.c index 44320ddf8a..e9a4ed8c82 100644 --- a/plug-ins/common/file-png.c +++ b/plug-ins/common/file-png.c @@ -1912,7 +1912,7 @@ load_defaults (void) { GimpParasite *parasite; - parasite = gimp_parasite_find (PNG_DEFAULTS_PARASITE); + parasite = gimp_get_parasite (PNG_DEFAULTS_PARASITE); if (parasite) { @@ -1969,7 +1969,7 @@ save_defaults (void) GIMP_PARASITE_PERSISTENT, strlen (def_str), def_str); - gimp_parasite_attach (parasite); + gimp_attach_parasite (parasite); gimp_parasite_free (parasite); g_free (def_str); diff --git a/plug-ins/file-jpeg/jpeg-exif.c b/plug-ins/file-jpeg/jpeg-exif.c index a5473867a7..28058586de 100644 --- a/plug-ins/file-jpeg/jpeg-exif.c +++ b/plug-ins/file-jpeg/jpeg-exif.c @@ -253,7 +253,7 @@ jpeg_exif_rotate_query (gint32 image_ID, if (orientation < 2 || orientation > 8) return; - parasite = gimp_parasite_find (JPEG_EXIF_ROTATE_PARASITE); + parasite = gimp_get_parasite (JPEG_EXIF_ROTATE_PARASITE); if (parasite) { @@ -388,7 +388,7 @@ jpeg_exif_rotate_query_dialog (gint32 image_ID) parasite = gimp_parasite_new (JPEG_EXIF_ROTATE_PARASITE, GIMP_PARASITE_PERSISTENT, strlen (str), str); - gimp_parasite_attach (parasite); + gimp_attach_parasite (parasite); gimp_parasite_free (parasite); } diff --git a/plug-ins/file-jpeg/jpeg-save.c b/plug-ins/file-jpeg/jpeg-save.c index a56a08a5bd..f68aa978ff 100644 --- a/plug-ins/file-jpeg/jpeg-save.c +++ b/plug-ins/file-jpeg/jpeg-save.c @@ -1266,7 +1266,7 @@ load_save_defaults (void) jsvals.save_thumbnail = TRUE; #endif /* HAVE_EXIF */ - parasite = gimp_parasite_find (JPEG_DEFAULTS_PARASITE); + parasite = gimp_get_parasite (JPEG_DEFAULTS_PARASITE); if (! parasite) return; @@ -1321,7 +1321,7 @@ save_defaults (void) GIMP_PARASITE_PERSISTENT, strlen (def_str), def_str); - gimp_parasite_attach (parasite); + gimp_attach_parasite (parasite); gimp_parasite_free (parasite); g_free (def_str); diff --git a/plug-ins/pygimp/gimpmodule.c b/plug-ins/pygimp/gimpmodule.c index 4a41b99282..7fe283dd93 100644 --- a/plug-ins/pygimp/gimpmodule.c +++ b/plug-ins/pygimp/gimpmodule.c @@ -1239,7 +1239,7 @@ pygimp_parasite_find(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s:parasite_find", &name)) return NULL; - return pygimp_parasite_new(gimp_parasite_find(name)); + return pygimp_parasite_new(gimp_get_parasite(name)); } static PyObject * @@ -1251,7 +1251,7 @@ pygimp_parasite_attach(PyObject *self, PyObject *args) &PyGimpParasite_Type, ¶site)) return NULL; - if (!gimp_parasite_attach(parasite->para)) { + if (!gimp_attach_parasite(parasite->para)) { PyErr_Format(pygimp_error, "could not attach parasite '%s'", gimp_parasite_name(parasite->para)); return NULL; @@ -1274,7 +1274,7 @@ pygimp_attach_new_parasite(PyObject *self, PyObject *args) parasite = gimp_parasite_new (name, flags, size, data); - if (!gimp_parasite_attach (parasite)) { + if (!gimp_attach_parasite (parasite)) { PyErr_Format(pygimp_error, "could not attach new parasite '%s'", name); gimp_parasite_free (parasite); return NULL; @@ -1294,7 +1294,7 @@ pygimp_parasite_detach(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s:parasite_detach", &name)) return NULL; - if (!gimp_parasite_detach(name)) { + if (!gimp_detach_parasite(name)) { PyErr_Format(pygimp_error, "could not detach parasite '%s'", name); return NULL; } @@ -1309,7 +1309,9 @@ pygimp_parasite_list(PyObject *self) gint num_parasites; gchar **parasites; - if (gimp_parasite_list(&num_parasites, ¶sites)) { + parasites = gimp_get_parasite_list (&num_parasites); + + if (parasites) { PyObject *ret; gint i; diff --git a/tools/pdbgen/Makefile.am b/tools/pdbgen/Makefile.am index a921fc65c6..a324813c13 100644 --- a/tools/pdbgen/Makefile.am +++ b/tools/pdbgen/Makefile.am @@ -36,7 +36,6 @@ pdb_sources = \ pdb/palette.pdb \ pdb/palette_select.pdb \ pdb/palettes.pdb \ - pdb/parasite.pdb \ pdb/paths.pdb \ pdb/pattern.pdb \ pdb/pattern_select.pdb \ diff --git a/tools/pdbgen/groups.pl b/tools/pdbgen/groups.pl index 692dae72bb..4681c3d235 100644 --- a/tools/pdbgen/groups.pl +++ b/tools/pdbgen/groups.pl @@ -34,7 +34,6 @@ palette palette_select palettes - parasite paths pattern pattern_select diff --git a/tools/pdbgen/pdb/gimp.pdb b/tools/pdbgen/pdb/gimp.pdb index 3ab8f53904..7e985c72d8 100644 --- a/tools/pdbgen/pdb/gimp.pdb +++ b/tools/pdbgen/pdb/gimp.pdb @@ -89,14 +89,116 @@ CODE ); } +sub attach_parasite { + $blurb = 'Add a global parasite.'; -@headers = qw("core/gimp.h"); + $help = <<'HELP'; +This procedure attaches a global parasite. It has no return values. +HELP + + &jay_pdb_misc('1998', '2.8'); + + @inargs = ( + { name => 'parasite', type => 'parasite', + desc => 'The parasite to attach' } + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_parasite_attach (gimp, parasite); +} +CODE + ); +} + +sub detach_parasite { + $blurb = 'Removes a global parasite.'; + + $help = <<'HELP'; +This procedure detaches a global parasite from. It has no return values. +HELP + + &jay_pdb_misc('1998', '2.8'); + + @inargs = ( + { name => 'name', type => 'string', + desc => 'The name of the parasite to detach.' } + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_parasite_detach (gimp, name); +} +CODE + ); +} + +sub get_parasite { + $blurb = 'Look up a global parasite.'; + + $help = <<'HELP'; +Finds and returns the global parasite that was previously attached. +HELP + + &jay_pdb_misc('1998', '2.8'); + + @inargs = ( + { name => 'name', type => 'string', + desc => 'The name of the parasite to find' } + ); + + @outargs = ( + { name => 'parasite', type => 'parasite', + desc => 'The found parasite' } + ); + + %invoke = ( + code => <<'CODE' +{ + parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name)); + + if (! parasite) + success = FALSE; +} +CODE + ); +} + +sub get_parasite_list { + $blurb = 'List all parasites.'; + $help = 'Returns a list of all currently attached global parasites.'; + + &marc_pdb_misc('1999', '2.8'); + + @outargs = ( + { name => 'parasites', type => 'stringarray', + desc => 'The names of currently attached parasites', + array => { desc => 'The number of attached parasites' } } + ); + + %invoke = ( + code => <<'CODE' +{ + parasites = gimp_parasite_list (gimp, &num_parasites); +} +CODE + ); +} + + +@headers = qw("core/gimp.h" + "core/gimp-parasites.h"); @procs = qw(version getpid - quit); + quit + attach_parasite detach_parasite + get_parasite + get_parasite_list); -%exports = (app => [@procs], lib => [@procs[0..1]]); +%exports = (app => [@procs], lib => [@procs[0..1,3..6]]); $desc = 'Miscellaneous'; $doc_title = 'gimp'; diff --git a/tools/pdbgen/pdb/parasite.pdb b/tools/pdbgen/pdb/parasite.pdb deleted file mode 100644 index b9f11fbb10..0000000000 --- a/tools/pdbgen/pdb/parasite.pdb +++ /dev/null @@ -1,130 +0,0 @@ -# GIMP - The GNU Image Manipulation Program -# Copyright (C) 1998 Jay Cox - -# 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 . - -# "Perlized" from C source by Manish Singh - -sub parasite_find { - $blurb = 'Look up a global parasite.'; - - $help = <<'HELP'; -Finds and returns the global parasite that was previously attached. -HELP - - &jay_pdb_misc('1998'); - - @inargs = ( - { name => 'name', type => 'string', - desc => 'The name of the parasite to find' } - ); - - @outargs = ( - { name => 'parasite', type => 'parasite', - desc => 'The found parasite' } - ); - - %invoke = ( - code => <<'CODE' -{ - parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name)); - - if (! parasite) - success = FALSE; -} -CODE - ); -} - -sub parasite_attach { - $blurb = 'Add a global parasite.'; - - $help = <<'HELP'; -This procedure attaches a global parasite. It has no return values. -HELP - - &jay_pdb_misc('1998'); - - @inargs = ( - { name => 'parasite', type => 'parasite', - desc => 'The parasite to attach' } - ); - - %invoke = ( - code => <<'CODE' -{ - gimp_parasite_attach (gimp, parasite); -} -CODE - ); -} - -sub parasite_detach { - $blurb = 'Removes a global parasite.'; - - $help = <<'HELP'; -This procedure detaches a global parasite from. It has no return values. -HELP - - &jay_pdb_misc('1998'); - - @inargs = ( - { name => 'name', type => 'string', - desc => 'The name of the parasite to detach.' } - ); - - %invoke = ( - code => <<'CODE' -{ - gimp_parasite_detach (gimp, name); -} -CODE - ); -} - -sub parasite_list { - $blurb = 'List all parasites.'; - $help = 'Returns a list of all currently attached global parasites.'; - - &marc_pdb_misc('1999'); - - @outargs = ( - { name => 'parasites', type => 'stringarray', void_ret => 1, - desc => 'The names of currently attached parasites', - array => { desc => 'The number of attached parasites' } } - ); - - %invoke = ( - code => <<'CODE' -{ - parasites = gimp_parasite_list (gimp, &num_parasites); -} -CODE - ); -} - -@headers = qw("core/gimp-parasites.h"); - -@procs = qw(parasite_find - parasite_attach parasite_detach - parasite_list); - -%exports = (app => [@procs], lib => [@procs]); - -$desc = 'Parasite procedures'; -$doc_title = 'gimpparasite'; -$doc_short_desc = 'Operations related to parasites.'; -$doc_long_desc = 'Operations related to parasites.'; - -1;