From a841e0fb06ca63b55bca40af63c4f803cb5f4037 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 1 Aug 2019 23:09:01 +0200 Subject: [PATCH] libgimp: add gimp_procedure_set_image_types() and remove the "image_types" parameter from gimp_procedure_set_strings(), which is only a bad hack copied from the core procedure class. --- libgimp/gimpprocedure.c | 52 +++++++++++++++++++++++++++++++-- libgimp/gimpprocedure.h | 6 ++-- plug-ins/common/goat-exercise.c | 6 ++-- plug-ins/help/help.c | 6 ++-- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c index dfb1dd588e..8179b9f4e1 100644 --- a/libgimp/gimpprocedure.c +++ b/libgimp/gimpprocedure.c @@ -169,6 +169,20 @@ gimp_procedure_finalize (GObject *object) * Creates a new procedure named @name which will call @run_func when * invoked. * + * 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). + * + * @proc_type should be %GIMP_PLUGIN for "normal" plug-ins. Using + * %GIMP_EXTENSION means that the plug-in will add temporary + * procedures. Therefore, the GIMP core will wait until the + * %GIMP_EXTENSION procedure has called gimp_extension_ack(), which + * means that the procedure has done its initialization, installed its + * temporary procedures and is ready to run. %GIMP_TEMPORARY must be + * used for temporary procedures that are created during a plug-ins + * lifetime. They must be added to the #GimpPlugIn using + * gimp_plug_in_add_temp_procedure(). + * * Returns: a new #GimpProcedure. **/ GimpProcedure * @@ -222,8 +236,7 @@ gimp_procedure_set_strings (GimpProcedure *procedure, const gchar *help_id, const gchar *author, const gchar *copyright, - const gchar *date, - const gchar *image_types) + const gchar *date) { g_return_if_fail (GIMP_IS_PROCEDURE (procedure)); @@ -236,7 +249,6 @@ gimp_procedure_set_strings (GimpProcedure *procedure, procedure->priv->author = g_strdup (author); procedure->priv->copyright = g_strdup (copyright); procedure->priv->date = g_strdup (date); - procedure->priv->image_types = g_strdup (image_types); } const gchar * @@ -303,6 +315,40 @@ gimp_procedure_get_date (GimpProcedure *procedure) return procedure->priv->date; } +/** + * gimp_procedure_set_image_types: + * @image_types the image types this procedure can operate on. + * + * 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) +{ + g_return_if_fail (GIMP_IS_PROCEDURE (procedure)); + + g_free (procedure->priv->image_types); + procedure->priv->image_types = g_strdup (image_types); +} + +/** + * gimp_procedure_get_image_types: + * + * This procedure retrieves the list of image types the procedure can + * operate on. See gimp_procedure_set_image_types(). + * + * Returns: The image types. + * + * Since: 3.0 + **/ const gchar * gimp_procedure_get_image_types (GimpProcedure *procedure) { diff --git a/libgimp/gimpprocedure.h b/libgimp/gimpprocedure.h index 44d4af0450..9f4a7f1620 100644 --- a/libgimp/gimpprocedure.h +++ b/libgimp/gimpprocedure.h @@ -79,8 +79,7 @@ void gimp_procedure_set_strings (GimpProcedure *procedure const gchar *help_id, const gchar *author, const gchar *copyright, - const gchar *date, - const gchar *image_types); + const gchar *date); const gchar * gimp_procedure_get_name (GimpProcedure *procedure); const gchar * gimp_procedure_get_menu_label (GimpProcedure *procedure); @@ -90,6 +89,9 @@ const gchar * gimp_procedure_get_help_id (GimpProcedure *procedure const gchar * gimp_procedure_get_author (GimpProcedure *procedure); const gchar * gimp_procedure_get_copyright (GimpProcedure *procedure); const gchar * gimp_procedure_get_date (GimpProcedure *procedure); + +void gimp_procedure_set_image_types (GimpProcedure *procedure, + const gchar *image_types); const gchar * gimp_procedure_get_image_types (GimpProcedure *procedure); void gimp_procedure_set_icon (GimpProcedure *procedure, diff --git a/plug-ins/common/goat-exercise.c b/plug-ins/common/goat-exercise.c index b61b737f33..92195b5b12 100644 --- a/plug-ins/common/goat-exercise.c +++ b/plug-ins/common/goat-exercise.c @@ -110,8 +110,10 @@ goat_create_procedure (GimpPlugIn *plug_in, PLUG_IN_PROC, "Øyvind Kolås ", "Øyvind Kolås ", - "21march 2012", - "RGB*, INDEXED*, GRAY*"); + "21march 2012"); + + gimp_procedure_set_image_types (procedure, + "RGB*, INDEXED*, GRAY*"); gimp_procedure_add_menu_path (procedure, "/Filters"); gimp_procedure_set_icon (procedure, GIMP_ICON_TYPE_ICON_NAME, diff --git a/plug-ins/help/help.c b/plug-ins/help/help.c index 167a659574..7e4b366c55 100644 --- a/plug-ins/help/help.c +++ b/plug-ins/help/help.c @@ -144,8 +144,7 @@ help_create_procedure (GimpPlugIn *plug_in, "Michael Natterer , " "Henrik Brix Andersen ", "Sven Neumann, Michael Natterer & Henrik Brix Andersen", - "1999-2008", - ""); + "1999-2008"); gimp_procedure_add_argument (procedure, gimp_param_spec_int32 ("num-domain-names", @@ -241,8 +240,7 @@ help_temp_proc_install (GimpPlugIn *plug_in) "Michael Natterer " "Henrik Brix Andersen