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