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