changeset 1011:616b14da08c2

do not access image_loader directly
author nadvornik
date Fri, 29 Aug 2008 12:35:13 +0000
parents 82fe98d2cfdb
children fe82830ab8fd
files src/fullscreen.c src/image-load.c src/image-load.h src/image-overlay.c src/print.c src/search.c src/thumb.c src/thumb_standard.c
diffstat 8 files changed, 42 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/fullscreen.c	Fri Aug 29 09:59:20 2008 +0000
+++ b/src/fullscreen.c	Fri Aug 29 12:35:13 2008 +0000
@@ -19,6 +19,7 @@
 #include "ui_menu.h"
 #include "ui_misc.h"
 #include "window.h"
+#include "image-load.h"
 
 enum {
 	FULLSCREEN_CURSOR_HIDDEN = 1 << 0,
@@ -160,7 +161,7 @@
 	FullScreenData *fs = data;
 
 	if (fs->imd->il &&
-	    fs->imd->il->pixbuf != image_get_pixbuf(fs->imd))
+	    image_loader_get_pixbuf(fs->imd->il) != image_get_pixbuf(fs->imd))
 		{
 		fullscreen_mouse_set_busy_idle(fs);
 		}
--- a/src/image-load.c	Fri Aug 29 09:59:20 2008 +0000
+++ b/src/image-load.c	Fri Aug 29 12:35:13 2008 +0000
@@ -520,6 +520,23 @@
 	return il->done;
 }
 
+FileData *image_loader_get_fd(ImageLoader *il)
+{
+	if (!il) return NULL;
+
+	return il->fd;
+	
+}
+
+gint image_loader_get_shrunk(ImageLoader *il)
+{
+	if (!il) return FALSE;
+
+	return il->shrunk;
+	
+}
+
+
 gint image_load_dimensions(FileData *fd, gint *width, gint *height)
 {
 	ImageLoader *il;
--- a/src/image-load.h	Fri Aug 29 09:59:20 2008 +0000
+++ b/src/image-load.h	Fri Aug 29 12:35:13 2008 +0000
@@ -52,6 +52,8 @@
 gchar *image_loader_get_format(ImageLoader *il);
 gdouble image_loader_get_percent(ImageLoader *il);
 gint image_loader_get_is_done(ImageLoader *il);
+FileData *image_loader_get_fd(ImageLoader *il);
+gint image_loader_get_shrunk(ImageLoader *il);
 
 gint image_load_dimensions(FileData *fd, gint *width, gint *height);
 
--- a/src/image-overlay.c	Fri Aug 29 09:59:20 2008 +0000
+++ b/src/image-overlay.c	Fri Aug 29 12:35:13 2008 +0000
@@ -24,6 +24,7 @@
 #include "pixbuf-renderer.h"
 #include "pixbuf_util.h"
 #include "ui_fileops.h"
+#include "image-load.h"
 
 /*
  *----------------------------------------------------------------------------
@@ -523,14 +524,15 @@
 		if (!imd->unknown)
 			{
 			gint w, h;
+			GdkPixbuf *load_pixbuf = image_loader_get_pixbuf(imd->il);
 
 			if (imd->delay_flip &&
-			    imd->il && imd->il->pixbuf &&
-			    image_get_pixbuf(imd) != imd->il->pixbuf)
+			    imd->il && load_pixbuf &&
+			    image_get_pixbuf(imd) != load_pixbuf)
 				{
-				w = gdk_pixbuf_get_width(imd->il->pixbuf);
-				h = gdk_pixbuf_get_height(imd->il->pixbuf);
-				imgpixbuf = imd->il->pixbuf;
+				w = gdk_pixbuf_get_width(load_pixbuf);
+				h = gdk_pixbuf_get_height(load_pixbuf);
+				imgpixbuf = load_pixbuf;
 				}
 			else
 				{
@@ -558,7 +560,7 @@
 		text = g_markup_escape_text(_("Untitled"), -1);
 	}
 
-	with_hist = (imgpixbuf && (osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram && (!imd->il || imd->il->done));
+	with_hist = (imgpixbuf && (osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram && (!imd->il || image_loader_get_is_done(imd->il)));
 	
 	{
 		gint active_marks = 0;
@@ -892,7 +894,7 @@
 		image_osd_icons_hide(osd);
 		}
 
-	if (osd->imd->il && osd->imd->il->done)
+	if (osd->imd->il && image_loader_get_is_done(osd->imd->il))
 		osd->changed_states = IMAGE_STATE_NONE;
 	osd->idle_id = -1;
 	return FALSE;
--- a/src/print.c	Fri Aug 29 09:59:20 2008 +0000
+++ b/src/print.c	Fri Aug 29 12:35:13 2008 +0000
@@ -2033,7 +2033,7 @@
 	if (pw->text_fields == 0) return TRUE;
 
 	string = g_string_new("");
-	path = pw->job_loader->fd->path;
+	path = image_loader_get_fd(pw->job_loader)->path;
 
 	if (pw->text_fields & TEXT_INFO_FILENAME)
 		{
@@ -2062,7 +2062,7 @@
 		{
 		if (newline)  g_string_append(string, "\n");
 		if (space) g_string_append(string, " - ");
-		g_string_append(string, text_from_time(filetime(pw->job_loader->fd->path)));
+		g_string_append(string, text_from_time(filetime(image_loader_get_fd(pw->job_loader)->path)));
 		newline = proof;
 		space = !proof;
 		}
@@ -2072,7 +2072,7 @@
 
 		if (newline)  g_string_append(string, "\n");
 		if (space) g_string_append(string, " - ");
-		size = text_from_size_abrev(filesize(pw->job_loader->fd->path));
+		size = text_from_size_abrev(filesize(image_loader_get_fd(pw->job_loader)->path));
 		g_string_append(string, size);
 		g_free(size);
 		}
@@ -2153,7 +2153,7 @@
 		y = y + h + PRINT_TEXT_PADDING;
 
 		success = (success &&
-			   print_job_text_image(pw, pw->job_loader->fd->path, x, y, dw, sw, sh, FALSE));
+			   print_job_text_image(pw, image_loader_get_fd(pw->job_loader)->path, x, y, dw, sw, sh, FALSE));
 		}
 
 	image_loader_free(pw->job_loader);
@@ -2274,7 +2274,7 @@
 	y = y + icon_h + (pw->proof_height - icon_h) / 2 + PRINT_TEXT_PADDING;
 
 	success = (success &&
-		   print_job_text_image(pw, pw->job_loader->fd->path, x, y, icon_w + PRINT_PROOF_MARGIN * 2, w, h, TRUE));
+		   print_job_text_image(pw, image_loader_get_fd(pw->job_loader)->path, x, y, icon_w + PRINT_PROOF_MARGIN * 2, w, h, TRUE));
 
 	if (!success)
 		{
--- a/src/search.c	Fri Aug 29 09:59:20 2008 +0000
+++ b/src/search.c	Fri Aug 29 12:35:13 2008 +0000
@@ -1518,13 +1518,13 @@
 			}
 
 		if (options->thumbnails.enable_caching &&
-		    sd->img_loader && sd->img_loader->fd)
+		    sd->img_loader && image_loader_get_fd(sd->img_loader))
 			{
 			gchar *base;
 			const gchar *path;
 			mode_t mode = 0755;
 
-			path = sd->img_loader->fd->path;
+			path = image_loader_get_fd(sd->img_loader)->path;
 			base = cache_get_location(CACHE_TYPE_SIM, path, FALSE, &mode);
 			if (cache_ensure_dir_exists(base, mode))
 				{
@@ -1532,7 +1532,7 @@
 				cd->path = cache_get_location(CACHE_TYPE_SIM, path, TRUE, NULL);
 				if (cache_sim_data_save(cd))
 					{
-					filetime_set(cd->path, filetime(sd->img_loader->fd->path));
+					filetime_set(cd->path, filetime(image_loader_get_fd(sd->img_loader)->path));
 					}
 				}
 			g_free(base);
--- a/src/thumb.c	Fri Aug 29 09:59:20 2008 +0000
+++ b/src/thumb.c	Fri Aug 29 12:35:13 2008 +0000
@@ -214,7 +214,7 @@
 			tl->fd->thumb_pixbuf = pixbuf;
 			gdk_pixbuf_ref(tl->fd->thumb_pixbuf);
 			}
-		save = il->shrunk;
+		save = image_loader_get_shrunk(il);
 		}
 
 	if (rotated) gdk_pixbuf_unref(rotated);
--- a/src/thumb_standard.c	Fri Aug 29 09:59:20 2008 +0000
+++ b/src/thumb_standard.c	Fri Aug 29 12:35:13 2008 +0000
@@ -543,7 +543,7 @@
 	GdkPixbuf *pixbuf;
 
 	DEBUG_1("thumb image done: %s", tl->fd ? tl->fd->path : "???");
-	DEBUG_1("            from: %s", tl->il->path);
+	DEBUG_1("            from: %s", image_loader_get_fd(tl->il)->path);
 
 	pixbuf = image_loader_get_pixbuf(tl->il);
 	if (!pixbuf)
@@ -566,7 +566,7 @@
 	if (tl->fd)
 		{
 		if (tl->fd->thumb_pixbuf) g_object_unref(tl->fd->thumb_pixbuf);
-		tl->fd->thumb_pixbuf = thumb_loader_std_finish(tl, pixbuf, il->shrunk);
+		tl->fd->thumb_pixbuf = thumb_loader_std_finish(tl, pixbuf, image_loader_get_shrunk(il));
 		}
 
 	if (tl->func_done) tl->func_done(tl, tl->data);
@@ -584,7 +584,7 @@
 		}
 	
 	DEBUG_1("thumb image error: %s", tl->fd->path);
-	DEBUG_1("             from: %s", tl->il->fd->path);
+	DEBUG_1("             from: %s", image_loader_get_fd(tl->il)->path);
 
 	if (thumb_loader_std_next_source(tl, TRUE)) return;