[nautilus] thumbnails: remove code unused for years
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] thumbnails: remove code unused for years
- Date: Mon, 4 Apr 2011 18:17:26 +0000 (UTC)
commit f9c6ca979f753339b91c125c363a927fceb64283
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Apr 4 14:06:41 2011 -0400
thumbnails: remove code unused for years
libnautilus-private/nautilus-thumbnails.c | 254 -----------------------------
1 files changed, 0 insertions(+), 254 deletions(-)
---
diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c
index faf9001..2f3d98b 100644
--- a/libnautilus-private/nautilus-thumbnails.c
+++ b/libnautilus-private/nautilus-thumbnails.c
@@ -336,260 +336,6 @@ nautilus_thumbnail_unframe_image (GdkPixbuf *pixbuf)
return pixbuf_without_frame;
}
-typedef struct {
- gboolean is_thumbnail;
- guint base_size;
- guint nominal_size;
- gboolean force_nominal;
- int original_height;
- int original_width;
- double *scale_x_out;
- double *scale_y_out;
-} ThumbnailLoadArgs;
-
-static void
-thumbnail_loader_size_prepared (GdkPixbufLoader *loader,
- int width,
- int height,
- ThumbnailLoadArgs *args)
-{
- int size = MAX (width, height);
- int thumbnail_icon_size;
-
- args->original_width = width;
- args->original_height = height;
-
- thumbnail_icon_size = g_settings_get_int (nautilus_icon_view_preferences,
- NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE);
-
- if (args->force_nominal) {
- args->base_size = size;
- } else if (args->base_size == 0) {
- if (args->is_thumbnail) {
- args->base_size = 128 * NAUTILUS_ICON_SIZE_STANDARD / thumbnail_icon_size;
- } else {
- if (size > args->nominal_size * thumbnail_icon_size / NAUTILUS_ICON_SIZE_STANDARD) {
- args->base_size = size * NAUTILUS_ICON_SIZE_STANDARD / thumbnail_icon_size;
- } else if (size > NAUTILUS_ICON_SIZE_STANDARD) {
- args->base_size = args->nominal_size;
- } else {
- /* Don't scale up small icons */
- args->base_size = NAUTILUS_ICON_SIZE_STANDARD;
- }
- }
- }
-
- if (args->base_size != args->nominal_size) {
- double scale;
-
- scale = (double) args->nominal_size / args->base_size;
-
- if ((int) (width * scale) > NAUTILUS_ICON_MAXIMUM_SIZE ||
- (int) (height * scale) > NAUTILUS_ICON_MAXIMUM_SIZE) {
- scale = MIN ((double) NAUTILUS_ICON_MAXIMUM_SIZE / width,
- (double) NAUTILUS_ICON_MAXIMUM_SIZE / height);
- }
-
- width = MAX (1, floor (width * scale + 0.5));
- height = MAX (1, floor (height * scale + 0.5));
-
- gdk_pixbuf_loader_set_size (loader, width, height);
- }
-
-}
-
-static void
-thumbnail_loader_area_prepared (GdkPixbufLoader *loader,
- ThumbnailLoadArgs *args)
-{
- GdkPixbuf *pixbuf;
-
- pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
-
- *args->scale_x_out = (double) gdk_pixbuf_get_width (pixbuf) / args->original_width;
- *args->scale_y_out = (double) gdk_pixbuf_get_height (pixbuf) / args->original_height;
-}
-
-static GdkPixbuf *
-get_pixbuf_from_data (const unsigned char *buffer,
- gsize buflen,
- const char *path,
- guint base_size,
- guint nominal_size,
- gboolean force_nominal,
- double *scale_x_out,
- double *scale_y_out)
-{
- GdkPixbufLoader *loader;
- GdkPixbuf *pixbuf;
- ThumbnailLoadArgs args;
- GError *error;
-
- loader = gdk_pixbuf_loader_new ();
- g_signal_connect (loader, "size-prepared",
- G_CALLBACK (thumbnail_loader_size_prepared),
- &args);
- g_signal_connect (loader, "area-prepared",
- G_CALLBACK (thumbnail_loader_area_prepared),
- &args);
-
- args.is_thumbnail = strstr (path, "/.thumbnails/") != NULL;
- args.base_size = base_size;
- args.nominal_size = nominal_size;
- args.force_nominal = force_nominal;
- args.scale_x_out = scale_x_out;
- args.scale_y_out = scale_y_out;
-
- error = NULL;
-
- if (!gdk_pixbuf_loader_write (loader, buffer, buflen, &error)) {
- g_message ("Failed to write %s to thumbnail pixbuf loader: %s", path, error->message);
-
- gdk_pixbuf_loader_close (loader, NULL);
- g_object_unref (G_OBJECT (loader));
- g_error_free (error);
-
- return NULL;
- }
-
- error = NULL;
-
- if (!gdk_pixbuf_loader_close (loader, &error) ||
- /* Seems we have to check this even if it returned TRUE (#403255) */
- error != NULL) {
- /* In some cases, we don't get an error even with FALSE returns (#538888) */
- if (error != NULL) {
- g_message ("Failed to close thumbnail pixbuf loader for %s: %s", path, error->message);
- } else {
- g_message ("Failed to close thumbnail pixbuf loader for %s", path);
- }
-
- g_object_unref (G_OBJECT (loader));
- g_error_free (error);
-
- return NULL;
- }
-
- pixbuf = g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader));
-
- g_object_unref (G_OBJECT (loader));
-
- return pixbuf;
-}
-
-
-/* routine to load an image from the passed-in path
- */
-GdkPixbuf *
-nautilus_thumbnail_load_image (const char *path,
- guint base_size,
- guint nominal_size,
- gboolean force_nominal,
- double *scale_x_out,
- double *scale_y_out)
-{
- GdkPixbuf *pixbuf;
- guchar *buffer;
- gsize buflen;
- GError *error;
-
- error = NULL;
-
- if (!g_file_get_contents (path, (gchar **) &buffer, &buflen, &error)) {
- g_message ("Failed to load %s into memory: %s", path, error->message);
-
- g_error_free (error);
-
- return NULL;
- }
-
- pixbuf = get_pixbuf_from_data (buffer, buflen, path,
- base_size, nominal_size, force_nominal,
- scale_x_out, scale_y_out);
-
- g_free (buffer);
-
- return pixbuf;
-}
-
-static void
-async_thumbnail_read_image (GObject *source_object,
- GAsyncResult *res,
- gpointer callback_data)
-{
- NautilusThumbnailAsyncLoadHandle *handle = callback_data;
- GdkPixbuf *pixbuf;
- double scale_x, scale_y;
- gsize file_size;
- char *file_contents;
-
- pixbuf = NULL;
- scale_x = scale_y = 1.0;
-
- if (g_file_load_contents_finish (G_FILE (source_object),
- res,
- &file_contents, &file_size,
- NULL, NULL)) {
- pixbuf = get_pixbuf_from_data (file_contents, file_size,
- handle->file_path,
- handle->base_size,
- handle->nominal_size,
- handle->force_nominal,
- &scale_x, &scale_y);
- g_free (file_contents);
- }
-
- handle->load_func (handle,
- handle->file_path,
- pixbuf, scale_x, scale_y,
- handle->load_func_user_data);
-
- g_object_unref (pixbuf);
-
- g_object_unref (handle->cancellable);
- g_free (handle->file_path);
- g_free (handle);
-}
-
-NautilusThumbnailAsyncLoadHandle *
-nautilus_thumbnail_load_image_async (const char *path,
- guint base_size,
- guint nominal_size,
- gboolean force_nominal,
- NautilusThumbnailAsyncLoadFunc load_func,
- gpointer load_func_user_data)
-{
- NautilusThumbnailAsyncLoadHandle *handle;
- GFile *location;
-
-
- handle = g_new (NautilusThumbnailAsyncLoadHandle, 1);
- handle->cancellable = g_cancellable_new ();
- handle->file_path = g_strdup (path);
- handle->base_size = base_size;
- handle->nominal_size = nominal_size;
- handle->force_nominal = force_nominal;
- handle->load_func = load_func;
- handle->load_func_user_data = load_func_user_data;
-
-
- location = g_file_new_for_path (path);
- g_file_load_contents_async (location, handle->cancellable,
- async_thumbnail_read_image,
- handle);
- g_object_unref (location);
-
- return handle;
-}
-
-void
-nautilus_thumbnail_load_image_cancel (NautilusThumbnailAsyncLoadHandle *handle)
-{
- g_assert (handle != NULL);
-
- g_cancellable_cancel (handle->cancellable);
-}
-
void
nautilus_thumbnail_remove_from_queue (const char *file_uri)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]