use GThreadPool
[geeqie.git] / src / image-load.h
1 /*
2  * Geeqie
3  * (C) 2004 John Ellis
4  * Copyright (C) 2008 The Geeqie Team
5  *
6  * Author: John Ellis
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13
14 #ifndef IMAGE_LOAD_H
15 #define IMAGE_LOAD_H
16
17 #define TYPE_IMAGE_LOADER               (image_loader_get_type())
18
19 //typedef struct _ImageLoader ImageLoader;
20 typedef struct _ImageLoaderClass ImageLoaderClass;
21
22 struct _ImageLoader
23 {
24         GObject parent;
25         
26         /*< private >*/
27         GdkPixbuf *pixbuf;
28         FileData *fd;
29         gchar *path;
30
31         gint bytes_read;
32         gint bytes_total;
33
34         gint preview;
35
36         gint requested_width;
37         gint requested_height;
38         gint shrunk;
39
40         gint done;
41         gint idle_id;
42         gint idle_priority;
43
44         GdkPixbufLoader *loader;
45
46         gint idle_done_id;
47         GList *area_param_list;
48         
49         GMutex *data_mutex;
50         gint stopping;
51         gint can_destroy;
52         GCond *can_destroy_cond;
53         gboolean thread;
54
55         guchar *mapped_file;
56         gint read_buffer_size;
57         gint idle_read_loop_count;
58 };
59
60 struct _ImageLoaderClass {
61         GObjectClass parent;
62         
63         /* class members */
64         void (*area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
65         void (*error)(ImageLoader *, gpointer);
66         void (*done)(ImageLoader *, gpointer);
67         void (*percent)(ImageLoader *, gdouble, gpointer);
68 };
69
70 GType image_loader_get_type(void);
71
72 ImageLoader *image_loader_new(FileData *fd);
73
74 void image_loader_free(ImageLoader *il);
75
76
77 /* Speed up loading when you only need at most width x height size image,
78  * only the jpeg GdkPixbuf loader benefits from it - so there is no
79  * guarantee that the image will scale down to the requested size..
80  */
81 void image_loader_set_requested_size(ImageLoader *il, gint width, gint height);
82
83 void image_loader_set_buffer_size(ImageLoader *il, guint size);
84
85 /* this only has effect if used before image_loader_start()
86  * default is G_PRIORITY_DEFAULT_IDLE
87  */
88 void image_loader_set_priority(ImageLoader *il, gint priority);
89
90 gint image_loader_start(ImageLoader *il);
91
92
93 GdkPixbuf *image_loader_get_pixbuf(ImageLoader *il);
94 gchar *image_loader_get_format(ImageLoader *il);
95 gdouble image_loader_get_percent(ImageLoader *il);
96 gint image_loader_get_is_done(ImageLoader *il);
97 FileData *image_loader_get_fd(ImageLoader *il);
98 gint image_loader_get_shrunk(ImageLoader *il);
99
100 gint image_load_dimensions(FileData *fd, gint *width, gint *height);
101
102 #endif