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