mirror of https://github.com/GNOME/gimp.git
app, libgimp, libgimpconfig, extensions: image procedures now with…
… drawable array instead of a single drawable. Instead of expecting a single drawable, GimpImageProcedure's run() function will now have an array of drawable as parameter. As a consequence, all existing plug-ins are broken again. I am going to fix them in the next commit so that this change can be easily reviewed and examined if needed later. I only fix the Vala demo plug-in now (or rather, I just use the first layer in the array for now) because otherwise the build fails.
This commit is contained in:
parent
dc7853233b
commit
353c73457a
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpparamspecs.h"
|
||||
#include "core/gimpprogress.h"
|
||||
|
||||
|
@ -243,27 +244,61 @@ procedure_commands_get_display_args (GimpProcedure *procedure,
|
|||
|
||||
if (image)
|
||||
{
|
||||
GList *drawables_list = gimp_image_get_selected_drawables (image);
|
||||
|
||||
g_value_set_object (gimp_value_array_index (args, n_args), image);
|
||||
n_args++;
|
||||
|
||||
if (gimp_value_array_length (args) > n_args &&
|
||||
GIMP_IS_PARAM_SPEC_DRAWABLE (procedure->args[n_args]))
|
||||
{
|
||||
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||
|
||||
if (drawable)
|
||||
if (drawables_list)
|
||||
{
|
||||
g_warning ("%s: plug-in procedures expecting a single drawable are deprecated!",
|
||||
G_STRFUNC);
|
||||
g_value_set_object (gimp_value_array_index (args, n_args),
|
||||
drawable);
|
||||
drawables_list->data);
|
||||
n_args++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Uh-oh, no active drawable for the plug-in!");
|
||||
|
||||
gimp_value_array_unref (args);
|
||||
g_list_free (drawables_list);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (gimp_value_array_length (args) > n_args + 1 &&
|
||||
G_IS_PARAM_SPEC_INT (procedure->args[n_args]) &&
|
||||
GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (procedure->args[n_args + 1]))
|
||||
{
|
||||
GimpDrawable **drawables = NULL;
|
||||
gint n_drawables;
|
||||
|
||||
n_drawables = g_list_length (drawables_list);
|
||||
|
||||
g_value_set_int (gimp_value_array_index (args, n_args++),
|
||||
n_drawables);
|
||||
|
||||
if (drawables_list)
|
||||
{
|
||||
GList *iter;
|
||||
gint i;
|
||||
|
||||
drawables = g_new (GimpDrawable *, n_drawables);
|
||||
for (iter = drawables_list, i = 0; iter; iter = iter->next, i++)
|
||||
drawables[i] = iter->data;
|
||||
}
|
||||
|
||||
gimp_value_set_object_array (gimp_value_array_index (args, n_args++),
|
||||
GIMP_TYPE_DRAWABLE,
|
||||
(GObject **) drawables, n_drawables);
|
||||
|
||||
g_free (drawables);
|
||||
}
|
||||
g_list_free (drawables_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,10 @@ public class Goat : Gimp.PlugIn {
|
|||
public Gimp.ValueArray run(Gimp.Procedure procedure,
|
||||
Gimp.RunMode run_mode,
|
||||
Gimp.Image image,
|
||||
Gimp.Drawable drawable,
|
||||
Gimp.Drawable[] drawables,
|
||||
Gimp.ValueArray args) {
|
||||
var drawable = drawables[0];
|
||||
|
||||
if (run_mode == Gimp.RunMode.INTERACTIVE) {
|
||||
GimpUi.init(PLUG_IN_BINARY);
|
||||
|
||||
|
|
|
@ -90,11 +90,17 @@ gimp_image_procedure_constructed (GObject *object)
|
|||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_DRAWABLE (procedure, "drawable",
|
||||
"Drawable",
|
||||
"The input drawable",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE);
|
||||
GIMP_PROC_ARG_INT (procedure, "num-drawables",
|
||||
"Number of drawables",
|
||||
"Number of input drawables",
|
||||
0, G_MAXINT, 1,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_OBJECT_ARRAY (procedure, "drawables",
|
||||
"Drawables",
|
||||
"The input drawables",
|
||||
GIMP_TYPE_DRAWABLE,
|
||||
G_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -119,12 +125,14 @@ gimp_image_procedure_run (GimpProcedure *procedure,
|
|||
GimpValueArray *return_values;
|
||||
GimpRunMode run_mode;
|
||||
GimpImage *image;
|
||||
GimpDrawable *drawable;
|
||||
GimpDrawable **drawables;
|
||||
gint n_drawables;
|
||||
gint i;
|
||||
|
||||
run_mode = GIMP_VALUES_GET_ENUM (args, 0);
|
||||
image = GIMP_VALUES_GET_IMAGE (args, 1);
|
||||
drawable = GIMP_VALUES_GET_DRAWABLE (args, 2);
|
||||
run_mode = GIMP_VALUES_GET_ENUM (args, 0);
|
||||
image = GIMP_VALUES_GET_IMAGE (args, 1);
|
||||
n_drawables = GIMP_VALUES_GET_INT (args, 2);
|
||||
drawables = GIMP_VALUES_GET_OBJECT_ARRAY (args, 3);
|
||||
|
||||
remaining = gimp_value_array_new (gimp_value_array_length (args) - ARG_OFFSET);
|
||||
|
||||
|
@ -137,7 +145,7 @@ gimp_image_procedure_run (GimpProcedure *procedure,
|
|||
|
||||
return_values = image_proc->priv->run_func (procedure,
|
||||
run_mode,
|
||||
image, drawable,
|
||||
image, n_drawables, drawables,
|
||||
remaining,
|
||||
image_proc->priv->run_data);
|
||||
|
||||
|
|
|
@ -31,11 +31,12 @@ G_BEGIN_DECLS
|
|||
|
||||
/**
|
||||
* GimpRunImageFunc:
|
||||
* @procedure: the #GimpProcedure that runs.
|
||||
* @run_mode: the #GimpRunMode.
|
||||
* @image: the #GimpImage.
|
||||
* @drawable: the #GimpDrawable.
|
||||
* @args: the @procedure's remaining arguments.
|
||||
* @procedure: the #GimpProcedure that runs.
|
||||
* @run_mode: the #GimpRunMode.
|
||||
* @image: the #GimpImage.
|
||||
* @n_drawables: the number of #GimpDrawable-s.
|
||||
* @drawables: (array length=n_drawables): the input #GimpDrawable-s.
|
||||
* @args: the @procedure's remaining arguments.
|
||||
* @run_data: (closure): the run_data given in gimp_image_procedure_new().
|
||||
*
|
||||
* The image function is run during the lifetime of the GIMP session,
|
||||
|
@ -45,12 +46,13 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
typedef GimpValueArray * (* GimpRunImageFunc) (GimpProcedure *procedure,
|
||||
GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GimpDrawable *drawable,
|
||||
const GimpValueArray *args,
|
||||
gpointer run_data);
|
||||
typedef GimpValueArray * (* GimpRunImageFunc) (GimpProcedure *procedure,
|
||||
GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
gint n_drawables,
|
||||
GimpDrawable **drawables,
|
||||
const GimpValueArray *args,
|
||||
gpointer run_data);
|
||||
|
||||
|
||||
#define GIMP_TYPE_IMAGE_PROCEDURE (gimp_image_procedure_get_type ())
|
||||
|
|
|
@ -141,8 +141,9 @@ gimp_config_class_init (GObjectClass *klass,
|
|||
{
|
||||
g_object_class_install_property (klass, i + 1, copy);
|
||||
}
|
||||
else if (! G_IS_PARAM_SPEC_OBJECT (pspec) &&
|
||||
! G_IS_PARAM_SPEC_POINTER (pspec))
|
||||
else if (! G_IS_PARAM_SPEC_OBJECT (pspec) &&
|
||||
! G_IS_PARAM_SPEC_POINTER (pspec) &&
|
||||
! GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (pspec))
|
||||
{
|
||||
/* silently ignore object properties */
|
||||
|
||||
|
|
Loading…
Reference in New Issue