GimpValueArray * procedure_commands_get_item_args (GimpProcedure *procedure, GimpImage *image, GimpItem *item) { GimpValueArray *args; gint n_args = 0; args = gimp_procedure_get_arguments (procedure); /* initialize the first argument */ g_value_set_int (gimp_value_array_index (args, n_args), GIMP_RUN_INTERACTIVE); n_args++; if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[n_args])) { if (image) { gimp_value_set_image (gimp_value_array_index (args, n_args), image); n_args++; if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_ITEM_ID (procedure->args[n_args])) { if (item && g_type_is_a (G_TYPE_FROM_INSTANCE (item), GIMP_PARAM_SPEC_ITEM_ID (procedure->args[n_args])->item_type)) { gimp_value_set_item (gimp_value_array_index (args, n_args), item); n_args++; } else { g_warning ("Uh-oh, no active item for the plug-in!"); gimp_value_array_unref (args); return NULL; } } } } gimp_value_array_truncate (args, n_args); return args; }
static gint plug_in_collect_item_args (GtkAction *action, GimpImage *image, GimpItem *item, GParamSpec **pspecs, GimpValueArray *args, gint n_args) { if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_IMAGE_ID (pspecs[n_args])) { if (image) { gimp_value_set_image (gimp_value_array_index (args, n_args), image); n_args++; if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_ITEM_ID (pspecs[n_args])) { if (item && g_type_is_a (G_TYPE_FROM_INSTANCE (item), GIMP_PARAM_SPEC_ITEM_ID (pspecs[n_args])->item_type)) { gimp_value_set_item (gimp_value_array_index (args, n_args), item); n_args++; } else { g_warning ("Uh-oh, no active item for the plug-in!"); return -1; } } } } return n_args; }