Fix up event source ids type: gint -> guint.
[geeqie.git] / src / image-load.h
1 /*
2  * Geeqie
3  * (C) 2004 John Ellis
4  * Copyright (C) 2008 - 2009 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         gsize bytes_read;
32         gsize bytes_total;
33
34         gboolean preview;
35
36         gint requested_width;
37         gint requested_height;
38         gboolean shrunk;
39
40         gboolean done;
41         guint idle_id; /* event source id */
42         gint idle_priority;
43
44         GdkPixbufLoader *loader;
45         GError *error;
46
47         guint idle_done_id; /* event source id */
48         GList *area_param_list;
49         GList *area_param_delayed_list;
50         
51         gboolean delay_area_ready;
52         
53         GMutex *data_mutex;
54         gboolean stopping;
55         gboolean can_destroy;
56         GCond *can_destroy_cond;
57         gboolean thread;
58
59         guchar *mapped_file;
60         gsize read_buffer_size;
61         gint idle_read_loop_count;
62 };
63
64 struct _ImageLoaderClass {
65         GObjectClass parent;
66         
67         /* class members */
68         void (*area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
69         void (*error)(ImageLoader *, gpointer);
70         void (*done)(ImageLoader *, gpointer);
71         void (*percent)(ImageLoader *, gdouble, gpointer);
72 };
73
74 GType image_loader_get_type(void);
75
76 ImageLoader *image_loader_new(FileData *fd);
77
78 void image_loader_free(ImageLoader *il);
79
80 /* delay area_ready signals */
81 void image_loader_delay_area_ready(ImageLoader *il, gboolean enable);
82
83 /* Speed up loading when you only need at most width x height size image,
84  * only the jpeg GdkPixbuf loader benefits from it - so there is no
85  * guarantee that the image will scale down to the requested size..
86  */
87 void image_loader_set_requested_size(ImageLoader *il, gint width, gint height);
88
89 void image_loader_set_buffer_size(ImageLoader *il, guint size);
90
91 /* this only has effect if used before image_loader_start()
92  * default is G_PRIORITY_DEFAULT_IDLE
93  */
94 void image_loader_set_priority(ImageLoader *il, gint priority);
95
96 gboolean image_loader_start(ImageLoader *il);
97
98
99 GdkPixbuf *image_loader_get_pixbuf(ImageLoader *il);
100 gchar *image_loader_get_format(ImageLoader *il);
101 gdouble image_loader_get_percent(ImageLoader *il);
102 gboolean image_loader_get_is_done(ImageLoader *il);
103 FileData *image_loader_get_fd(ImageLoader *il);
104 gboolean image_loader_get_shrunk(ImageLoader *il);
105 const gchar *image_loader_get_error(ImageLoader *il);
106
107 gboolean image_load_dimensions(FileData *fd, gint *width, gint *height);
108
109 #endif
110 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */