Mercurial > geeqie
annotate src/img-view.c @ 327:049d6b00cc14
Rename color profile options.
author | zas_ |
---|---|
date | Sat, 12 Apr 2008 08:05:44 +0000 |
parents | b16b9b8979e5 |
children | df868b947aa0 |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
94
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
3 * (C) 2006 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
9 | 12 |
281 | 13 #include "main.h" |
9 | 14 #include "img-view.h" |
15 | |
16 #include "collect.h" | |
17 #include "collect-io.h" | |
18 #include "dnd.h" | |
19 #include "editors.h" | |
20 #include "filelist.h" | |
21 #include "fullscreen.h" | |
1 | 22 #include "image.h" |
9 | 23 #include "image-overlay.h" |
24 #include "info.h" | |
25 #include "menu.h" | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
26 #include "pixbuf-renderer.h" |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
89
diff
changeset
|
27 #include "pixbuf_util.h" |
94
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
28 #include "print.h" |
9 | 29 #include "slideshow.h" |
30 #include "utilops.h" | |
31 #include "ui_bookmark.h" | |
32 #include "ui_fileops.h" | |
33 #include "ui_menu.h" | |
34 | |
1 | 35 #include <gdk/gdkkeysyms.h> /* for keyboard values */ |
36 | |
9 | 37 |
38 typedef struct _ViewWindow ViewWindow; | |
39 struct _ViewWindow | |
40 { | |
41 GtkWidget *window; | |
42 ImageWindow *imd; | |
43 FullScreenData *fs; | |
44 SlideShowData *ss; | |
45 | |
46 GList *list; | |
47 GList *list_pointer; | |
48 }; | |
49 | |
50 | |
51 static GList *view_window_list = NULL; | |
52 | |
53 | |
54 static GtkWidget *view_popup_menu(ViewWindow *vw); | |
55 static void view_fullscreen_toggle(ViewWindow *vw, gint force_off); | |
56 static void view_overlay_toggle(ViewWindow *vw); | |
57 | |
58 static void view_slideshow_next(ViewWindow *vw); | |
59 static void view_slideshow_prev(ViewWindow *vw); | |
60 static void view_slideshow_start(ViewWindow *vw); | |
61 static void view_slideshow_stop(ViewWindow *vw); | |
62 | |
63 static void view_window_close(ViewWindow *vw); | |
64 | |
65 static void view_window_dnd_init(ViewWindow *vw); | |
66 | |
67 | |
68 /* | |
69 *----------------------------------------------------------------------------- | |
70 * misc | |
71 *----------------------------------------------------------------------------- | |
72 */ | |
73 | |
74 static ImageWindow *view_window_active_image(ViewWindow *vw) | |
75 { | |
76 if (vw->fs) return vw->fs->imd; | |
77 | |
78 return vw->imd; | |
79 } | |
80 | |
81 static void view_window_set_list(ViewWindow *vw, GList *list) | |
82 { | |
83 | |
138 | 84 filelist_free(vw->list); |
9 | 85 vw->list = NULL; |
86 vw->list_pointer = NULL; | |
87 | |
138 | 88 vw->list = filelist_copy(list); |
9 | 89 } |
90 | |
91 static gint view_window_contains_collection(ViewWindow *vw) | |
92 { | |
93 CollectionData *cd; | |
94 CollectInfo *info; | |
95 | |
96 cd = image_get_collection(view_window_active_image(vw), &info); | |
97 | |
98 return (cd && info); | |
99 } | |
100 | |
101 static void view_collection_step(ViewWindow *vw, gint next) | |
102 { | |
103 ImageWindow *imd = view_window_active_image(vw); | |
104 CollectionData *cd; | |
105 CollectInfo *info; | |
106 CollectInfo *read_ahead_info = NULL; | |
107 | |
108 cd = image_get_collection(imd, &info); | |
109 | |
110 if (!cd || !info) return; | |
111 | |
112 if (next) | |
113 { | |
114 info = collection_next_by_info(cd, info); | |
318 | 115 if (options->enable_read_ahead) |
9 | 116 { |
117 read_ahead_info = collection_next_by_info(cd, info); | |
118 if (!read_ahead_info) read_ahead_info = collection_prev_by_info(cd, info); | |
119 } | |
120 } | |
121 else | |
122 { | |
123 info = collection_prev_by_info(cd, info); | |
318 | 124 if (options->enable_read_ahead) |
9 | 125 { |
126 read_ahead_info = collection_prev_by_info(cd, info); | |
127 if (!read_ahead_info) read_ahead_info = collection_next_by_info(cd, info); | |
128 } | |
129 } | |
130 | |
131 if (info) | |
132 { | |
318 | 133 image_change_from_collection(imd, cd, info, image_zoom_get_default(imd, options->zoom_mode)); |
9 | 134 |
138 | 135 if (read_ahead_info) image_prebuffer_set(imd, read_ahead_info->fd); |
9 | 136 } |
137 | |
138 } | |
139 | |
140 static void view_collection_step_to_end(ViewWindow *vw, gint last) | |
141 { | |
142 ImageWindow *imd = view_window_active_image(vw); | |
143 CollectionData *cd; | |
144 CollectInfo *info; | |
145 CollectInfo *read_ahead_info = NULL; | |
146 | |
147 cd = image_get_collection(imd, &info); | |
148 | |
149 if (!cd || !info) return; | |
150 | |
151 if (last) | |
152 { | |
153 info = collection_get_last(cd); | |
318 | 154 if (options->enable_read_ahead) read_ahead_info = collection_prev_by_info(cd, info); |
9 | 155 } |
156 else | |
157 { | |
158 info = collection_get_first(cd); | |
318 | 159 if (options->enable_read_ahead) read_ahead_info = collection_next_by_info(cd, info); |
9 | 160 } |
161 | |
162 if (info) | |
163 { | |
318 | 164 image_change_from_collection(imd, cd, info, image_zoom_get_default(imd, options->zoom_mode)); |
138 | 165 if (read_ahead_info) image_prebuffer_set(imd, read_ahead_info->fd); |
9 | 166 } |
167 } | |
168 | |
169 static void view_list_step(ViewWindow *vw, gint next) | |
170 { | |
171 ImageWindow *imd = view_window_active_image(vw); | |
138 | 172 FileData *fd; |
9 | 173 GList *work; |
174 GList *work_ahead; | |
175 | |
176 if (!vw->list) return; | |
177 | |
138 | 178 fd = image_get_fd(imd); |
179 if (!fd) return; | |
9 | 180 |
181 if (g_list_position(vw->list, vw->list_pointer) >= 0) | |
182 { | |
183 work = vw->list_pointer; | |
184 } | |
185 else | |
186 { | |
187 gint found = FALSE; | |
188 | |
189 work = vw->list; | |
190 while (work && !found) | |
191 { | |
138 | 192 FileData *temp; |
9 | 193 |
194 temp = work->data; | |
195 | |
138 | 196 if (fd == temp) |
9 | 197 { |
198 found = TRUE; | |
199 } | |
200 else | |
201 { | |
202 work = work->next; | |
203 } | |
204 } | |
205 } | |
206 if (!work) return; | |
207 | |
208 work_ahead = NULL; | |
209 if (next) | |
210 { | |
211 work = work->next; | |
212 if (work) work_ahead = work->next; | |
213 } | |
214 else | |
215 { | |
216 work = work->prev; | |
217 if (work) work_ahead = work->prev; | |
218 } | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
219 |
9 | 220 if (!work) return; |
221 | |
222 vw->list_pointer = work; | |
138 | 223 fd = work->data; |
318 | 224 image_change_fd(imd, fd, image_zoom_get_default(imd, options->zoom_mode)); |
9 | 225 |
318 | 226 if (options->enable_read_ahead && work_ahead) |
9 | 227 { |
138 | 228 FileData *next_fd = work_ahead->data; |
229 image_prebuffer_set(imd, next_fd); | |
9 | 230 } |
231 } | |
232 | |
233 static void view_list_step_to_end(ViewWindow *vw, gint last) | |
234 { | |
235 ImageWindow *imd = view_window_active_image(vw); | |
138 | 236 FileData *fd; |
9 | 237 GList *work; |
238 GList *work_ahead; | |
239 | |
240 if (!vw->list) return; | |
241 | |
242 if (last) | |
243 { | |
244 work = g_list_last(vw->list); | |
245 work_ahead = work->prev; | |
246 } | |
247 else | |
248 { | |
249 work = vw->list; | |
250 work_ahead = work->next; | |
251 } | |
252 | |
253 vw->list_pointer = work; | |
138 | 254 fd = work->data; |
318 | 255 image_change_fd(imd, fd, image_zoom_get_default(imd, options->zoom_mode)); |
9 | 256 |
318 | 257 if (options->enable_read_ahead && work_ahead) |
9 | 258 { |
138 | 259 FileData *next_fd = work_ahead->data; |
260 image_prebuffer_set(imd, next_fd); | |
9 | 261 } |
262 } | |
263 | |
264 static void view_step_next(ViewWindow *vw) | |
265 { | |
266 if (vw->ss) | |
267 { | |
268 view_slideshow_next(vw); | |
269 } | |
270 else if (vw->list) | |
271 { | |
272 view_list_step(vw, TRUE); | |
273 } | |
274 else | |
275 { | |
276 view_collection_step(vw, TRUE); | |
277 } | |
278 } | |
279 | |
280 static void view_step_prev(ViewWindow *vw) | |
281 { | |
282 if (vw->ss) | |
283 { | |
284 view_slideshow_prev(vw); | |
285 } | |
286 else if (vw->list) | |
287 { | |
288 view_list_step(vw, FALSE); | |
289 } | |
290 else | |
291 { | |
292 view_collection_step(vw, FALSE); | |
293 } | |
294 } | |
295 | |
296 static void view_step_to_end(ViewWindow *vw, gint last) | |
297 { | |
298 if (vw->list) | |
299 { | |
300 view_list_step_to_end(vw, last); | |
301 } | |
302 else | |
303 { | |
304 view_collection_step_to_end(vw, last); | |
305 } | |
306 } | |
307 | |
1 | 308 /* |
309 *----------------------------------------------------------------------------- | |
310 * view window keyboard | |
311 *----------------------------------------------------------------------------- | |
312 */ | |
313 | |
9 | 314 static void view_window_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) |
315 { | |
316 ViewWindow *vw = data; | |
317 ImageWindow *imd; | |
318 | |
319 imd = view_window_active_image(vw); | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
320 gdk_window_get_origin(imd->pr->window, x, y); |
9 | 321 popup_menu_position_clamp(menu, x, y, 0); |
322 } | |
323 | |
1 | 324 static gint view_window_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
325 { | |
9 | 326 ViewWindow *vw = data; |
327 ImageWindow *imd; | |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
328 gint stop_signal; |
9 | 329 GtkWidget *menu; |
1 | 330 gint x = 0; |
331 gint y = 0; | |
332 | |
9 | 333 imd = view_window_active_image(vw); |
334 | |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
335 stop_signal = TRUE; |
1 | 336 switch (event->keyval) |
337 { | |
9 | 338 case GDK_Left: case GDK_KP_Left: |
1 | 339 x -= 1; |
340 break; | |
9 | 341 case GDK_Right: case GDK_KP_Right: |
1 | 342 x += 1; |
343 break; | |
9 | 344 case GDK_Up: case GDK_KP_Up: |
1 | 345 y -= 1; |
346 break; | |
9 | 347 case GDK_Down: case GDK_KP_Down: |
1 | 348 y += 1; |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
349 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
350 default: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
351 stop_signal = FALSE; |
1 | 352 break; |
9 | 353 } |
354 | |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
355 if (x != 0 || y!= 0) |
9 | 356 { |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
357 if (event->state & GDK_SHIFT_MASK) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
358 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
359 x *= 3; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
360 y *= 3; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
361 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
362 |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
363 keyboard_scroll_calc(&x, &y, event); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
364 image_scroll(imd, x, y); |
1 | 365 } |
366 | |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
367 if (stop_signal) return stop_signal; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
368 |
1 | 369 if (event->state & GDK_CONTROL_MASK) |
370 { | |
371 gint n = -1; | |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
372 |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
373 stop_signal = TRUE; |
1 | 374 switch (event->keyval) |
375 { | |
376 case '1': | |
377 n = 0; | |
378 break; | |
379 case '2': | |
380 n = 1; | |
381 break; | |
382 case '3': | |
383 n = 2; | |
384 break; | |
385 case '4': | |
386 n = 3; | |
387 break; | |
388 case '5': | |
389 n = 4; | |
390 break; | |
391 case '6': | |
392 n = 5; | |
393 break; | |
394 case '7': | |
395 n = 6; | |
396 break; | |
397 case '8': | |
398 n = 7; | |
399 break; | |
9 | 400 case '9': |
401 n = 8; | |
402 break; | |
403 case '0': | |
404 n = 9; | |
405 break; | |
406 case 'C': case 'c': | |
138 | 407 file_util_copy(image_get_fd(imd), NULL, NULL, imd->widget); |
9 | 408 break; |
409 case 'M': case 'm': | |
138 | 410 file_util_move(image_get_fd(imd), NULL, NULL, imd->widget); |
9 | 411 break; |
412 case 'R': case 'r': | |
138 | 413 file_util_rename(image_get_fd(imd), NULL, imd->widget); |
9 | 414 break; |
415 case 'D': case 'd': | |
138 | 416 file_util_delete(image_get_fd(imd), NULL, imd->widget); |
9 | 417 break; |
418 case 'P': case 'p': | |
138 | 419 info_window_new(image_get_fd(imd), NULL); |
9 | 420 break; |
421 case 'W': case 'w': | |
422 view_window_close(vw); | |
423 break; | |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
424 default: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
425 stop_signal = FALSE; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
426 break; |
1 | 427 } |
428 if (n != -1) | |
429 { | |
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
430 if (!editor_window_flag_set(n)) |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
431 { |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
432 view_fullscreen_toggle(vw, TRUE); |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
433 } |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
434 imd = view_window_active_image(vw); |
138 | 435 start_editor_from_file(n, image_get_fd(imd)); |
1 | 436 } |
437 } | |
9 | 438 else if (event->state & GDK_SHIFT_MASK) |
1 | 439 { |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
440 stop_signal = TRUE; |
9 | 441 switch (event->keyval) |
442 { | |
443 case 'R': case 'r': | |
444 image_alter(imd, ALTER_ROTATE_180); | |
445 break; | |
446 case 'M': case 'm': | |
447 image_alter(imd, ALTER_MIRROR); | |
448 break; | |
449 case 'F': case 'f': | |
450 image_alter(imd, ALTER_FLIP); | |
451 break; | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
452 case 'G': case 'g': |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
453 image_alter(imd, ALTER_DESATURATE); |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
454 break; |
94
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
455 case 'P': case 'p': |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
456 { |
138 | 457 FileData *fd; |
94
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
458 |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
459 view_fullscreen_toggle(vw, TRUE); |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
460 imd = view_window_active_image(vw); |
138 | 461 fd = image_get_fd(imd); |
462 print_window_new(fd, | |
463 fd ? g_list_append(NULL, file_data_ref(fd)) : NULL, | |
464 filelist_copy(vw->list), vw->window); | |
94
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
465 } |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
466 break; |
9 | 467 default: |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
468 stop_signal = FALSE; |
9 | 469 break; |
470 } | |
1 | 471 } |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
472 else |
1 | 473 { |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
474 stop_signal = TRUE; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
475 switch (event->keyval) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
476 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
477 case GDK_Page_Up: case GDK_KP_Page_Up: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
478 case GDK_BackSpace: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
479 case 'B': case 'b': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
480 view_step_prev(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
481 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
482 case GDK_Page_Down: case GDK_KP_Page_Down: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
483 case GDK_space: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
484 case 'N': case 'n': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
485 view_step_next(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
486 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
487 case GDK_Home: case GDK_KP_Home: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
488 view_step_to_end(vw, FALSE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
489 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
490 case GDK_End: case GDK_KP_End: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
491 view_step_to_end(vw, TRUE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
492 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
493 case '+': case '=': case GDK_KP_Add: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
494 image_zoom_adjust(imd, get_zoom_increment()); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
495 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
496 case '-': case GDK_KP_Subtract: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
497 image_zoom_adjust(imd, -get_zoom_increment()); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
498 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
499 case 'X': case 'x': case GDK_KP_Multiply: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
500 image_zoom_set(imd, 0.0); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
501 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
502 case 'Z': case 'z': case GDK_KP_Divide: case '1': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
503 image_zoom_set(imd, 1.0); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
504 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
505 case '2': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
506 image_zoom_set(imd, 2.0); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
507 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
508 case '3': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
509 image_zoom_set(imd, 3.0); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
510 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
511 case '4': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
512 image_zoom_set(imd, 4.0); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
513 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
514 case '7': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
515 image_zoom_set(imd, -4.0); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
516 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
517 case '8': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
518 image_zoom_set(imd, -3.0); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
519 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
520 case '9': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
521 image_zoom_set(imd, -2.0); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
522 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
523 case 'W': case 'w': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
524 image_zoom_set_fill_geometry(imd, FALSE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
525 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
526 case 'H': case 'h': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
527 image_zoom_set_fill_geometry(imd, TRUE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
528 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
529 case 'R': case 'r': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
530 image_reload(imd); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
531 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
532 case 'S': case 's': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
533 if (vw->ss) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
534 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
535 view_slideshow_stop(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
536 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
537 else |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
538 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
539 view_slideshow_start(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
540 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
541 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
542 case 'P': case 'p': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
543 slideshow_pause_toggle(vw->ss); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
544 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
545 case 'F': case 'f': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
546 case 'V': case 'v': |
86
cade6a52a165
Mon Oct 23 05:34:29 2006 John Ellis <johne@verizon.net>
gqview
parents:
84
diff
changeset
|
547 case GDK_F11: |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
548 view_fullscreen_toggle(vw, FALSE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
549 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
550 case 'I': case 'i': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
551 view_overlay_toggle(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
552 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
553 case ']': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
554 image_alter(imd, ALTER_ROTATE_90); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
555 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
556 case '[': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
557 image_alter(imd, ALTER_ROTATE_90_CC); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
558 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
559 case GDK_Delete: case GDK_KP_Delete: |
318 | 560 if (options->enable_delete_key) |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
561 { |
138 | 562 file_util_delete(image_get_fd(imd), NULL, imd->widget); |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
563 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
564 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
565 case GDK_Escape: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
566 if (vw->fs) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
567 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
568 view_fullscreen_toggle(vw, TRUE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
569 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
570 else |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
571 { |
89
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
572 view_window_close(vw); |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
573 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
574 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
575 case GDK_Menu: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
576 case GDK_F10: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
577 menu = view_popup_menu(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
578 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
579 view_window_menu_pos_cb, vw, 0, GDK_CURRENT_TIME); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
580 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
581 default: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
582 stop_signal = FALSE; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
583 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
584 } |
1 | 585 } |
586 | |
587 return stop_signal; | |
588 } | |
589 | |
590 /* | |
591 *----------------------------------------------------------------------------- | |
592 * view window main routines | |
593 *----------------------------------------------------------------------------- | |
594 */ | |
595 | |
9 | 596 static void button_cb(ImageWindow *imd, gint button, guint32 time, |
597 gdouble x, gdouble y, guint state, gpointer data) | |
598 { | |
599 ViewWindow *vw = data; | |
600 GtkWidget *menu; | |
601 | |
602 switch (button) | |
603 { | |
604 case 1: | |
605 view_step_next(vw); | |
606 break; | |
607 case 2: | |
608 view_step_prev(vw); | |
609 break; | |
610 case 3: | |
611 menu = view_popup_menu(vw); | |
612 gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, time); | |
613 break; | |
614 default: | |
615 break; | |
616 } | |
617 } | |
618 | |
619 static void scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 time, | |
620 gdouble x, gdouble y, guint state, gpointer data) | |
1 | 621 { |
9 | 622 ViewWindow *vw = data; |
623 | |
624 if (state & GDK_CONTROL_MASK) | |
625 { | |
626 switch (direction) | |
627 { | |
628 case GDK_SCROLL_UP: | |
629 image_zoom_adjust_at_point(imd, get_zoom_increment(), x, y); | |
630 break; | |
631 case GDK_SCROLL_DOWN: | |
632 image_zoom_adjust_at_point(imd, -get_zoom_increment(), x, y); | |
633 break; | |
634 default: | |
635 break; | |
636 } | |
637 } | |
318 | 638 else if ( (state & GDK_SHIFT_MASK) != (options->mousewheel_scrolls)) |
9 | 639 { |
640 switch (direction) | |
641 { | |
642 case GDK_SCROLL_UP: | |
643 image_scroll(imd, 0, -MOUSEWHEEL_SCROLL_SIZE); | |
644 break; | |
645 case GDK_SCROLL_DOWN: | |
646 image_scroll(imd, 0, MOUSEWHEEL_SCROLL_SIZE); | |
647 break; | |
648 case GDK_SCROLL_LEFT: | |
649 image_scroll(imd, -MOUSEWHEEL_SCROLL_SIZE, 0); | |
650 break; | |
651 case GDK_SCROLL_RIGHT: | |
652 image_scroll(imd, MOUSEWHEEL_SCROLL_SIZE, 0); | |
653 break; | |
654 default: | |
655 break; | |
656 } | |
657 } | |
658 else | |
659 { | |
660 switch (direction) | |
661 { | |
662 case GDK_SCROLL_UP: | |
663 view_step_prev(vw); | |
664 break; | |
665 case GDK_SCROLL_DOWN: | |
666 view_step_next(vw); | |
667 break; | |
668 default: | |
669 break; | |
670 } | |
671 } | |
672 } | |
673 | |
674 static void view_image_set_buttons(ViewWindow *vw, ImageWindow *imd) | |
675 { | |
676 image_set_button_func(imd, button_cb, vw); | |
677 image_set_scroll_func(imd, scroll_cb, vw); | |
678 } | |
679 | |
680 static void view_fullscreen_stop_func(FullScreenData *fs, gpointer data) | |
681 { | |
682 ViewWindow *vw = data; | |
683 | |
684 vw->fs = NULL; | |
685 | |
686 if (vw->ss) vw->ss->imd = vw->imd; | |
1 | 687 } |
688 | |
9 | 689 static void view_fullscreen_toggle(ViewWindow *vw, gint force_off) |
4 | 690 { |
9 | 691 if (force_off && !vw->fs) return; |
692 | |
693 if (vw->fs) | |
694 { | |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
695 if (image_osd_get(vw->fs->imd, NULL, NULL)) |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
696 { |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
697 image_osd_set(vw->imd, TRUE, TRUE); |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
698 } |
9 | 699 |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
700 fullscreen_stop(vw->fs); |
9 | 701 } |
702 else | |
703 { | |
704 vw->fs = fullscreen_start(vw->window, vw->imd, view_fullscreen_stop_func, vw); | |
705 | |
706 view_image_set_buttons(vw, vw->fs->imd); | |
707 g_signal_connect(G_OBJECT(vw->fs->window), "key_press_event", | |
708 G_CALLBACK(view_window_key_press_cb), vw); | |
709 | |
710 if (vw->ss) vw->ss->imd = vw->fs->imd; | |
711 | |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
712 if (image_osd_get(vw->imd, NULL, NULL)) |
9 | 713 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
714 image_osd_set(vw->imd, FALSE, FALSE); |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
715 image_osd_set(vw->fs->imd, TRUE, TRUE); |
9 | 716 } |
717 } | |
718 } | |
719 | |
720 static void view_overlay_toggle(ViewWindow *vw) | |
721 { | |
722 ImageWindow *imd; | |
723 | |
724 imd = view_window_active_image(vw); | |
725 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
726 if (!image_osd_get(imd, NULL, NULL)) |
9 | 727 { |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
728 image_osd_set(imd, TRUE, TRUE); |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
118
diff
changeset
|
729 image_osd_icon(imd, IMAGE_OSD_ICON, -1); |
9 | 730 } |
731 else | |
732 { | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
733 image_osd_set(imd, FALSE, FALSE); |
9 | 734 } |
735 } | |
736 | |
737 static void view_slideshow_next(ViewWindow *vw) | |
738 { | |
739 if (vw->ss) slideshow_next(vw->ss); | |
4 | 740 } |
741 | |
9 | 742 static void view_slideshow_prev(ViewWindow *vw) |
743 { | |
744 if (vw->ss) slideshow_prev(vw->ss); | |
745 } | |
746 | |
747 static void view_slideshow_stop_func(SlideShowData *fs, gpointer data) | |
748 { | |
749 ViewWindow *vw = data; | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
750 GList *work; |
138 | 751 FileData *fd; |
9 | 752 |
753 vw->ss = NULL; | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
754 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
755 work = vw->list; |
138 | 756 fd = image_get_fd(view_window_active_image(vw)); |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
757 while (work) |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
758 { |
138 | 759 FileData *temp; |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
760 |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
761 temp = work->data; |
138 | 762 if (fd == temp) |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
763 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
764 vw->list_pointer = work; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
765 work = NULL; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
766 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
767 else |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
768 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
769 work = work->next; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
770 } |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
771 } |
9 | 772 } |
773 | |
774 static void view_slideshow_start(ViewWindow *vw) | |
4 | 775 { |
9 | 776 if (!vw->ss) |
777 { | |
778 CollectionData *cd; | |
779 CollectInfo *info; | |
780 | |
781 if (vw->list) | |
782 { | |
138 | 783 vw->ss = slideshow_start_from_filelist(view_window_active_image(vw), |
784 filelist_copy(vw->list), | |
9 | 785 view_slideshow_stop_func, vw); |
786 vw->list_pointer = NULL; | |
787 return; | |
788 } | |
789 | |
790 cd = image_get_collection(view_window_active_image(vw), &info); | |
791 if (cd && info) | |
792 { | |
793 vw->ss = slideshow_start_from_collection(view_window_active_image(vw), cd, | |
794 view_slideshow_stop_func, vw, info); | |
795 } | |
796 } | |
797 } | |
798 | |
799 static void view_slideshow_stop(ViewWindow *vw) | |
800 { | |
801 if (vw->ss) slideshow_free(vw->ss); | |
802 } | |
803 | |
89
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
804 static void view_window_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 805 { |
89
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
806 ViewWindow *vw = data; |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
807 |
9 | 808 view_window_list = g_list_remove(view_window_list, vw); |
809 | |
810 view_slideshow_stop(vw); | |
89
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
811 fullscreen_stop(vw->fs); |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
812 |
138 | 813 filelist_free(vw->list); |
89
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
814 g_free(vw); |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
815 } |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
816 |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
817 static void view_window_close(ViewWindow *vw) |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
818 { |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
819 view_slideshow_stop(vw); |
9 | 820 view_fullscreen_toggle(vw, TRUE); |
821 gtk_widget_destroy(vw->window); | |
4 | 822 } |
823 | |
1 | 824 static gint view_window_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) |
825 { | |
9 | 826 ViewWindow *vw = data; |
827 | |
828 view_window_close(vw); | |
1 | 829 return TRUE; |
830 } | |
831 | |
138 | 832 static ViewWindow *real_view_window_new(FileData *fd, GList *list, CollectionData *cd, CollectInfo *info) |
1 | 833 { |
9 | 834 ViewWindow *vw; |
1 | 835 GtkAllocation req_size; |
9 | 836 GdkGeometry geometry; |
1 | 837 gint w, h; |
9 | 838 |
138 | 839 if (!fd && !list && (!cd || !info)) return NULL; |
9 | 840 |
841 vw = g_new0(ViewWindow, 1); | |
842 vw->fs = NULL; | |
843 vw->ss = NULL; | |
844 vw->list = NULL; | |
845 vw->list_pointer = NULL; | |
846 | |
289
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
847 vw->window = window_new(GTK_WINDOW_TOPLEVEL, "view", PIXBUF_INLINE_ICON_VIEW, NULL, NULL); |
9 | 848 |
849 geometry.min_width = 8; | |
850 geometry.min_height = 8; | |
851 gtk_window_set_geometry_hints(GTK_WINDOW(vw->window), NULL, &geometry, GDK_HINT_MIN_SIZE); | |
1 | 852 |
9 | 853 gtk_window_set_resizable(GTK_WINDOW(vw->window), TRUE); |
854 gtk_container_set_border_width(GTK_CONTAINER(vw->window), 0); | |
855 | |
856 vw->imd = image_new(FALSE); | |
857 | |
318 | 858 image_background_set_color(vw->imd, options->user_specified_window_background ? &options->window_background_color : NULL); |
9 | 859 |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
860 image_attach_window(vw->imd, vw->window, NULL, GQ_APPNAME, TRUE); |
9 | 861 |
862 image_auto_refresh(vw->imd, 0); | |
863 image_top_window_set_sync(vw->imd, TRUE); | |
864 | |
865 gtk_container_add(GTK_CONTAINER(vw->window), vw->imd->widget); | |
866 gtk_widget_show(vw->imd->widget); | |
867 | |
868 view_window_dnd_init(vw); | |
1 | 869 |
9 | 870 view_image_set_buttons(vw, vw->imd); |
1 | 871 |
89
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
872 g_signal_connect(G_OBJECT(vw->window), "destroy", |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
873 G_CALLBACK(view_window_destroy_cb), vw); |
9 | 874 g_signal_connect(G_OBJECT(vw->window), "delete_event", |
875 G_CALLBACK(view_window_delete_cb), vw); | |
876 g_signal_connect(G_OBJECT(vw->window), "key_press_event", | |
877 G_CALLBACK(view_window_key_press_cb), vw); | |
878 if (cd && info) | |
879 { | |
318 | 880 image_change_from_collection(vw->imd, cd, info, image_zoom_get_default(NULL, options->zoom_mode)); |
881 if (options->enable_read_ahead) | |
9 | 882 { |
883 CollectInfo * r_info = collection_next_by_info(cd, info); | |
884 if (!r_info) r_info = collection_prev_by_info(cd, info); | |
138 | 885 if (r_info) image_prebuffer_set(vw->imd, r_info->fd); |
9 | 886 } |
887 } | |
888 else if (list) | |
889 { | |
890 view_window_set_list(vw, list); | |
891 vw->list_pointer = vw->list; | |
318 | 892 image_change_fd(vw->imd, (FileData *)vw->list->data, image_zoom_get_default(NULL, options->zoom_mode)); |
1 | 893 |
318 | 894 if (options->enable_read_ahead) |
9 | 895 { |
896 GList *work = vw->list->next; | |
138 | 897 if (work) image_prebuffer_set(vw->imd, (FileData *)work->data); |
9 | 898 } |
899 } | |
900 else | |
901 { | |
318 | 902 image_change_fd(vw->imd, fd, image_zoom_get_default(NULL, options->zoom_mode)); |
9 | 903 } |
1 | 904 |
9 | 905 if (image_zoom_get(vw->imd) == 0.0) |
906 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
907 pixbuf_renderer_get_image_size(PIXBUF_RENDERER(vw->imd->pr), &w, &h); |
9 | 908 } |
909 else | |
910 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
911 pixbuf_renderer_get_scaled_size(PIXBUF_RENDERER(vw->imd->pr), &w, &h); |
9 | 912 } |
318 | 913 if (options->limit_window_size) |
1 | 914 { |
318 | 915 gint mw = gdk_screen_width() * options->max_window_size / 100; |
916 gint mh = gdk_screen_height() * options->max_window_size / 100; | |
1 | 917 |
918 if (w > mw) w = mw; | |
919 if (h > mh) h = mh; | |
920 } | |
921 | |
9 | 922 gtk_window_set_default_size(GTK_WINDOW(vw->window), w, h); |
1 | 923 req_size.x = req_size.y = 0; |
924 req_size.width = w; | |
925 req_size.height = h; | |
9 | 926 gtk_widget_size_allocate(GTK_WIDGET(vw->window), &req_size); |
927 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
928 gtk_widget_set_size_request(vw->imd->pr, w, h); |
9 | 929 |
930 gtk_widget_show(vw->window); | |
931 | |
932 view_window_list = g_list_append(view_window_list, vw); | |
933 | |
934 return vw; | |
935 } | |
936 | |
937 static void view_window_collection_unref_cb(GtkWidget *widget, gpointer data) | |
938 { | |
939 CollectionData *cd = data; | |
940 | |
941 collection_unref(cd); | |
942 } | |
943 | |
138 | 944 void view_window_new(FileData *fd) |
9 | 945 { |
138 | 946 if (file_extension_match(fd->path, ".gqv")) |
9 | 947 { |
948 ViewWindow *vw; | |
949 CollectionData *cd; | |
950 CollectInfo *info; | |
951 | |
138 | 952 cd = collection_new(fd->path); |
953 if (collection_load(cd, fd->path, FALSE)) | |
9 | 954 { |
955 info = collection_get_first(cd); | |
956 } | |
957 else | |
958 { | |
959 collection_unref(cd); | |
960 cd = NULL; | |
961 info = NULL; | |
962 } | |
963 vw = real_view_window_new(NULL, NULL, cd, info); | |
964 if (vw && cd) | |
965 { | |
966 g_signal_connect(G_OBJECT(vw->window), "destroy", | |
967 G_CALLBACK(view_window_collection_unref_cb), cd); | |
968 } | |
969 } | |
138 | 970 else if (isdir(fd->path)) |
9 | 971 { |
972 GList *list = NULL; | |
1 | 973 |
138 | 974 if (filelist_read(fd->path, &list, NULL)) |
9 | 975 { |
138 | 976 list = filelist_sort_path(list); |
977 list = filelist_filter(list, FALSE); | |
9 | 978 } |
979 real_view_window_new(NULL, list, NULL, NULL); | |
138 | 980 filelist_free(list); |
9 | 981 } |
982 else | |
983 { | |
138 | 984 real_view_window_new(fd, NULL, NULL, NULL); |
9 | 985 } |
986 } | |
987 | |
988 void view_window_new_from_list(GList *list) | |
989 { | |
990 real_view_window_new(NULL, list, NULL, NULL); | |
991 } | |
992 | |
993 void view_window_new_from_collection(CollectionData *cd, CollectInfo *info) | |
994 { | |
995 real_view_window_new(NULL, NULL, cd, info); | |
996 } | |
997 | |
998 /* | |
999 *----------------------------------------------------------------------------- | |
1000 * public | |
1001 *----------------------------------------------------------------------------- | |
1002 */ | |
1003 | |
1004 void view_window_colors_update(void) | |
1005 { | |
1006 GList *work; | |
1 | 1007 |
9 | 1008 work = view_window_list; |
1009 while (work) | |
1010 { | |
1011 ViewWindow *vw = work->data; | |
1012 work = work->next; | |
1013 | |
318 | 1014 image_background_set_color(vw->imd, options->user_specified_window_background ? &options->window_background_color : NULL); |
9 | 1015 } |
1016 } | |
1017 | |
1018 gint view_window_find_image(ImageWindow *imd, gint *index, gint *total) | |
1019 { | |
1020 GList *work; | |
1021 | |
1022 work = view_window_list; | |
1023 while (work) | |
1024 { | |
1025 ViewWindow *vw = work->data; | |
1026 work = work->next; | |
1027 | |
1028 if (vw->imd == imd || | |
1029 (vw->fs && vw->fs->imd == imd)) | |
1030 { | |
1031 if (vw->ss) | |
1032 { | |
1033 gint n; | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1034 gint t; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1035 |
9 | 1036 n = g_list_length(vw->ss->list_done); |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1037 t = n + g_list_length(vw->ss->list); |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1038 if (n == 0) n = t; |
9 | 1039 if (index) *index = n - 1; |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1040 if (total) *total = t; |
9 | 1041 } |
1042 else | |
1043 { | |
1044 if (index) *index = g_list_position(vw->list, vw->list_pointer); | |
1045 if (total) *total = g_list_length(vw->list); | |
1046 } | |
1047 return TRUE; | |
1048 } | |
1049 } | |
1050 | |
1051 return FALSE; | |
1 | 1052 } |
1053 | |
1054 /* | |
1055 *----------------------------------------------------------------------------- | |
1056 * view window menu routines and callbacks | |
1057 *----------------------------------------------------------------------------- | |
1058 */ | |
1059 | |
9 | 1060 static void view_new_window_cb(GtkWidget *widget, gpointer data) |
1 | 1061 { |
9 | 1062 ViewWindow *vw = data; |
1063 CollectionData *cd; | |
1064 CollectInfo *info; | |
1065 | |
1066 cd = image_get_collection(vw->imd, &info); | |
1067 | |
1068 if (cd && info) | |
1069 { | |
1070 view_window_new_from_collection(cd, info); | |
1071 } | |
1072 else | |
1073 { | |
138 | 1074 view_window_new(image_get_fd(vw->imd)); |
9 | 1075 } |
1 | 1076 } |
1077 | |
9 | 1078 static void view_edit_cb(GtkWidget *widget, gpointer data) |
1 | 1079 { |
9 | 1080 ViewWindow *vw; |
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1081 ImageWindow *imd; |
9 | 1082 gint n; |
1083 | |
1084 vw = submenu_item_get_data(widget); | |
1085 n = GPOINTER_TO_INT(data); | |
1086 if (!vw) return; | |
1087 | |
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1088 if (!editor_window_flag_set(n)) |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1089 { |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1090 view_fullscreen_toggle(vw, TRUE); |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1091 } |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1092 |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1093 imd = view_window_active_image(vw); |
138 | 1094 start_editor_from_file(n, image_get_fd(imd)); |
1 | 1095 } |
1096 | |
9 | 1097 static void view_alter_cb(GtkWidget *widget, gpointer data) |
1098 { | |
1099 ViewWindow *vw; | |
1100 AlterType type; | |
1101 | |
1102 vw = submenu_item_get_data(widget); | |
1103 type = GPOINTER_TO_INT(data); | |
1104 | |
1105 if (!vw) return; | |
1106 image_alter(vw->imd, type); | |
1107 } | |
1108 | |
1109 static void view_info_cb(GtkWidget *widget, gpointer data) | |
3 | 1110 { |
9 | 1111 ViewWindow *vw = data; |
1112 ImageWindow *imd; | |
1113 | |
1114 imd = view_window_active_image(vw); | |
138 | 1115 info_window_new(image_get_fd(imd), NULL); |
9 | 1116 } |
1117 | |
1118 static void view_wallpaper_cb(GtkWidget *widget, gpointer data) | |
1119 { | |
1120 ViewWindow *vw = data; | |
1121 ImageWindow *imd; | |
1122 | |
1123 imd = view_window_active_image(vw); | |
1124 image_to_root_window(imd, (image_zoom_get(imd) == 0.0)); | |
3 | 1125 } |
1126 | |
1 | 1127 static void view_zoom_in_cb(GtkWidget *widget, gpointer data) |
1128 { | |
9 | 1129 ViewWindow *vw = data; |
1130 | |
1131 image_zoom_adjust(view_window_active_image(vw), get_zoom_increment()); | |
1 | 1132 } |
1133 | |
1134 static void view_zoom_out_cb(GtkWidget *widget, gpointer data) | |
1135 { | |
9 | 1136 ViewWindow *vw = data; |
1137 | |
1138 image_zoom_adjust(view_window_active_image(vw), -get_zoom_increment()); | |
1 | 1139 } |
1140 | |
1141 static void view_zoom_1_1_cb(GtkWidget *widget, gpointer data) | |
1142 { | |
9 | 1143 ViewWindow *vw = data; |
1144 | |
1145 image_zoom_set(view_window_active_image(vw), 1.0); | |
1 | 1146 } |
1147 | |
1148 static void view_zoom_fit_cb(GtkWidget *widget, gpointer data) | |
1149 { | |
9 | 1150 ViewWindow *vw = data; |
1151 | |
1152 image_zoom_set(view_window_active_image(vw), 0.0); | |
1 | 1153 } |
1154 | |
1155 static void view_copy_cb(GtkWidget *widget, gpointer data) | |
1156 { | |
9 | 1157 ViewWindow *vw = data; |
1158 ImageWindow *imd; | |
1159 | |
1160 imd = view_window_active_image(vw); | |
138 | 1161 file_util_copy(image_get_fd(imd), NULL, NULL, imd->widget); |
1 | 1162 } |
1163 | |
1164 static void view_move_cb(GtkWidget *widget, gpointer data) | |
1165 { | |
9 | 1166 ViewWindow *vw = data; |
1167 ImageWindow *imd; | |
1168 | |
1169 imd = view_window_active_image(vw); | |
138 | 1170 file_util_move(image_get_fd(imd), NULL, NULL, imd->widget); |
1 | 1171 } |
1172 | |
1173 static void view_rename_cb(GtkWidget *widget, gpointer data) | |
1174 { | |
9 | 1175 ViewWindow *vw = data; |
1176 ImageWindow *imd; | |
1177 | |
1178 imd = view_window_active_image(vw); | |
138 | 1179 file_util_rename(image_get_fd(imd), NULL, imd->widget); |
1 | 1180 } |
1181 | |
1182 static void view_delete_cb(GtkWidget *widget, gpointer data) | |
1183 { | |
9 | 1184 ViewWindow *vw = data; |
1185 ImageWindow *imd; | |
1186 | |
1187 imd = view_window_active_image(vw); | |
138 | 1188 file_util_delete(image_get_fd(imd), NULL, imd->widget); |
9 | 1189 } |
1190 | |
1191 static void view_fullscreen_cb(GtkWidget *widget, gpointer data) | |
1192 { | |
1193 ViewWindow *vw = data; | |
1194 | |
1195 view_fullscreen_toggle(vw, FALSE); | |
1196 } | |
1197 | |
1198 static void view_slideshow_start_cb(GtkWidget *widget, gpointer data) | |
1199 { | |
1200 ViewWindow *vw = data; | |
1201 | |
1202 view_slideshow_start(vw); | |
1203 } | |
1204 | |
1205 static void view_slideshow_stop_cb(GtkWidget *widget, gpointer data) | |
1206 { | |
1207 ViewWindow *vw = data; | |
1208 | |
1209 view_slideshow_stop(vw); | |
1210 } | |
1211 | |
1212 static void view_slideshow_pause_cb(GtkWidget *widget, gpointer data) | |
1213 { | |
1214 ViewWindow *vw = data; | |
1215 | |
1216 slideshow_pause_toggle(vw->ss); | |
1 | 1217 } |
1218 | |
1219 static void view_close_cb(GtkWidget *widget, gpointer data) | |
1220 { | |
9 | 1221 ViewWindow *vw = data; |
1222 | |
1223 view_window_close(vw); | |
1224 } | |
1225 | |
1226 static GtkWidget *view_popup_menu(ViewWindow *vw) | |
1227 { | |
1228 GtkWidget *menu; | |
1229 GtkWidget *item; | |
1230 | |
1231 menu = popup_menu_short_lived(); | |
1232 | |
1233 menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN, G_CALLBACK(view_zoom_in_cb), vw); | |
1234 menu_item_add_stock(menu, _("Zoom _out"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(view_zoom_out_cb), vw); | |
1235 menu_item_add_stock(menu, _("Zoom _1:1"), GTK_STOCK_ZOOM_100, G_CALLBACK(view_zoom_1_1_cb), vw); | |
1236 menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(view_zoom_fit_cb), vw); | |
1237 menu_item_add_divider(menu); | |
1238 | |
1239 item = submenu_add_edit(menu, NULL, G_CALLBACK(view_edit_cb), vw); | |
1240 menu_item_add_divider(item); | |
1241 menu_item_add(item, _("Set as _wallpaper"), G_CALLBACK(view_wallpaper_cb), vw); | |
1242 | |
1243 submenu_add_alter(menu, G_CALLBACK(view_alter_cb), vw); | |
1244 | |
1245 menu_item_add_stock(menu, _("_Properties"), GTK_STOCK_PROPERTIES, G_CALLBACK(view_info_cb), vw); | |
1246 | |
1247 menu_item_add_stock(menu, _("View in _new window"), GTK_STOCK_NEW, G_CALLBACK(view_new_window_cb), vw); | |
1248 | |
1249 menu_item_add_divider(menu); | |
1250 menu_item_add_stock(menu, _("_Copy..."), GTK_STOCK_COPY, G_CALLBACK(view_copy_cb), vw); | |
1251 menu_item_add(menu, _("_Move..."), G_CALLBACK(view_move_cb), vw); | |
1252 menu_item_add(menu, _("_Rename..."), G_CALLBACK(view_rename_cb), vw); | |
1253 menu_item_add_stock(menu, _("_Delete..."), GTK_STOCK_DELETE, G_CALLBACK(view_delete_cb), vw); | |
1254 | |
1255 menu_item_add_divider(menu); | |
1256 | |
1257 if (vw->ss) | |
1258 { | |
1259 menu_item_add(menu, _("_Stop slideshow"), G_CALLBACK(view_slideshow_stop_cb), vw); | |
1260 if (slideshow_paused(vw->ss)) | |
1261 { | |
1262 item = menu_item_add(menu, _("Continue slides_how"), | |
1263 G_CALLBACK(view_slideshow_pause_cb), vw); | |
1264 } | |
1265 else | |
1266 { | |
1267 item = menu_item_add(menu, _("Pause slides_how"), | |
1268 G_CALLBACK(view_slideshow_pause_cb), vw); | |
1269 } | |
1270 } | |
1271 else | |
1272 { | |
1273 item = menu_item_add(menu, _("_Start slideshow"), G_CALLBACK(view_slideshow_start_cb), vw); | |
1274 gtk_widget_set_sensitive(item, (vw->list != NULL) || view_window_contains_collection(vw)); | |
1275 item = menu_item_add(menu, _("Pause slides_how"), G_CALLBACK(view_slideshow_pause_cb), vw); | |
1276 gtk_widget_set_sensitive(item, FALSE); | |
1277 } | |
1278 | |
1279 if (vw->fs) | |
1280 { | |
1281 menu_item_add(menu, _("Exit _full screen"), G_CALLBACK(view_fullscreen_cb), vw); | |
1282 } | |
1283 else | |
1284 { | |
1285 menu_item_add(menu, _("_Full screen"), G_CALLBACK(view_fullscreen_cb), vw); | |
1286 } | |
1287 | |
1288 menu_item_add_divider(menu); | |
1289 menu_item_add_stock(menu, _("C_lose window"), GTK_STOCK_CLOSE, G_CALLBACK(view_close_cb), vw); | |
1290 | |
1291 return menu; | |
1292 } | |
1293 | |
1294 /* | |
1295 *------------------------------------------------------------------- | |
1296 * dnd confirm dir | |
1297 *------------------------------------------------------------------- | |
1298 */ | |
1299 | |
1300 typedef struct { | |
1301 ViewWindow *vw; | |
1302 GList *list; | |
1303 } CViewConfirmD; | |
1304 | |
1305 static void view_dir_list_cancel(GtkWidget *widget, gpointer data) | |
1306 { | |
1307 /* do nothing */ | |
1308 } | |
1309 | |
1310 static void view_dir_list_do(ViewWindow *vw, GList *list, gint skip, gint recurse) | |
1311 { | |
1312 GList *work; | |
1313 | |
1314 view_window_set_list(vw, NULL); | |
1315 | |
1316 work = list; | |
1317 while (work) | |
1318 { | |
138 | 1319 FileData *fd = work->data; |
9 | 1320 work = work->next; |
1321 | |
138 | 1322 if (isdir(fd->path)) |
9 | 1323 { |
1324 if (!skip) | |
1325 { | |
1326 GList *list = NULL; | |
1327 | |
1328 if (recurse) | |
1329 { | |
138 | 1330 list = filelist_recursive(fd->path); |
9 | 1331 } |
1332 else | |
138 | 1333 { /*FIXME */ |
1334 filelist_read(fd->path, &list, NULL); | |
1335 list = filelist_sort_path(list); | |
1336 list = filelist_filter(list, FALSE); | |
9 | 1337 } |
1338 if (list) vw->list = g_list_concat(vw->list, list); | |
1339 } | |
1340 } | |
1341 else | |
1342 { | |
1343 /* FIXME: no filtering here */ | |
138 | 1344 vw->list = g_list_append(vw->list, file_data_ref(fd)); |
9 | 1345 } |
1346 } | |
1347 | |
1348 if (vw->list) | |
1349 { | |
138 | 1350 FileData *fd; |
9 | 1351 |
1352 vw->list_pointer = vw->list; | |
138 | 1353 fd = vw->list->data; |
318 | 1354 image_change_fd(vw->imd, fd, image_zoom_get_default(vw->imd, options->zoom_mode)); |
9 | 1355 |
1356 work = vw->list->next; | |
318 | 1357 if (options->enable_read_ahead && work) |
9 | 1358 { |
138 | 1359 fd = work->data; |
1360 image_prebuffer_set(vw->imd, fd); | |
9 | 1361 } |
1362 } | |
1363 else | |
1364 { | |
318 | 1365 image_change_fd(vw->imd, NULL, image_zoom_get_default(vw->imd, options->zoom_mode)); |
9 | 1366 } |
1367 } | |
1368 | |
1369 static void view_dir_list_add(GtkWidget *widget, gpointer data) | |
1370 { | |
1371 CViewConfirmD *d = data; | |
1372 view_dir_list_do(d->vw, d->list, FALSE, FALSE); | |
1373 } | |
1374 | |
1375 static void view_dir_list_recurse(GtkWidget *widget, gpointer data) | |
1376 { | |
1377 CViewConfirmD *d = data; | |
1378 view_dir_list_do(d->vw, d->list, FALSE, TRUE); | |
1379 } | |
1380 | |
1381 static void view_dir_list_skip(GtkWidget *widget, gpointer data) | |
1382 { | |
1383 CViewConfirmD *d = data; | |
1384 view_dir_list_do(d->vw, d->list, TRUE, FALSE); | |
1385 } | |
1386 | |
1387 static void view_dir_list_destroy(GtkWidget *widget, gpointer data) | |
1388 { | |
1389 CViewConfirmD *d = data; | |
138 | 1390 filelist_free(d->list); |
9 | 1391 g_free(d); |
1392 } | |
1393 | |
1394 static GtkWidget *view_confirm_dir_list(ViewWindow *vw, GList *list) | |
1395 { | |
1396 GtkWidget *menu; | |
1397 CViewConfirmD *d; | |
1398 | |
1399 d = g_new(CViewConfirmD, 1); | |
1400 d->vw = vw; | |
1401 d->list = list; | |
1402 | |
1403 menu = popup_menu_short_lived(); | |
1404 g_signal_connect(G_OBJECT(menu), "destroy", | |
1405 G_CALLBACK(view_dir_list_destroy), d); | |
1406 | |
1407 menu_item_add_stock(menu, _("Dropped list includes folders."), GTK_STOCK_DND_MULTIPLE, NULL, NULL); | |
1408 menu_item_add_divider(menu); | |
1409 menu_item_add_stock(menu, _("_Add contents"), GTK_STOCK_OK, G_CALLBACK(view_dir_list_add), d); | |
1410 menu_item_add_stock(menu, _("Add contents _recursive"), GTK_STOCK_ADD, G_CALLBACK(view_dir_list_recurse), d); | |
1411 menu_item_add_stock(menu, _("_Skip folders"), GTK_STOCK_REMOVE, G_CALLBACK(view_dir_list_skip), d); | |
1412 menu_item_add_divider(menu); | |
1413 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, G_CALLBACK(view_dir_list_cancel), d); | |
1414 | |
1415 return menu; | |
1 | 1416 } |
1417 | |
9 | 1418 /* |
1419 *----------------------------------------------------------------------------- | |
1420 * image drag and drop routines | |
1421 *----------------------------------------------------------------------------- | |
1422 */ | |
1423 | |
1424 static void view_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, | |
1425 gint x, gint y, | |
1426 GtkSelectionData *selection_data, guint info, | |
1427 guint time, gpointer data) | |
1 | 1428 { |
9 | 1429 ViewWindow *vw = data; |
1430 ImageWindow *imd; | |
1431 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1432 if (gtk_drag_get_source_widget(context) == vw->imd->pr) return; |
9 | 1433 |
1434 imd = vw->imd; | |
1435 | |
1436 if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER) | |
1437 { | |
1438 CollectionData *source; | |
1439 GList *list; | |
1440 GList *info_list; | |
1441 | |
1442 if (info == TARGET_URI_LIST) | |
1443 { | |
1444 GList *work; | |
1445 | |
138 | 1446 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); |
9 | 1447 |
1448 work = list; | |
1449 while (work) | |
1450 { | |
138 | 1451 FileData *fd = work->data; |
1452 if (isdir(fd->path)) | |
9 | 1453 { |
1454 GtkWidget *menu; | |
1455 menu = view_confirm_dir_list(vw, list); | |
1456 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, time); | |
1457 return; | |
1458 } | |
1459 work = work->next; | |
1460 } | |
1461 | |
138 | 1462 list = filelist_filter(list, FALSE); |
9 | 1463 |
1464 source = NULL; | |
1465 info_list = NULL; | |
1466 } | |
1467 else | |
1468 { | |
1469 source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); | |
1470 } | |
1471 | |
1472 if (list) | |
1473 { | |
138 | 1474 FileData *fd; |
9 | 1475 |
138 | 1476 fd = list->data; |
1477 if (isfile(fd->path)) | |
9 | 1478 { |
1479 view_slideshow_stop(vw); | |
1480 view_window_set_list(vw, NULL); | |
1 | 1481 |
9 | 1482 if (source && info_list) |
1483 { | |
318 | 1484 image_change_from_collection(imd, source, info_list->data, image_zoom_get_default(imd, options->zoom_mode)); |
9 | 1485 } |
1486 else | |
1487 { | |
1488 if (list->next) | |
1489 { | |
1490 vw->list = list; | |
1491 list = NULL; | |
1492 | |
1493 vw->list_pointer = vw->list; | |
1494 } | |
318 | 1495 image_change_fd(imd, fd, image_zoom_get_default(imd, options->zoom_mode)); |
9 | 1496 } |
1497 } | |
1498 } | |
138 | 1499 filelist_free(list); |
9 | 1500 g_list_free(info_list); |
1501 } | |
1502 } | |
1503 | |
1504 static void view_window_set_dnd_data(GtkWidget *widget, GdkDragContext *context, | |
1505 GtkSelectionData *selection_data, guint info, | |
1506 guint time, gpointer data) | |
1507 { | |
1508 ViewWindow *vw = data; | |
138 | 1509 FileData *fd; |
9 | 1510 |
138 | 1511 fd = image_get_fd(vw->imd); |
1 | 1512 |
138 | 1513 if (fd) |
9 | 1514 { |
1515 gchar *text = NULL; | |
1516 gint len; | |
1517 gint plain_text; | |
1518 GList *list; | |
1 | 1519 |
9 | 1520 switch (info) |
1521 { | |
1522 case TARGET_URI_LIST: | |
1523 plain_text = FALSE; | |
1524 break; | |
1525 case TARGET_TEXT_PLAIN: | |
1526 default: | |
1527 plain_text = TRUE; | |
1528 break; | |
1529 } | |
138 | 1530 list = g_list_append(NULL, fd); |
1531 text = uri_text_from_filelist(list, &len, plain_text); | |
9 | 1532 g_list_free(list); |
1533 if (text) | |
1534 { | |
1535 gtk_selection_data_set (selection_data, selection_data->target, | |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
60
diff
changeset
|
1536 8, (guchar *)text, len); |
9 | 1537 g_free(text); |
1538 } | |
1539 } | |
1540 else | |
1541 { | |
1542 gtk_selection_data_set (selection_data, selection_data->target, | |
1543 8, NULL, 0); | |
1544 } | |
1 | 1545 } |
1546 | |
9 | 1547 static void view_window_dnd_init(ViewWindow *vw) |
1548 { | |
1549 ImageWindow *imd; | |
1 | 1550 |
9 | 1551 imd = vw->imd; |
1552 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1553 gtk_drag_source_set(imd->pr, GDK_BUTTON2_MASK, |
9 | 1554 dnd_file_drag_types, dnd_file_drag_types_count, |
1555 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1556 g_signal_connect(G_OBJECT(imd->pr), "drag_data_get", |
9 | 1557 G_CALLBACK(view_window_set_dnd_data), vw); |
1558 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1559 gtk_drag_dest_set(imd->pr, |
9 | 1560 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, |
1561 dnd_file_drop_types, dnd_file_drop_types_count, | |
1562 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1563 g_signal_connect(G_OBJECT(imd->pr), "drag_data_received", |
9 | 1564 G_CALLBACK(view_window_get_dnd_data), vw); |
1565 } | |
1566 | |
1567 /* | |
1568 *----------------------------------------------------------------------------- | |
1569 * maintenance (for rename, move, remove) | |
1570 *----------------------------------------------------------------------------- | |
1571 */ | |
1572 | |
138 | 1573 static void view_real_removed(ViewWindow *vw, FileData *fd, GList *ignore_list) |
9 | 1574 { |
1575 ImageWindow *imd; | |
138 | 1576 FileData *image_fd; |
9 | 1577 |
1578 imd = view_window_active_image(vw); | |
138 | 1579 image_fd = image_get_fd(imd); |
9 | 1580 |
138 | 1581 if (image_fd && image_fd == fd) |
9 | 1582 { |
1583 if (vw->list) | |
1584 { | |
1585 view_list_step(vw, TRUE); | |
138 | 1586 if (image_get_fd(imd) == image_fd) |
9 | 1587 { |
1588 view_list_step(vw, FALSE); | |
1589 } | |
1590 } | |
1591 else if (view_window_contains_collection(vw)) | |
1592 { | |
1593 view_collection_step(vw, TRUE); | |
138 | 1594 if (image_get_fd(imd) == image_fd) |
9 | 1595 { |
1596 view_collection_step(vw, FALSE); | |
1597 } | |
1598 } | |
138 | 1599 if (image_get_fd(imd) == image_fd) |
9 | 1600 { |
318 | 1601 image_change_fd(imd, NULL, image_zoom_get_default(imd, options->zoom_mode)); |
9 | 1602 } |
1603 } | |
1604 | |
1605 if (vw->list) | |
1606 { | |
1607 GList *work; | |
1608 GList *old; | |
1609 | |
1610 old = vw->list_pointer; | |
1611 | |
1612 work = vw->list; | |
1613 while (work) | |
1614 { | |
138 | 1615 FileData *chk_fd; |
9 | 1616 GList *chk_link; |
1617 | |
138 | 1618 chk_fd = work->data; |
9 | 1619 chk_link = work; |
1620 work = work->next; | |
1621 | |
138 | 1622 if (chk_fd == fd) |
9 | 1623 { |
1624 if (vw->list_pointer == chk_link) | |
1625 { | |
1626 vw->list_pointer = (chk_link->next) ? chk_link->next : chk_link->prev; | |
1627 } | |
138 | 1628 vw->list = g_list_remove(vw->list, chk_fd); |
1629 file_data_unref(chk_fd); | |
9 | 1630 } |
1631 } | |
1632 | |
1633 /* handles stepping correctly when same image is in the list more than once */ | |
1634 if (old && old != vw->list_pointer) | |
1635 { | |
138 | 1636 FileData *fd; |
9 | 1637 |
1638 if (vw->list_pointer) | |
1639 { | |
138 | 1640 fd = vw->list_pointer->data; |
9 | 1641 } |
1642 else | |
1643 { | |
138 | 1644 fd = NULL; |
9 | 1645 } |
1646 | |
318 | 1647 image_change_fd(imd, fd, image_zoom_get_default(imd, options->zoom_mode)); |
9 | 1648 } |
1649 } | |
1650 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
1651 image_osd_update(imd); |
9 | 1652 } |
1653 | |
138 | 1654 static void view_real_moved(ViewWindow *vw, FileData *fd) |
9 | 1655 { |
138 | 1656 /* |
9 | 1657 ImageWindow *imd; |
1658 const gchar *image_path; | |
1659 | |
1660 imd = view_window_active_image(vw); | |
138 | 1661 */ |
1662 /* | |
9 | 1663 image_path = image_get_path(imd); |
1664 | |
138 | 1665 if (image_path && strcmp(image_path, fd->change->source) == 0) |
9 | 1666 { |
138 | 1667 image_set_fd(imd, dest); |
9 | 1668 } |
138 | 1669 */ |
1670 /* | |
9 | 1671 if (vw->list) |
1672 { | |
1673 GList *work; | |
1674 work = vw->list; | |
1675 while (work) | |
1676 { | |
1677 gchar *chk_path; | |
1678 | |
1679 chk_path = work->data; | |
1680 | |
1681 if (strcmp(chk_path, source) == 0) | |
1682 { | |
1683 work->data = g_strdup(dest); | |
1684 g_free(chk_path); | |
1685 } | |
1686 | |
1687 work = work->next; | |
1688 } | |
1689 } | |
138 | 1690 */ |
9 | 1691 } |
1692 | |
138 | 1693 void view_window_maint_removed(FileData *fd, GList *ignore_list) |
9 | 1694 { |
1695 GList *work = view_window_list; | |
1696 while (work) | |
1697 { | |
1698 ViewWindow *vw = work->data; | |
1699 work = work->next; | |
1700 | |
138 | 1701 view_real_removed(vw, fd, ignore_list); |
9 | 1702 } |
1703 } | |
1704 | |
138 | 1705 void view_window_maint_moved(FileData *fd) |
9 | 1706 { |
1707 GList *work = view_window_list; | |
1708 while (work) | |
1709 { | |
1710 ViewWindow *vw = work->data; | |
1711 work = work->next; | |
1712 | |
138 | 1713 view_real_moved(vw, fd); |
9 | 1714 } |
1715 } | |
1716 |