do not access image_loader directly
authorVladimir Nadvornik <nadvornik@suse.cz>
Fri, 29 Aug 2008 12:35:13 +0000 (12:35 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Fri, 29 Aug 2008 12:35:13 +0000 (12:35 +0000)
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

index d84a5d2..bbb76de 100644 (file)
@@ -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 @@ static void fullscreen_image_update_cb(ImageWindow *imd, gpointer data)
        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);
                }
index 3154fec..80ec311 100644 (file)
@@ -520,6 +520,23 @@ gint image_loader_get_is_done(ImageLoader *il)
        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;
index effdcbd..12e4520 100644 (file)
@@ -52,6 +52,8 @@ GdkPixbuf *image_loader_get_pixbuf(ImageLoader *il);
 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);
 
index 1280b44..c7b9188 100644 (file)
@@ -24,6 +24,7 @@
 #include "pixbuf-renderer.h"
 #include "pixbuf_util.h"
 #include "ui_fileops.h"
+#include "image-load.h"
 
 /*
  *----------------------------------------------------------------------------
@@ -523,14 +524,15 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
                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 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
                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 @@ static gint image_osd_update_cb(gpointer data)
                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;
index 2e3e4f4..7dff2c1 100644 (file)
@@ -2033,7 +2033,7 @@ static gint print_job_text_image(PrintWindow *pw, const gchar *path,
        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 @@ static gint print_job_text_image(PrintWindow *pw, const gchar *path,
                {
                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 @@ static gint print_job_text_image(PrintWindow *pw, const gchar *path,
 
                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 @@ static void print_job_render_image_loader_done(ImageLoader *il, gpointer data)
                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 @@ static void print_job_render_proof_loader_done(ImageLoader *il, gpointer data)
        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)
                {
index 38862d9..6ce3841 100644 (file)
@@ -1518,13 +1518,13 @@ static void search_file_load_process(SearchData *sd, CacheData *cd)
                        }
 
                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 @@ static void search_file_load_process(SearchData *sd, CacheData *cd)
                                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);
index 778d415..e72e876 100644 (file)
@@ -214,7 +214,7 @@ static void thumb_loader_done_cb(ImageLoader *il, gpointer data)
                        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);
index c6ab9ab..298e4cb 100644 (file)
@@ -543,7 +543,7 @@ static void thumb_loader_std_done_cb(ImageLoader *il, gpointer data)
        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 @@ static void thumb_loader_std_done_cb(ImageLoader *il, gpointer data)
        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 @@ static void thumb_loader_std_error_cb(ImageLoader *il, gpointer data)
                }
        
        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;