[gthumb] Load images from fd->local_path, instead of a local cache
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] Load images from fd->local_path, instead of a local cache
- Date: Thu, 7 May 2009 15:16:23 -0400 (EDT)
commit 77666a79c53ceff93b58b2f8105c1c44ca405ee8
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Thu May 7 15:15:42 2009 -0400
Load images from fd->local_path, instead of a local cache
---
libgthumb/file-utils.c | 43 +++++++++++++++----------------------------
1 files changed, 15 insertions(+), 28 deletions(-)
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index f261ff0..0145c1b 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -2690,8 +2690,6 @@ get_pixbuf_using_external_converter (FileData *file,
int requested_width,
int requested_height)
{
- char *local_file;
- char *local_uri;
char *cache_file;
char *md5_file;
char *cache_file_full;
@@ -2703,12 +2701,10 @@ get_pixbuf_using_external_converter (FileData *file,
gboolean is_hdr;
gboolean is_thumbnail;
- local_file = get_cache_filename_from_uri (file->path);
- if (local_file == NULL)
+ if (! file_data_has_local_path (file, NULL))
return NULL;
is_thumbnail = requested_width > 0;
- local_uri = get_uri_from_local_path (local_file);
is_raw = mime_type_is_raw (file->mime_type);
is_hdr = mime_type_is_hdr (file->mime_type);
@@ -2716,7 +2712,7 @@ get_pixbuf_using_external_converter (FileData *file,
/* The output filename, and its persistence, depend on the input file
type, and whether or not a thumbnail has been requested. */
- md5_file = gnome_thumbnail_md5 (local_uri);
+ md5_file = gnome_thumbnail_md5 (file->local_path);
if (is_raw && !is_thumbnail)
/* Full-sized converted RAW file */
@@ -2738,14 +2734,12 @@ get_pixbuf_using_external_converter (FileData *file,
g_free (md5_file);
if (cache_file == NULL) {
- g_free (local_file);
- g_free (local_uri);
g_free (cache_file);
g_free (cache_file_esc);
return NULL;
}
- local_file_esc = g_shell_quote (local_file);
+ local_file_esc = g_shell_quote (file->local_path);
/* Do nothing if an up-to-date converted file is already in the cache */
if (! path_is_file (cache_file) || (file->mtime > get_file_mtime (cache_file))) {
@@ -2763,7 +2757,7 @@ get_pixbuf_using_external_converter (FileData *file,
g_spawn_command_line_sync (thumb_command, NULL, NULL, NULL, NULL);
g_free (thumb_command);
- first_part = remove_extension_from_path (local_file);
+ first_part = remove_extension_from_path (file->local_path);
jpg_thumbnail = g_strdup_printf ("%s.thumb.jpg", first_part);
tiff_thumbnail = g_strdup_printf ("%s.thumb.tiff", first_part);
ppm_thumbnail = g_strdup_printf ("%s.thumb.ppm", first_part);
@@ -2838,8 +2832,6 @@ get_pixbuf_using_external_converter (FileData *file,
g_free (cache_file);
g_free (cache_file_esc);
g_free (local_file_esc);
- g_free (local_file);
- g_free (local_uri);
return pixbuf;
}
@@ -2908,13 +2900,11 @@ gth_pixbuf_new_from_file (FileData *file,
{
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *rotated = NULL;
- char *local_file = NULL;
if (file == NULL)
return NULL;
- local_file = get_cache_filename_from_uri (file->path);
- if (local_file == NULL)
+ if (! file_data_has_local_path (file, NULL))
return NULL;
if (mime_type_is_video (file->mime_type)) {
@@ -2929,7 +2919,7 @@ gth_pixbuf_new_from_file (FileData *file,
if ((pixbuf == NULL)
&& mime_type_is_raw (file->mime_type)
&& (requested_width > 0))
- pixbuf = or_gdkpixbuf_extract_thumbnail (local_file, requested_width);
+ pixbuf = or_gdkpixbuf_extract_thumbnail (file->local_path, requested_width);
#endif
/* Use dcraw for raw images, pfstools for HDR images */
@@ -2944,7 +2934,7 @@ gth_pixbuf_new_from_file (FileData *file,
if ((pixbuf == NULL) && (requested_width > 0)) {
int w, h;
- if (gdk_pixbuf_get_file_info (local_file, &w, &h) == NULL) {
+ if (gdk_pixbuf_get_file_info (file->local_path, &w, &h) == NULL) {
w = -1;
h = -1;
}
@@ -2952,17 +2942,17 @@ gth_pixbuf_new_from_file (FileData *file,
/* scale the image only if the original size is larger than
* the requested size. */
if ((w > requested_width) || (h > requested_height))
- pixbuf = gdk_pixbuf_new_from_file_at_scale (local_file,
+ pixbuf = gdk_pixbuf_new_from_file_at_scale (file->local_path,
requested_width,
requested_height,
TRUE,
error);
else
- pixbuf = gdk_pixbuf_new_from_file (local_file, error);
+ pixbuf = gdk_pixbuf_new_from_file (file->local_path, error);
}
else if (pixbuf == NULL)
/* otherwise, no scaling required */
- pixbuf = gdk_pixbuf_new_from_file (local_file, error);
+ pixbuf = gdk_pixbuf_new_from_file (file->local_path, error);
/* Did any of the loaders work? */
if (pixbuf == NULL)
@@ -2970,7 +2960,7 @@ gth_pixbuf_new_from_file (FileData *file,
/* rotate pixbuf if required, based on exif orientation tag (jpeg only) */
- debug (DEBUG_INFO, "Check orientation tag of %s. Width %d\n\r", local_file, requested_width);
+ debug (DEBUG_INFO, "Check orientation tag of %s. Width %d\n\r", file->local_path, requested_width);
#if GDK_PIXBUF_CHECK_VERSION(2,11,5)
/* New in gtk 2.11.5 - see bug 439567 */
@@ -2996,7 +2986,6 @@ gth_pixbuf_new_from_file (FileData *file,
}
g_object_unref (pixbuf);
- g_free (local_file);
return rotated;
}
@@ -3015,13 +3004,11 @@ gth_pixbuf_animation_new_from_file (FileData *file,
if (file->mime_type == NULL)
return NULL;
- if (mime_type_is (file->mime_type, "image/gif")) {
- char *local_file;
-
- local_file = get_cache_filename_from_uri (file->path);
- animation = gdk_pixbuf_animation_new_from_file (local_file, error);
- g_free (local_file);
+ if (! file_data_has_local_path (file, NULL))
+ return NULL;
+ if (mime_type_is (file->mime_type, "image/gif")) {
+ animation = gdk_pixbuf_animation_new_from_file (file->local_path, error);
return animation;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]