gboolean caja_can_thumbnail (CajaFile *file) { MateDesktopThumbnailFactory *factory; gboolean res; char *uri; time_t mtime; char *mime_type; uri = caja_file_get_uri (file); mime_type = caja_file_get_mime_type (file); mtime = caja_file_get_mtime (file); factory = get_thumbnail_factory (); res = mate_desktop_thumbnail_factory_can_thumbnail (factory, uri, mime_type, mtime); g_free (mime_type); g_free (uri); return res; }
GdkPixbuf* eom_thumbnail_load (EomImage *image, GError **error) { GdkPixbuf *thumb = NULL; GFile *file; EomThumbData *data; GdkPixbuf *pixbuf; g_return_val_if_fail (image != NULL, NULL); g_return_val_if_fail (error != NULL && *error == NULL, NULL); file = eom_image_get_file (image); data = eom_thumb_data_new (file, error); g_object_unref (file); if (data == NULL) return NULL; if (!data->can_read || (data->failed_thumb_exists && mate_desktop_thumbnail_factory_has_valid_failed_thumbnail (factory, data->uri_str, data->mtime))) { eom_debug_message (DEBUG_THUMBNAIL, "%s: bad permissions or valid failed thumbnail present",data->uri_str); set_thumb_error (error, EOM_THUMB_ERROR_GENERIC, "Thumbnail creation failed"); return NULL; } /* check if there is already a valid cached thumbnail */ thumb = get_valid_thumbnail (data, error); if (thumb != NULL) { eom_debug_message (DEBUG_THUMBNAIL, "%s: loaded from cache",data->uri_str); } else if (mate_desktop_thumbnail_factory_can_thumbnail (factory, data->uri_str, data->mime_type, data->mtime)) { pixbuf = eom_image_get_pixbuf (image); if (pixbuf != NULL) { /* generate a thumbnail from the in-memory image, if we have already loaded the image */ eom_debug_message (DEBUG_THUMBNAIL, "%s: creating from pixbuf",data->uri_str); thumb = create_thumbnail_from_pixbuf (data, pixbuf, error); g_object_unref (pixbuf); } else { /* generate a thumbnail from the file */ eom_debug_message (DEBUG_THUMBNAIL, "%s: creating from file",data->uri_str); thumb = mate_desktop_thumbnail_factory_generate_thumbnail (factory, data->uri_str, data->mime_type); } if (thumb != NULL) { /* Save the new thumbnail */ mate_desktop_thumbnail_factory_save_thumbnail (factory, thumb, data->uri_str, data->mtime); eom_debug_message (DEBUG_THUMBNAIL, "%s: normal thumbnail saved",data->uri_str); } else { /* Save a failed thumbnail, to stop further thumbnail attempts */ mate_desktop_thumbnail_factory_create_failed_thumbnail (factory, data->uri_str, data->mtime); eom_debug_message (DEBUG_THUMBNAIL, "%s: failed thumbnail saved",data->uri_str); set_thumb_error (error, EOM_THUMB_ERROR_GENERIC, "Thumbnail creation failed"); } } eom_thumb_data_free (data); return thumb; }