Mercurial > geeqie
annotate src/image.c @ 398:c4080362d619
image post-processing (rotation and color management) moved to
pixbuf-renderer
author | nadvornik |
---|---|
date | Thu, 17 Apr 2008 17:44:54 +0000 |
parents | 0226daf8c30b |
children | 49c1cbe058ae |
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); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
406 } |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
407 else |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
408 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
409 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
|
410 input_type, input_file, |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
411 screen_type, screen_file); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
412 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
413 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
414 if (cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
415 { |
116
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
416 if (start_row > 0) |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
417 { |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
418 cm->row = start_row; |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
419 cm->incremental_sync = TRUE; |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
420 } |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
421 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
422 imd->cm = (gpointer)cm; |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
423 #if 0 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
424 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
|
425 #endif |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
426 return TRUE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
427 } |
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 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
430 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
431 |
9 | 432 static void image_post_process(ImageWindow *imd, gint clamp) |
433 { | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
434 #if 0 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
435 ExifData *exif = NULL; |
109
1818abf306c1
Fri Nov 10 18:11:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
436 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
437 if (!image_get_pixbuf(imd)) return; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
438 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
439 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
|
440 |
334 | 441 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
|
442 (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
|
443 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
181
diff
changeset
|
444 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
|
445 } |
334 | 446 if (options->image.exif_rotate_enable && exif) |
9 | 447 { |
448 gint orientation; | |
449 | |
180 | 450 if (exif_get_integer(exif, "Exif.Image.Orientation", &orientation)) |
9 | 451 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
452 gint rotate = TRUE; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
453 |
9 | 454 /* see http://jpegclub.org/exif_orientation.html |
455 1 2 3 4 5 6 7 8 | |
456 | |
457 888888 888888 88 88 8888888888 88 88 8888888888 | |
458 88 88 88 88 88 88 88 88 88 88 88 88 | |
459 8888 8888 8888 8888 88 8888888888 8888888888 88 | |
460 88 88 88 88 | |
461 88 88 888888 888888 | |
462 */ | |
463 switch (orientation) | |
464 { | |
465 case EXIF_ORIENTATION_TOP_LEFT: | |
466 /* normal -- nothing to do */ | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
467 rotate = FALSE; |
9 | 468 break; |
469 case EXIF_ORIENTATION_TOP_RIGHT: | |
470 /* mirrored */ | |
471 imd->delay_alter_type = ALTER_MIRROR; | |
472 break; | |
473 case EXIF_ORIENTATION_BOTTOM_RIGHT: | |
474 /* upside down */ | |
475 imd->delay_alter_type = ALTER_ROTATE_180; | |
476 break; | |
477 case EXIF_ORIENTATION_BOTTOM_LEFT: | |
478 /* flipped */ | |
479 imd->delay_alter_type = ALTER_FLIP; | |
480 break; | |
481 case EXIF_ORIENTATION_LEFT_TOP: | |
482 /* 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
|
483 rotate = FALSE; |
9 | 484 break; |
485 case EXIF_ORIENTATION_RIGHT_TOP: | |
486 /* rotated -90 (270) */ | |
487 imd->delay_alter_type = ALTER_ROTATE_90; | |
488 break; | |
489 case EXIF_ORIENTATION_RIGHT_BOTTOM: | |
490 /* 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
|
491 rotate = FALSE; |
9 | 492 break; |
493 case EXIF_ORIENTATION_LEFT_BOTTOM: | |
494 /* rotated 90 */ | |
495 imd->delay_alter_type = ALTER_ROTATE_90_CC; | |
496 break; | |
497 default: | |
498 /* 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
|
499 rotate = FALSE; |
9 | 500 break; |
501 } | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
502 |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
503 if (rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO); |
9 | 504 } |
505 } | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
506 if (imd->color_profile_enable) |
9 | 507 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
508 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
|
509 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
510 /* fixme: note error to user */ |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
511 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
|
512 } |
9 | 513 } |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
514 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
515 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
516 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
|
517 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
518 exif_free(exif); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
519 #endif |
9 | 520 } |
521 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
522 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
|
523 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
524 ImageWindow *imd = (ImageWindow *)data; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
525 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
|
526 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
|
527 |
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 void image_alter(ImageWindow *imd, AlterType type) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
531 { |
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 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
|
534 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
|
535 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
|
536 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
|
537 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
|
538 |
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 if (!imd || !imd->pr) return; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
541 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
542 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
|
543 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
544 switch (type) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
545 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
546 case ALTER_ROTATE_90: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
547 imd->orientation = rotate_90[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
548 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
549 case ALTER_ROTATE_90_CC: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
550 imd->orientation = rotate_90_cc[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
551 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
552 case ALTER_ROTATE_180: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
553 imd->orientation = rotate_180[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
554 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
555 case ALTER_MIRROR: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
556 imd->orientation = mirror[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
557 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
558 case ALTER_FLIP: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
559 imd->orientation = flip[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
560 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
561 case ALTER_DESATURATE: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
562 imd->desaturate = !imd->desaturate; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
563 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
564 case ALTER_NONE: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
565 default: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
566 return; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
567 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
568 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
569 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
570 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
571 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
|
572 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
573 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
|
574 } |
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 |
9 | 577 /* |
578 *------------------------------------------------------------------- | |
579 * read ahead (prebuffer) | |
580 *------------------------------------------------------------------- | |
581 */ | |
582 | |
583 static void image_read_ahead_cancel(ImageWindow *imd) | |
584 { | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
585 if (debug) printf("%s read ahead cancelled for :%s\n", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null"); |
9 | 586 |
587 image_loader_free(imd->read_ahead_il); | |
588 imd->read_ahead_il = NULL; | |
589 | |
590 if (imd->read_ahead_pixbuf) g_object_unref(imd->read_ahead_pixbuf); | |
591 imd->read_ahead_pixbuf = NULL; | |
592 | |
138 | 593 file_data_unref(imd->read_ahead_fd); |
594 imd->read_ahead_fd = NULL; | |
9 | 595 } |
596 | |
597 static void image_read_ahead_done_cb(ImageLoader *il, gpointer data) | |
598 { | |
599 ImageWindow *imd = data; | |
600 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
601 if (debug) printf("%s read ahead done for :%s\n", get_exec_time(), imd->read_ahead_fd->path); |
9 | 602 |
603 imd->read_ahead_pixbuf = image_loader_get_pixbuf(imd->read_ahead_il); | |
604 if (imd->read_ahead_pixbuf) | |
605 { | |
606 g_object_ref(imd->read_ahead_pixbuf); | |
607 } | |
608 else | |
609 { | |
610 imd->read_ahead_pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); | |
611 } | |
612 image_loader_free(imd->read_ahead_il); | |
613 imd->read_ahead_il = NULL; | |
614 | |
615 image_complete_util(imd, TRUE); | |
616 } | |
617 | |
618 static void image_read_ahead_error_cb(ImageLoader *il, gpointer data) | |
619 { | |
620 /* we even treat errors as success, maybe at least some of the file was ok */ | |
621 image_read_ahead_done_cb(il, data); | |
622 } | |
623 | |
624 static void image_read_ahead_start(ImageWindow *imd) | |
625 { | |
626 /* already started ? */ | |
138 | 627 if (!imd->read_ahead_fd || imd->read_ahead_il || imd->read_ahead_pixbuf) return; |
9 | 628 |
629 /* still loading ?, do later */ | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
630 if (imd->il /*|| imd->cm*/) return; |
9 | 631 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
632 if (debug) printf("%s read ahead started for :%s\n", get_exec_time(), imd->read_ahead_fd->path); |
9 | 633 |
138 | 634 imd->read_ahead_il = image_loader_new(imd->read_ahead_fd); |
9 | 635 |
636 image_loader_set_error_func(imd->read_ahead_il, image_read_ahead_error_cb, imd); | |
637 if (!image_loader_start(imd->read_ahead_il, image_read_ahead_done_cb, imd)) | |
638 { | |
639 image_read_ahead_cancel(imd); | |
640 image_complete_util(imd, TRUE); | |
641 } | |
642 } | |
643 | |
138 | 644 static void image_read_ahead_set(ImageWindow *imd, FileData *fd) |
9 | 645 { |
138 | 646 if (imd->read_ahead_fd && fd && imd->read_ahead_fd == fd) return; |
9 | 647 |
648 image_read_ahead_cancel(imd); | |
649 | |
138 | 650 imd->read_ahead_fd = file_data_ref(fd); |
9 | 651 |
138 | 652 if (debug) printf("read ahead set to :%s\n", imd->read_ahead_fd->path); |
9 | 653 |
654 image_read_ahead_start(imd); | |
655 } | |
656 | |
657 /* | |
658 *------------------------------------------------------------------- | |
659 * post buffering | |
660 *------------------------------------------------------------------- | |
661 */ | |
662 | |
138 | 663 static void image_post_buffer_set(ImageWindow *imd, FileData *fd, GdkPixbuf *pixbuf, gint color_row) |
9 | 664 { |
138 | 665 file_data_unref(imd->prev_fd); |
9 | 666 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); |
667 | |
138 | 668 if (fd && pixbuf) |
9 | 669 { |
138 | 670 imd->prev_fd = file_data_ref(fd); |
9 | 671 |
672 g_object_ref(pixbuf); | |
673 imd->prev_pixbuf = pixbuf; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
674 imd->prev_color_row = color_row; |
9 | 675 } |
676 else | |
677 { | |
138 | 678 imd->prev_fd = NULL; |
9 | 679 imd->prev_pixbuf = NULL; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
680 imd->prev_color_row = -1; |
9 | 681 } |
682 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
683 if (debug) printf("%s post buffer set: %s\n", get_exec_time(), fd ? fd->path : "null"); |
9 | 684 } |
685 | |
686 static gint image_post_buffer_get(ImageWindow *imd) | |
687 { | |
688 gint success; | |
689 | |
690 if (imd->prev_pixbuf && | |
138 | 691 imd->image_fd && imd->prev_fd && imd->image_fd == imd->prev_fd) |
9 | 692 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
693 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
|
694 if (imd->prev_color_row >= 0) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
695 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
696 ExifData *exif = NULL; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
697 |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
181
diff
changeset
|
698 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
|
699 // 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
|
700 exif_free(exif); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
701 } |
9 | 702 success = TRUE; |
703 } | |
704 else | |
705 { | |
706 success = FALSE; | |
707 } | |
708 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
709 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); |
9 | 710 imd->prev_pixbuf = NULL; |
711 | |
138 | 712 file_data_unref(imd->prev_fd); |
713 imd->prev_fd = NULL; | |
9 | 714 |
715 return success; | |
716 } | |
717 | |
718 /* | |
719 *------------------------------------------------------------------- | |
720 * loading | |
721 *------------------------------------------------------------------- | |
722 */ | |
723 | |
724 static void image_load_pixbuf_ready(ImageWindow *imd) | |
725 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
726 if (image_get_pixbuf(imd) || !imd->il) return; |
9 | 727 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
728 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 729 } |
730 | |
731 static void image_load_area_cb(ImageLoader *il, guint x, guint y, guint w, guint h, gpointer data) | |
732 { | |
733 ImageWindow *imd = data; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
734 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
735 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
736 pr = (PixbufRenderer *)imd->pr; |
9 | 737 |
738 if (imd->delay_flip && | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
739 pr->pixbuf != image_loader_get_pixbuf(il)) |
9 | 740 { |
741 return; | |
742 } | |
743 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
744 if (!pr->pixbuf) image_load_pixbuf_ready(imd); |
9 | 745 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
746 pixbuf_renderer_area_changed(pr, x, y, w, h); |
9 | 747 } |
748 | |
749 static void image_load_done_cb(ImageLoader *il, gpointer data) | |
1 | 750 { |
751 ImageWindow *imd = data; | |
9 | 752 |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
753 if (debug) printf ("%s image done\n", get_exec_time()); |
9 | 754 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
755 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
|
756 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
|
757 |
9 | 758 if (imd->delay_flip && |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
759 image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) |
9 | 760 { |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
29
diff
changeset
|
761 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
|
762 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 763 } |
764 | |
765 image_loader_free(imd->il); | |
766 imd->il = NULL; | |
767 | |
768 image_post_process(imd, TRUE); | |
769 | |
770 image_read_ahead_start(imd); | |
771 } | |
772 | |
773 static void image_load_error_cb(ImageLoader *il, gpointer data) | |
774 { | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
775 if (debug) printf ("%s image error\n", get_exec_time()); |
9 | 776 |
777 /* even on error handle it like it was done, | |
778 * since we have a pixbuf with _something_ */ | |
779 | |
780 image_load_done_cb(il, data); | |
781 } | |
782 | |
783 #ifdef IMAGE_THROTTLE_LARGER_IMAGES | |
784 static void image_load_buffer_throttle(ImageLoader *il) | |
785 { | |
786 if (!il || il->bytes_total < IMAGE_THROTTLE_THRESHOLD) return; | |
787 | |
788 /* Larger image files usually have larger chunks of data per pixel... | |
789 * So increase the buffer read size so that the rendering chunks called | |
790 * are also larger. | |
791 */ | |
792 | |
793 image_loader_set_buffer_size(il, IMAGE_LOAD_BUFFER_COUNT * IMAGE_THROTTLE_FACTOR); | |
794 } | |
795 #endif | |
796 | |
797 /* this read ahead is located here merely for the callbacks, above */ | |
798 | |
799 static gint image_read_ahead_check(ImageWindow *imd) | |
800 { | |
138 | 801 if (!imd->read_ahead_fd) return FALSE; |
9 | 802 if (imd->il) return FALSE; |
803 | |
138 | 804 if (!imd->image_fd || imd->read_ahead_fd != imd->image_fd) |
9 | 805 { |
806 image_read_ahead_cancel(imd); | |
807 return FALSE; | |
808 } | |
809 | |
810 if (imd->read_ahead_il) | |
811 { | |
812 imd->il = imd->read_ahead_il; | |
813 imd->read_ahead_il = NULL; | |
814 | |
815 /* override the old signals */ | |
816 image_loader_set_area_ready_func(imd->il, image_load_area_cb, imd); | |
817 image_loader_set_error_func(imd->il, image_load_error_cb, imd); | |
818 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT); | |
819 | |
820 #ifdef IMAGE_THROTTLE_LARGER_IMAGES | |
821 image_load_buffer_throttle(imd->il); | |
822 #endif | |
823 | |
824 /* do this one directly (probably should add a set func) */ | |
825 imd->il->func_done = image_load_done_cb; | |
826 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
827 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
|
828 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
|
829 |
9 | 830 if (!imd->delay_flip) |
831 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
832 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd)); |
9 | 833 } |
834 | |
835 image_read_ahead_cancel(imd); | |
836 return TRUE; | |
837 } | |
838 else if (imd->read_ahead_pixbuf) | |
839 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
840 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
|
841 g_object_unref(imd->read_ahead_pixbuf); |
9 | 842 imd->read_ahead_pixbuf = NULL; |
843 | |
844 image_read_ahead_cancel(imd); | |
845 | |
846 image_post_process(imd, FALSE); | |
847 return TRUE; | |
848 } | |
849 | |
850 image_read_ahead_cancel(imd); | |
851 return FALSE; | |
852 } | |
853 | |
138 | 854 static gint image_load_begin(ImageWindow *imd, FileData *fd) |
9 | 855 { |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
856 if (debug) printf ("%s image begin \n", get_exec_time()); |
9 | 857 |
858 if (imd->il) return FALSE; | |
859 | |
860 imd->completed = FALSE; | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
861 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL); |
9 | 862 |
863 if (image_post_buffer_get(imd)) | |
864 { | |
138 | 865 if (debug) printf("from post buffer: %s\n", imd->image_fd->path); |
9 | 866 return TRUE; |
867 } | |
868 | |
869 if (image_read_ahead_check(imd)) | |
870 { | |
138 | 871 if (debug) printf("from read ahead buffer: %s\n", imd->image_fd->path); |
9 | 872 return TRUE; |
873 } | |
874 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
875 if (!imd->delay_flip && image_get_pixbuf(imd)) |
9 | 876 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
877 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
878 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
879 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
880 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
|
881 pr->pixbuf = NULL; |
9 | 882 } |
883 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
884 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
|
885 |
138 | 886 imd->il = image_loader_new(fd); |
9 | 887 |
888 image_loader_set_area_ready_func(imd->il, image_load_area_cb, imd); | |
889 image_loader_set_error_func(imd->il, image_load_error_cb, imd); | |
890 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT); | |
891 | |
892 if (!image_loader_start(imd->il, image_load_done_cb, imd)) | |
893 { | |
894 if (debug) printf("image start error\n"); | |
895 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
896 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
|
897 |
9 | 898 image_loader_free(imd->il); |
899 imd->il = NULL; | |
900 | |
901 image_complete_util(imd, FALSE); | |
902 | |
903 return FALSE; | |
904 } | |
905 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
906 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
|
907 |
9 | 908 #ifdef IMAGE_THROTTLE_LARGER_IMAGES |
909 image_load_buffer_throttle(imd->il); | |
910 #endif | |
911 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
912 if (!imd->delay_flip && !image_get_pixbuf(imd)) image_load_pixbuf_ready(imd); |
9 | 913 |
914 return TRUE; | |
915 } | |
916 | |
917 static void image_reset(ImageWindow *imd) | |
918 { | |
919 /* stops anything currently being done */ | |
920 | |
386
0226daf8c30b
in debug mode print time information on selected events
nadvornik
parents:
334
diff
changeset
|
921 if (debug) printf("%s image reset\n", get_exec_time()); |
9 | 922 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
923 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
|
924 |
9 | 925 image_loader_free(imd->il); |
926 imd->il = NULL; | |
927 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
928 color_man_free((ColorMan *)imd->cm); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
929 imd->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
930 |
9 | 931 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
|
932 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
933 image_state_set(imd, IMAGE_STATE_NONE); |
9 | 934 } |
935 | |
936 /* | |
937 *------------------------------------------------------------------- | |
938 * image changer | |
939 *------------------------------------------------------------------- | |
940 */ | |
941 | |
942 static void image_change_complete(ImageWindow *imd, gdouble zoom, gint new) | |
943 { | |
944 image_reset(imd); | |
945 | |
138 | 946 if (imd->image_fd && isfile(imd->image_fd->path)) |
9 | 947 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
948 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
949 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
950 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
951 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
|
952 |
138 | 953 if (image_load_begin(imd, imd->image_fd)) |
9 | 954 { |
955 imd->unknown = FALSE; | |
956 } | |
957 else | |
958 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
959 GdkPixbuf *pixbuf; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
960 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
961 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
|
962 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
|
963 g_object_unref(pixbuf); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
964 |
9 | 965 imd->unknown = TRUE; |
966 } | |
138 | 967 imd->size = filesize(imd->image_fd->path); |
968 imd->mtime = filetime(imd->image_fd->path); | |
9 | 969 } |
970 else | |
971 { | |
138 | 972 if (imd->image_fd) |
9 | 973 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
974 GdkPixbuf *pixbuf; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
975 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
976 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
|
977 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
|
978 g_object_unref(pixbuf); |
138 | 979 imd->mtime = filetime(imd->image_fd->path); |
9 | 980 } |
981 else | |
982 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
983 image_change_pixbuf(imd, NULL, zoom); |
9 | 984 imd->mtime = 0; |
985 } | |
986 imd->unknown = TRUE; | |
987 imd->size = 0; | |
988 } | |
989 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
990 image_update_util(imd); |
9 | 991 } |
992 | |
138 | 993 static void image_change_real(ImageWindow *imd, FileData *fd, |
9 | 994 CollectionData *cd, CollectInfo *info, gdouble zoom) |
995 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
996 GdkPixbuf *pixbuf; |
9 | 997 GdkPixbuf *prev_pixbuf = NULL; |
138 | 998 FileData *prev_fd = NULL; |
9 | 999 gint prev_clear = FALSE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1000 gint prev_color_row = -1; |
9 | 1001 |
1002 imd->collection = cd; | |
1003 imd->collection_info = info; | |
1004 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1005 pixbuf = image_get_pixbuf(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1006 |
334 | 1007 if (options->image.enable_read_ahead && imd->image_fd && pixbuf) |
9 | 1008 { |
1009 if (imd->il) | |
1010 { | |
1011 /* current image is not finished */ | |
1012 prev_clear = TRUE; | |
1013 } | |
1014 else | |
1015 { | |
138 | 1016 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
|
1017 prev_pixbuf = pixbuf; |
9 | 1018 g_object_ref(prev_pixbuf); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1019 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1020 if (imd->cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1021 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1022 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1023 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1024 cm = (ColorMan *)imd->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1025 prev_color_row = cm->row; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1026 } |
9 | 1027 } |
1028 } | |
1029 | |
138 | 1030 file_data_unref(imd->image_fd); |
1031 imd->image_fd = file_data_ref(fd); | |
9 | 1032 |
1033 image_change_complete(imd, zoom, TRUE); | |
1034 | |
1035 if (prev_pixbuf) | |
1036 { | |
138 | 1037 image_post_buffer_set(imd, prev_fd, prev_pixbuf, prev_color_row); |
1038 file_data_unref(prev_fd); | |
9 | 1039 g_object_unref(prev_pixbuf); |
1040 } | |
1041 else if (prev_clear) | |
1042 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1043 image_post_buffer_set(imd, NULL, NULL, -1); |
9 | 1044 } |
1045 | |
1046 image_update_title(imd); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1047 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1048 } |
1049 | |
1050 /* | |
1051 *------------------------------------------------------------------- | |
1052 * focus stuff | |
1053 *------------------------------------------------------------------- | |
1054 */ | |
1055 | |
1056 static void image_focus_paint(ImageWindow *imd, gint has_focus, GdkRectangle *area) | |
1057 { | |
1058 GtkWidget *widget; | |
1059 | |
1060 widget = imd->widget; | |
1061 if (!widget->window) return; | |
1062 | |
1063 if (has_focus) | |
1064 { | |
1065 gtk_paint_focus (widget->style, widget->window, GTK_STATE_ACTIVE, | |
1066 area, widget, "image_window", | |
1067 widget->allocation.x, widget->allocation.y, | |
1068 widget->allocation.width - 1, widget->allocation.height - 1); | |
1069 } | |
1070 else | |
1071 { | |
1072 gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, | |
1073 area, widget, "image_window", | |
1074 widget->allocation.x, widget->allocation.y, | |
1075 widget->allocation.width - 1, widget->allocation.height - 1); | |
1076 } | |
1077 } | |
1078 | |
1079 static gint image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) | |
1080 { | |
1081 ImageWindow *imd = data; | |
1082 | |
1083 image_focus_paint(imd, GTK_WIDGET_HAS_FOCUS(widget), &event->area); | |
1084 return TRUE; | |
1085 } | |
1086 | |
1087 static gint image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
1088 { | |
1089 ImageWindow *imd = data; | |
1090 | |
1091 GTK_WIDGET_SET_FLAGS(imd->widget, GTK_HAS_FOCUS); | |
1092 image_focus_paint(imd, TRUE, NULL); | |
1093 | |
1094 return TRUE; | |
1095 } | |
1096 | |
1097 static gint image_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
1098 { | |
1099 ImageWindow *imd = data; | |
1100 | |
1101 GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS); | |
1102 image_focus_paint(imd, FALSE, NULL); | |
1103 | |
1104 return TRUE; | |
1105 } | |
1106 | |
1107 gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y, | |
1108 gint relative, gint always) | |
1109 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1110 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, relative, always); |
9 | 1111 } |
1112 | |
1113 void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y) | |
1114 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1115 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y); |
9 | 1116 } |
1117 | |
1118 gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y) | |
1119 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1120 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y); |
9 | 1121 } |
1122 | |
1123 void image_overlay_remove(ImageWindow *imd, gint id) | |
1124 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1125 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id); |
9 | 1126 } |
1127 | |
1128 static gint image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data) | |
1129 { | |
1130 ImageWindow *imd = data; | |
1131 | |
1132 if (imd->func_scroll && | |
1133 event && event->type == GDK_SCROLL) | |
1134 { | |
1135 imd->func_scroll(imd, event->direction, event->time, | |
1136 event->x, event->y, event->state, imd->data_scroll); | |
1137 return TRUE; | |
1138 } | |
1139 | |
1140 return FALSE; | |
1141 } | |
1142 | |
1143 /* | |
1144 *------------------------------------------------------------------- | |
1145 * public interface | |
1146 *------------------------------------------------------------------- | |
1147 */ | |
1148 | |
1149 void image_attach_window(ImageWindow *imd, GtkWidget *window, | |
1150 const gchar *title, const gchar *title_right, gint show_zoom) | |
1 | 1151 { |
1152 imd->top_window = window; | |
1153 g_free(imd->title); | |
9 | 1154 imd->title = g_strdup(title); |
1155 g_free(imd->title_right); | |
1156 imd->title_right = g_strdup(title_right); | |
1157 imd->title_show_zoom = show_zoom; | |
1158 | |
334 | 1159 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
|
1160 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1161 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
|
1162 |
9 | 1163 image_update_title(imd); |
1164 } | |
1165 | |
1166 void image_set_update_func(ImageWindow *imd, | |
1167 void (*func)(ImageWindow *imd, gpointer data), | |
1168 gpointer data) | |
1169 { | |
1170 imd->func_update = func; | |
1171 imd->data_update = data; | |
1 | 1172 } |
1173 | |
9 | 1174 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
|
1175 void (*func)(ImageWindow *imd, gint preload, gpointer data), |
9 | 1176 gpointer data) |
1 | 1177 { |
9 | 1178 imd->func_complete = func; |
1179 imd->data_complete = data; | |
1 | 1180 } |
1181 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1182 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
|
1183 void (*func)(ImageWindow *imd, ImageState state, gpointer data), |
9 | 1184 gpointer data) |
1 | 1185 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1186 imd->func_state = func; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1187 imd->data_state = data; |
9 | 1188 } |
1189 | |
1190 | |
1191 void image_set_button_func(ImageWindow *imd, | |
1192 void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gpointer), | |
1193 gpointer data) | |
1194 { | |
1195 imd->func_button = func; | |
1196 imd->data_button = data; | |
1197 } | |
1198 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1199 void image_set_drag_func(ImageWindow *imd, |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1200 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
|
1201 gpointer data) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1202 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1203 imd->func_drag = func; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1204 imd->data_drag = data; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1205 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1206 |
9 | 1207 void image_set_scroll_func(ImageWindow *imd, |
1208 void (*func)(ImageWindow *, GdkScrollDirection direction, guint32 time, gdouble x, gdouble y, guint state, gpointer), | |
1209 gpointer data) | |
1 | 1210 { |
9 | 1211 imd->func_scroll = func; |
1212 imd->data_scroll = data; | |
1 | 1213 } |
1214 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1215 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
|
1216 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
|
1217 gpointer data) |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1218 { |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1219 imd->func_scroll_notify = func; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1220 imd->data_scroll_notify = data; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1221 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1222 |
9 | 1223 /* path, name */ |
1224 | |
1225 const gchar *image_get_path(ImageWindow *imd) | |
1226 { | |
138 | 1227 if (imd->image_fd == NULL) return NULL; |
1228 return imd->image_fd->path; | |
9 | 1229 } |
1230 | |
1231 const gchar *image_get_name(ImageWindow *imd) | |
1232 { | |
138 | 1233 if (imd->image_fd == NULL) return NULL; |
1234 return imd->image_fd->name; | |
1235 } | |
1236 | |
1237 FileData *image_get_fd(ImageWindow *imd) | |
1238 { | |
1239 return imd->image_fd; | |
9 | 1240 } |
1241 | |
1242 /* merely changes path string, does not change the image! */ | |
138 | 1243 void image_set_fd(ImageWindow *imd, FileData *fd) |
1 | 1244 { |
138 | 1245 file_data_unref(imd->image_fd); |
1246 imd->image_fd = file_data_ref(fd); | |
9 | 1247 |
1248 image_update_title(imd); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1249 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1250 } |
1251 | |
1252 /* load a new image */ | |
1253 | |
138 | 1254 void image_change_fd(ImageWindow *imd, FileData *fd, gdouble zoom) |
9 | 1255 { |
138 | 1256 if (imd->image_fd == fd) return; |
9 | 1257 |
138 | 1258 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
|
1259 } |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1260 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1261 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
|
1262 { |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1263 return pixbuf_renderer_get_pixbuf((PixbufRenderer *)imd->pr); |
9 | 1264 } |
1265 | |
1266 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom) | |
1267 { | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1268 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1269 ExifData *exif = NULL; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1270 gint orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1271 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1272 if (options->image.exif_rotate_enable || |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1273 (imd->color_profile_enable && imd->color_profile_use_image) ) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1274 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1275 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
|
1276 } |
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 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
|
1279 imd->orientation = orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1280 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1281 imd->orientation = 1; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1282 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1283 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
|
1284 if (imd->cm) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1285 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1286 color_man_free(imd->cm); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1287 imd->cm = NULL; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1288 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1289 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1290 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
|
1291 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1292 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1293 if (imd->color_profile_enable) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1294 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1295 if (!image_post_process_color(imd, 0, exif, FALSE)) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1296 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1297 /* fixme: note error to user */ |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1298 // image_state_set(imd, IMAGE_STATE_COLOR_ADJ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1299 } |
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 exif_free(exif); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1303 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1304 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1305 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
|
1306 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1307 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1308 } |
1309 | |
1310 void image_change_from_collection(ImageWindow *imd, CollectionData *cd, CollectInfo *info, gdouble zoom) | |
1311 { | |
1312 if (!cd || !info || !g_list_find(cd->list, info)) return; | |
1313 | |
138 | 1314 image_change_real(imd, info->fd, cd, info, zoom); |
9 | 1315 } |
1316 | |
1317 CollectionData *image_get_collection(ImageWindow *imd, CollectInfo **info) | |
1318 { | |
1319 if (collection_to_number(imd->collection) >= 0) | |
1320 { | |
1321 if (g_list_find(imd->collection->list, imd->collection_info) != NULL) | |
1322 { | |
1323 if (info) *info = imd->collection_info; | |
1324 } | |
1325 else | |
1326 { | |
1327 if (info) *info = NULL; | |
1328 } | |
1329 return imd->collection; | |
1330 } | |
1331 | |
1332 if (info) *info = NULL; | |
1333 return NULL; | |
1334 } | |
1335 | |
1336 static void image_loader_sync_data(ImageLoader *il, gpointer data) | |
1337 { | |
1338 /* change data for the callbacks directly */ | |
1339 | |
1340 il->data_area_ready = data; | |
1341 il->data_error = data; | |
1342 il->data_done = data; | |
1343 il->data_percent = data; | |
1 | 1344 } |
1345 | |
9 | 1346 /* 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
|
1347 * it moves most data from source to imd |
9 | 1348 */ |
1349 void image_change_from_image(ImageWindow *imd, ImageWindow *source) | |
1350 { | |
1351 if (imd == source) return; | |
1352 | |
1353 imd->unknown = source->unknown; | |
1354 | |
1355 imd->collection = source->collection; | |
1356 imd->collection_info = source->collection_info; | |
1357 imd->size = source->size; | |
1358 imd->mtime = source->mtime; | |
1359 | |
138 | 1360 image_set_fd(imd, image_get_fd(source)); |
9 | 1361 |
1362 image_loader_free(imd->il); | |
1363 imd->il = NULL; | |
1364 | |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1365 if (source->il) |
9 | 1366 { |
1367 imd->il = source->il; | |
1368 source->il = NULL; | |
1369 | |
1370 image_loader_sync_data(imd->il, imd); | |
1371 | |
1372 imd->delay_alter_type = source->delay_alter_type; | |
1373 source->delay_alter_type = ALTER_NONE; | |
1374 } | |
1375 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1376 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
|
1377 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
|
1378 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
|
1379 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
|
1380 color_man_free((ColorMan *)imd->cm); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1381 imd->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1382 if (source->cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1383 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1384 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1385 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1386 imd->cm = source->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1387 source->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1388 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1389 cm = (ColorMan *)imd->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1390 cm->imd = imd; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1391 cm->func_done_data = imd; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1392 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1393 |
9 | 1394 image_loader_free(imd->read_ahead_il); |
1395 imd->read_ahead_il = source->read_ahead_il; | |
1396 source->read_ahead_il = NULL; | |
1397 if (imd->read_ahead_il) image_loader_sync_data(imd->read_ahead_il, imd); | |
1398 | |
1399 if (imd->read_ahead_pixbuf) g_object_unref(imd->read_ahead_pixbuf); | |
1400 imd->read_ahead_pixbuf = source->read_ahead_pixbuf; | |
1401 source->read_ahead_pixbuf = NULL; | |
1402 | |
138 | 1403 file_data_unref(imd->read_ahead_fd); |
1404 imd->read_ahead_fd = source->read_ahead_fd; | |
1405 source->read_ahead_fd = NULL; | |
9 | 1406 |
1407 if (imd->prev_pixbuf) g_object_unref(imd->prev_pixbuf); | |
1408 imd->prev_pixbuf = source->prev_pixbuf; | |
1409 source->prev_pixbuf = NULL; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1410 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
|
1411 source->prev_color_row = -1; |
9 | 1412 |
138 | 1413 file_data_unref(imd->prev_fd); |
1414 imd->prev_fd = source->prev_fd; | |
1415 source->prev_fd = NULL; | |
9 | 1416 |
1417 imd->completed = source->completed; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1418 imd->state = source->state; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1419 source->state = IMAGE_STATE_NONE; |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1420 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1421 imd->orientation = source->orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1422 imd->desaturate = source->desaturate; |
9 | 1423 |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1424 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
|
1425 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1426 if (imd->cm || imd->desaturate) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1427 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
|
1428 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1429 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
|
1430 |
9 | 1431 } |
1432 | |
1433 /* manipulation */ | |
1434 | |
1435 void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height) | |
1436 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1437 pixbuf_renderer_area_changed((PixbufRenderer *)imd->pr, x, y, width, height); |
9 | 1438 } |
1439 | |
1440 void image_reload(ImageWindow *imd) | |
1441 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1442 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
|
1443 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1444 image_change_complete(imd, image_zoom_get(imd), FALSE); |
9 | 1445 } |
1446 | |
1447 void image_scroll(ImageWindow *imd, gint x, gint y) | |
1448 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1449 pixbuf_renderer_scroll((PixbufRenderer *)imd->pr, x, y); |
9 | 1450 } |
1451 | |
13
ef790149ae21
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
12
diff
changeset
|
1452 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
|
1453 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
|
1454 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1455 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
|
1456 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1457 |
131 | 1458 void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y) |
1459 { | |
1460 pixbuf_renderer_get_scroll_center(PIXBUF_RENDERER(imd->pr), x, y); | |
1461 } | |
1462 | |
1463 void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y) | |
1464 { | |
1465 pixbuf_renderer_set_scroll_center(PIXBUF_RENDERER(imd->pr), x, y); | |
1466 } | |
1467 | |
1468 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1469 #if 0 |
9 | 1470 void image_alter(ImageWindow *imd, AlterType type) |
1 | 1471 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1472 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
|
1473 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1474 if (imd->il || imd->cm) |
9 | 1475 { |
1476 /* still loading, wait till done */ | |
1477 imd->delay_alter_type = type; | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1478 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
|
1479 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1480 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
|
1481 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1482 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
|
1483 } |
9 | 1484 return; |
1485 } | |
1486 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
1487 image_alter_real(imd, type, TRUE); |
9 | 1488 } |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1489 #endif |
9 | 1490 |
1491 void image_zoom_adjust(ImageWindow *imd, gdouble increment) | |
1492 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1493 pixbuf_renderer_zoom_adjust((PixbufRenderer *)imd->pr, increment); |
9 | 1494 } |
1495 | |
1496 void image_zoom_adjust_at_point(ImageWindow *imd, gdouble increment, gint x, gint y) | |
1497 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1498 pixbuf_renderer_zoom_adjust_at_point((PixbufRenderer *)imd->pr, increment, x, y); |
9 | 1499 } |
1500 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1501 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
|
1502 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1503 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
|
1504 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1505 |
9 | 1506 void image_zoom_set(ImageWindow *imd, gdouble zoom) |
1507 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1508 pixbuf_renderer_zoom_set((PixbufRenderer *)imd->pr, zoom); |
9 | 1509 } |
1510 | |
1511 void image_zoom_set_fill_geometry(ImageWindow *imd, gint vertical) | |
1512 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1513 PixbufRenderer *pr; |
9 | 1514 gdouble zoom; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1515 gint width, height; |
9 | 1516 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1517 pr = (PixbufRenderer *)imd->pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1518 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1519 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
|
1520 !pixbuf_renderer_get_image_size(pr, &width, &height)) return; |
9 | 1521 |
1522 if (vertical) | |
1523 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1524 zoom = (gdouble)pr->window_height / height; |
9 | 1525 } |
1526 else | |
1527 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1528 zoom = (gdouble)pr->window_width / width; |
9 | 1529 } |
1530 | |
1531 if (zoom < 1.0) | |
1532 { | |
1533 zoom = 0.0 - 1.0 / zoom; | |
1 | 1534 } |
9 | 1535 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1536 pixbuf_renderer_zoom_set(pr, zoom); |
9 | 1537 } |
1538 | |
1539 gdouble image_zoom_get(ImageWindow *imd) | |
1540 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1541 return pixbuf_renderer_zoom_get((PixbufRenderer *)imd->pr); |
9 | 1542 } |
1543 | |
1544 gdouble image_zoom_get_real(ImageWindow *imd) | |
1545 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1546 return pixbuf_renderer_zoom_get_scale((PixbufRenderer *)imd->pr); |
9 | 1547 } |
1548 | |
1549 gchar *image_zoom_get_as_text(ImageWindow *imd) | |
1550 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1551 gdouble zoom; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1552 gdouble scale; |
9 | 1553 gdouble l = 1.0; |
1554 gdouble r = 1.0; | |
1555 gint pl = 0; | |
1556 gint pr = 0; | |
1557 gchar *approx = " "; | |
1558 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1559 zoom = image_zoom_get(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1560 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
|
1561 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1562 if (zoom > 0.0) |
1 | 1563 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1564 l = zoom; |
9 | 1565 } |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1566 else if (zoom < 0.0) |
9 | 1567 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1568 r = 0.0 - zoom; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1569 } |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1570 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
|
1571 { |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1572 if (scale >= 1.0) |
9 | 1573 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1574 l = scale; |
9 | 1575 } |
1576 else | |
1577 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1578 r = 1.0 / scale; |
9 | 1579 } |
1580 approx = " ~"; | |
1581 } | |
1582 | |
1583 if (rint(l) != l) pl = 1; | |
1584 if (rint(r) != r) pr = 1; | |
1585 | |
1586 return g_strdup_printf("%.*f :%s%.*f", pl, l, approx, pr, r); | |
1587 } | |
1588 | |
1589 gdouble image_zoom_get_default(ImageWindow *imd, gint mode) | |
1590 { | |
1591 gdouble zoom; | |
1592 | |
1593 if (mode == ZOOM_RESET_ORIGINAL) | |
1594 { | |
1595 zoom = 1.0; | |
1596 } | |
1597 else if (mode == ZOOM_RESET_FIT_WINDOW) | |
1598 { | |
1599 zoom = 0.0; | |
1 | 1600 } |
1601 else | |
1602 { | |
1603 if (imd) | |
1604 { | |
9 | 1605 zoom = image_zoom_get(imd); |
1 | 1606 } |
1607 else | |
1608 { | |
9 | 1609 zoom = 1.0; |
1 | 1610 } |
1611 } | |
1612 | |
1613 return zoom; | |
1614 } | |
1615 | |
9 | 1616 /* read ahead */ |
1617 | |
138 | 1618 void image_prebuffer_set(ImageWindow *imd, FileData *fd) |
9 | 1619 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1620 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
|
1621 |
138 | 1622 if (fd) |
9 | 1623 { |
138 | 1624 image_read_ahead_set(imd, fd); |
9 | 1625 } |
1626 else | |
1627 { | |
1628 image_read_ahead_cancel(imd); | |
1629 } | |
1630 } | |
1631 | |
1632 static gint image_auto_refresh_cb(gpointer data) | |
1633 { | |
1634 ImageWindow *imd = data; | |
1635 time_t newtime; | |
1636 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1637 if (!imd || !image_get_pixbuf(imd) || |
138 | 1638 imd->il || !imd->image_fd || |
320 | 1639 !options->update_on_time_change) return TRUE; |
9 | 1640 |
138 | 1641 newtime = filetime(imd->image_fd->path); |
9 | 1642 if (newtime > 0 && newtime != imd->mtime) |
1643 { | |
1644 imd->mtime = newtime; | |
1645 image_reload(imd); | |
1646 } | |
1647 | |
1648 return TRUE; | |
1649 } | |
1650 | |
1651 /* image auto refresh on time stamp change, in 1/1000's second, -1 disables */ | |
1652 | |
1653 void image_auto_refresh(ImageWindow *imd, gint interval) | |
1654 { | |
1655 if (!imd) return; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1656 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
9 | 1657 |
1658 if (imd->auto_refresh_id > -1) | |
1659 { | |
1660 g_source_remove(imd->auto_refresh_id); | |
1661 imd->auto_refresh_id = -1; | |
1662 imd->auto_refresh_interval = -1; | |
1663 } | |
1664 | |
1665 if (interval < 0) return; | |
1666 | |
1667 if (interval == 0) interval = IMAGE_AUTO_REFRESH_TIME; | |
1668 | |
1669 imd->auto_refresh_id = g_timeout_add((guint32)interval, image_auto_refresh_cb, imd); | |
1670 imd->auto_refresh_interval = interval; | |
1671 } | |
1672 | |
1673 void image_top_window_set_sync(ImageWindow *imd, gint allow_sync) | |
1674 { | |
1675 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
|
1676 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1677 g_object_set(G_OBJECT(imd->pr), "window_fit", allow_sync, NULL); |
9 | 1678 } |
1679 | |
1680 void image_background_set_color(ImageWindow *imd, GdkColor *color) | |
1681 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1682 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); |
9 | 1683 } |
1684 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1685 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
|
1686 gint input_type, gint screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1687 gint use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1688 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1689 if (!imd) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1690 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1691 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
|
1692 screen_type < 0 || screen_type > 1) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1693 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1694 return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1695 } |
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 imd->color_profile_input = input_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1698 imd->color_profile_screen = screen_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1699 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
|
1700 } |
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 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
|
1703 gint *input_type, gint *screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1704 gint *use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1705 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1706 if (!imd) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1707 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1708 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
|
1709 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
|
1710 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
|
1711 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1712 return TRUE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1713 } |
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 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
|
1716 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1717 if (!imd) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1718 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1719 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
|
1720 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1721 imd->color_profile_enable = enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1722 } |
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 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
|
1725 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1726 if (!imd) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1727 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1728 return imd->color_profile_enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1729 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1730 |
9 | 1731 void image_set_delay_flip(ImageWindow *imd, gint delay) |
1732 { | |
1733 if (!imd || | |
1734 imd->delay_flip == delay) return; | |
1735 | |
1736 imd->delay_flip = delay; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1737 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1738 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
|
1739 |
9 | 1740 if (!imd->delay_flip && imd->il) |
1741 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1742 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1743 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1744 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1745 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
|
1746 pr->pixbuf = NULL; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1747 |
9 | 1748 image_load_pixbuf_ready(imd); |
1749 } | |
1750 } | |
1751 | |
1752 void image_to_root_window(ImageWindow *imd, gint scaled) | |
1753 { | |
1754 GdkScreen *screen; | |
3 | 1755 GdkWindow *rootwindow; |
1756 GdkPixmap *pixmap; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1757 GdkPixbuf *pixbuf; |
9 | 1758 GdkPixbuf *pb; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1759 gint width, height; |
9 | 1760 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1761 if (!imd) return; |
9 | 1762 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1763 pixbuf = image_get_pixbuf(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1764 if (!pixbuf) return; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1765 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1766 screen = gtk_widget_get_screen(imd->widget); |
9 | 1767 rootwindow = gdk_screen_get_root_window(screen); |
1768 if (gdk_drawable_get_visual(rootwindow) != gdk_visual_get_system()) return; | |
3 | 1769 |
1770 if (scaled) | |
1771 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1772 width = gdk_screen_width(); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1773 height = gdk_screen_height(); |
3 | 1774 } |
1775 else | |
1776 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1777 pixbuf_renderer_get_scaled_size((PixbufRenderer *)imd->pr, &width, &height); |
3 | 1778 } |
1779 | |
334 | 1780 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
|
1781 |
9 | 1782 gdk_pixbuf_render_pixmap_and_mask (pb, &pixmap, NULL, 128); |
3 | 1783 gdk_window_set_back_pixmap(rootwindow, pixmap, FALSE); |
1784 gdk_window_clear(rootwindow); | |
9 | 1785 g_object_unref(pb); |
1786 g_object_unref(pixmap); | |
3 | 1787 |
1788 gdk_flush(); | |
1789 } | |
1790 | |
127 | 1791 void image_select(ImageWindow *imd, gboolean select) |
1792 { | |
1793 if (imd->has_frame) | |
1794 { | |
151 | 1795 if (select) |
127 | 1796 { |
154 | 1797 gtk_widget_set_state(imd->widget, GTK_STATE_SELECTED); |
151 | 1798 gtk_widget_set_state(imd->pr, GTK_STATE_NORMAL); /* do not propagate */ |
127 | 1799 } |
1800 else | |
154 | 1801 gtk_widget_set_state(imd->widget, GTK_STATE_NORMAL); |
127 | 1802 } |
1803 } | |
1804 | |
1805 | |
174 | 1806 |
1807 void image_set_selectable(ImageWindow *imd, gboolean selectable) | |
1808 { | |
1809 if (imd->has_frame) | |
1810 { | |
1811 if (selectable) | |
1812 { | |
175 | 1813 gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE); |
1814 gtk_container_set_border_width (GTK_CONTAINER (imd->frame), 4); | |
174 | 1815 } |
1816 else | |
1817 { | |
175 | 1818 gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE); |
1819 gtk_container_set_border_width (GTK_CONTAINER (imd->frame), 0); | |
174 | 1820 } |
1821 } | |
1822 } | |
1823 | |
9 | 1824 /* |
1825 *------------------------------------------------------------------- | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1826 * prefs sync |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1827 *------------------------------------------------------------------- |
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 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
|
1831 { |
334 | 1832 g_object_set(G_OBJECT(imd->pr), "zoom_quality", options->image.zoom_quality, |
1833 "zoom_2pass", options->image.zoom_2pass, | |
1834 "zoom_expand", options->image.zoom_to_fit_allow_expand, | |
1835 "dither_quality", options->image.dither_quality, | |
1836 "scroll_reset", options->image.scroll_reset_method, | |
1837 "cache_display", options->image.tile_cache_max, | |
1838 "window_fit", (imd->top_window_sync && options->image.fit_window_to_image), | |
1839 "window_limit", options->image.limit_window_size, | |
1840 "window_limit_value", options->image.max_window_size, | |
1841 "autofit_limit", options->image.limit_autofit_size, | |
1842 "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
|
1843 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1844 NULL); |
27
9c24765c2d3a
Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net>
gqview
parents:
26
diff
changeset
|
1845 |
9c24765c2d3a
Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net>
gqview
parents:
26
diff
changeset
|
1846 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
|
1847 } |
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 void image_options_sync(void) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1850 { |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1851 GList *work; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1852 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1853 work = image_list; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1854 while (work) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1855 { |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1856 ImageWindow *imd; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1857 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1858 imd = work->data; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1859 work = work->next; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1860 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1861 image_options_set(imd); |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1862 } |
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 *------------------------------------------------------------------- |
9 | 1867 * init / destroy |
1868 *------------------------------------------------------------------- | |
1869 */ | |
1870 | |
1871 static void image_free(ImageWindow *imd) | |
1872 { | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1873 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
|
1874 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1875 image_reset(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1876 |
9 | 1877 image_read_ahead_cancel(imd); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1878 image_post_buffer_set(imd, NULL, NULL, -1); |
9 | 1879 image_auto_refresh(imd, -1); |
1880 | |
138 | 1881 file_data_unref(imd->image_fd); |
9 | 1882 g_free(imd->title); |
1883 g_free(imd->title_right); | |
1884 | |
1885 g_free(imd); | |
1886 } | |
1887 | |
1888 static void image_destroy_cb(GtkObject *widget, gpointer data) | |
1889 { | |
1890 ImageWindow *imd = data; | |
1891 image_free(imd); | |
1892 } | |
1893 | |
151 | 1894 gboolean selectable_frame_expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) |
1895 { | |
1896 gtk_paint_flat_box(widget->style, | |
1897 widget->window, | |
1898 widget->state, | |
1899 GTK_FRAME (widget)->shadow_type, | |
1900 NULL, | |
1901 widget, | |
1902 NULL, | |
174 | 1903 widget->allocation.x + 3, widget->allocation.y + 3, |
1904 widget->allocation.width - 6, widget->allocation.height - 6); | |
151 | 1905 |
1906 | |
1907 return FALSE; | |
1908 } | |
1909 | |
1910 | |
175 | 1911 void image_set_frame(ImageWindow *imd, gboolean frame) |
1912 { | |
1913 frame = !!frame; | |
1914 | |
1915 if (frame == imd->has_frame) return; | |
1916 | |
1917 gtk_widget_hide(imd->pr); | |
1918 | |
1919 if (frame) | |
1920 { | |
1921 imd->frame = gtk_frame_new(NULL); | |
1922 gtk_widget_ref(imd->pr); | |
1923 if (imd->has_frame != -1) gtk_container_remove(GTK_CONTAINER(imd->widget), imd->pr); | |
1924 gtk_container_add(GTK_CONTAINER(imd->frame), imd->pr); | |
1925 gtk_widget_unref(imd->pr); | |
1926 g_signal_connect (G_OBJECT (imd->frame), "expose_event", | |
1927 G_CALLBACK (selectable_frame_expose_cb), NULL); | |
1928 | |
1929 GTK_WIDGET_SET_FLAGS(imd->frame, GTK_CAN_FOCUS); | |
1930 g_signal_connect(G_OBJECT(imd->frame), "focus_in_event", | |
1931 G_CALLBACK(image_focus_in_cb), imd); | |
1932 g_signal_connect(G_OBJECT(imd->frame), "focus_out_event", | |
1933 G_CALLBACK(image_focus_out_cb), imd); | |
1934 | |
1935 g_signal_connect_after(G_OBJECT(imd->frame), "expose_event", | |
1936 G_CALLBACK(image_focus_expose), imd); | |
1937 | |
1938 | |
1939 gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->frame); | |
1940 gtk_widget_show(imd->frame); | |
1941 } | |
1942 else | |
1943 { | |
1944 gtk_widget_ref(imd->pr); | |
1945 if (imd->frame) | |
1946 { | |
1947 gtk_container_remove(GTK_CONTAINER(imd->frame), imd->pr); | |
1948 gtk_widget_destroy(imd->frame); | |
1949 imd->frame = NULL; | |
1950 } | |
1951 gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->pr); | |
1952 gtk_widget_unref(imd->pr); | |
1953 } | |
1954 | |
1955 gtk_widget_show(imd->pr); | |
1956 | |
1957 imd->has_frame = frame; | |
1958 } | |
1959 | |
9 | 1960 ImageWindow *image_new(gint frame) |
1961 { | |
1962 ImageWindow *imd; | |
1963 | |
1964 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
|
1965 |
9 | 1966 imd->top_window = NULL; |
1967 imd->title = NULL; | |
1968 imd->title_right = NULL; | |
1969 imd->title_show_zoom = FALSE; | |
1970 | |
1971 imd->unknown = TRUE; | |
1972 | |
175 | 1973 imd->has_frame = -1; /* not initialized; for image_set_frame */ |
9 | 1974 imd->top_window_sync = FALSE; |
1975 | |
1976 imd->delay_alter_type = ALTER_NONE; | |
1977 | |
1978 imd->read_ahead_il = NULL; | |
1979 imd->read_ahead_pixbuf = NULL; | |
138 | 1980 imd->read_ahead_fd = NULL; |
9 | 1981 |
1982 imd->completed = FALSE; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1983 imd->state = IMAGE_STATE_NONE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1984 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1985 imd->color_profile_enable = FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1986 imd->color_profile_input = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1987 imd->color_profile_screen = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1988 imd->color_profile_use_image = FALSE; |
9 | 1989 |
1990 imd->auto_refresh_id = -1; | |
1991 imd->auto_refresh_interval = -1; | |
1992 | |
1993 imd->delay_flip = FALSE; | |
1994 | |
1995 imd->func_update = NULL; | |
1996 imd->func_complete = NULL; | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1997 imd->func_tile_request = NULL; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1998 imd->func_tile_dispose = NULL; |
9 | 1999 |
2000 imd->func_button = NULL; | |
2001 imd->func_scroll = NULL; | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
2002 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
2003 imd->orientation = 1; |
9 | 2004 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2005 imd->pr = GTK_WIDGET(pixbuf_renderer_new()); |
9 | 2006 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
2007 image_options_set(imd); |
9 | 2008 |
175 | 2009 |
2010 imd->widget = gtk_vbox_new(0, 0); | |
151 | 2011 |
175 | 2012 image_set_frame(imd, frame); |
9 | 2013 |
175 | 2014 image_set_selectable(imd, 0); |
9 | 2015 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2016 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
|
2017 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
|
2018 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
|
2019 G_CALLBACK(image_scroll_notify_cb), imd); |
9 | 2020 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2021 g_signal_connect(G_OBJECT(imd->pr), "scroll_event", |
9 | 2022 G_CALLBACK(image_scroll_cb), imd); |
2023 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
2024 g_signal_connect(G_OBJECT(imd->pr), "destroy", |
9 | 2025 G_CALLBACK(image_destroy_cb), imd); |
2026 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2027 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
|
2028 G_CALLBACK(image_zoom_cb), imd); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
2029 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
|
2030 G_CALLBACK(image_render_complete_cb), imd); |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
2031 g_signal_connect(G_OBJECT(imd->pr), "drag", |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
2032 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
|
2033 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
2034 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
|
2035 |
9 | 2036 return imd; |
2037 } | |
2038 |