static gint plug_in_collect_display_args (GtkAction *action, GimpDisplay *display, GParamSpec **pspecs, GimpValueArray *args, gint n_args) { if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_DISPLAY_ID (pspecs[n_args])) { if (display) { gimp_value_set_display (gimp_value_array_index (args, n_args), GIMP_OBJECT (display)); n_args++; } else { g_warning ("Uh-oh, no active display for the plug-in!"); return -1; } } if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_IMAGE_ID (pspecs[n_args])) { GimpImage *image = display ? gimp_display_get_image (display) : NULL; 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_DRAWABLE_ID (pspecs[n_args])) { GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (drawable) { gimp_value_set_drawable (gimp_value_array_index (args, n_args), drawable); n_args++; } else { g_warning ("Uh-oh, no active drawable for the plug-in!"); return -1; } } } } return n_args; }
GimpValueArray * procedure_commands_get_display_args (GimpProcedure *procedure, GimpDisplay *display) { 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_DISPLAY_ID (procedure->args[n_args])) { if (display) { gimp_value_set_display (gimp_value_array_index (args, n_args), GIMP_OBJECT (display)); n_args++; } else { g_warning ("Uh-oh, no active display for the plug-in!"); gimp_value_array_unref (args); return NULL; } } if (gimp_value_array_length (args) > n_args && GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[n_args])) { GimpImage *image = display ? gimp_display_get_image (display) : NULL; 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_DRAWABLE_ID (procedure->args[n_args])) { GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (drawable) { gimp_value_set_drawable (gimp_value_array_index (args, n_args), drawable); n_args++; } else { g_warning ("Uh-oh, no active drawable for the plug-in!"); gimp_value_array_unref (args); return NULL; } } } } gimp_value_array_truncate (args, n_args); return args; }