static GthImage * facebook_thumbnail_loader (GInputStream *istream, GthFileData *file_data, int requested_size, int *original_width, int *original_height, gboolean *loaded_original, gpointer user_data, GCancellable *cancellable, GError **error) { GthImage *image = NULL; FacebookPhoto *photo; const char *uri; photo = (FacebookPhoto *) g_file_info_get_attribute_object (file_data->info, "facebook::object"); uri = facebook_photo_get_thumbnail_url (photo, requested_size); if (uri == NULL) uri = facebook_photo_get_original_url (photo); if (uri != NULL) { GFile *file; void *buffer; gsize size; file = g_file_new_for_uri (uri); if (_g_file_load_in_buffer (file, &buffer, &size, cancellable, error)) { GInputStream *stream; GdkPixbuf *pixbuf; stream = g_memory_input_stream_new_from_data (buffer, size, g_free); pixbuf = gdk_pixbuf_new_from_stream (stream, cancellable, error); if (pixbuf != NULL) { GdkPixbuf *rotated; rotated = gdk_pixbuf_apply_embedded_orientation (pixbuf); g_object_unref (pixbuf); pixbuf = rotated; image = gth_image_new_for_pixbuf (pixbuf); } g_object_unref (pixbuf); g_object_unref (stream); } g_object_unref (file); } else *error = g_error_new_literal (GTH_ERROR, 0, "cannot generate the thumbnail"); return image; }
static GthImage * flickr_thumbnail_loader (GInputStream *istream, GthFileData *file_data, int requested_size, int *original_width, int *original_height, gboolean *loaded_original, gpointer user_data, GCancellable *cancellable, GError **error) { GthImage *image = NULL; GthThumbLoader *thumb_loader = user_data; FlickrPhoto *photo; const char *uri = NULL; photo = (FlickrPhoto *) g_file_info_get_attribute_object (file_data->info, "flickr::object"); requested_size = gth_thumb_loader_get_requested_size (thumb_loader); if (requested_size == FLICKR_SIZE_SMALL_SQUARE) uri = photo->url[FLICKR_URL_SQ]; else if (requested_size == FLICKR_SIZE_THUMBNAIL) uri = photo->url[FLICKR_URL_T]; else if (requested_size == FLICKR_SIZE_SMALL) uri = photo->url[FLICKR_URL_S]; else if (requested_size == FLICKR_SIZE_MEDIUM) uri = photo->url[FLICKR_URL_M]; if (uri == NULL) uri = photo->url[FLICKR_URL_O]; if (uri != NULL) { GFile *file; void *buffer; gsize size; file = g_file_new_for_uri (uri); if (_g_file_load_in_buffer (file, &buffer, &size, cancellable, error)) { GInputStream *stream; GdkPixbuf *pixbuf; stream = g_memory_input_stream_new_from_data (buffer, size, g_free); pixbuf = gdk_pixbuf_new_from_stream (stream, cancellable, error); if (pixbuf != NULL) { GdkPixbuf *rotated; rotated = gdk_pixbuf_apply_embedded_orientation (pixbuf); g_object_unref (pixbuf); pixbuf = rotated; image = gth_image_new_for_pixbuf (pixbuf); } g_object_unref (pixbuf); g_object_unref (stream); } g_object_unref (file); } else *error = g_error_new_literal (GTH_ERROR, 0, "cannot generate the thumbnail"); return image; }
static GthImage * picasa_web_thumbnail_loader (GInputStream *istream, GthFileData *file_data, int requested_size, int *original_width, int *original_height, gboolean *loaded_original, gpointer user_data, GCancellable *cancellable, GError **error) { GthImage *image = NULL; GthThumbLoader *thumb_loader = user_data; PicasaWebPhoto *photo; const char *uri; photo = (PicasaWebPhoto *) g_file_info_get_attribute_object (file_data->info, "gphoto::object"); requested_size = gth_thumb_loader_get_requested_size (thumb_loader); if (requested_size == 72) uri = photo->thumbnail_72; else if (requested_size == 144) uri = photo->thumbnail_144; else if (requested_size == 288) uri = photo->thumbnail_288; else uri = NULL; if (uri == NULL) uri = photo->uri; if (uri != NULL) { GFile *file; void *buffer; gsize size; file = g_file_new_for_uri (uri); if (_g_file_load_in_buffer (file, &buffer, &size, cancellable, error)) { GInputStream *stream; GdkPixbuf *pixbuf; stream = g_memory_input_stream_new_from_data (buffer, size, g_free); pixbuf = gdk_pixbuf_new_from_stream (stream, cancellable, error); if (pixbuf != NULL) { GdkPixbuf *rotated; rotated = gdk_pixbuf_apply_embedded_orientation (pixbuf); g_object_unref (pixbuf); pixbuf = rotated; image = gth_image_new_for_pixbuf (pixbuf); } g_object_unref (pixbuf); g_object_unref (stream); } g_object_unref (file); } else *error = g_error_new_literal (GTH_ERROR, 0, "cannot generate the thumbnail"); return image; }