[gthumb] image loader: get the mime type from the input stream



commit ac805449d3308632f32cfad6b483af2722e5fc73
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Sep 4 18:27:28 2012 +0200

    image loader: get the mime type from the input stream
    
    instead of opening the file again

 gthumb/gth-image-loader.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/gthumb/gth-image-loader.c b/gthumb/gth-image-loader.c
index 6318ed9..c3a7c20 100644
--- a/gthumb/gth-image-loader.c
+++ b/gthumb/gth-image-loader.c
@@ -177,19 +177,22 @@ load_pixbuf_thread (GSimpleAsyncResult *result,
 						    &error);
 	}
 	else  {
-		GthImageLoaderFunc loader_func;
+		GthImageLoaderFunc  loader_func = NULL;
+		const char         *mime_type;
+
+		mime_type = _g_content_type_get_from_stream (istream, cancellable, NULL);
+		if (mime_type != NULL)
+			loader_func = gth_main_get_image_loader_func (mime_type, self->priv->preferred_format);
 
-		loader_func = gth_main_get_image_loader_func (gth_file_data_get_mime_type_from_content (load_data->file_data, cancellable),
-							      self->priv->preferred_format);
 		if (loader_func != NULL)
 			image = loader_func (istream,
-					     load_data->file_data,
-				             load_data->requested_size,
-				             &original_width,
-				             &original_height,
-				             NULL,
-				             cancellable,
-				             &error);
+					load_data->file_data,
+					load_data->requested_size,
+					&original_width,
+					&original_height,
+					NULL,
+					cancellable,
+					&error);
 		else
 			error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("No suitable loader available for this file type"));
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]