Writing a callback for the preview
When the preview want the plug-in to render a new image it will call a
callback function in your plug-in. In most cases you should be able to
use the following:
static void
render_callback (GtkWidget * widget, GimpPreviewUpdateEvent * event,
gpointer data)
{
GimpPreview *preview = GIMP_PREVIEW (widget);
GimpDrawable *drawable = (GimpDrawable *) data;
GimpDrawable *dest_drawable;
GimpPreviewProgressUpdater preview_progress_updater;
/* Get a scratch drawable */
dest_drawable = gimp_preview_get_temp_drawable (drawable, event->image_x, event->image_y,
event->image_width, event->image_height);
/* Initialize the GimpPreviewProgressUpdater */
gimp_preview_progress_updater_init_for_preview (&preview_progress_updater, preview);
/* Render to the scratch drawable */
render (drawable, dest_drawable, event->image_x, event->image_y,
event->image_width, event->image_height,
&render_params,
&preview_progress_updater);
/* Draw the scratch drawable on the preview */
gimp_preview_draw_unscaled_drawable (preview, dest_drawable);
/* Delete the scratch drawable */
gimp_preview_free_temp_drawable (dest_drawable);
}