static void load_done (GnomeGdkPixbufAsyncHandle *handle, GnomeVFSResult result, GdkPixbuf *pixbuf) { (* handle->load_callback) (handle, result, pixbuf, handle->callback_data); free_pixbuf_load_handle (handle); }
void gnome_gdk_pixbuf_new_from_uri_cancel (GnomeGdkPixbufAsyncHandle *handle) { if (handle == NULL) { return; } if (handle->cancellable != NULL) { g_cancellable_cancel (handle->cancellable); } free_pixbuf_load_handle (handle); }
static void file_read_callback (GObject *source_object, GAsyncResult *res, gpointer user_data) { EelPixbufLoadHandle *handle; gssize bytes_read; GError *error; handle = user_data; if (g_cancellable_is_cancelled (handle->cancellable)) { free_pixbuf_load_handle (handle); return; } error = NULL; bytes_read = g_input_stream_read_finish (G_INPUT_STREAM (source_object), res, &error); if (bytes_read > 0) { if (!gdk_pixbuf_loader_write (handle->loader, handle->buffer, bytes_read, &error)) { bytes_read = -1; } else { g_input_stream_read_async (handle->stream, handle->buffer, sizeof (handle->buffer), 0, handle->cancellable, file_read_callback, handle); return; } } load_done (handle, error, bytes_read == 0); if (error != NULL) { g_error_free (error); } }
static void load_done (EelPixbufLoadHandle *handle, GError *error, gboolean get_pixbuf) { GdkPixbuf *pixbuf; if (handle->loader != NULL) { gdk_pixbuf_loader_close (handle->loader, NULL); } pixbuf = get_pixbuf ? gdk_pixbuf_loader_get_pixbuf (handle->loader) : NULL; handle->callback (error, pixbuf, handle->callback_data); free_pixbuf_load_handle (handle); }
static void file_opened_callback (GObject *source_object, GAsyncResult *res, gpointer user_data) { EelPixbufLoadHandle *handle; GFileInputStream *stream; GError *error; handle = user_data; if (g_cancellable_is_cancelled (handle->cancellable)) { free_pixbuf_load_handle (handle); return; } error = NULL; stream = g_file_read_finish (G_FILE (source_object), res, &error); if (stream == NULL) { load_done (handle, error, FALSE); g_error_free (error); return; } handle->stream = G_INPUT_STREAM (stream); handle->loader = gdk_pixbuf_loader_new (); g_input_stream_read_async (handle->stream, handle->buffer, sizeof (handle->buffer), 0, handle->cancellable, file_read_callback, handle); }