Mercurial > geeqie.yaz
annotate src/image.c @ 414:49c1cbe058ae
partially fixed reading embedded color profiles with exiv2
author | nadvornik |
---|---|
date | Fri, 18 Apr 2008 22:31:58 +0000 |
parents | c4080362d619 |
children | 4f7362028062 |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
3 * (C) 2006 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
9 | 12 |
281 | 13 #include "main.h" |
1 | 14 #include "image.h" |
9 | 15 |
16 | |
17 #include "image-load.h" | |
18 #include "collect.h" | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
19 #include "color-man.h" |
9 | 20 #include "exif.h" |
284 | 21 #include "layout.h" |
22 #include "layout_image.h" | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
23 #include "pixbuf-renderer.h" |
9 | 24 #include "pixbuf_util.h" |
25 #include "ui_fileops.h" | |
26 | |
138 | 27 #include "filelist.h" |
28 | |
9 | 29 #include <math.h> |
30 | |
31 | |
32 /* size of the image loader buffer (512 bytes x defined number) */ | |
33 #define IMAGE_LOAD_BUFFER_COUNT 8 | |
34 | |
35 /* define this so that more bytes are read per idle loop on larger images (> 1MB) */ | |
36 #define IMAGE_THROTTLE_LARGER_IMAGES 1 | |
37 | |
38 /* throttle factor to increase read bytes by (2 is double, 3 is triple, etc.) */ | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
39 #define IMAGE_THROTTLE_FACTOR 32 |
9 | 40 |
41 /* the file size at which throttling take place */ | |
42 #define IMAGE_THROTTLE_THRESHOLD 1048576 | |
43 | |
44 #define IMAGE_AUTO_REFRESH_TIME 3000 | |
45 | |
1 | 46 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
47 static GList *image_list = NULL; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
48 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
49 |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
50 static void image_update_title(ImageWindow *imd); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
51 static void image_post_process(ImageWindow *imd, gint clamp); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
52 static void image_read_ahead_start(ImageWindow *imd); |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
53 |
1 | 54 /* |
9 | 55 *------------------------------------------------------------------- |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
56 * 'signals' |
9 | 57 *------------------------------------------------------------------- |
58 */ | |
59 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
60 static void image_click_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data) |
9 | 61 { |
62 ImageWindow *imd = data; | |
63 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
64 if (imd->func_button) |
9 | 65 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
66 imd->func_button(imd, event->button, event->time, |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
67 event->x, event->y, event->state, imd->data_button); |
9 | 68 } |
69 } | |
70 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
71 static void image_drag_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
72 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
73 ImageWindow *imd = data; |
129 | 74 gint width, height; |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
75 |
129 | 76 pixbuf_renderer_get_scaled_size(pr, &width, &height); |
77 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
78 if (imd->func_drag) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
79 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
80 imd->func_drag(imd, event->button, event->time, |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
81 event->x, event->y, event->state, |
129 | 82 (gfloat)(pr->drag_last_x - event->x) / width, (gfloat)(pr->drag_last_y - event->y) / height, |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
83 imd->data_button); |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
84 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
85 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
86 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
87 static void image_scroll_notify_cb(PixbufRenderer *pr, gpointer data) |
9 | 88 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
89 ImageWindow *imd = data; |
9 | 90 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
91 if (imd->func_scroll_notify && pr->scale) |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
92 { |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
93 imd->func_scroll_notify(imd, |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
94 (gint)((gdouble)pr->x_scroll / pr->scale), |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
95 (gint)((gdouble)pr->y_scroll / pr->scale), |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
96 (gint)((gdouble)pr->image_width - pr->vis_width / pr->scale), |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
97 (gint)((gdouble)pr->image_height - pr->vis_height / pr->scale), |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
98 imd->data_scroll_notify); |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
99 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
100 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
101 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
102 static void image_update_util(ImageWindow *imd) |
1 | 103 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
104 if (imd->func_update) imd->func_update(imd, imd->data_update); |
9 | 105 } |
106 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
107 static void image_zoom_cb(PixbufRenderer *pr, gdouble zoom, gpointer data) |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
108 { |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
109 ImageWindow *imd = data; |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
110 |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
111 if (imd->title_show_zoom) image_update_title(imd); |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
112 image_update_util(imd); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
113 } |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
114 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
115 static void image_complete_util(ImageWindow *imd, gint preload) |
9 | 116 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
117 if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return; |
9 | 118 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
119 if (debug) printf("%s image load completed \"%s\" (%s)\n", get_exec_time(), |
203 | 120 (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") : |
121 (imd->image_fd ? imd->image_fd->path : "null"), | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
122 (preload) ? "preload" : "current"); |
9 | 123 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
124 if (!preload) imd->completed = TRUE; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
125 if (imd->func_complete) imd->func_complete(imd, preload, imd->data_complete); |
1 | 126 } |
127 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
128 static void image_render_complete_cb(PixbufRenderer *pr, gpointer data) |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
129 { |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
130 ImageWindow *imd = data; |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
131 |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
132 image_complete_util(imd, FALSE); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
133 } |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
134 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
135 static void image_state_set(ImageWindow *imd, ImageState state) |
9 | 136 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
137 if (state == IMAGE_STATE_NONE) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
138 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
139 imd->state = state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
140 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
141 else |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
142 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
143 imd->state |= state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
144 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
145 if (imd->func_state) imd->func_state(imd, state, imd->data_state); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
146 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
147 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
148 static void image_state_unset(ImageWindow *imd, ImageState state) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
149 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
150 imd->state &= ~state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
151 if (imd->func_state) imd->func_state(imd, state, imd->data_state); |
1 | 152 } |
153 | |
154 /* | |
9 | 155 *------------------------------------------------------------------- |
156 * misc | |
157 *------------------------------------------------------------------- | |
158 */ | |
159 | |
160 static void image_update_title(ImageWindow *imd) | |
1 | 161 { |
9 | 162 gchar *title = NULL; |
163 gchar *zoom = NULL; | |
164 gchar *collection = NULL; | |
165 | |
166 if (!imd->top_window) return; | |
167 | |
168 if (imd->collection && collection_to_number(imd->collection) >= 0) | |
169 { | |
170 const gchar *name; | |
171 name = imd->collection->name; | |
172 if (!name) name = _("Untitled"); | |
173 collection = g_strdup_printf(" (Collection %s)", name); | |
174 } | |
175 | |
176 if (imd->title_show_zoom) | |
1 | 177 { |
9 | 178 gchar *buf = image_zoom_get_as_text(imd); |
179 zoom = g_strconcat(" [", buf, "]", NULL); | |
180 g_free(buf); | |
1 | 181 } |
182 | |
9 | 183 title = g_strdup_printf("%s%s%s%s%s%s", |
184 imd->title ? imd->title : "", | |
138 | 185 imd->image_fd ? imd->image_fd->name : "", |
9 | 186 zoom ? zoom : "", |
187 collection ? collection : "", | |
138 | 188 imd->image_fd ? " - " : "", |
9 | 189 imd->title_right ? imd->title_right : ""); |
190 | |
191 gtk_window_set_title(GTK_WINDOW(imd->top_window), title); | |
192 | |
193 g_free(title); | |
194 g_free(zoom); | |
195 g_free(collection); | |
196 } | |
197 | |
198 /* | |
199 *------------------------------------------------------------------- | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
200 * rotation, flip, etc. |
9 | 201 *------------------------------------------------------------------- |
202 */ | |
203 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
204 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
205 #if 0 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
206 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
207 static void image_alter_real(ImageWindow *imd, AlterType type, gint clamp) |
9 | 208 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
209 PixbufRenderer *pr; |
9 | 210 GdkPixbuf *new = NULL; |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
211 gint exif_rotate; |
9 | 212 gint x, y; |
213 gint t; | |
214 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
215 pr = (PixbufRenderer *)imd->pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
216 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
217 exif_rotate = (imd->delay_alter_type != ALTER_NONE && (imd->state & IMAGE_STATE_ROTATE_AUTO)); |
9 | 218 imd->delay_alter_type = ALTER_NONE; |
219 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
220 if (!pr->pixbuf) return; |
9 | 221 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
222 x = pr->x_scroll + (pr->vis_width / 2); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
223 y = pr->y_scroll + (pr->vis_height / 2); |
9 | 224 |
225 switch (type) | |
226 { | |
227 case ALTER_ROTATE_90: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
228 new = pixbuf_copy_rotate_90(pr->pixbuf, FALSE); |
9 | 229 t = x; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
230 x = pr->height - y; |
9 | 231 y = t; |
232 break; | |
233 case ALTER_ROTATE_90_CC: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
234 new = pixbuf_copy_rotate_90(pr->pixbuf, TRUE); |
9 | 235 t = x; |
236 x = y; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
237 y = pr->width - t; |
9 | 238 break; |
239 case ALTER_ROTATE_180: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
240 new = pixbuf_copy_mirror(pr->pixbuf, TRUE, TRUE); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
241 x = pr->width - x; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
242 y = pr->height - y; |
9 | 243 break; |
244 case ALTER_MIRROR: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
245 new = pixbuf_copy_mirror(pr->pixbuf, TRUE, FALSE); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
246 x = pr->width - x; |
9 | 247 break; |
248 case ALTER_FLIP: | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
249 new = pixbuf_copy_mirror(pr->pixbuf, FALSE, TRUE); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
250 y = pr->height - y; |
9 | 251 break; |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
252 case ALTER_DESATURATE: |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
253 pixbuf_desaturate_rect(pr->pixbuf, |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
254 0, 0, pr->image_width, pr->image_height); |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
255 image_area_changed(imd, 0, 0, pr->image_width, pr->image_height); |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
244
diff
changeset
|
256 layout_image_overlay_update(layout_find_by_image(imd)); |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
61
diff
changeset
|
257 break; |
9 | 258 case ALTER_NONE: |
259 default: | |
260 return; | |
261 break; | |
262 } | |
263 | |
264 if (!new) return; | |
265 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
266 pixbuf_renderer_set_pixbuf(pr, new, pr->zoom); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
267 g_object_unref(new); |
9 | 268 |
109
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
269 if (clamp && pr->zoom != 0.0 && pr->scale != 0.0) |
9 | 270 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
271 if (exif_rotate) |
109
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
272 { |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
273 switch (pr->scroll_reset) |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
274 { |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
275 case PR_SCROLL_RESET_NOCHANGE: |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
276 break; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
277 case PR_SCROLL_RESET_CENTER: |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
278 x = (gint)((gdouble)pr->image_width / 2.0 * pr->scale); |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
279 y = (gint)((gdouble)pr->image_height / 2.0 * pr->scale); |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
280 break; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
281 case PR_SCROLL_RESET_TOPLEFT: |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
282 default: |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
283 x = 0; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
284 y = 0; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
285 break; |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
286 } |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
287 } |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
288 pixbuf_renderer_scroll_to_point(pr, (gint)((gdouble)x / pr->scale), |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
289 (gint)((gdouble)y / pr->scale), |
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
290 0.50, 0.50); |
9 | 291 } |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
292 |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
293 if (exif_rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO); |
273
e0e2c2b72c5a
reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
244
diff
changeset
|
294 layout_image_overlay_update(layout_find_by_image(imd)); |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
295 if (debug) printf("%s image postprocess done: %s\n", get_exec_time(), imd->image_fd->name); |
1 | 296 } |
297 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
298 static void image_post_process_alter(ImageWindow *imd, gint clamp) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
299 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
300 if (imd->delay_alter_type != ALTER_NONE) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
301 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
302 image_alter_real(imd, imd->delay_alter_type, clamp); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
303 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
304 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
305 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
306 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
307 static void image_post_process_color_cb(ColorMan *cm, ColorManReturnType type, gpointer data) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
308 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
309 ImageWindow *imd = data; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
310 |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
311 color_man_free(cm); |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
312 if (type == COLOR_RETURN_IMAGE_CHANGED) |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
313 { |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
314 if (cm == imd->cm) imd->cm = NULL; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
315 return; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
316 } |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
317 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
318 imd->cm = NULL; |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
319 image_state_set(imd, IMAGE_STATE_COLOR_ADJ); |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
320 if (debug) printf("%s image postprocess cm done: %s\n", get_exec_time(), imd->image_fd->name); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
321 |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
322 image_post_process_alter(imd, FALSE); |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
323 |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
324 image_read_ahead_start(imd); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
325 } |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
326 #endif |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
327 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
328 static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData *exif, gint run_in_bg) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
329 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
330 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
331 ColorManProfileType input_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
332 ColorManProfileType screen_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
333 const gchar *input_file; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
334 const gchar *screen_file; |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
335 ExifItem *item = NULL; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
336 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
337 if (imd->cm) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
338 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
339 if (imd->color_profile_input >= 1 && |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
340 imd->color_profile_input <= COLOR_PROFILE_INPUTS) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
341 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
342 gint n; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
343 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
344 n = imd->color_profile_input - 1; |
327 | 345 if (!options->color_profile.input_file[n]) return FALSE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
346 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
347 input_type = COLOR_PROFILE_FILE; |
327 | 348 input_file = options->color_profile.input_file[n]; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
349 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
350 else if (imd->color_profile_input == 0) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
351 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
352 input_type = COLOR_PROFILE_SRGB; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
353 input_file = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
354 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
355 else |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
356 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
357 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
358 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
359 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
360 if (imd->color_profile_screen == 1 && |
327 | 361 options->color_profile.screen_file) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
362 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
363 screen_type = COLOR_PROFILE_FILE; |
327 | 364 screen_file = options->color_profile.screen_file; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
365 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
366 else if (imd->color_profile_screen == 0) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
367 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
368 screen_type = COLOR_PROFILE_SRGB; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
369 screen_file = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
370 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
371 else |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
372 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
373 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
374 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
375 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
376 if (imd->color_profile_use_image && exif) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
377 { |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
209
diff
changeset
|
378 item = exif_get_item(exif, "Exif.Image.InterColorProfile"); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
379 if (!item) |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
380 { |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
381 gint cs; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
382 |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
383 /* ColorSpace == 1 specifies sRGB per EXIF 2.2 */ |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
180
diff
changeset
|
384 if (exif_get_integer(exif, "Exif.Photo.ColorSpace", &cs) && |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
385 cs == 1) |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
386 { |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
387 input_type = COLOR_PROFILE_SRGB; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
388 input_file = NULL; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
389 |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
390 if (debug) printf("Found EXIF ColorSpace of sRGB\n"); |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
391 } |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
392 } |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
393 } |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
394 |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
395 if (item && exif_item_get_format_id(item) == EXIF_FORMAT_UNDEFINED) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
396 { |
244 | 397 unsigned char *data; |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
398 guint data_len; |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
399 if (debug) printf("Found embedded color profile\n"); |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
400 |
244 | 401 data = (unsigned char *) exif_item_get_data(item, &data_len); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
402 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
403 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
404 data, data_len, |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
405 screen_type, screen_file); |
414
49c1cbe058ae
partially fixed reading embedded color profiles with exiv2
nadvornik
parents:
398
diff
changeset
|
406 g_free(data); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
407 } |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
408 else |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
409 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
410 cm = color_man_new(run_in_bg ? imd : NULL, NULL, |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
411 input_type, input_file, |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
412 screen_type, screen_file); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
413 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
414 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
415 if (cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
416 { |
116
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
417 if (start_row > 0) |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
418 { |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
419 cm->row = start_row; |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
420 cm->incremental_sync = TRUE; |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
421 } |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
422 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
423 imd->cm = (gpointer)cm; |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
424 #if 0 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
425 if (run_in_bg) color_man_start_bg(imd->cm, image_post_process_color_cb, imd); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
426 #endif |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
427 return TRUE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
428 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
429 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
430 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
431 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
432 |
9 | 433 static void image_post_process(ImageWindow *imd, gint clamp) |
434 { | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
435 #if 0 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
436 ExifData *exif = NULL; |
109
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
437 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
438 if (!image_get_pixbuf(imd)) return; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
439 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
440 if (debug) printf("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name); |
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
441 |
334 | 442 if (options->image.exif_rotate_enable || |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
443 (imd->color_profile_enable && imd->color_profile_use_image) ) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
444 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
181
diff
changeset
|
445 exif = exif_read_fd(imd->image_fd, (imd->color_profile_enable && imd->color_profile_use_image)); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
446 } |
334 | 447 if (options->image.exif_rotate_enable && exif) |
9 | 448 { |
449 gint orientation; | |
450 | |
180 | 451 if (exif_get_integer(exif, "Exif.Image.Orientation", &orientation)) |
9 | 452 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
453 gint rotate = TRUE; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
454 |
9 | 455 /* see http://jpegclub.org/exif_orientation.html |
456 1 2 3 4 5 6 7 8 | |
457 | |
458 888888 888888 88 88 8888888888 88 88 8888888888 | |
459 88 88 88 88 88 88 88 88 88 88 88 88 | |
460 8888 8888 8888 8888 88 8888888888 8888888888 88 | |
461 88 88 88 88 | |
462 88 88 888888 888888 | |
463 */ | |
464 switch (orientation) | |
465 { | |
466 case EXIF_ORIENTATION_TOP_LEFT: | |
467 /* normal -- nothing to do */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
468 rotate = FALSE; |
9 | 469 break; |
470 case EXIF_ORIENTATION_TOP_RIGHT: | |
471 /* mirrored */ | |
472 imd->delay_alter_type = ALTER_MIRROR; | |
473 break; | |
474 case EXIF_ORIENTATION_BOTTOM_RIGHT: | |
475 /* upside down */ | |
476 imd->delay_alter_type = ALTER_ROTATE_180; | |
477 break; | |
478 case EXIF_ORIENTATION_BOTTOM_LEFT: | |
479 /* flipped */ | |
480 imd->delay_alter_type = ALTER_FLIP; | |
481 break; | |
482 case EXIF_ORIENTATION_LEFT_TOP: | |
483 /* not implemented -- too wacky to fix in one step */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
484 rotate = FALSE; |
9 | 485 break; |
486 case EXIF_ORIENTATION_RIGHT_TOP: | |
487 /* rotated -90 (270) */ | |
488 imd->delay_alter_type = ALTER_ROTATE_90; | |
489 break; | |
490 case EXIF_ORIENTATION_RIGHT_BOTTOM: | |
491 /* not implemented -- too wacky to fix in one step */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
492 rotate = FALSE; |
9 | 493 break; |
494 case EXIF_ORIENTATION_LEFT_BOTTOM: | |
495 /* rotated 90 */ | |
496 imd->delay_alter_type = ALTER_ROTATE_90_CC; | |
497 break; | |
498 default: | |
499 /* The other values are out of range */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
500 rotate = FALSE; |
9 | 501 break; |
502 } | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
503 |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
504 if (rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO); |
9 | 505 } |
506 } | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
507 if (imd->color_profile_enable) |
9 | 508 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
509 if (!image_post_process_color(imd, 0, exif, TRUE)) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
510 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
511 /* fixme: note error to user */ |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
512 image_state_set(imd, IMAGE_STATE_COLOR_ADJ); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
513 } |
9 | 514 } |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
515 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
516 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
517 if (!imd->cm) image_post_process_alter(imd, clamp); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
518 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
519 exif_free(exif); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
520 #endif |
9 | 521 } |
522 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
523 static void image_post_process_tile_color_cb(PixbufRenderer *pr, GdkPixbuf **pixbuf, gint x, gint y, gint w, gint h, gpointer data) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
524 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
525 ImageWindow *imd = (ImageWindow *)data; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
526 if (imd->cm) color_man_correct_region(imd->cm, *pixbuf, x, y, w, h); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
527 if (imd->desaturate) pixbuf_desaturate_rect(*pixbuf, x, y, w, h); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
528 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
529 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
530 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
531 void image_alter(ImageWindow *imd, AlterType type) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
532 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
533 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
534 const static gint rotate_90[] = {1, 6, 7, 8, 5, 2, 3, 4, 1}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
535 const static gint rotate_90_cc[] = {1, 8, 5, 6, 7, 4, 1, 2, 3}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
536 const static gint rotate_180[] = {1, 3, 4, 1, 2, 7, 8, 5, 6}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
537 const static gint mirror[] = {1, 2, 1, 4, 3, 6, 5, 8, 7}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
538 const static gint flip[] = {1, 4, 3, 2, 1, 8, 7, 6, 5}; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
539 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
540 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
541 if (!imd || !imd->pr) return; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
542 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
543 if (imd->orientation < 1 || imd->orientation > 8) imd->orientation = 1; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
544 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
545 switch (type) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
546 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
547 case ALTER_ROTATE_90: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
548 imd->orientation = rotate_90[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
549 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
550 case ALTER_ROTATE_90_CC: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
551 imd->orientation = rotate_90_cc[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
552 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
553 case ALTER_ROTATE_180: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
554 imd->orientation = rotate_180[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
555 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
556 case ALTER_MIRROR: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
557 imd->orientation = mirror[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
558 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
559 case ALTER_FLIP: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
560 imd->orientation = flip[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
561 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
562 case ALTER_DESATURATE: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
563 imd->desaturate = !imd->desaturate; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
564 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
565 case ALTER_NONE: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
566 default: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
567 return; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
568 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
569 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
570 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
571 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
572 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
573 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
574 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
575 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
576 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
577 |
9 | 578 /* |
579 *------------------------------------------------------------------- | |
580 * read ahead (prebuffer) | |
581 *------------------------------------------------------------------- | |
582 */ | |
583 | |
584 static void image_read_ahead_cancel(ImageWindow *imd) | |
585 { | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
586 if (debug) printf("%s read ahead cancelled for :%s\n", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null"); |
9 | 587 |
588 image_loader_free(imd->read_ahead_il); | |
589 imd->read_ahead_il = NULL; | |
590 | |
591 if (imd->read_ahead_pixbuf) g_object_unref(imd->read_ahead_pixbuf); | |
592 imd->read_ahead_pixbuf = NULL; | |
593 | |
138 | 594 file_data_unref(imd->read_ahead_fd); |
595 imd->read_ahead_fd = NULL; | |
9 | 596 } |
597 | |
598 static void image_read_ahead_done_cb(ImageLoader *il, gpointer data) | |
599 { | |
600 ImageWindow *imd = data; | |
601 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
602 if (debug) printf("%s read ahead done for :%s\n", get_exec_time(), imd->read_ahead_fd->path); |
9 | 603 |
604 imd->read_ahead_pixbuf = image_loader_get_pixbuf(imd->read_ahead_il); | |
605 if (imd->read_ahead_pixbuf) | |
606 { | |
607 g_object_ref(imd->read_ahead_pixbuf); | |
608 } | |
609 else | |
610 { | |
611 imd->read_ahead_pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); | |
612 } | |
613 image_loader_free(imd->read_ahead_il); | |
614 imd->read_ahead_il = NULL; | |
615 | |
616 image_complete_util(imd, TRUE); | |
617 } | |
618 | |
619 static void image_read_ahead_error_cb(ImageLoader *il, gpointer data) | |
620 { | |
621 /* we even treat errors as success, maybe at least some of the file was ok */ | |
622 image_read_ahead_done_cb(il, data); | |
623 } | |
624 | |
625 static void image_read_ahead_start(ImageWindow *imd) | |
626 { | |
627 /* already started ? */ | |
138 | 628 if (!imd->read_ahead_fd || imd->read_ahead_il || imd->read_ahead_pixbuf) return; |
9 | 629 |
630 /* still loading ?, do later */ | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
631 if (imd->il /*|| imd->cm*/) return; |
9 | 632 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
633 if (debug) printf("%s read ahead started for :%s\n", get_exec_time(), imd->read_ahead_fd->path); |
9 | 634 |
138 | 635 imd->read_ahead_il = image_loader_new(imd->read_ahead_fd); |
9 | 636 |
637 image_loader_set_error_func(imd->read_ahead_il, image_read_ahead_error_cb, imd); | |
638 if (!image_loader_start(imd->read_ahead_il, image_read_ahead_done_cb, imd)) | |
639 { | |
640 image_read_ahead_cancel(imd); | |
641 image_complete_util(imd, TRUE); | |
642 } | |
643 } | |
644 | |
138 | 645 static void image_read_ahead_set(ImageWindow *imd, FileData *fd) |
9 | 646 { |
138 | 647 if (imd->read_ahead_fd && fd && imd->read_ahead_fd == fd) return; |
9 | 648 |
649 image_read_ahead_cancel(imd); | |
650 | |
138 | 651 imd->read_ahead_fd = file_data_ref(fd); |
9 | 652 |
138 | 653 if (debug) printf("read ahead set to :%s\n", imd->read_ahead_fd->path); |
9 | 654 |
655 image_read_ahead_start(imd); | |
656 } | |
657 | |
658 /* | |
659 *------------------------------------------------------------------- | |
660 * post buffering | |
661 *------------------------------------------------------------------- | |
662 */ | |
663 | |
138 | 664 static void image_post_buffer_set(ImageWindow *imd, FileData *fd, GdkPixbuf *pixbuf, gint color_row) |
9 | 665 { |
138 | 666 file_data_unref(imd->prev_fd); |
9 | 667 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); |
668 | |
138 | 669 if (fd && pixbuf) |
9 | 670 { |
138 | 671 imd->prev_fd = file_data_ref(fd); |
9 | 672 |
673 g_object_ref(pixbuf); | |
674 imd->prev_pixbuf = pixbuf; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
675 imd->prev_color_row = color_row; |
9 | 676 } |
677 else | |
678 { | |
138 | 679 imd->prev_fd = NULL; |
9 | 680 imd->prev_pixbuf = NULL; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
681 imd->prev_color_row = -1; |
9 | 682 } |
683 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
684 if (debug) printf("%s post buffer set: %s\n", get_exec_time(), fd ? fd->path : "null"); |
9 | 685 } |
686 | |
687 static gint image_post_buffer_get(ImageWindow *imd) | |
688 { | |
689 gint success; | |
690 | |
691 if (imd->prev_pixbuf && | |
138 | 692 imd->image_fd && imd->prev_fd && imd->image_fd == imd->prev_fd) |
9 | 693 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
694 image_change_pixbuf(imd, imd->prev_pixbuf, image_zoom_get(imd)); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
695 if (imd->prev_color_row >= 0) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
696 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
697 ExifData *exif = NULL; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
698 |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
181
diff
changeset
|
699 if (imd->color_profile_use_image) exif = exif_read_fd(imd->image_fd, TRUE); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
700 // image_post_process_color(imd, imd->prev_color_row, exif, TRUE); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
701 exif_free(exif); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
702 } |
9 | 703 success = TRUE; |
704 } | |
705 else | |
706 { | |
707 success = FALSE; | |
708 } | |
709 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
710 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); |
9 | 711 imd->prev_pixbuf = NULL; |
712 | |
138 | 713 file_data_unref(imd->prev_fd); |
714 imd->prev_fd = NULL; | |
9 | 715 |
716 return success; | |
717 } | |
718 | |
719 /* | |
720 *------------------------------------------------------------------- | |
721 * loading | |
722 *------------------------------------------------------------------- | |
723 */ | |
724 | |
725 static void image_load_pixbuf_ready(ImageWindow *imd) | |
726 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
727 if (image_get_pixbuf(imd) || !imd->il) return; |
9 | 728 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
729 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 730 } |
731 | |
732 static void image_load_area_cb(ImageLoader *il, guint x, guint y, guint w, guint h, gpointer data) | |
733 { | |
734 ImageWindow *imd = data; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
735 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
736 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
737 pr = (PixbufRenderer *)imd->pr; |
9 | 738 |
739 if (imd->delay_flip && | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
740 pr->pixbuf != image_loader_get_pixbuf(il)) |
9 | 741 { |
742 return; | |
743 } | |
744 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
745 if (!pr->pixbuf) image_load_pixbuf_ready(imd); |
9 | 746 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
747 pixbuf_renderer_area_changed(pr, x, y, w, h); |
9 | 748 } |
749 | |
750 static void image_load_done_cb(ImageLoader *il, gpointer data) | |
1 | 751 { |
752 ImageWindow *imd = data; | |
9 | 753 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
754 if (debug) printf ("%s image done\n", get_exec_time()); |
9 | 755 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
756 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
757 image_state_unset(imd, IMAGE_STATE_LOADING); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
758 |
9 | 759 if (imd->delay_flip && |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
760 image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) |
9 | 761 { |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
29
diff
changeset
|
762 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
763 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 764 } |
765 | |
766 image_loader_free(imd->il); | |
767 imd->il = NULL; | |
768 | |
769 image_post_process(imd, TRUE); | |
770 | |
771 image_read_ahead_start(imd); | |
772 } | |
773 | |
774 static void image_load_error_cb(ImageLoader *il, gpointer data) | |
775 { | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
776 if (debug) printf ("%s image error\n", get_exec_time()); |
9 | 777 |
778 /* even on error handle it like it was done, | |
779 * since we have a pixbuf with _something_ */ | |
780 | |
781 image_load_done_cb(il, data); | |
782 } | |
783 | |
784 #ifdef IMAGE_THROTTLE_LARGER_IMAGES | |
785 static void image_load_buffer_throttle(ImageLoader *il) | |
786 { | |
787 if (!il || il->bytes_total < IMAGE_THROTTLE_THRESHOLD) return; | |
788 | |
789 /* Larger image files usually have larger chunks of data per pixel... | |
790 * So increase the buffer read size so that the rendering chunks called | |
791 * are also larger. | |
792 */ | |
793 | |
794 image_loader_set_buffer_size(il, IMAGE_LOAD_BUFFER_COUNT * IMAGE_THROTTLE_FACTOR); | |
795 } | |
796 #endif | |
797 | |
798 /* this read ahead is located here merely for the callbacks, above */ | |
799 | |
800 static gint image_read_ahead_check(ImageWindow *imd) | |
801 { | |
138 | 802 if (!imd->read_ahead_fd) return FALSE; |
9 | 803 if (imd->il) return FALSE; |
804 | |
138 | 805 if (!imd->image_fd || imd->read_ahead_fd != imd->image_fd) |
9 | 806 { |
807 image_read_ahead_cancel(imd); | |
808 return FALSE; | |
809 } | |
810 | |
811 if (imd->read_ahead_il) | |
812 { | |
813 imd->il = imd->read_ahead_il; | |
814 imd->read_ahead_il = NULL; | |
815 | |
816 /* override the old signals */ | |
817 image_loader_set_area_ready_func(imd->il, image_load_area_cb, imd); | |
818 image_loader_set_error_func(imd->il, image_load_error_cb, imd); | |
819 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT); | |
820 | |
821 #ifdef IMAGE_THROTTLE_LARGER_IMAGES | |
822 image_load_buffer_throttle(imd->il); | |
823 #endif | |
824 | |
825 /* do this one directly (probably should add a set func) */ | |
826 imd->il->func_done = image_load_done_cb; | |
827 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
828 g_object_set(G_OBJECT(imd->pr), "loading", TRUE, NULL); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
829 image_state_set(imd, IMAGE_STATE_LOADING); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
830 |
9 | 831 if (!imd->delay_flip) |
832 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
833 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 834 } |
835 | |
836 image_read_ahead_cancel(imd); | |
837 return TRUE; | |
838 } | |
839 else if (imd->read_ahead_pixbuf) | |
840 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
841 image_change_pixbuf(imd, imd->read_ahead_pixbuf, image_zoom_get(imd)); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
842 g_object_unref(imd->read_ahead_pixbuf); |
9 | 843 imd->read_ahead_pixbuf = NULL; |
844 | |
845 image_read_ahead_cancel(imd); | |
846 | |
847 image_post_process(imd, FALSE); | |
848 return TRUE; | |
849 } | |
850 | |
851 image_read_ahead_cancel(imd); | |
852 return FALSE; | |
853 } | |
854 | |
138 | 855 static gint image_load_begin(ImageWindow *imd, FileData *fd) |
9 | 856 { |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
857 if (debug) printf ("%s image begin \n", get_exec_time()); |
9 | 858 |
859 if (imd->il) return FALSE; | |
860 | |
861 imd->completed = FALSE; | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
862 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL); |
9 | 863 |
864 if (image_post_buffer_get(imd)) | |
865 { | |
138 | 866 if (debug) printf("from post buffer: %s\n", imd->image_fd->path); |
9 | 867 return TRUE; |
868 } | |
869 | |
870 if (image_read_ahead_check(imd)) | |
871 { | |
138 | 872 if (debug) printf("from read ahead buffer: %s\n", imd->image_fd->path); |
9 | 873 return TRUE; |
874 } | |
875 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
876 if (!imd->delay_flip && image_get_pixbuf(imd)) |
9 | 877 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
878 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
879 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
880 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
881 if (pr->pixbuf) g_object_unref(pr->pixbuf); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
882 pr->pixbuf = NULL; |
9 | 883 } |
884 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
885 g_object_set(G_OBJECT(imd->pr), "loading", TRUE, NULL); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
886 |
138 | 887 imd->il = image_loader_new(fd); |
9 | 888 |
889 image_loader_set_area_ready_func(imd->il, image_load_area_cb, imd); | |
890 image_loader_set_error_func(imd->il, image_load_error_cb, imd); | |
891 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT); | |
892 | |
893 if (!image_loader_start(imd->il, image_load_done_cb, imd)) | |
894 { | |
895 if (debug) printf("image start error\n"); | |
896 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
897 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
898 |
9 | 899 image_loader_free(imd->il); |
900 imd->il = NULL; | |
901 | |
902 image_complete_util(imd, FALSE); | |
903 | |
904 return FALSE; | |
905 } | |
906 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
907 image_state_set(imd, IMAGE_STATE_LOADING); |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
908 |
9 | 909 #ifdef IMAGE_THROTTLE_LARGER_IMAGES |
910 image_load_buffer_throttle(imd->il); | |
911 #endif | |
912 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
913 if (!imd->delay_flip && !image_get_pixbuf(imd)) image_load_pixbuf_ready(imd); |
9 | 914 |
915 return TRUE; | |
916 } | |
917 | |
918 static void image_reset(ImageWindow *imd) | |
919 { | |
920 /* stops anything currently being done */ | |
921 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
922 if (debug) printf("%s image reset\n", get_exec_time()); |
9 | 923 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
924 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
925 |
9 | 926 image_loader_free(imd->il); |
927 imd->il = NULL; | |
928 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
929 color_man_free((ColorMan *)imd->cm); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
930 imd->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
931 |
9 | 932 imd->delay_alter_type = ALTER_NONE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
933 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
934 image_state_set(imd, IMAGE_STATE_NONE); |
9 | 935 } |
936 | |
937 /* | |
938 *------------------------------------------------------------------- | |
939 * image changer | |
940 *------------------------------------------------------------------- | |
941 */ | |
942 | |
943 static void image_change_complete(ImageWindow *imd, gdouble zoom, gint new) | |
944 { | |
945 image_reset(imd); | |
946 | |
138 | 947 if (imd->image_fd && isfile(imd->image_fd->path)) |
9 | 948 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
949 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
950 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
951 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
952 pr->zoom = zoom; /* store the zoom, needed by the loader */ |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
953 |
138 | 954 if (image_load_begin(imd, imd->image_fd)) |
9 | 955 { |
956 imd->unknown = FALSE; | |
957 } | |
958 else | |
959 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
960 GdkPixbuf *pixbuf; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
961 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
962 pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
963 image_change_pixbuf(imd, pixbuf, zoom); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
964 g_object_unref(pixbuf); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
965 |
9 | 966 imd->unknown = TRUE; |
967 } | |
138 | 968 imd->size = filesize(imd->image_fd->path); |
969 imd->mtime = filetime(imd->image_fd->path); | |
9 | 970 } |
971 else | |
972 { | |
138 | 973 if (imd->image_fd) |
9 | 974 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
975 GdkPixbuf *pixbuf; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
976 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
977 pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
978 image_change_pixbuf(imd, pixbuf, zoom); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
979 g_object_unref(pixbuf); |
138 | 980 imd->mtime = filetime(imd->image_fd->path); |
9 | 981 } |
982 else | |
983 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
984 image_change_pixbuf(imd, NULL, zoom); |
9 | 985 imd->mtime = 0; |
986 } | |
987 imd->unknown = TRUE; | |
988 imd->size = 0; | |
989 } | |
990 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
991 image_update_util(imd); |
9 | 992 } |
993 | |
138 | 994 static void image_change_real(ImageWindow *imd, FileData *fd, |
9 | 995 CollectionData *cd, CollectInfo *info, gdouble zoom) |
996 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
997 GdkPixbuf *pixbuf; |
9 | 998 GdkPixbuf *prev_pixbuf = NULL; |
138 | 999 FileData *prev_fd = NULL; |
9 | 1000 gint prev_clear = FALSE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1001 gint prev_color_row = -1; |
9 | 1002 |
1003 imd->collection = cd; | |
1004 imd->collection_info = info; | |
1005 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1006 pixbuf = image_get_pixbuf(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1007 |
334 | 1008 if (options->image.enable_read_ahead && imd->image_fd && pixbuf) |
9 | 1009 { |
1010 if (imd->il) | |
1011 { | |
1012 /* current image is not finished */ | |
1013 prev_clear = TRUE; | |
1014 } | |
1015 else | |
1016 { | |
138 | 1017 prev_fd = file_data_ref(imd->image_fd); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1018 prev_pixbuf = pixbuf; |
9 | 1019 g_object_ref(prev_pixbuf); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1020 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1021 if (imd->cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1022 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1023 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1024 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1025 cm = (ColorMan *)imd->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1026 prev_color_row = cm->row; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1027 } |
9 | 1028 } |
1029 } | |
1030 | |
138 | 1031 file_data_unref(imd->image_fd); |
1032 imd->image_fd = file_data_ref(fd); | |
9 | 1033 |
1034 image_change_complete(imd, zoom, TRUE); | |
1035 | |
1036 if (prev_pixbuf) | |
1037 { | |
138 | 1038 image_post_buffer_set(imd, prev_fd, prev_pixbuf, prev_color_row); |
1039 file_data_unref(prev_fd); | |
9 | 1040 g_object_unref(prev_pixbuf); |
1041 } | |
1042 else if (prev_clear) | |
1043 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1044 image_post_buffer_set(imd, NULL, NULL, -1); |
9 | 1045 } |
1046 | |
1047 image_update_title(imd); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1048 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1049 } |
1050 | |
1051 /* | |
1052 *------------------------------------------------------------------- | |
1053 * focus stuff | |
1054 *------------------------------------------------------------------- | |
1055 */ | |
1056 | |
1057 static void image_focus_paint(ImageWindow *imd, gint has_focus, GdkRectangle *area) | |
1058 { | |
1059 GtkWidget *widget; | |
1060 | |
1061 widget = imd->widget; | |
1062 if (!widget->window) return; | |
1063 | |
1064 if (has_focus) | |
1065 { | |
1066 gtk_paint_focus (widget->style, widget->window, GTK_STATE_ACTIVE, | |
1067 area, widget, "image_window", | |
1068 widget->allocation.x, widget->allocation.y, | |
1069 widget->allocation.width - 1, widget->allocation.height - 1); | |
1070 } | |
1071 else | |
1072 { | |
1073 gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, | |
1074 area, widget, "image_window", | |
1075 widget->allocation.x, widget->allocation.y, | |
1076 widget->allocation.width - 1, widget->allocation.height - 1); | |
1077 } | |
1078 } | |
1079 | |
1080 static gint image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) | |
1081 { | |
1082 ImageWindow *imd = data; | |
1083 | |
1084 image_focus_paint(imd, GTK_WIDGET_HAS_FOCUS(widget), &event->area); | |
1085 return TRUE; | |
1086 } | |
1087 | |
1088 static gint image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
1089 { | |
1090 ImageWindow *imd = data; | |
1091 | |
1092 GTK_WIDGET_SET_FLAGS(imd->widget, GTK_HAS_FOCUS); | |
1093 image_focus_paint(imd, TRUE, NULL); | |
1094 | |
1095 return TRUE; | |
1096 } | |
1097 | |
1098 static gint image_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
1099 { | |
1100 ImageWindow *imd = data; | |
1101 | |
1102 GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS); | |
1103 image_focus_paint(imd, FALSE, NULL); | |
1104 | |
1105 return TRUE; | |
1106 } | |
1107 | |
1108 gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y, | |
1109 gint relative, gint always) | |
1110 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1111 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, relative, always); |
9 | 1112 } |
1113 | |
1114 void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y) | |
1115 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1116 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y); |
9 | 1117 } |
1118 | |
1119 gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y) | |
1120 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1121 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y); |
9 | 1122 } |
1123 | |
1124 void image_overlay_remove(ImageWindow *imd, gint id) | |
1125 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1126 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id); |
9 | 1127 } |
1128 | |
1129 static gint image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data) | |
1130 { | |
1131 ImageWindow *imd = data; | |
1132 | |
1133 if (imd->func_scroll && | |
1134 event && event->type == GDK_SCROLL) | |
1135 { | |
1136 imd->func_scroll(imd, event->direction, event->time, | |
1137 event->x, event->y, event->state, imd->data_scroll); | |
1138 return TRUE; | |
1139 } | |
1140 | |
1141 return FALSE; | |
1142 } | |
1143 | |
1144 /* | |
1145 *------------------------------------------------------------------- | |
1146 * public interface | |
1147 *------------------------------------------------------------------- | |
1148 */ | |
1149 | |
1150 void image_attach_window(ImageWindow *imd, GtkWidget *window, | |
1151 const gchar *title, const gchar *title_right, gint show_zoom) | |
1 | 1152 { |
1153 imd->top_window = window; | |
1154 g_free(imd->title); | |
9 | 1155 imd->title = g_strdup(title); |
1156 g_free(imd->title_right); | |
1157 imd->title_right = g_strdup(title_right); | |
1158 imd->title_show_zoom = show_zoom; | |
1159 | |
334 | 1160 if (!options->image.fit_window_to_image) window = NULL; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1161 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1162 pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)window); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1163 |
9 | 1164 image_update_title(imd); |
1165 } | |
1166 | |
1167 void image_set_update_func(ImageWindow *imd, | |
1168 void (*func)(ImageWindow *imd, gpointer data), | |
1169 gpointer data) | |
1170 { | |
1171 imd->func_update = func; | |
1172 imd->data_update = data; | |
1 | 1173 } |
1174 | |
9 | 1175 void image_set_complete_func(ImageWindow *imd, |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1176 void (*func)(ImageWindow *imd, gint preload, gpointer data), |
9 | 1177 gpointer data) |
1 | 1178 { |
9 | 1179 imd->func_complete = func; |
1180 imd->data_complete = data; | |
1 | 1181 } |
1182 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1183 void image_set_state_func(ImageWindow *imd, |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1184 void (*func)(ImageWindow *imd, ImageState state, gpointer data), |
9 | 1185 gpointer data) |
1 | 1186 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1187 imd->func_state = func; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1188 imd->data_state = data; |
9 | 1189 } |
1190 | |
1191 | |
1192 void image_set_button_func(ImageWindow *imd, | |
1193 void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gpointer), | |
1194 gpointer data) | |
1195 { | |
1196 imd->func_button = func; | |
1197 imd->data_button = data; | |
1198 } | |
1199 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1200 void image_set_drag_func(ImageWindow *imd, |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1201 void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy, gpointer), |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1202 gpointer data) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1203 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1204 imd->func_drag = func; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1205 imd->data_drag = data; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1206 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1207 |
9 | 1208 void image_set_scroll_func(ImageWindow *imd, |
1209 void (*func)(ImageWindow *, GdkScrollDirection direction, guint32 time, gdouble x, gdouble y, guint state, gpointer), | |
1210 gpointer data) | |
1 | 1211 { |
9 | 1212 imd->func_scroll = func; |
1213 imd->data_scroll = data; | |
1 | 1214 } |
1215 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1216 void image_set_scroll_notify_func(ImageWindow *imd, |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1217 void (*func)(ImageWindow *imd, gint x, gint y, gint width, gint height, gpointer data), |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1218 gpointer data) |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1219 { |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1220 imd->func_scroll_notify = func; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1221 imd->data_scroll_notify = data; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1222 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1223 |
9 | 1224 /* path, name */ |
1225 | |
1226 const gchar *image_get_path(ImageWindow *imd) | |
1227 { | |
138 | 1228 if (imd->image_fd == NULL) return NULL; |
1229 return imd->image_fd->path; | |
9 | 1230 } |
1231 | |
1232 const gchar *image_get_name(ImageWindow *imd) | |
1233 { | |
138 | 1234 if (imd->image_fd == NULL) return NULL; |
1235 return imd->image_fd->name; | |
1236 } | |
1237 | |
1238 FileData *image_get_fd(ImageWindow *imd) | |
1239 { | |
1240 return imd->image_fd; | |
9 | 1241 } |
1242 | |
1243 /* merely changes path string, does not change the image! */ | |
138 | 1244 void image_set_fd(ImageWindow *imd, FileData *fd) |
1 | 1245 { |
138 | 1246 file_data_unref(imd->image_fd); |
1247 imd->image_fd = file_data_ref(fd); | |
9 | 1248 |
1249 image_update_title(imd); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1250 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1251 } |
1252 | |
1253 /* load a new image */ | |
1254 | |
138 | 1255 void image_change_fd(ImageWindow *imd, FileData *fd, gdouble zoom) |
9 | 1256 { |
138 | 1257 if (imd->image_fd == fd) return; |
9 | 1258 |
138 | 1259 image_change_real(imd, fd, NULL, NULL, zoom); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1260 } |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1261 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1262 GdkPixbuf *image_get_pixbuf(ImageWindow *imd) |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1263 { |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1264 return pixbuf_renderer_get_pixbuf((PixbufRenderer *)imd->pr); |
9 | 1265 } |
1266 | |
1267 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom) | |
1268 { | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1269 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1270 ExifData *exif = NULL; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1271 gint orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1272 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1273 if (options->image.exif_rotate_enable || |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1274 (imd->color_profile_enable && imd->color_profile_use_image) ) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1275 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1276 exif = exif_read_fd(imd->image_fd, (imd->color_profile_enable && imd->color_profile_use_image)); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1277 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1278 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1279 if (options->image.exif_rotate_enable && exif && exif_get_integer(exif, "Exif.Image.Orientation", &orientation)) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1280 imd->orientation = orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1281 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1282 imd->orientation = 1; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1283 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1284 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, FALSE); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1285 if (imd->cm) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1286 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1287 color_man_free(imd->cm); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1288 imd->cm = NULL; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1289 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1290 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1291 pixbuf_renderer_set_pixbuf((PixbufRenderer *)imd->pr, pixbuf, zoom); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1292 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1293 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1294 if (imd->color_profile_enable) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1295 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1296 if (!image_post_process_color(imd, 0, exif, FALSE)) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1297 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1298 /* fixme: note error to user */ |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1299 // image_state_set(imd, IMAGE_STATE_COLOR_ADJ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1300 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1301 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1302 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1303 exif_free(exif); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1304 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1305 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1306 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1307 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1308 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1309 } |
1310 | |
1311 void image_change_from_collection(ImageWindow *imd, CollectionData *cd, CollectInfo *info, gdouble zoom) | |
1312 { | |
1313 if (!cd || !info || !g_list_find(cd->list, info)) return; | |
1314 | |
138 | 1315 image_change_real(imd, info->fd, cd, info, zoom); |
9 | 1316 } |
1317 | |
1318 CollectionData *image_get_collection(ImageWindow *imd, CollectInfo **info) | |
1319 { | |
1320 if (collection_to_number(imd->collection) >= 0) | |
1321 { | |
1322 if (g_list_find(imd->collection->list, imd->collection_info) != NULL) | |
1323 { | |
1324 if (info) *info = imd->collection_info; | |
1325 } | |
1326 else | |
1327 { | |
1328 if (info) *info = NULL; | |
1329 } | |
1330 return imd->collection; | |
1331 } | |
1332 | |
1333 if (info) *info = NULL; | |
1334 return NULL; | |
1335 } | |
1336 | |
1337 static void image_loader_sync_data(ImageLoader *il, gpointer data) | |
1338 { | |
1339 /* change data for the callbacks directly */ | |
1340 | |
1341 il->data_area_ready = data; | |
1342 il->data_error = data; | |
1343 il->data_done = data; | |
1344 il->data_percent = data; | |
1 | 1345 } |
1346 | |
9 | 1347 /* this is more like a move function |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1348 * it moves most data from source to imd |
9 | 1349 */ |
1350 void image_change_from_image(ImageWindow *imd, ImageWindow *source) | |
1351 { | |
1352 if (imd == source) return; | |
1353 | |
1354 imd->unknown = source->unknown; | |
1355 | |
1356 imd->collection = source->collection; | |
1357 imd->collection_info = source->collection_info; | |
1358 imd->size = source->size; | |
1359 imd->mtime = source->mtime; | |
1360 | |
138 | 1361 image_set_fd(imd, image_get_fd(source)); |
9 | 1362 |
1363 image_loader_free(imd->il); | |
1364 imd->il = NULL; | |
1365 | |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1366 if (source->il) |
9 | 1367 { |
1368 imd->il = source->il; | |
1369 source->il = NULL; | |
1370 | |
1371 image_loader_sync_data(imd->il, imd); | |
1372 | |
1373 imd->delay_alter_type = source->delay_alter_type; | |
1374 source->delay_alter_type = ALTER_NONE; | |
1375 } | |
1376 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1377 imd->color_profile_enable = source->color_profile_enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1378 imd->color_profile_input = source->color_profile_input; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1379 imd->color_profile_screen = source->color_profile_screen; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1380 imd->color_profile_use_image = source->color_profile_use_image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1381 color_man_free((ColorMan *)imd->cm); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1382 imd->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1383 if (source->cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1384 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1385 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1386 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1387 imd->cm = source->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1388 source->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1389 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1390 cm = (ColorMan *)imd->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1391 cm->imd = imd; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1392 cm->func_done_data = imd; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1393 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1394 |
9 | 1395 image_loader_free(imd->read_ahead_il); |
1396 imd->read_ahead_il = source->read_ahead_il; | |
1397 source->read_ahead_il = NULL; | |
1398 if (imd->read_ahead_il) image_loader_sync_data(imd->read_ahead_il, imd); | |
1399 | |
1400 if (imd->read_ahead_pixbuf) g_object_unref(imd->read_ahead_pixbuf); | |
1401 imd->read_ahead_pixbuf = source->read_ahead_pixbuf; | |
1402 source->read_ahead_pixbuf = NULL; | |
1403 | |
138 | 1404 file_data_unref(imd->read_ahead_fd); |
1405 imd->read_ahead_fd = source->read_ahead_fd; | |
1406 source->read_ahead_fd = NULL; | |
9 | 1407 |
1408 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); | |
1409 imd->prev_pixbuf = source->prev_pixbuf; | |
1410 source->prev_pixbuf = NULL; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1411 imd->prev_color_row = source->prev_color_row; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1412 source->prev_color_row = -1; |
9 | 1413 |
138 | 1414 file_data_unref(imd->prev_fd); |
1415 imd->prev_fd = source->prev_fd; | |
1416 source->prev_fd = NULL; | |
9 | 1417 |
1418 imd->completed = source->completed; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1419 imd->state = source->state; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1420 source->state = IMAGE_STATE_NONE; |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1421 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1422 imd->orientation = source->orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1423 imd->desaturate = source->desaturate; |
9 | 1424 |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1425 pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr)); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1426 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1427 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1428 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1429 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1430 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1431 |
9 | 1432 } |
1433 | |
1434 /* manipulation */ | |
1435 | |
1436 void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height) | |
1437 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1438 pixbuf_renderer_area_changed((PixbufRenderer *)imd->pr, x, y, width, height); |
9 | 1439 } |
1440 | |
1441 void image_reload(ImageWindow *imd) | |
1442 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1443 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1444 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1445 image_change_complete(imd, image_zoom_get(imd), FALSE); |
9 | 1446 } |
1447 | |
1448 void image_scroll(ImageWindow *imd, gint x, gint y) | |
1449 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1450 pixbuf_renderer_scroll((PixbufRenderer *)imd->pr, x, y); |
9 | 1451 } |
1452 | |
13
ef790149ae21
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
12
diff
changeset
|
1453 void image_scroll_to_point(ImageWindow *imd, gint x, gint y, |
ef790149ae21
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
12
diff
changeset
|
1454 gdouble x_align, gdouble y_align) |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1455 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1456 pixbuf_renderer_scroll_to_point((PixbufRenderer *)imd->pr, x, y, x_align, y_align); |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1457 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1458 |
131 | 1459 void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y) |
1460 { | |
1461 pixbuf_renderer_get_scroll_center(PIXBUF_RENDERER(imd->pr), x, y); | |
1462 } | |
1463 | |
1464 void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y) | |
1465 { | |
1466 pixbuf_renderer_set_scroll_center(PIXBUF_RENDERER(imd->pr), x, y); | |
1467 } | |
1468 | |
1469 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1470 #if 0 |
9 | 1471 void image_alter(ImageWindow *imd, AlterType type) |
1 | 1472 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1473 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1474 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1475 if (imd->il || imd->cm) |
9 | 1476 { |
1477 /* still loading, wait till done */ | |
1478 imd->delay_alter_type = type; | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1479 image_state_set(imd, IMAGE_STATE_ROTATE_USER); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1480 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1481 if (imd->cm && (imd->state & IMAGE_STATE_ROTATE_AUTO)) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1482 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1483 image_state_unset(imd, IMAGE_STATE_ROTATE_AUTO); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1484 } |
9 | 1485 return; |
1486 } | |
1487 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1488 image_alter_real(imd, type, TRUE); |
9 | 1489 } |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1490 #endif |
9 | 1491 |
1492 void image_zoom_adjust(ImageWindow *imd, gdouble increment) | |
1493 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1494 pixbuf_renderer_zoom_adjust((PixbufRenderer *)imd->pr, increment); |
9 | 1495 } |
1496 | |
1497 void image_zoom_adjust_at_point(ImageWindow *imd, gdouble increment, gint x, gint y) | |
1498 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1499 pixbuf_renderer_zoom_adjust_at_point((PixbufRenderer *)imd->pr, increment, x, y); |
9 | 1500 } |
1501 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1502 void image_zoom_set_limits(ImageWindow *imd, gdouble min, gdouble max) |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1503 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1504 pixbuf_renderer_zoom_set_limits((PixbufRenderer *)imd->pr, min, max); |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1505 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1506 |
9 | 1507 void image_zoom_set(ImageWindow *imd, gdouble zoom) |
1508 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1509 pixbuf_renderer_zoom_set((PixbufRenderer *)imd->pr, zoom); |
9 | 1510 } |
1511 | |
1512 void image_zoom_set_fill_geometry(ImageWindow *imd, gint vertical) | |
1513 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1514 PixbufRenderer *pr; |
9 | 1515 gdouble zoom; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1516 gint width, height; |
9 | 1517 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1518 pr = (PixbufRenderer *)imd->pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1519 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1520 if (!pixbuf_renderer_get_pixbuf(pr) || |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1521 !pixbuf_renderer_get_image_size(pr, &width, &height)) return; |
9 | 1522 |
1523 if (vertical) | |
1524 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1525 zoom = (gdouble)pr->window_height / height; |
9 | 1526 } |
1527 else | |
1528 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1529 zoom = (gdouble)pr->window_width / width; |
9 | 1530 } |
1531 | |
1532 if (zoom < 1.0) | |
1533 { | |
1534 zoom = 0.0 - 1.0 / zoom; | |
1 | 1535 } |
9 | 1536 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1537 pixbuf_renderer_zoom_set(pr, zoom); |
9 | 1538 } |
1539 | |
1540 gdouble image_zoom_get(ImageWindow *imd) | |
1541 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1542 return pixbuf_renderer_zoom_get((PixbufRenderer *)imd->pr); |
9 | 1543 } |
1544 | |
1545 gdouble image_zoom_get_real(ImageWindow *imd) | |
1546 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1547 return pixbuf_renderer_zoom_get_scale((PixbufRenderer *)imd->pr); |
9 | 1548 } |
1549 | |
1550 gchar *image_zoom_get_as_text(ImageWindow *imd) | |
1551 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1552 gdouble zoom; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1553 gdouble scale; |
9 | 1554 gdouble l = 1.0; |
1555 gdouble r = 1.0; | |
1556 gint pl = 0; | |
1557 gint pr = 0; | |
1558 gchar *approx = " "; | |
1559 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1560 zoom = image_zoom_get(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1561 scale = image_zoom_get_real(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1562 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1563 if (zoom > 0.0) |
1 | 1564 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1565 l = zoom; |
9 | 1566 } |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1567 else if (zoom < 0.0) |
9 | 1568 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1569 r = 0.0 - zoom; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1570 } |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1571 else if (zoom == 0.0 && scale != 0.0) |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1572 { |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1573 if (scale >= 1.0) |
9 | 1574 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1575 l = scale; |
9 | 1576 } |
1577 else | |
1578 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1579 r = 1.0 / scale; |
9 | 1580 } |
1581 approx = " ~"; | |
1582 } | |
1583 | |
1584 if (rint(l) != l) pl = 1; | |
1585 if (rint(r) != r) pr = 1; | |
1586 | |
1587 return g_strdup_printf("%.*f :%s%.*f", pl, l, approx, pr, r); | |
1588 } | |
1589 | |
1590 gdouble image_zoom_get_default(ImageWindow *imd, gint mode) | |
1591 { | |
1592 gdouble zoom; | |
1593 | |
1594 if (mode == ZOOM_RESET_ORIGINAL) | |
1595 { | |
1596 zoom = 1.0; | |
1597 } | |
1598 else if (mode == ZOOM_RESET_FIT_WINDOW) | |
1599 { | |
1600 zoom = 0.0; | |
1 | 1601 } |
1602 else | |
1603 { | |
1604 if (imd) | |
1605 { | |
9 | 1606 zoom = image_zoom_get(imd); |
1 | 1607 } |
1608 else | |
1609 { | |
9 | 1610 zoom = 1.0; |
1 | 1611 } |
1612 } | |
1613 | |
1614 return zoom; | |
1615 } | |
1616 | |
9 | 1617 /* read ahead */ |
1618 | |
138 | 1619 void image_prebuffer_set(ImageWindow *imd, FileData *fd) |
9 | 1620 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1621 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1622 |
138 | 1623 if (fd) |
9 | 1624 { |
138 | 1625 image_read_ahead_set(imd, fd); |
9 | 1626 } |
1627 else | |
1628 { | |
1629 image_read_ahead_cancel(imd); | |
1630 } | |
1631 } | |
1632 | |
1633 static gint image_auto_refresh_cb(gpointer data) | |
1634 { | |
1635 ImageWindow *imd = data; | |
1636 time_t newtime; | |
1637 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1638 if (!imd || !image_get_pixbuf(imd) || |
138 | 1639 imd->il || !imd->image_fd || |
320 | 1640 !options->update_on_time_change) return TRUE; |
9 | 1641 |
138 | 1642 newtime = filetime(imd->image_fd->path); |
9 | 1643 if (newtime > 0 && newtime != imd->mtime) |
1644 { | |
1645 imd->mtime = newtime; | |
1646 image_reload(imd); | |
1647 } | |
1648 | |
1649 return TRUE; | |
1650 } | |
1651 | |
1652 /* image auto refresh on time stamp change, in 1/1000's second, -1 disables */ | |
1653 | |
1654 void image_auto_refresh(ImageWindow *imd, gint interval) | |
1655 { | |
1656 if (!imd) return; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1657 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
9 | 1658 |
1659 if (imd->auto_refresh_id > -1) | |
1660 { | |
1661 g_source_remove(imd->auto_refresh_id); | |
1662 imd->auto_refresh_id = -1; | |
1663 imd->auto_refresh_interval = -1; | |
1664 } | |
1665 | |
1666 if (interval < 0) return; | |
1667 | |
1668 if (interval == 0) interval = IMAGE_AUTO_REFRESH_TIME; | |
1669 | |
1670 imd->auto_refresh_id = g_timeout_add((guint32)interval, image_auto_refresh_cb, imd); | |
1671 imd->auto_refresh_interval = interval; | |
1672 } | |
1673 | |
1674 void image_top_window_set_sync(ImageWindow *imd, gint allow_sync) | |
1675 { | |
1676 imd->top_window_sync = allow_sync; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1677 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1678 g_object_set(G_OBJECT(imd->pr), "window_fit", allow_sync, NULL); |
9 | 1679 } |
1680 | |
1681 void image_background_set_color(ImageWindow *imd, GdkColor *color) | |
1682 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1683 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); |
9 | 1684 } |
1685 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1686 void image_color_profile_set(ImageWindow *imd, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1687 gint input_type, gint screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1688 gint use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1689 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1690 if (!imd) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1691 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1692 if (input_type < 0 || input_type > COLOR_PROFILE_INPUTS || |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1693 screen_type < 0 || screen_type > 1) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1694 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1695 return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1696 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1697 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1698 imd->color_profile_input = input_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1699 imd->color_profile_screen = screen_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1700 imd->color_profile_use_image = use_image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1701 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1702 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1703 gint image_color_profile_get(ImageWindow *imd, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1704 gint *input_type, gint *screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1705 gint *use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1706 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1707 if (!imd) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1708 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1709 if (input_type) *input_type = imd->color_profile_input; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1710 if (screen_type) *screen_type = imd->color_profile_screen; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1711 if (use_image) *use_image = imd->color_profile_use_image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1712 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1713 return TRUE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1714 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1715 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1716 void image_color_profile_set_use(ImageWindow *imd, gint enable) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1717 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1718 if (!imd) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1719 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1720 if (imd->color_profile_enable == enable) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1721 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1722 imd->color_profile_enable = enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1723 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1724 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1725 gint image_color_profile_get_use(ImageWindow *imd) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1726 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1727 if (!imd) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1728 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1729 return imd->color_profile_enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1730 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1731 |
9 | 1732 void image_set_delay_flip(ImageWindow *imd, gint delay) |
1733 { | |
1734 if (!imd || | |
1735 imd->delay_flip == delay) return; | |
1736 | |
1737 imd->delay_flip = delay; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1738 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1739 g_object_set(G_OBJECT(imd->pr), "delay_flip", delay, NULL); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1740 |
9 | 1741 if (!imd->delay_flip && imd->il) |
1742 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1743 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1744 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1745 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1746 if (pr->pixbuf) g_object_unref(pr->pixbuf); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1747 pr->pixbuf = NULL; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1748 |
9 | 1749 image_load_pixbuf_ready(imd); |
1750 } | |
1751 } | |
1752 | |
1753 void image_to_root_window(ImageWindow *imd, gint scaled) | |
1754 { | |
1755 GdkScreen *screen; | |
3 | 1756 GdkWindow *rootwindow; |
1757 GdkPixmap *pixmap; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1758 GdkPixbuf *pixbuf; |
9 | 1759 GdkPixbuf *pb; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1760 gint width, height; |
9 | 1761 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1762 if (!imd) return; |
9 | 1763 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1764 pixbuf = image_get_pixbuf(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1765 if (!pixbuf) return; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1766 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1767 screen = gtk_widget_get_screen(imd->widget); |
9 | 1768 rootwindow = gdk_screen_get_root_window(screen); |
1769 if (gdk_drawable_get_visual(rootwindow) != gdk_visual_get_system()) return; | |
3 | 1770 |
1771 if (scaled) | |
1772 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1773 width = gdk_screen_width(); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1774 height = gdk_screen_height(); |
3 | 1775 } |
1776 else | |
1777 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1778 pixbuf_renderer_get_scaled_size((PixbufRenderer *)imd->pr, &width, &height); |
3 | 1779 } |
1780 | |
334 | 1781 pb = gdk_pixbuf_scale_simple(pixbuf, width, height, (GdkInterpType)options->image.zoom_quality); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1782 |
9 | 1783 gdk_pixbuf_render_pixmap_and_mask (pb, &pixmap, NULL, 128); |
3 | 1784 gdk_window_set_back_pixmap(rootwindow, pixmap, FALSE); |
1785 gdk_window_clear(rootwindow); | |
9 | 1786 g_object_unref(pb); |
1787 g_object_unref(pixmap); | |
3 | 1788 |
1789 gdk_flush(); | |
1790 } | |
1791 | |
127 | 1792 void image_select(ImageWindow *imd, gboolean select) |
1793 { | |
1794 if (imd->has_frame) | |
1795 { | |
151 | 1796 if (select) |
127 | 1797 { |
154 | 1798 gtk_widget_set_state(imd->widget, GTK_STATE_SELECTED); |
151 | 1799 gtk_widget_set_state(imd->pr, GTK_STATE_NORMAL); /* do not propagate */ |
127 | 1800 } |
1801 else | |
154 | 1802 gtk_widget_set_state(imd->widget, GTK_STATE_NORMAL); |
127 | 1803 } |
1804 } | |
1805 | |
1806 | |
174 | 1807 |
1808 void image_set_selectable(ImageWindow *imd, gboolean selectable) | |
1809 { | |
1810 if (imd->has_frame) | |
1811 { | |
1812 if (selectable) | |
1813 { | |
175 | 1814 gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE); |
1815 gtk_container_set_border_width (GTK_CONTAINER (imd->frame), 4); | |
174 | 1816 } |
1817 else | |
1818 { | |
175 | 1819 gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE); |
1820 gtk_container_set_border_width (GTK_CONTAINER (imd->frame), 0); | |
174 | 1821 } |
1822 } | |
1823 } | |
1824 | |
9 | 1825 /* |
1826 *------------------------------------------------------------------- | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1827 * prefs sync |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1828 *------------------------------------------------------------------- |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1829 */ |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1830 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1831 static void image_options_set(ImageWindow *imd) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1832 { |
334 | 1833 g_object_set(G_OBJECT(imd->pr), "zoom_quality", options->image.zoom_quality, |
1834 "zoom_2pass", options->image.zoom_2pass, | |
1835 "zoom_expand", options->image.zoom_to_fit_allow_expand, | |
1836 "dither_quality", options->image.dither_quality, | |
1837 "scroll_reset", options->image.scroll_reset_method, | |
1838 "cache_display", options->image.tile_cache_max, | |
1839 "window_fit", (imd->top_window_sync && options->image.fit_window_to_image), | |
1840 "window_limit", options->image.limit_window_size, | |
1841 "window_limit_value", options->image.max_window_size, | |
1842 "autofit_limit", options->image.limit_autofit_size, | |
1843 "autofit_limit_value", options->image.max_autofit_size, | |
209
ad78ad18523a
configurable frame around image - geeqie_autofit_maxsize.patch by Laurent MONIN
nadvornik
parents:
208
diff
changeset
|
1844 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1845 NULL); |
27
9c24765c2d3a
Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net>
gqview
parents:
26
diff
changeset
|
1846 |
9c24765c2d3a
Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net>
gqview
parents:
26
diff
changeset
|
1847 pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)imd->top_window); |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1848 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1849 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1850 void image_options_sync(void) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1851 { |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1852 GList *work; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1853 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1854 work = image_list; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1855 while (work) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1856 { |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1857 ImageWindow *imd; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1858 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1859 imd = work->data; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1860 work = work->next; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1861 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1862 image_options_set(imd); |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1863 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1864 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1865 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1866 /* |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1867 *------------------------------------------------------------------- |
9 | 1868 * init / destroy |
1869 *------------------------------------------------------------------- | |
1870 */ | |
1871 | |
1872 static void image_free(ImageWindow *imd) | |
1873 { | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1874 image_list = g_list_remove(image_list, imd); |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1875 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1876 image_reset(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1877 |
9 | 1878 image_read_ahead_cancel(imd); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1879 image_post_buffer_set(imd, NULL, NULL, -1); |
9 | 1880 image_auto_refresh(imd, -1); |
1881 | |
138 | 1882 file_data_unref(imd->image_fd); |
9 | 1883 g_free(imd->title); |
1884 g_free(imd->title_right); | |
1885 | |
1886 g_free(imd); | |
1887 } | |
1888 | |
1889 static void image_destroy_cb(GtkObject *widget, gpointer data) | |
1890 { | |
1891 ImageWindow *imd = data; | |
1892 image_free(imd); | |
1893 } | |
1894 | |
151 | 1895 gboolean selectable_frame_expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) |
1896 { | |
1897 gtk_paint_flat_box(widget->style, | |
1898 widget->window, | |
1899 widget->state, | |
1900 GTK_FRAME (widget)->shadow_type, | |
1901 NULL, | |
1902 widget, | |
1903 NULL, | |
174 | 1904 widget->allocation.x + 3, widget->allocation.y + 3, |
1905 widget->allocation.width - 6, widget->allocation.height - 6); | |
151 | 1906 |
1907 | |
1908 return FALSE; | |
1909 } | |
1910 | |
1911 | |
175 | 1912 void image_set_frame(ImageWindow *imd, gboolean frame) |
1913 { | |
1914 frame = !!frame; | |
1915 | |
1916 if (frame == imd->has_frame) return; | |
1917 | |
1918 gtk_widget_hide(imd->pr); | |
1919 | |
1920 if (frame) | |
1921 { | |
1922 imd->frame = gtk_frame_new(NULL); | |
1923 gtk_widget_ref(imd->pr); | |
1924 if (imd->has_frame != -1) gtk_container_remove(GTK_CONTAINER(imd->widget), imd->pr); | |
1925 gtk_container_add(GTK_CONTAINER(imd->frame), imd->pr); | |
1926 gtk_widget_unref(imd->pr); | |
1927 g_signal_connect (G_OBJECT (imd->frame), "expose_event", | |
1928 G_CALLBACK (selectable_frame_expose_cb), NULL); | |
1929 | |
1930 GTK_WIDGET_SET_FLAGS(imd->frame, GTK_CAN_FOCUS); | |
1931 g_signal_connect(G_OBJECT(imd->frame), "focus_in_event", | |
1932 G_CALLBACK(image_focus_in_cb), imd); | |
1933 g_signal_connect(G_OBJECT(imd->frame), "focus_out_event", | |
1934 G_CALLBACK(image_focus_out_cb), imd); | |
1935 | |
1936 g_signal_connect_after(G_OBJECT(imd->frame), "expose_event", | |
1937 G_CALLBACK(image_focus_expose), imd); | |
1938 | |
1939 | |
1940 gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->frame); | |
1941 gtk_widget_show(imd->frame); | |
1942 } | |
1943 else | |
1944 { | |
1945 gtk_widget_ref(imd->pr); | |
1946 if (imd->frame) | |
1947 { | |
1948 gtk_container_remove(GTK_CONTAINER(imd->frame), imd->pr); | |
1949 gtk_widget_destroy(imd->frame); | |
1950 imd->frame = NULL; | |
1951 } | |
1952 gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->pr); | |
1953 gtk_widget_unref(imd->pr); | |
1954 } | |
1955 | |
1956 gtk_widget_show(imd->pr); | |
1957 | |
1958 imd->has_frame = frame; | |
1959 } | |
1960 | |
9 | 1961 ImageWindow *image_new(gint frame) |
1962 { | |
1963 ImageWindow *imd; | |
1964 | |
1965 imd = g_new0(ImageWindow, 1); | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1966 |
9 | 1967 imd->top_window = NULL; |
1968 imd->title = NULL; | |
1969 imd->title_right = NULL; | |
1970 imd->title_show_zoom = FALSE; | |
1971 | |
1972 imd->unknown = TRUE; | |
1973 | |
175 | 1974 imd->has_frame = -1; /* not initialized; for image_set_frame */ |
9 | 1975 imd->top_window_sync = FALSE; |
1976 | |
1977 imd->delay_alter_type = ALTER_NONE; | |
1978 | |
1979 imd->read_ahead_il = NULL; | |
1980 imd->read_ahead_pixbuf = NULL; | |
138 | 1981 imd->read_ahead_fd = NULL; |
9 | 1982 |
1983 imd->completed = FALSE; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1984 imd->state = IMAGE_STATE_NONE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1985 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1986 imd->color_profile_enable = FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1987 imd->color_profile_input = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1988 imd->color_profile_screen = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1989 imd->color_profile_use_image = FALSE; |
9 | 1990 |
1991 imd->auto_refresh_id = -1; | |
1992 imd->auto_refresh_interval = -1; | |
1993 | |
1994 imd->delay_flip = FALSE; | |
1995 | |
1996 imd->func_update = NULL; | |
1997 imd->func_complete = NULL; | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1998 imd->func_tile_request = NULL; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1999 imd->func_tile_dispose = NULL; |
9 | 2000 |
2001 imd->func_button = NULL; | |
2002 imd->func_scroll = NULL; | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
2003 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
2004 imd->orientation = 1; |
9 | 2005 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2006 imd->pr = GTK_WIDGET(pixbuf_renderer_new()); |
9 | 2007 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
2008 image_options_set(imd); |
9 | 2009 |
175 | 2010 |
2011 imd->widget = gtk_vbox_new(0, 0); | |
151 | 2012 |
175 | 2013 image_set_frame(imd, frame); |
9 | 2014 |
175 | 2015 image_set_selectable(imd, 0); |
9 | 2016 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2017 g_signal_connect(G_OBJECT(imd->pr), "clicked", |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2018 G_CALLBACK(image_click_cb), imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2019 g_signal_connect(G_OBJECT(imd->pr), "scroll_notify", |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2020 G_CALLBACK(image_scroll_notify_cb), imd); |
9 | 2021 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2022 g_signal_connect(G_OBJECT(imd->pr), "scroll_event", |
9 | 2023 G_CALLBACK(image_scroll_cb), imd); |
2024 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2025 g_signal_connect(G_OBJECT(imd->pr), "destroy", |
9 | 2026 G_CALLBACK(image_destroy_cb), imd); |
2027 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2028 g_signal_connect(G_OBJECT(imd->pr), "zoom", |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2029 G_CALLBACK(image_zoom_cb), imd); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2030 g_signal_connect(G_OBJECT(imd->pr), "render_complete", |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2031 G_CALLBACK(image_render_complete_cb), imd); |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
2032 g_signal_connect(G_OBJECT(imd->pr), "drag", |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
2033 G_CALLBACK(image_drag_cb), imd); |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2034 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
2035 image_list = g_list_append(image_list, imd); |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
2036 |
9 | 2037 return imd; |
2038 } | |
2039 |