Mercurial > geeqie
annotate src/image.c @ 1360:721ffb823d6e
Introduce is_readable_file() which test if file exists, is regular and readable.
author | zas_ |
---|---|
date | Sun, 01 Mar 2009 17:10:45 +0000 |
parents | 8f3d44564146 |
children | b3156b2ec4c5 |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
3 * (C) 2006 John Ellis |
1284 | 4 * Copyright (C) 2008 - 2009 The Geeqie Team |
1 | 5 * |
6 * Author: John Ellis | |
7 * | |
9 | 8 * This software is released under the GNU General Public License (GNU GPL). |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 11 */ |
12 | |
9 | 13 |
281 | 14 #include "main.h" |
1 | 15 #include "image.h" |
9 | 16 |
17 | |
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" |
1288 | 21 #include "metadata.h" |
480
805c3258d228
Make histogram depends on image window not layout window.
zas_
parents:
475
diff
changeset
|
22 #include "histogram.h" |
507 | 23 #include "image-load.h" |
415 | 24 #include "image-overlay.h" |
284 | 25 #include "layout.h" |
26 #include "layout_image.h" | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
27 #include "pixbuf-renderer.h" |
9 | 28 #include "pixbuf_util.h" |
29 #include "ui_fileops.h" | |
30 | |
586 | 31 #include "filedata.h" |
846 | 32 #include "filecache.h" |
138 | 33 |
9 | 34 #include <math.h> |
35 | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
36 static GList *image_list = NULL; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
37 |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
38 static void image_update_title(ImageWindow *imd); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
39 static void image_read_ahead_start(ImageWindow *imd); |
846 | 40 static void image_cache_set(ImageWindow *imd, FileData *fd); |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
41 |
1 | 42 /* |
9 | 43 *------------------------------------------------------------------- |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
44 * 'signals' |
9 | 45 *------------------------------------------------------------------- |
46 */ | |
47 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
48 static void image_click_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data) |
9 | 49 { |
50 ImageWindow *imd = data; | |
51 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
52 if (imd->func_button) |
9 | 53 { |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
54 imd->func_button(imd, event, imd->data_button); |
9 | 55 } |
56 } | |
57 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
58 static void image_drag_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
59 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
60 ImageWindow *imd = data; |
129 | 61 gint width, height; |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
62 |
129 | 63 pixbuf_renderer_get_scaled_size(pr, &width, &height); |
442 | 64 |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
65 if (imd->func_drag) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
66 { |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
67 imd->func_drag(imd, event, |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
68 (gfloat)(pr->drag_last_x - event->x) / width, |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
69 (gfloat)(pr->drag_last_y - event->y) / height, |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
70 imd->data_button); |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
71 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
72 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
73 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
74 static void image_scroll_notify_cb(PixbufRenderer *pr, gpointer data) |
9 | 75 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
76 ImageWindow *imd = data; |
9 | 77 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
78 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
|
79 { |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
80 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
|
81 (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
|
82 (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
|
83 (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
|
84 (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
|
85 imd->data_scroll_notify); |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
86 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
87 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
88 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
89 static void image_update_util(ImageWindow *imd) |
1 | 90 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
91 if (imd->func_update) imd->func_update(imd, imd->data_update); |
9 | 92 } |
93 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
94 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
|
95 { |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
96 ImageWindow *imd = data; |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
97 |
61
0c912a2d94f1
Mon Jun 13 20:22:58 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
98 if (imd->title_show_zoom) image_update_title(imd); |
415 | 99 if (imd->overlay_show_zoom) image_osd_update(imd); |
100 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
101 image_update_util(imd); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
102 } |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
103 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
104 static void image_complete_util(ImageWindow *imd, gint preload) |
9 | 105 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
106 if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return; |
9 | 107 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
108 DEBUG_1("%s image load completed \"%s\" (%s)", get_exec_time(), |
442 | 109 (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") : |
110 (imd->image_fd ? imd->image_fd->path : "null"), | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
111 (preload) ? "preload" : "current"); |
9 | 112 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
113 if (!preload) imd->completed = TRUE; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
114 if (imd->func_complete) imd->func_complete(imd, preload, imd->data_complete); |
1 | 115 } |
116 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
117 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
|
118 { |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
119 ImageWindow *imd = data; |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
120 |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
121 image_complete_util(imd, FALSE); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
122 } |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
123 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
124 static void image_state_set(ImageWindow *imd, ImageState state) |
9 | 125 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
126 if (state == IMAGE_STATE_NONE) |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
127 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
128 imd->state = state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
129 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
130 else |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
131 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
132 imd->state |= state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
133 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
134 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
|
135 } |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
136 |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
137 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
|
138 { |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
139 imd->state &= ~state; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
140 if (imd->func_state) imd->func_state(imd, state, imd->data_state); |
1 | 141 } |
142 | |
143 /* | |
9 | 144 *------------------------------------------------------------------- |
145 * misc | |
146 *------------------------------------------------------------------- | |
147 */ | |
148 | |
149 static void image_update_title(ImageWindow *imd) | |
1 | 150 { |
9 | 151 gchar *title = NULL; |
152 gchar *zoom = NULL; | |
153 gchar *collection = NULL; | |
154 | |
155 if (!imd->top_window) return; | |
156 | |
157 if (imd->collection && collection_to_number(imd->collection) >= 0) | |
158 { | |
987 | 159 const gchar *name = imd->collection->name; |
9 | 160 if (!name) name = _("Untitled"); |
987 | 161 collection = g_strdup_printf(_(" (Collection %s)"), name); |
9 | 162 } |
163 | |
164 if (imd->title_show_zoom) | |
1 | 165 { |
9 | 166 gchar *buf = image_zoom_get_as_text(imd); |
167 zoom = g_strconcat(" [", buf, "]", NULL); | |
168 g_free(buf); | |
1 | 169 } |
170 | |
9 | 171 title = g_strdup_printf("%s%s%s%s%s%s", |
172 imd->title ? imd->title : "", | |
138 | 173 imd->image_fd ? imd->image_fd->name : "", |
9 | 174 zoom ? zoom : "", |
175 collection ? collection : "", | |
138 | 176 imd->image_fd ? " - " : "", |
9 | 177 imd->title_right ? imd->title_right : ""); |
178 | |
179 gtk_window_set_title(GTK_WINDOW(imd->top_window), title); | |
180 | |
181 g_free(title); | |
182 g_free(zoom); | |
183 g_free(collection); | |
184 } | |
185 | |
186 /* | |
187 *------------------------------------------------------------------- | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
188 * rotation, flip, etc. |
9 | 189 *------------------------------------------------------------------- |
190 */ | |
191 | |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
192 static gint image_post_process_color(ImageWindow *imd, gint start_row, gint run_in_bg) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
193 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
194 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
195 ColorManProfileType input_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
196 ColorManProfileType screen_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
197 const gchar *input_file; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
198 const gchar *screen_file; |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
199 guchar *profile = NULL; |
449 | 200 guint profile_len; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
201 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
202 if (imd->cm) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
203 |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
204 if (imd->color_profile_input >= COLOR_PROFILE_FILE && |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
205 imd->color_profile_input < COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
206 { |
1356
681e79dd0820
Slightly modify access_file() and use it to test profile files existence and read access.
zas_
parents:
1346
diff
changeset
|
207 const gchar *file = options->color_profile.input_file[imd->color_profile_input - COLOR_PROFILE_FILE]; |
681e79dd0820
Slightly modify access_file() and use it to test profile files existence and read access.
zas_
parents:
1346
diff
changeset
|
208 |
681e79dd0820
Slightly modify access_file() and use it to test profile files existence and read access.
zas_
parents:
1346
diff
changeset
|
209 if (!access_file(file, R_OK)) return FALSE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
210 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
211 input_type = COLOR_PROFILE_FILE; |
1356
681e79dd0820
Slightly modify access_file() and use it to test profile files existence and read access.
zas_
parents:
1346
diff
changeset
|
212 input_file = file; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
213 } |
442 | 214 else if (imd->color_profile_input >= COLOR_PROFILE_SRGB && |
215 imd->color_profile_input < COLOR_PROFILE_FILE) | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
216 { |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
217 input_type = imd->color_profile_input; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
218 input_file = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
219 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
220 else |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
221 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
222 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
223 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
224 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
225 if (imd->color_profile_screen == 1 && |
1356
681e79dd0820
Slightly modify access_file() and use it to test profile files existence and read access.
zas_
parents:
1346
diff
changeset
|
226 access_file(options->color_profile.screen_file, R_OK)) |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
227 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
228 screen_type = COLOR_PROFILE_FILE; |
327 | 229 screen_file = options->color_profile.screen_file; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
230 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
231 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
|
232 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
233 screen_type = COLOR_PROFILE_SRGB; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
234 screen_file = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
235 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
236 else |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
237 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
238 return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
239 } |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
240 imd->color_profile_from_image = COLOR_PROFILE_NONE; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
241 |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
242 if (imd->color_profile_use_image) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
243 { |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
244 ExifData *exif = exif_read_fd(imd->image_fd); |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
245 |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
246 if (exif) |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
247 { |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
248 profile = exif_get_color_profile(exif, &profile_len); |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
249 if (!profile) |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
250 { |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
251 gint cs; |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
252 gchar *interop_index; |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
253 |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
254 /* ColorSpace == 1 specifies sRGB per EXIF 2.2 */ |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
255 if (!exif_get_integer(exif, "Exif.Photo.ColorSpace", &cs)) cs = 0; |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
256 interop_index = exif_get_data_as_text(exif, "Exif.Iop.InteroperabilityIndex"); |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
257 |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
258 if (cs == 1) |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
259 { |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
260 input_type = COLOR_PROFILE_SRGB; |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
261 input_file = NULL; |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
262 imd->color_profile_from_image = COLOR_PROFILE_SRGB; |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
263 |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
264 DEBUG_1("Found EXIF ColorSpace of sRGB"); |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
265 } |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
266 if (cs == 2 || (interop_index && !strcmp(interop_index, "R03"))) |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
267 { |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
268 input_type = COLOR_PROFILE_ADOBERGB; |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
269 input_file = NULL; |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
270 imd->color_profile_from_image = COLOR_PROFILE_ADOBERGB; |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
271 |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
272 DEBUG_1("Found EXIF ColorSpace of AdobeRGB"); |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
273 } |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
274 |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
275 g_free(interop_index); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
276 } |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
277 else |
424 | 278 { |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
279 DEBUG_1("Found embedded color profile"); |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
280 imd->color_profile_from_image = COLOR_PROFILE_MEM; |
424 | 281 } |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
282 |
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
283 exif_free_fd(imd->image_fd, exif); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
284 } |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
285 } |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
175
diff
changeset
|
286 |
449 | 287 if (profile) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
288 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
289 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, |
449 | 290 profile, profile_len, |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
291 screen_type, screen_file); |
449 | 292 g_free(profile); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
293 } |
442 | 294 else |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
295 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
296 cm = color_man_new(run_in_bg ? imd : NULL, NULL, |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
297 input_type, input_file, |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
298 screen_type, screen_file); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
299 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
300 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
301 if (cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
302 { |
116
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
303 if (start_row > 0) |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
304 { |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
305 cm->row = start_row; |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
306 cm->incremental_sync = TRUE; |
1bd40943dc2a
Tue Nov 28 13:17:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
115
diff
changeset
|
307 } |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
308 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
309 imd->cm = (gpointer)cm; |
442 | 310 #if 0 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
311 if (run_in_bg) color_man_start_bg(imd->cm, image_post_process_color_cb, imd); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
312 #endif |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
313 return TRUE; |
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 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
316 return FALSE; |
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 |
9 | 319 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
320 static void image_post_process_tile_color_cb(PixbufRenderer *pr, GdkPixbuf **pixbuf, gint x, gint y, gint w, gint h, gpointer data) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
321 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
322 ImageWindow *imd = (ImageWindow *)data; |
442 | 323 if (imd->cm) color_man_correct_region(imd->cm, *pixbuf, x, y, w, h); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
324 if (imd->desaturate) pixbuf_desaturate_rect(*pixbuf, x, y, w, h); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
325 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
326 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
327 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
328 void image_alter(ImageWindow *imd, AlterType type) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
329 { |
691 | 330 static const gint rotate_90[] = {1, 6, 7, 8, 5, 2, 3, 4, 1}; |
331 static const gint rotate_90_cc[] = {1, 8, 5, 6, 7, 4, 1, 2, 3}; | |
332 static const gint rotate_180[] = {1, 3, 4, 1, 2, 7, 8, 5, 6}; | |
333 static const gint mirror[] = {1, 2, 1, 4, 3, 6, 5, 8, 7}; | |
334 static const gint flip[] = {1, 4, 3, 2, 1, 8, 7, 6, 5}; | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
335 |
442 | 336 |
994
c879a4c14f33
Fixed segfaulting when alter image in directory without images.
bruclik
parents:
987
diff
changeset
|
337 if (!imd || !imd->pr || !imd->image_fd) return; |
442 | 338 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
339 if (imd->orientation < 1 || imd->orientation > 8) imd->orientation = 1; |
442 | 340 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
341 switch (type) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
342 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
343 case ALTER_ROTATE_90: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
344 imd->orientation = rotate_90[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
345 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
346 case ALTER_ROTATE_90_CC: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
347 imd->orientation = rotate_90_cc[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
348 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
349 case ALTER_ROTATE_180: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
350 imd->orientation = rotate_180[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
351 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
352 case ALTER_MIRROR: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
353 imd->orientation = mirror[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
354 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
355 case ALTER_FLIP: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
356 imd->orientation = flip[imd->orientation]; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
357 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
358 case ALTER_DESATURATE: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
359 imd->desaturate = !imd->desaturate; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
360 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
361 case ALTER_NONE: |
439 | 362 imd->orientation = imd->image_fd->exif_orientation ? imd->image_fd->exif_orientation : 1; |
363 imd->desaturate = FALSE; | |
364 break; | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
365 default: |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
366 return; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
367 break; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
368 } |
434
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
369 |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
370 if (type != ALTER_NONE && type != ALTER_DESATURATE) |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
371 { |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
372 if (imd->image_fd->user_orientation == 0) file_data_ref(imd->image_fd); |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
373 imd->image_fd->user_orientation = imd->orientation; |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
374 } |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
375 else |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
376 { |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
377 if (imd->image_fd->user_orientation != 0) file_data_unref(imd->image_fd); |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
378 imd->image_fd->user_orientation = 0; |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
379 } |
1b0aee2b162e
Keep image orientation set by the user during the session.
zas_
parents:
432
diff
changeset
|
380 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
381 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); |
442 | 382 if (imd->cm || imd->desaturate) |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
383 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
384 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
385 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
386 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
387 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
388 |
9 | 389 /* |
390 *------------------------------------------------------------------- | |
391 * read ahead (prebuffer) | |
392 *------------------------------------------------------------------- | |
393 */ | |
394 | |
395 static void image_read_ahead_cancel(ImageWindow *imd) | |
396 { | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
397 DEBUG_1("%s read ahead cancelled for :%s", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null"); |
9 | 398 |
399 image_loader_free(imd->read_ahead_il); | |
400 imd->read_ahead_il = NULL; | |
401 | |
138 | 402 file_data_unref(imd->read_ahead_fd); |
403 imd->read_ahead_fd = NULL; | |
9 | 404 } |
405 | |
406 static void image_read_ahead_done_cb(ImageLoader *il, gpointer data) | |
407 { | |
408 ImageWindow *imd = data; | |
409 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
410 DEBUG_1("%s read ahead done for :%s", get_exec_time(), imd->read_ahead_fd->path); |
9 | 411 |
846 | 412 if (!imd->read_ahead_fd->pixbuf) |
9 | 413 { |
846 | 414 imd->read_ahead_fd->pixbuf = image_loader_get_pixbuf(imd->read_ahead_il); |
415 if (imd->read_ahead_fd->pixbuf) | |
416 { | |
417 g_object_ref(imd->read_ahead_fd->pixbuf); | |
418 image_cache_set(imd, imd->read_ahead_fd); | |
419 } | |
9 | 420 } |
421 image_loader_free(imd->read_ahead_il); | |
422 imd->read_ahead_il = NULL; | |
423 | |
424 image_complete_util(imd, TRUE); | |
425 } | |
426 | |
427 static void image_read_ahead_error_cb(ImageLoader *il, gpointer data) | |
428 { | |
429 /* we even treat errors as success, maybe at least some of the file was ok */ | |
430 image_read_ahead_done_cb(il, data); | |
431 } | |
432 | |
433 static void image_read_ahead_start(ImageWindow *imd) | |
434 { | |
435 /* already started ? */ | |
846 | 436 if (!imd->read_ahead_fd || imd->read_ahead_il || imd->read_ahead_fd->pixbuf) return; |
9 | 437 |
438 /* still loading ?, do later */ | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
439 if (imd->il /*|| imd->cm*/) return; |
9 | 440 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
441 DEBUG_1("%s read ahead started for :%s", get_exec_time(), imd->read_ahead_fd->path); |
9 | 442 |
138 | 443 imd->read_ahead_il = image_loader_new(imd->read_ahead_fd); |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
444 |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
445 image_loader_delay_area_ready(imd->read_ahead_il, TRUE); /* we will need the area_ready signals later */ |
9 | 446 |
1346
c9949c19a6d0
No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents:
1338
diff
changeset
|
447 g_signal_connect(G_OBJECT(imd->read_ahead_il), "error", (GCallback)image_read_ahead_error_cb, imd); |
c9949c19a6d0
No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents:
1338
diff
changeset
|
448 g_signal_connect(G_OBJECT(imd->read_ahead_il), "done", (GCallback)image_read_ahead_done_cb, imd); |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
449 |
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
450 if (!image_loader_start(imd->read_ahead_il)) |
9 | 451 { |
452 image_read_ahead_cancel(imd); | |
453 image_complete_util(imd, TRUE); | |
454 } | |
455 } | |
456 | |
138 | 457 static void image_read_ahead_set(ImageWindow *imd, FileData *fd) |
9 | 458 { |
138 | 459 if (imd->read_ahead_fd && fd && imd->read_ahead_fd == fd) return; |
9 | 460 |
461 image_read_ahead_cancel(imd); | |
462 | |
138 | 463 imd->read_ahead_fd = file_data_ref(fd); |
9 | 464 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
465 DEBUG_1("read ahead set to :%s", imd->read_ahead_fd->path); |
9 | 466 |
467 image_read_ahead_start(imd); | |
468 } | |
469 | |
470 /* | |
471 *------------------------------------------------------------------- | |
472 * post buffering | |
473 *------------------------------------------------------------------- | |
474 */ | |
475 | |
846 | 476 static void image_cache_release_cb(FileData *fd) |
9 | 477 { |
846 | 478 g_object_unref(fd->pixbuf); |
479 fd->pixbuf = NULL; | |
9 | 480 } |
481 | |
1182
6ae6d77a1f15
Fix up deprecated function and not a prototype warnings.
zas_
parents:
1055
diff
changeset
|
482 static FileCacheData *image_get_cache(void) |
846 | 483 { |
484 static FileCacheData *cache = NULL; | |
848 | 485 if (!cache) cache = file_cache_new(image_cache_release_cb, 1); |
486 file_cache_set_max_size(cache, (gulong)options->image.image_cache_max * 1048576); /* update from options */ | |
846 | 487 return cache; |
488 } | |
489 | |
490 static void image_cache_set(ImageWindow *imd, FileData *fd) | |
491 { | |
847 | 492 g_assert(fd->pixbuf); |
846 | 493 |
847 | 494 file_cache_put(image_get_cache(), fd, (gulong)gdk_pixbuf_get_rowstride(fd->pixbuf) * (gulong)gdk_pixbuf_get_height(fd->pixbuf)); |
1298 | 495 file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); /* to update histogram */ |
846 | 496 } |
497 | |
498 static gint image_cache_get(ImageWindow *imd) | |
9 | 499 { |
500 gint success; | |
501 | |
846 | 502 success = file_cache_get(image_get_cache(), imd->image_fd); |
503 if (success) | |
9 | 504 { |
846 | 505 g_assert(imd->image_fd->pixbuf); |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
506 image_change_pixbuf(imd, imd->image_fd->pixbuf, image_zoom_get(imd), FALSE); |
9 | 507 } |
846 | 508 |
509 file_cache_dump(image_get_cache()); | |
9 | 510 return success; |
511 } | |
512 | |
513 /* | |
514 *------------------------------------------------------------------- | |
515 * loading | |
516 *------------------------------------------------------------------- | |
517 */ | |
518 | |
519 static void image_load_pixbuf_ready(ImageWindow *imd) | |
520 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
521 if (image_get_pixbuf(imd) || !imd->il) return; |
9 | 522 |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
523 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd), FALSE); |
9 | 524 } |
525 | |
526 static void image_load_area_cb(ImageLoader *il, guint x, guint y, guint w, guint h, gpointer data) | |
527 { | |
528 ImageWindow *imd = data; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
529 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
530 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
531 pr = (PixbufRenderer *)imd->pr; |
9 | 532 |
533 if (imd->delay_flip && | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
534 pr->pixbuf != image_loader_get_pixbuf(il)) |
9 | 535 { |
536 return; | |
537 } | |
538 | |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
539 if (!pr->pixbuf) image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd), TRUE); |
9 | 540 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
541 pixbuf_renderer_area_changed(pr, x, y, w, h); |
9 | 542 } |
543 | |
544 static void image_load_done_cb(ImageLoader *il, gpointer data) | |
1 | 545 { |
546 ImageWindow *imd = data; | |
9 | 547 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
548 DEBUG_1("%s image done", get_exec_time()); |
9 | 549 |
846 | 550 if (options->image.enable_read_ahead && imd->image_fd && !imd->image_fd->pixbuf && image_loader_get_pixbuf(imd->il)) |
551 { | |
1043 | 552 imd->image_fd->pixbuf = g_object_ref(image_loader_get_pixbuf(imd->il)); |
846 | 553 image_cache_set(imd, imd->image_fd); |
554 } | |
1294 | 555 /* call the callback triggered by image_state after fd->pixbuf is set */ |
556 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); | |
557 image_state_unset(imd, IMAGE_STATE_LOADING); | |
846 | 558 |
1031 | 559 if (!image_loader_get_pixbuf(imd->il)) |
560 { | |
561 GdkPixbuf *pixbuf; | |
562 | |
563 pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); | |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
564 image_change_pixbuf(imd, pixbuf, image_zoom_get(imd), FALSE); |
1031 | 565 g_object_unref(pixbuf); |
566 | |
567 imd->unknown = TRUE; | |
568 } | |
569 else if (imd->delay_flip && | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
570 image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) |
9 | 571 { |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
29
diff
changeset
|
572 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL); |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
573 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd), FALSE); |
9 | 574 } |
575 | |
576 image_loader_free(imd->il); | |
577 imd->il = NULL; | |
578 | |
846 | 579 // image_post_process(imd, TRUE); |
9 | 580 |
581 image_read_ahead_start(imd); | |
582 } | |
583 | |
584 static void image_load_error_cb(ImageLoader *il, gpointer data) | |
585 { | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
586 DEBUG_1("%s image error", get_exec_time()); |
9 | 587 |
588 /* even on error handle it like it was done, | |
589 * since we have a pixbuf with _something_ */ | |
590 | |
591 image_load_done_cb(il, data); | |
592 } | |
593 | |
1338 | 594 static void image_load_set_signals(ImageWindow *imd, gboolean override_old_signals) |
595 { | |
596 g_assert(imd->il); | |
597 if (override_old_signals) | |
598 { | |
599 /* override the old signals */ | |
600 g_signal_handlers_disconnect_matched(G_OBJECT(imd->il), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, imd); | |
601 } | |
602 | |
603 g_signal_connect(G_OBJECT(imd->il), "area_ready", (GCallback)image_load_area_cb, imd); | |
604 g_signal_connect(G_OBJECT(imd->il), "error", (GCallback)image_load_error_cb, imd); | |
605 g_signal_connect(G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd); | |
606 } | |
607 | |
9 | 608 /* this read ahead is located here merely for the callbacks, above */ |
609 | |
610 static gint image_read_ahead_check(ImageWindow *imd) | |
611 { | |
138 | 612 if (!imd->read_ahead_fd) return FALSE; |
9 | 613 if (imd->il) return FALSE; |
614 | |
138 | 615 if (!imd->image_fd || imd->read_ahead_fd != imd->image_fd) |
9 | 616 { |
617 image_read_ahead_cancel(imd); | |
618 return FALSE; | |
619 } | |
620 | |
621 if (imd->read_ahead_il) | |
622 { | |
623 imd->il = imd->read_ahead_il; | |
624 imd->read_ahead_il = NULL; | |
625 | |
1338 | 626 image_load_set_signals(imd, TRUE); |
9 | 627 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
628 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
|
629 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
|
630 |
9 | 631 if (!imd->delay_flip) |
632 { | |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
633 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd), TRUE); |
9 | 634 } |
635 | |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
636 image_loader_delay_area_ready(imd->il, FALSE); /* send the delayed area_ready signals */ |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
637 |
846 | 638 file_data_unref(imd->read_ahead_fd); |
639 imd->read_ahead_fd = NULL; | |
9 | 640 return TRUE; |
641 } | |
846 | 642 else if (imd->read_ahead_fd->pixbuf) |
9 | 643 { |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
644 image_change_pixbuf(imd, imd->read_ahead_fd->pixbuf, image_zoom_get(imd), FALSE); |
9 | 645 |
846 | 646 file_data_unref(imd->read_ahead_fd); |
647 imd->read_ahead_fd = NULL; | |
9 | 648 |
846 | 649 // image_post_process(imd, FALSE); |
9 | 650 return TRUE; |
651 } | |
652 | |
653 image_read_ahead_cancel(imd); | |
654 return FALSE; | |
655 } | |
656 | |
138 | 657 static gint image_load_begin(ImageWindow *imd, FileData *fd) |
9 | 658 { |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
659 DEBUG_1("%s image begin", get_exec_time()); |
9 | 660 |
661 if (imd->il) return FALSE; | |
662 | |
663 imd->completed = FALSE; | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
664 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL); |
9 | 665 |
846 | 666 if (image_cache_get(imd)) |
9 | 667 { |
847 | 668 DEBUG_1("from cache: %s", imd->image_fd->path); |
9 | 669 return TRUE; |
670 } | |
671 | |
672 if (image_read_ahead_check(imd)) | |
673 { | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
674 DEBUG_1("from read ahead buffer: %s", imd->image_fd->path); |
9 | 675 return TRUE; |
676 } | |
677 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
678 if (!imd->delay_flip && image_get_pixbuf(imd)) |
9 | 679 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
680 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
681 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
682 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
683 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
|
684 pr->pixbuf = NULL; |
9 | 685 } |
686 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
687 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
|
688 |
138 | 689 imd->il = image_loader_new(fd); |
9 | 690 |
1338 | 691 image_load_set_signals(imd, FALSE); |
9 | 692 |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
693 if (!image_loader_start(imd->il)) |
9 | 694 { |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
695 DEBUG_1("image start error"); |
9 | 696 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
697 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
|
698 |
9 | 699 image_loader_free(imd->il); |
700 imd->il = NULL; | |
701 | |
702 image_complete_util(imd, FALSE); | |
703 | |
704 return FALSE; | |
705 } | |
706 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
707 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
|
708 |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
709 /* |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
710 if (!imd->delay_flip && !image_get_pixbuf(imd) && image_loader_get_pixbuf(imd->il)) |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
711 { |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
712 image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd), TRUE); |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
713 } |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
714 */ |
9 | 715 return TRUE; |
716 } | |
717 | |
718 static void image_reset(ImageWindow *imd) | |
719 { | |
720 /* stops anything currently being done */ | |
721 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
722 DEBUG_1("%s image reset", get_exec_time()); |
9 | 723 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
724 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
|
725 |
9 | 726 image_loader_free(imd->il); |
727 imd->il = NULL; | |
728 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
729 color_man_free((ColorMan *)imd->cm); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
730 imd->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
731 |
9 | 732 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
|
733 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
734 image_state_set(imd, IMAGE_STATE_NONE); |
9 | 735 } |
736 | |
737 /* | |
738 *------------------------------------------------------------------- | |
739 * image changer | |
740 *------------------------------------------------------------------- | |
741 */ | |
742 | |
743 static void image_change_complete(ImageWindow *imd, gdouble zoom, gint new) | |
744 { | |
745 image_reset(imd); | |
1337
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
746 imd->unknown = TRUE; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
747 |
1337
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
748 if (!imd->image_fd) |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
749 { |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
750 image_change_pixbuf(imd, NULL, zoom, FALSE); |
9 | 751 } |
752 else | |
753 { | |
1337
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
754 |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
755 if (isfile(imd->image_fd->path)) |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
756 { |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
757 PixbufRenderer *pr; |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
758 |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
759 pr = PIXBUF_RENDERER(imd->pr); |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
760 pr->zoom = zoom; /* store the zoom, needed by the loader */ |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
761 |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
762 if (image_load_begin(imd, imd->image_fd)) |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
763 { |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
764 imd->unknown = FALSE; |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
765 } |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
766 } |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
767 |
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
768 if (imd->unknown == TRUE) |
9 | 769 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
770 GdkPixbuf *pixbuf; |
1337
091ba3e6aedb
image_change_complete(): reduce code redundancy and implify.
zas_
parents:
1333
diff
changeset
|
771 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
772 pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
773 image_change_pixbuf(imd, pixbuf, zoom, FALSE); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
774 g_object_unref(pixbuf); |
9 | 775 } |
776 } | |
777 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
778 image_update_util(imd); |
9 | 779 } |
780 | |
138 | 781 static void image_change_real(ImageWindow *imd, FileData *fd, |
9 | 782 CollectionData *cd, CollectInfo *info, gdouble zoom) |
783 { | |
784 | |
785 imd->collection = cd; | |
786 imd->collection_info = info; | |
787 | |
888 | 788 if (imd->auto_refresh && imd->image_fd) |
789 file_data_unregister_real_time_monitor(imd->image_fd); | |
790 | |
138 | 791 file_data_unref(imd->image_fd); |
792 imd->image_fd = file_data_ref(fd); | |
9 | 793 |
888 | 794 |
9 | 795 image_change_complete(imd, zoom, TRUE); |
796 | |
797 image_update_title(imd); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
798 image_state_set(imd, IMAGE_STATE_IMAGE); |
888 | 799 |
800 if (imd->auto_refresh && imd->image_fd) | |
801 file_data_register_real_time_monitor(imd->image_fd); | |
9 | 802 } |
803 | |
804 /* | |
805 *------------------------------------------------------------------- | |
806 * focus stuff | |
807 *------------------------------------------------------------------- | |
808 */ | |
809 | |
810 static void image_focus_paint(ImageWindow *imd, gint has_focus, GdkRectangle *area) | |
811 { | |
812 GtkWidget *widget; | |
813 | |
814 widget = imd->widget; | |
815 if (!widget->window) return; | |
816 | |
817 if (has_focus) | |
818 { | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
819 gtk_paint_focus(widget->style, widget->window, GTK_STATE_ACTIVE, |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
820 area, widget, "image_window", |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
821 widget->allocation.x, widget->allocation.y, |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
822 widget->allocation.width - 1, widget->allocation.height - 1); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
823 } |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
824 else |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
825 { |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
826 gtk_paint_shadow(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, |
9 | 827 area, widget, "image_window", |
828 widget->allocation.x, widget->allocation.y, | |
442 | 829 widget->allocation.width - 1, widget->allocation.height - 1); |
9 | 830 } |
831 } | |
832 | |
833 static gint image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) | |
834 { | |
835 ImageWindow *imd = data; | |
836 | |
837 image_focus_paint(imd, GTK_WIDGET_HAS_FOCUS(widget), &event->area); | |
838 return TRUE; | |
839 } | |
840 | |
841 static gint image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
842 { | |
843 ImageWindow *imd = data; | |
844 | |
845 GTK_WIDGET_SET_FLAGS(imd->widget, GTK_HAS_FOCUS); | |
846 image_focus_paint(imd, TRUE, NULL); | |
847 | |
848 return TRUE; | |
849 } | |
850 | |
851 static gint image_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
852 { | |
853 ImageWindow *imd = data; | |
854 | |
855 GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS); | |
856 image_focus_paint(imd, FALSE, NULL); | |
857 | |
858 return TRUE; | |
859 } | |
860 | |
861 static gint image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data) | |
862 { | |
863 ImageWindow *imd = data; | |
864 | |
865 if (imd->func_scroll && | |
866 event && event->type == GDK_SCROLL) | |
442 | 867 { |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
868 imd->func_scroll(imd, event, imd->data_scroll); |
9 | 869 return TRUE; |
870 } | |
871 | |
872 return FALSE; | |
873 } | |
874 | |
875 /* | |
876 *------------------------------------------------------------------- | |
877 * public interface | |
878 *------------------------------------------------------------------- | |
879 */ | |
880 | |
881 void image_attach_window(ImageWindow *imd, GtkWidget *window, | |
882 const gchar *title, const gchar *title_right, gint show_zoom) | |
1 | 883 { |
884 imd->top_window = window; | |
885 g_free(imd->title); | |
9 | 886 imd->title = g_strdup(title); |
887 g_free(imd->title_right); | |
888 imd->title_right = g_strdup(title_right); | |
889 imd->title_show_zoom = show_zoom; | |
890 | |
334 | 891 if (!options->image.fit_window_to_image) window = NULL; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
892 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
893 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
|
894 |
9 | 895 image_update_title(imd); |
896 } | |
897 | |
898 void image_set_update_func(ImageWindow *imd, | |
899 void (*func)(ImageWindow *imd, gpointer data), | |
900 gpointer data) | |
901 { | |
902 imd->func_update = func; | |
903 imd->data_update = data; | |
1 | 904 } |
905 | |
9 | 906 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
|
907 void (*func)(ImageWindow *imd, gint preload, gpointer data), |
9 | 908 gpointer data) |
1 | 909 { |
9 | 910 imd->func_complete = func; |
911 imd->data_complete = data; | |
1 | 912 } |
913 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
914 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
|
915 void (*func)(ImageWindow *imd, ImageState state, gpointer data), |
9 | 916 gpointer data) |
1 | 917 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
918 imd->func_state = func; |
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
919 imd->data_state = data; |
9 | 920 } |
921 | |
922 | |
923 void image_set_button_func(ImageWindow *imd, | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
924 void (*func)(ImageWindow *, GdkEventButton *event, gpointer), |
9 | 925 gpointer data) |
926 { | |
927 imd->func_button = func; | |
928 imd->data_button = data; | |
929 } | |
930 | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
931 void image_set_drag_func(ImageWindow *imd, |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
932 void (*func)(ImageWindow *, GdkEventButton *event, gdouble dx, gdouble dy, gpointer), |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
933 gpointer data) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
934 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
935 imd->func_drag = func; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
936 imd->data_drag = data; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
937 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
938 |
9 | 939 void image_set_scroll_func(ImageWindow *imd, |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
863
diff
changeset
|
940 void (*func)(ImageWindow *, GdkEventScroll *event, gpointer), |
9 | 941 gpointer data) |
1 | 942 { |
9 | 943 imd->func_scroll = func; |
944 imd->data_scroll = data; | |
1 | 945 } |
946 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
947 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
|
948 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
|
949 gpointer data) |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
950 { |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
951 imd->func_scroll_notify = func; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
952 imd->data_scroll_notify = data; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
953 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
954 |
9 | 955 /* path, name */ |
956 | |
957 const gchar *image_get_path(ImageWindow *imd) | |
958 { | |
138 | 959 if (imd->image_fd == NULL) return NULL; |
960 return imd->image_fd->path; | |
9 | 961 } |
962 | |
963 const gchar *image_get_name(ImageWindow *imd) | |
964 { | |
138 | 965 if (imd->image_fd == NULL) return NULL; |
966 return imd->image_fd->name; | |
967 } | |
968 | |
969 FileData *image_get_fd(ImageWindow *imd) | |
970 { | |
971 return imd->image_fd; | |
9 | 972 } |
973 | |
974 /* merely changes path string, does not change the image! */ | |
138 | 975 void image_set_fd(ImageWindow *imd, FileData *fd) |
1 | 976 { |
888 | 977 if (imd->auto_refresh && imd->image_fd) |
978 file_data_unregister_real_time_monitor(imd->image_fd); | |
979 | |
138 | 980 file_data_unref(imd->image_fd); |
981 imd->image_fd = file_data_ref(fd); | |
9 | 982 |
983 image_update_title(imd); | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
984 image_state_set(imd, IMAGE_STATE_IMAGE); |
888 | 985 |
986 if (imd->auto_refresh && imd->image_fd) | |
987 file_data_register_real_time_monitor(imd->image_fd); | |
9 | 988 } |
989 | |
990 /* load a new image */ | |
991 | |
138 | 992 void image_change_fd(ImageWindow *imd, FileData *fd, gdouble zoom) |
9 | 993 { |
138 | 994 if (imd->image_fd == fd) return; |
9 | 995 |
138 | 996 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
|
997 } |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
998 |
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
513
diff
changeset
|
999 gint image_get_image_size(ImageWindow *imd, gint *width, gint *height) |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
513
diff
changeset
|
1000 { |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
513
diff
changeset
|
1001 return pixbuf_renderer_get_image_size(PIXBUF_RENDERER(imd->pr), width, height); |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
513
diff
changeset
|
1002 } |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
513
diff
changeset
|
1003 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1004 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
|
1005 { |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1006 return pixbuf_renderer_get_pixbuf((PixbufRenderer *)imd->pr); |
9 | 1007 } |
1008 | |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1009 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gint lazy) |
9 | 1010 { |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1011 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1012 |
1247 | 1013 /* read_exif and similar functions can actually notice that the file has changed and triger a notification |
1014 that removes the pixbuf from cache and unref it. Therefore we must ref it here before it is taken over by the renderer. */ | |
1251 | 1015 if (pixbuf) g_object_ref(pixbuf); |
1247 | 1016 |
1288 | 1017 if (imd->image_fd) |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1018 { |
1288 | 1019 if (imd->image_fd->user_orientation) |
437
f707aa712b1f
Fix the case "orientation from FileData, color profile from exif".
zas_
parents:
434
diff
changeset
|
1020 { |
1288 | 1021 imd->orientation = imd->image_fd->user_orientation; |
1022 } | |
1023 else if (options->image.exif_rotate_enable) | |
1024 { | |
1025 imd->orientation = metadata_read_int(imd->image_fd, "Exif.Image.Orientation", EXIF_ORIENTATION_TOP_LEFT); | |
439 | 1026 imd->image_fd->exif_orientation = imd->orientation; |
437
f707aa712b1f
Fix the case "orientation from FileData, color profile from exif".
zas_
parents:
434
diff
changeset
|
1027 } |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1028 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1029 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1030 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, FALSE); |
442 | 1031 if (imd->cm) |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1032 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1033 color_man_free(imd->cm); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1034 imd->cm = NULL; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1035 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1036 |
1045
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1037 if (lazy) |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1038 { |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1039 pixbuf_renderer_set_pixbuf_lazy((PixbufRenderer *)imd->pr, pixbuf, zoom, imd->orientation); |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1040 } |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1041 else |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1042 { |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1043 pixbuf_renderer_set_pixbuf((PixbufRenderer *)imd->pr, pixbuf, zoom); |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1044 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); |
0ab0deb0cfcc
added possibility to redraw only the parts of image that are already
nadvornik
parents:
1043
diff
changeset
|
1045 } |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1046 |
1251 | 1047 if (pixbuf) g_object_unref(pixbuf); |
1247 | 1048 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1049 if (imd->color_profile_enable) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1050 { |
1357
4ca837d74999
image_post_process_color(): remove exif parameter, just extract it when needed.
zas_
parents:
1356
diff
changeset
|
1051 image_post_process_color(imd, 0, FALSE); /* TODO: error handling */ |
1288 | 1052 } |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1053 |
442 | 1054 if (imd->cm || imd->desaturate) |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1055 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
442 | 1056 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
116
diff
changeset
|
1057 image_state_set(imd, IMAGE_STATE_IMAGE); |
9 | 1058 } |
1059 | |
1060 void image_change_from_collection(ImageWindow *imd, CollectionData *cd, CollectInfo *info, gdouble zoom) | |
1061 { | |
1062 if (!cd || !info || !g_list_find(cd->list, info)) return; | |
1063 | |
138 | 1064 image_change_real(imd, info->fd, cd, info, zoom); |
9 | 1065 } |
1066 | |
1067 CollectionData *image_get_collection(ImageWindow *imd, CollectInfo **info) | |
1068 { | |
1069 if (collection_to_number(imd->collection) >= 0) | |
1070 { | |
1071 if (g_list_find(imd->collection->list, imd->collection_info) != NULL) | |
1072 { | |
1073 if (info) *info = imd->collection_info; | |
1074 } | |
1075 else | |
1076 { | |
1077 if (info) *info = NULL; | |
1078 } | |
1079 return imd->collection; | |
1080 } | |
1081 | |
1082 if (info) *info = NULL; | |
1083 return NULL; | |
1084 } | |
1085 | |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1086 static void image_loader_sync_read_ahead_data(ImageLoader *il, gpointer old_data, gpointer data) |
9 | 1087 { |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1088 if (g_signal_handlers_disconnect_by_func(G_OBJECT(il), (GCallback)image_read_ahead_error_cb, old_data)) |
1338 | 1089 g_signal_connect(G_OBJECT(il), "error", (GCallback)image_read_ahead_error_cb, data); |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1090 |
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1091 if (g_signal_handlers_disconnect_by_func(G_OBJECT(il), (GCallback)image_read_ahead_done_cb, old_data)) |
1338 | 1092 g_signal_connect(G_OBJECT(il), "done", (GCallback)image_read_ahead_done_cb, data); |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1093 } |
9 | 1094 |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1095 static void image_loader_sync_data(ImageLoader *il, gpointer old_data, gpointer data) |
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1096 { |
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1097 if (g_signal_handlers_disconnect_by_func(G_OBJECT(il), (GCallback)image_load_area_cb, old_data)) |
1338 | 1098 g_signal_connect(G_OBJECT(il), "area_ready", (GCallback)image_load_area_cb, data); |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1099 |
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1100 if (g_signal_handlers_disconnect_by_func(G_OBJECT(il), (GCallback)image_load_error_cb, old_data)) |
1338 | 1101 g_signal_connect(G_OBJECT(il), "error", (GCallback)image_load_error_cb, data); |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1102 |
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1103 if (g_signal_handlers_disconnect_by_func(G_OBJECT(il), (GCallback)image_load_done_cb, old_data)) |
1338 | 1104 g_signal_connect(G_OBJECT(il), "done", (GCallback)image_load_done_cb, data); |
1 | 1105 } |
1106 | |
9 | 1107 /* 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
|
1108 * it moves most data from source to imd |
9 | 1109 */ |
1110 void image_change_from_image(ImageWindow *imd, ImageWindow *source) | |
1111 { | |
1112 if (imd == source) return; | |
1113 | |
1114 imd->unknown = source->unknown; | |
1115 | |
1116 imd->collection = source->collection; | |
1117 imd->collection_info = source->collection_info; | |
1118 | |
1119 image_loader_free(imd->il); | |
1120 imd->il = NULL; | |
1121 | |
846 | 1122 image_set_fd(imd, image_get_fd(source)); |
1123 | |
1124 | |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1125 if (source->il) |
9 | 1126 { |
863
8ddd00cc8b69
fixed crash in entering fullscreen during loading
nadvornik
parents:
848
diff
changeset
|
1127 imd->il = source->il; |
8ddd00cc8b69
fixed crash in entering fullscreen during loading
nadvornik
parents:
848
diff
changeset
|
1128 source->il = NULL; |
9 | 1129 |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1130 image_loader_sync_data(imd->il, source, imd); |
9 | 1131 |
1132 imd->delay_alter_type = source->delay_alter_type; | |
1133 source->delay_alter_type = ALTER_NONE; | |
1134 } | |
1135 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1136 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
|
1137 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
|
1138 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
|
1139 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
|
1140 color_man_free((ColorMan *)imd->cm); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1141 imd->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1142 if (source->cm) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1143 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1144 ColorMan *cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1145 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1146 imd->cm = source->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1147 source->cm = NULL; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1148 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1149 cm = (ColorMan *)imd->cm; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1150 cm->imd = imd; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1151 cm->func_done_data = imd; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1152 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1153 |
9 | 1154 image_loader_free(imd->read_ahead_il); |
1155 imd->read_ahead_il = source->read_ahead_il; | |
1156 source->read_ahead_il = NULL; | |
1012
fe82830ab8fd
converted image loader to a GObject and use signals for notification
nadvornik
parents:
1000
diff
changeset
|
1157 if (imd->read_ahead_il) image_loader_sync_read_ahead_data(imd->read_ahead_il, source, imd); |
9 | 1158 |
138 | 1159 file_data_unref(imd->read_ahead_fd); |
1160 imd->read_ahead_fd = source->read_ahead_fd; | |
1161 source->read_ahead_fd = NULL; | |
9 | 1162 |
1163 imd->completed = source->completed; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1164 imd->state = source->state; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1165 source->state = IMAGE_STATE_NONE; |
442 | 1166 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1167 imd->orientation = source->orientation; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1168 imd->desaturate = source->desaturate; |
9 | 1169 |
24
104e34f9ab1f
Wed Mar 23 00:22:28 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1170 pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr)); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1171 |
442 | 1172 if (imd->cm || imd->desaturate) |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1173 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1174 else |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1175 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1176 |
9 | 1177 } |
1178 | |
1179 /* manipulation */ | |
1180 | |
1181 void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height) | |
1182 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1183 pixbuf_renderer_area_changed((PixbufRenderer *)imd->pr, x, y, width, height); |
9 | 1184 } |
1185 | |
1186 void image_reload(ImageWindow *imd) | |
1187 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1188 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
|
1189 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1190 image_change_complete(imd, image_zoom_get(imd), FALSE); |
9 | 1191 } |
1192 | |
1193 void image_scroll(ImageWindow *imd, gint x, gint y) | |
1194 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1195 pixbuf_renderer_scroll((PixbufRenderer *)imd->pr, x, y); |
9 | 1196 } |
1197 | |
13
ef790149ae21
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
12
diff
changeset
|
1198 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
|
1199 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
|
1200 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1201 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
|
1202 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1203 |
131 | 1204 void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y) |
1205 { | |
1206 pixbuf_renderer_get_scroll_center(PIXBUF_RENDERER(imd->pr), x, y); | |
1207 } | |
1208 | |
1209 void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y) | |
1210 { | |
1211 pixbuf_renderer_set_scroll_center(PIXBUF_RENDERER(imd->pr), x, y); | |
1212 } | |
1213 | |
9 | 1214 void image_zoom_adjust(ImageWindow *imd, gdouble increment) |
1215 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1216 pixbuf_renderer_zoom_adjust((PixbufRenderer *)imd->pr, increment); |
9 | 1217 } |
1218 | |
1219 void image_zoom_adjust_at_point(ImageWindow *imd, gdouble increment, gint x, gint y) | |
1220 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1221 pixbuf_renderer_zoom_adjust_at_point((PixbufRenderer *)imd->pr, increment, x, y); |
9 | 1222 } |
1223 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1224 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
|
1225 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1226 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
|
1227 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1228 |
9 | 1229 void image_zoom_set(ImageWindow *imd, gdouble zoom) |
1230 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1231 pixbuf_renderer_zoom_set((PixbufRenderer *)imd->pr, zoom); |
9 | 1232 } |
1233 | |
1269 | 1234 void image_zoom_set_fill_geometry(ImageWindow *imd, gboolean vertical) |
9 | 1235 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1236 PixbufRenderer *pr; |
9 | 1237 gdouble zoom; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1238 gint width, height; |
9 | 1239 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1240 pr = (PixbufRenderer *)imd->pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1241 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1242 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
|
1243 !pixbuf_renderer_get_image_size(pr, &width, &height)) return; |
9 | 1244 |
1245 if (vertical) | |
1246 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1247 zoom = (gdouble)pr->window_height / height; |
9 | 1248 } |
1249 else | |
1250 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1251 zoom = (gdouble)pr->window_width / width; |
9 | 1252 } |
1253 | |
1254 if (zoom < 1.0) | |
1255 { | |
1256 zoom = 0.0 - 1.0 / zoom; | |
1 | 1257 } |
9 | 1258 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1259 pixbuf_renderer_zoom_set(pr, zoom); |
9 | 1260 } |
1261 | |
1262 gdouble image_zoom_get(ImageWindow *imd) | |
1263 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1264 return pixbuf_renderer_zoom_get((PixbufRenderer *)imd->pr); |
9 | 1265 } |
1266 | |
1267 gdouble image_zoom_get_real(ImageWindow *imd) | |
1268 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1269 return pixbuf_renderer_zoom_get_scale((PixbufRenderer *)imd->pr); |
9 | 1270 } |
1271 | |
1272 gchar *image_zoom_get_as_text(ImageWindow *imd) | |
1273 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1274 gdouble zoom; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1275 gdouble scale; |
9 | 1276 gdouble l = 1.0; |
1277 gdouble r = 1.0; | |
1278 gint pl = 0; | |
1279 gint pr = 0; | |
1280 gchar *approx = " "; | |
1281 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1282 zoom = image_zoom_get(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1283 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
|
1284 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1285 if (zoom > 0.0) |
1 | 1286 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1287 l = zoom; |
9 | 1288 } |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1289 else if (zoom < 0.0) |
9 | 1290 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1291 r = 0.0 - zoom; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1292 } |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1293 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
|
1294 { |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1295 if (scale >= 1.0) |
9 | 1296 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1297 l = scale; |
9 | 1298 } |
1299 else | |
1300 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1301 r = 1.0 / scale; |
9 | 1302 } |
415 | 1303 approx = "~"; |
9 | 1304 } |
1305 | |
1306 if (rint(l) != l) pl = 1; | |
1307 if (rint(r) != r) pr = 1; | |
1308 | |
1309 return g_strdup_printf("%.*f :%s%.*f", pl, l, approx, pr, r); | |
1310 } | |
1311 | |
885
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1312 gdouble image_zoom_get_default(ImageWindow *imd) |
9 | 1313 { |
885
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1314 gdouble zoom = 1.0; |
9 | 1315 |
885
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1316 switch (options->image.zoom_mode) |
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1317 { |
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1318 case ZOOM_RESET_ORIGINAL: |
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1319 break; |
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1320 case ZOOM_RESET_FIT_WINDOW: |
9 | 1321 zoom = 0.0; |
885
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1322 break; |
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1323 case ZOOM_RESET_NONE: |
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1324 if (imd) zoom = image_zoom_get(imd); |
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1325 break; |
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
868
diff
changeset
|
1326 } |
1 | 1327 |
1328 return zoom; | |
1329 } | |
1330 | |
9 | 1331 /* read ahead */ |
1332 | |
138 | 1333 void image_prebuffer_set(ImageWindow *imd, FileData *fd) |
9 | 1334 { |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1335 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
|
1336 |
138 | 1337 if (fd) |
9 | 1338 { |
846 | 1339 if (!file_cache_get(image_get_cache(), fd)) |
1340 { | |
1341 image_read_ahead_set(imd, fd); | |
1342 } | |
9 | 1343 } |
1344 else | |
1345 { | |
1346 image_read_ahead_cancel(imd); | |
1347 } | |
1348 } | |
1349 | |
888 | 1350 static void image_notify_cb(FileData *fd, NotifyType type, gpointer data) |
9 | 1351 { |
1352 ImageWindow *imd = data; | |
442 | 1353 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1354 if (!imd || !image_get_pixbuf(imd) || |
995 | 1355 /* imd->il || */ /* loading in progress - do not check - it should start from the beginning anyway */ |
891 | 1356 !imd->image_fd || /* nothing to reload */ |
903
c93823609f15
periodic testing of changed files can be now disabled
nadvornik
parents:
891
diff
changeset
|
1357 imd->state == IMAGE_STATE_NONE /* loading not started, no need to reload */ |
c93823609f15
periodic testing of changed files can be now disabled
nadvornik
parents:
891
diff
changeset
|
1358 ) return; |
9 | 1359 |
888 | 1360 if (type == NOTIFY_TYPE_REREAD && fd == imd->image_fd) |
9 | 1361 { |
1362 image_reload(imd); | |
1363 } | |
1364 } | |
1365 | |
888 | 1366 void image_auto_refresh_enable(ImageWindow *imd, gboolean enable) |
9 | 1367 { |
888 | 1368 if (!enable && imd->auto_refresh && imd->image_fd) |
1369 file_data_unregister_real_time_monitor(imd->image_fd); | |
9 | 1370 |
888 | 1371 if (enable && !imd->auto_refresh && imd->image_fd) |
1372 file_data_register_real_time_monitor(imd->image_fd); | |
9 | 1373 |
888 | 1374 imd->auto_refresh = enable; |
9 | 1375 } |
1376 | |
1377 void image_top_window_set_sync(ImageWindow *imd, gint allow_sync) | |
1378 { | |
1379 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
|
1380 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1381 g_object_set(G_OBJECT(imd->pr), "window_fit", allow_sync, NULL); |
9 | 1382 } |
1383 | |
1384 void image_background_set_color(ImageWindow *imd, GdkColor *color) | |
1385 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1386 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); |
9 | 1387 } |
1388 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1389 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
|
1390 gint input_type, gint screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1391 gint use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1392 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1393 if (!imd) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1394 |
432 | 1395 if (input_type < 0 || input_type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS || |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1396 screen_type < 0 || screen_type > 1) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1397 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1398 return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1399 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1400 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1401 imd->color_profile_input = input_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1402 imd->color_profile_screen = screen_type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1403 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
|
1404 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1405 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1406 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
|
1407 gint *input_type, gint *screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1408 gint *use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1409 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1410 if (!imd) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1411 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1412 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
|
1413 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
|
1414 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
|
1415 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1416 return TRUE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1417 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1418 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1419 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
|
1420 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1421 if (!imd) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1422 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1423 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
|
1424 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1425 imd->color_profile_enable = enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1426 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1427 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1428 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
|
1429 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1430 if (!imd) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1431 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1432 return imd->color_profile_enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1433 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1434 |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1435 gint image_color_profile_get_from_image(ImageWindow *imd) |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1436 { |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1437 if (!imd) return FALSE; |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1438 |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1439 return imd->color_profile_from_image; |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1440 } |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1441 |
9 | 1442 void image_set_delay_flip(ImageWindow *imd, gint delay) |
1443 { | |
1444 if (!imd || | |
1445 imd->delay_flip == delay) return; | |
1446 | |
1447 imd->delay_flip = delay; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1448 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1449 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
|
1450 |
9 | 1451 if (!imd->delay_flip && imd->il) |
1452 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1453 PixbufRenderer *pr; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1454 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1455 pr = PIXBUF_RENDERER(imd->pr); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1456 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
|
1457 pr->pixbuf = NULL; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1458 |
9 | 1459 image_load_pixbuf_ready(imd); |
1460 } | |
1461 } | |
1462 | |
1463 void image_to_root_window(ImageWindow *imd, gint scaled) | |
1464 { | |
1465 GdkScreen *screen; | |
3 | 1466 GdkWindow *rootwindow; |
1467 GdkPixmap *pixmap; | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1468 GdkPixbuf *pixbuf; |
9 | 1469 GdkPixbuf *pb; |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1470 gint width, height; |
9 | 1471 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1472 if (!imd) return; |
9 | 1473 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1474 pixbuf = image_get_pixbuf(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1475 if (!pixbuf) return; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1476 |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1477 screen = gtk_widget_get_screen(imd->widget); |
9 | 1478 rootwindow = gdk_screen_get_root_window(screen); |
1479 if (gdk_drawable_get_visual(rootwindow) != gdk_visual_get_system()) return; | |
3 | 1480 |
1481 if (scaled) | |
1482 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1483 width = gdk_screen_width(); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1484 height = gdk_screen_height(); |
3 | 1485 } |
1486 else | |
1487 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1488 pixbuf_renderer_get_scaled_size((PixbufRenderer *)imd->pr, &width, &height); |
3 | 1489 } |
1490 | |
334 | 1491 pb = gdk_pixbuf_scale_simple(pixbuf, width, height, (GdkInterpType)options->image.zoom_quality); |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1492 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1493 gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, NULL, 128); |
3 | 1494 gdk_window_set_back_pixmap(rootwindow, pixmap, FALSE); |
1495 gdk_window_clear(rootwindow); | |
9 | 1496 g_object_unref(pb); |
1497 g_object_unref(pixmap); | |
3 | 1498 |
1499 gdk_flush(); | |
1500 } | |
1501 | |
127 | 1502 void image_select(ImageWindow *imd, gboolean select) |
1503 { | |
1359 | 1504 if (!imd->has_frame) return; |
1505 | |
1506 if (select) | |
127 | 1507 { |
1359 | 1508 gtk_widget_set_state(imd->widget, GTK_STATE_SELECTED); |
1509 gtk_widget_set_state(imd->pr, GTK_STATE_NORMAL); /* do not propagate */ | |
127 | 1510 } |
1359 | 1511 else |
1512 gtk_widget_set_state(imd->widget, GTK_STATE_NORMAL); | |
127 | 1513 } |
1514 | |
174 | 1515 void image_set_selectable(ImageWindow *imd, gboolean selectable) |
1516 { | |
1359 | 1517 if (!imd->has_frame) return; |
1518 | |
1519 gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE); | |
1520 gtk_container_set_border_width(GTK_CONTAINER(imd->frame), selectable ? 4 : 0); | |
174 | 1521 } |
1522 | |
9 | 1523 /* |
1524 *------------------------------------------------------------------- | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1525 * prefs sync |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1526 *------------------------------------------------------------------- |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1527 */ |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1528 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1529 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
|
1530 { |
334 | 1531 g_object_set(G_OBJECT(imd->pr), "zoom_quality", options->image.zoom_quality, |
1532 "zoom_2pass", options->image.zoom_2pass, | |
1533 "zoom_expand", options->image.zoom_to_fit_allow_expand, | |
1534 "dither_quality", options->image.dither_quality, | |
1535 "scroll_reset", options->image.scroll_reset_method, | |
1536 "cache_display", options->image.tile_cache_max, | |
1537 "window_fit", (imd->top_window_sync && options->image.fit_window_to_image), | |
1538 "window_limit", options->image.limit_window_size, | |
1539 "window_limit_value", options->image.max_window_size, | |
1540 "autofit_limit", options->image.limit_autofit_size, | |
1541 "autofit_limit_value", options->image.max_autofit_size, | |
209
ad78ad18523a
configurable frame around image - geeqie_autofit_maxsize.patch by Laurent MONIN
nadvornik
parents:
208
diff
changeset
|
1542 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1543 NULL); |
27
9c24765c2d3a
Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net>
gqview
parents:
26
diff
changeset
|
1544 |
9c24765c2d3a
Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net>
gqview
parents:
26
diff
changeset
|
1545 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
|
1546 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1547 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1548 void image_options_sync(void) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1549 { |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1550 GList *work; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1551 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1552 work = image_list; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1553 while (work) |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1554 { |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1555 ImageWindow *imd; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1556 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1557 imd = work->data; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1558 work = work->next; |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1559 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1560 image_options_set(imd); |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1561 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1562 } |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1563 |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1564 /* |
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1565 *------------------------------------------------------------------- |
9 | 1566 * init / destroy |
1567 *------------------------------------------------------------------- | |
1568 */ | |
1569 | |
1570 static void image_free(ImageWindow *imd) | |
1571 { | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1572 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
|
1573 |
888 | 1574 if (imd->auto_refresh && imd->image_fd) |
1575 file_data_unregister_real_time_monitor(imd->image_fd); | |
1576 | |
1577 file_data_unregister_notify_func(image_notify_cb, imd); | |
1578 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1579 image_reset(imd); |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1580 |
9 | 1581 image_read_ahead_cancel(imd); |
1582 | |
138 | 1583 file_data_unref(imd->image_fd); |
9 | 1584 g_free(imd->title); |
1585 g_free(imd->title_right); | |
1586 g_free(imd); | |
1587 } | |
1588 | |
1589 static void image_destroy_cb(GtkObject *widget, gpointer data) | |
1590 { | |
1591 ImageWindow *imd = data; | |
1592 image_free(imd); | |
1593 } | |
1594 | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1595 gboolean selectable_frame_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
151 | 1596 { |
1597 gtk_paint_flat_box(widget->style, | |
442 | 1598 widget->window, |
1599 widget->state, | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1600 (GTK_FRAME(widget))->shadow_type, |
442 | 1601 NULL, |
1602 widget, | |
1603 NULL, | |
1604 widget->allocation.x + 3, widget->allocation.y + 3, | |
1605 widget->allocation.width - 6, widget->allocation.height - 6); | |
1606 | |
1607 | |
151 | 1608 return FALSE; |
1609 } | |
1610 | |
1611 | |
175 | 1612 void image_set_frame(ImageWindow *imd, gboolean frame) |
1613 { | |
1614 frame = !!frame; | |
442 | 1615 |
175 | 1616 if (frame == imd->has_frame) return; |
442 | 1617 |
175 | 1618 gtk_widget_hide(imd->pr); |
442 | 1619 |
175 | 1620 if (frame) |
1621 { | |
1622 imd->frame = gtk_frame_new(NULL); | |
1043 | 1623 #if GTK_CHECK_VERSION(2,12,0) |
1358 | 1624 g_object_ref(imd->pr); |
1043 | 1625 #else |
1358 | 1626 gtk_widget_ref(imd->pr); |
1043 | 1627 #endif |
175 | 1628 if (imd->has_frame != -1) gtk_container_remove(GTK_CONTAINER(imd->widget), imd->pr); |
1629 gtk_container_add(GTK_CONTAINER(imd->frame), imd->pr); | |
1043 | 1630 |
1631 #if GTK_CHECK_VERSION(2,12,0) | |
1358 | 1632 g_object_unref(imd->pr); |
1043 | 1633 #else |
1358 | 1634 gtk_widget_unref(imd->pr); |
1043 | 1635 #endif |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1636 g_signal_connect(G_OBJECT(imd->frame), "expose_event", |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1637 G_CALLBACK(selectable_frame_expose_cb), NULL); |
175 | 1638 |
1639 GTK_WIDGET_SET_FLAGS(imd->frame, GTK_CAN_FOCUS); | |
1640 g_signal_connect(G_OBJECT(imd->frame), "focus_in_event", | |
1641 G_CALLBACK(image_focus_in_cb), imd); | |
1642 g_signal_connect(G_OBJECT(imd->frame), "focus_out_event", | |
1643 G_CALLBACK(image_focus_out_cb), imd); | |
1644 | |
1645 g_signal_connect_after(G_OBJECT(imd->frame), "expose_event", | |
1646 G_CALLBACK(image_focus_expose), imd); | |
1647 | |
1182
6ae6d77a1f15
Fix up deprecated function and not a prototype warnings.
zas_
parents:
1055
diff
changeset
|
1648 #if GTK_CHECK_VERSION(2,14,0) |
1358 | 1649 gtk_box_pack_start(GTK_BOX(imd->widget), imd->frame, TRUE, TRUE, 0); |
1182
6ae6d77a1f15
Fix up deprecated function and not a prototype warnings.
zas_
parents:
1055
diff
changeset
|
1650 #else |
1358 | 1651 gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->frame); |
1182
6ae6d77a1f15
Fix up deprecated function and not a prototype warnings.
zas_
parents:
1055
diff
changeset
|
1652 #endif |
1358 | 1653 gtk_widget_show(imd->frame); |
175 | 1654 } |
1655 else | |
1656 { | |
1043 | 1657 #if GTK_CHECK_VERSION(2,12,0) |
1658 g_object_ref(imd->pr); | |
1659 #else | |
175 | 1660 gtk_widget_ref(imd->pr); |
1043 | 1661 #endif |
442 | 1662 if (imd->frame) |
175 | 1663 { |
1664 gtk_container_remove(GTK_CONTAINER(imd->frame), imd->pr); | |
1665 gtk_widget_destroy(imd->frame); | |
1666 imd->frame = NULL; | |
1667 } | |
1182
6ae6d77a1f15
Fix up deprecated function and not a prototype warnings.
zas_
parents:
1055
diff
changeset
|
1668 #if GTK_CHECK_VERSION(2,14,0) |
1358 | 1669 gtk_box_pack_start(GTK_BOX(imd->widget), imd->pr, TRUE, TRUE, 0); |
1182
6ae6d77a1f15
Fix up deprecated function and not a prototype warnings.
zas_
parents:
1055
diff
changeset
|
1670 #else |
175 | 1671 gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->pr); |
1182
6ae6d77a1f15
Fix up deprecated function and not a prototype warnings.
zas_
parents:
1055
diff
changeset
|
1672 #endif |
1043 | 1673 |
1674 #if GTK_CHECK_VERSION(2,12,0) | |
1358 | 1675 g_object_unref(imd->pr); |
1043 | 1676 #else |
1358 | 1677 gtk_widget_unref(imd->pr); |
1043 | 1678 #endif |
175 | 1679 } |
1680 | |
1681 gtk_widget_show(imd->pr); | |
442 | 1682 |
175 | 1683 imd->has_frame = frame; |
1684 } | |
1685 | |
9 | 1686 ImageWindow *image_new(gint frame) |
1687 { | |
1688 ImageWindow *imd; | |
1689 | |
1690 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
|
1691 |
9 | 1692 imd->top_window = NULL; |
1693 imd->title = NULL; | |
1694 imd->title_right = NULL; | |
1695 imd->title_show_zoom = FALSE; | |
1696 | |
1697 imd->unknown = TRUE; | |
1698 | |
175 | 1699 imd->has_frame = -1; /* not initialized; for image_set_frame */ |
9 | 1700 imd->top_window_sync = FALSE; |
1701 | |
1702 imd->delay_alter_type = ALTER_NONE; | |
1703 | |
1704 imd->read_ahead_il = NULL; | |
138 | 1705 imd->read_ahead_fd = NULL; |
9 | 1706 |
1707 imd->completed = FALSE; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1708 imd->state = IMAGE_STATE_NONE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1709 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1710 imd->color_profile_enable = FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1711 imd->color_profile_input = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1712 imd->color_profile_screen = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
109
diff
changeset
|
1713 imd->color_profile_use_image = FALSE; |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
424
diff
changeset
|
1714 imd->color_profile_from_image = COLOR_PROFILE_NONE; |
9 | 1715 |
888 | 1716 imd->auto_refresh = FALSE; |
9 | 1717 |
1718 imd->delay_flip = FALSE; | |
1719 | |
1720 imd->func_update = NULL; | |
1721 imd->func_complete = NULL; | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1722 imd->func_tile_request = NULL; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1723 imd->func_tile_dispose = NULL; |
9 | 1724 |
1725 imd->func_button = NULL; | |
1726 imd->func_scroll = NULL; | |
442 | 1727 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
386
diff
changeset
|
1728 imd->orientation = 1; |
9 | 1729 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1730 imd->pr = GTK_WIDGET(pixbuf_renderer_new()); |
9 | 1731 |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1732 image_options_set(imd); |
9 | 1733 |
442 | 1734 |
175 | 1735 imd->widget = gtk_vbox_new(0, 0); |
151 | 1736 |
175 | 1737 image_set_frame(imd, frame); |
9 | 1738 |
175 | 1739 image_set_selectable(imd, 0); |
9 | 1740 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1741 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
|
1742 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
|
1743 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
|
1744 G_CALLBACK(image_scroll_notify_cb), imd); |
9 | 1745 |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1746 g_signal_connect(G_OBJECT(imd->pr), "scroll_event", |
9 | 1747 G_CALLBACK(image_scroll_cb), imd); |
1748 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
14
diff
changeset
|
1749 g_signal_connect(G_OBJECT(imd->pr), "destroy", |
9 | 1750 G_CALLBACK(image_destroy_cb), imd); |
1751 | |
25
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
1752 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
|
1753 G_CALLBACK(image_zoom_cb), imd); |
0c3b353b666e
Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents:
24
diff
changeset
|
1754 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
|
1755 G_CALLBACK(image_render_complete_cb), imd); |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1756 g_signal_connect(G_OBJECT(imd->pr), "drag", |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1757 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
|
1758 |
888 | 1759 file_data_register_notify_func(image_notify_cb, imd, NOTIFY_PRIORITY_LOW); |
1760 | |
26
acd9885ebd78
Mon Mar 28 20:23:34 2005 John Ellis <johne@verizon.net>
gqview
parents:
25
diff
changeset
|
1761 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
|
1762 |
9 | 1763 return imd; |
1764 } | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1045
diff
changeset
|
1765 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |