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

plug-ins: port film and guillotine to objects arrays

parent c59eaa5e
......@@ -61,7 +61,7 @@ typedef struct
gint number_pos[2]; /* flags where to draw numbers (top/bottom) */
gint keep_height; /* flag if to keep max. image height */
gint num_images; /* number of images */
GList *images; /* list of image IDs */
GList *images; /* list of images */
} FilmVals;
/* Data to use for the dialog */
......@@ -285,10 +285,11 @@ film_create_procedure (GimpPlugIn *plug_in,
1, MAX_FILM_PICTURES, 1,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT32_ARRAY (procedure, "image-ids",
"Image IDs",
"num-images image IDs to be used for film",
G_PARAM_READWRITE);
GIMP_PROC_ARG_OBJECT_ARRAY (procedure, "images",
"Images",
"num-images images to be used for film",
GIMP_TYPE_IMAGE,
G_PARAM_READWRITE);
GIMP_PROC_VAL_IMAGE (procedure, "new-image",
"New image",
......@@ -308,10 +309,10 @@ film_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data)
{
GimpValueArray *return_vals = NULL;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
const gint32 *ids;
gint i;
GimpValueArray *return_vals = NULL;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpImage **images;
gint i;
INIT_I18N ();
gegl_init (NULL, NULL);
......@@ -340,21 +341,19 @@ film_run (GimpProcedure *procedure,
filmvals.keep_height = FALSE;
}
GIMP_VALUES_GET_RGB (args, 1, &filmvals.film_color);
filmvals.number_start = GIMP_VALUES_GET_INT (args, 2);
g_strlcpy (filmvals.number_font,
GIMP_VALUES_GET_STRING (args, 3),
FONT_LEN);
filmvals.number_start = GIMP_VALUES_GET_INT (args, 2);
g_strlcpy (filmvals.number_font,
GIMP_VALUES_GET_STRING (args, 3),
FONT_LEN);
GIMP_VALUES_GET_RGB (args, 4, &filmvals.number_color);
filmvals.number_pos[0] = GIMP_VALUES_GET_INT (args, 5);
filmvals.number_pos[1] = GIMP_VALUES_GET_INT (args, 6);
filmvals.number_pos[0] = GIMP_VALUES_GET_INT (args, 5);
filmvals.number_pos[1] = GIMP_VALUES_GET_INT (args, 6);
filmvals.num_images = GIMP_VALUES_GET_INT (args, 7);
images = GIMP_VALUES_GET_OBJECT_ARRAY (args, 8);
filmvals.num_images = GIMP_VALUES_GET_INT (args, 7);
ids = GIMP_VALUES_GET_INT32_ARRAY (args, 8);
filmvals.images = NULL;
for (i = 0; i < filmvals.num_images; i++)
filmvals.images = g_list_prepend (filmvals.images,
gimp_image_get_by_id (ids[i]));
filmvals.images = g_list_prepend (filmvals.images, images[i]);
filmvals.images = g_list_reverse (filmvals.images);
break;
......
......@@ -124,10 +124,11 @@ guillotine_create_procedure (GimpPlugIn *plug_in,
0, G_MAXINT, 0,
G_PARAM_READWRITE);
GIMP_PROC_VAL_INT32_ARRAY (procedure, "image-ids",
"Output images IDs",
"Output images IDs",
G_PARAM_READWRITE);
GIMP_PROC_VAL_OBJECT_ARRAY (procedure, "images",
"Output images",
"Output images",
GIMP_TYPE_IMAGE,
G_PARAM_READWRITE);
}
return procedure;
......@@ -150,24 +151,30 @@ guillotine_run (GimpProcedure *procedure,
NULL);
if (status == GIMP_PDB_SUCCESS)
{
GList *images;
GList *list;
gint32 *ids;
gint i;
GList *image_list;
GList *list;
GimpImage **images;
gint num_images;
gint i;
gimp_progress_init (_("Guillotine"));
images = guillotine (image, run_mode == GIMP_RUN_INTERACTIVE);
ids = g_new (gint32, g_list_length (images));
image_list = guillotine (image, run_mode == GIMP_RUN_INTERACTIVE);
for (list = images, i = 0; list; list = g_list_next (list), i++)
num_images = g_list_length (image_list);
images = g_new (GimpImage *, num_images);
for (list = image_list, i = 0;
list;
list = g_list_next (list), i++)
{
ids[i] = gimp_image_get_id (list->data);
images[i] = g_object_ref (list->data);
}
g_list_free (images);
GIMP_VALUES_SET_INT (return_vals, 1, g_list_length (images));
GIMP_VALUES_TAKE_INT32_ARRAY (return_vals, 2, ids, g_list_length (images));
g_list_free (image_list);
GIMP_VALUES_SET_INT (return_vals, 1, num_images);
GIMP_VALUES_TAKE_OBJECT_ARRAY (return_vals, 2, GIMP_TYPE_IMAGE, images, num_images);
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_displays_flush ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment