static gboolean gdk_pixbuf__svg_image_stop_load (gpointer data, GError **error) { SvgContext *context = (SvgContext *)data; GdkPixbuf *pixbuf; gboolean result = TRUE; if (error) *error = NULL; if (!context->handle) { rsvg_propegate_error (error, _("Error displaying image"), ERROR_DISPLAYING_IMAGE); return FALSE; } rsvg_handle_close (context->handle, error); pixbuf = rsvg_handle_get_pixbuf (context->handle); if (pixbuf != NULL) { emit_prepared (context, pixbuf); emit_updated (context, pixbuf); g_object_unref (pixbuf); } else { rsvg_propegate_error (error, _("Error displaying image"), ERROR_DISPLAYING_IMAGE); result = FALSE; } g_object_unref (context->handle); g_free (context); return result; }
static gboolean stop_load (GpBitmap *bitmap, GdipContext *context, GError **error) { guint n_frames = 1, i; GdkPixbufGdipAnim *animation = NULL; gdip_bitmap_get_n_frames (bitmap, &n_frames, TRUE); for (i = 0; i < n_frames; i++) { GdkPixbuf *pixbuf = NULL; GdkPixbufFrame *frame; guint frame_delay = 0; gdip_bitmap_select_frame (bitmap, i, TRUE); pixbuf = gdip_bitmap_to_pixbuf (bitmap, error); if (!pixbuf) { if (animation != NULL) g_object_unref (G_OBJECT (animation)); GdipDisposeImage ((GpImage *)bitmap); destroy_gdipcontext (context); return FALSE; } if (animation == NULL) { guint n_loops = 1; animation = g_object_new (GDK_TYPE_PIXBUF_GDIP_ANIM, NULL); gdip_bitmap_get_n_loops (bitmap, &n_loops); animation->loop = n_loops; } frame = g_new (GdkPixbufFrame, 1); frame->pixbuf = pixbuf; gdip_bitmap_get_frame_delay (bitmap, &frame_delay); animation->n_frames++; animation->frames = g_list_append (animation->frames, frame); animation->width = gdk_pixbuf_get_width (pixbuf); animation->height = gdk_pixbuf_get_height (pixbuf); /* GIF delay is in hundredths, we want thousandths */ frame->delay_time = frame_delay * 10; frame->elapsed = animation->total_time; /* Some GIFs apparently have delay time of 0, * that crashes everything so set it to "fast". * Also, timeouts less than 20 or so just lock up * the app or make the animation choppy, so fix them. */ if (frame->delay_time < 20) frame->delay_time = 20; /* 20 = "fast" */ animation->total_time += frame->delay_time; if (i == 0) emit_prepared (context, pixbuf, GDK_PIXBUF_ANIMATION (animation)); emit_updated (context, pixbuf); } if (animation != NULL) g_object_unref (G_OBJECT (animation)); GdipDisposeImage ((GpImage *)bitmap); destroy_gdipcontext (context); return TRUE; }