Mercurial > geeqie
annotate src/img-view.c @ 131:b1acdfc7271b
relative scroll is working; some cleanup
author | nadvornik |
---|---|
date | Thu, 12 Jul 2007 20:46:28 +0000 |
parents | e2a8b7f2165b |
children | 71e1ebee420e |
rev | line source |
---|---|
1 | 1 /* |
9 | 2 * GQview |
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 |
1 | 13 #include "gqview.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 | |
84 path_list_free(vw->list); | |
85 vw->list = NULL; | |
86 vw->list_pointer = NULL; | |
87 | |
88 vw->list = path_list_copy(list); | |
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); | |
115 if (enable_read_ahead) | |
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); | |
124 if (enable_read_ahead) | |
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 { | |
133 image_change_from_collection(imd, cd, info, image_zoom_get_default(imd, zoom_mode)); | |
134 | |
135 if (read_ahead_info) image_prebuffer_set(imd, read_ahead_info->path); | |
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); | |
154 if (enable_read_ahead) read_ahead_info = collection_prev_by_info(cd, info); | |
155 } | |
156 else | |
157 { | |
158 info = collection_get_first(cd); | |
159 if (enable_read_ahead) read_ahead_info = collection_next_by_info(cd, info); | |
160 } | |
161 | |
162 if (info) | |
163 { | |
164 image_change_from_collection(imd, cd, info, image_zoom_get_default(imd, zoom_mode)); | |
165 if (read_ahead_info) image_prebuffer_set(imd, read_ahead_info->path); | |
166 } | |
167 } | |
168 | |
169 static void view_list_step(ViewWindow *vw, gint next) | |
170 { | |
171 ImageWindow *imd = view_window_active_image(vw); | |
172 const gchar *path; | |
173 GList *work; | |
174 GList *work_ahead; | |
175 | |
176 if (!vw->list) return; | |
177 | |
178 path = image_get_path(imd); | |
179 if (!path) return; | |
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 { | |
192 gchar *temp; | |
193 | |
194 temp = work->data; | |
195 | |
196 if (strcmp(path, temp) == 0) | |
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; | |
223 path = work->data; | |
224 image_change_path(imd, path, image_zoom_get_default(imd, zoom_mode)); | |
225 | |
226 if (enable_read_ahead && work_ahead) | |
227 { | |
228 const gchar *next_path = work_ahead->data; | |
229 image_prebuffer_set(imd, next_path); | |
230 } | |
231 } | |
232 | |
233 static void view_list_step_to_end(ViewWindow *vw, gint last) | |
234 { | |
235 ImageWindow *imd = view_window_active_image(vw); | |
236 const gchar *path; | |
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; | |
254 path = work->data; | |
255 image_change_path(imd, path, image_zoom_get_default(imd, zoom_mode)); | |
256 | |
257 if (enable_read_ahead && work_ahead) | |
258 { | |
259 const gchar *next_path = work_ahead->data; | |
260 image_prebuffer_set(imd, next_path); | |
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': | |
407 file_util_copy(image_get_path(imd), NULL, NULL, imd->widget); | |
408 break; | |
409 case 'M': case 'm': | |
410 file_util_move(image_get_path(imd), NULL, NULL, imd->widget); | |
411 break; | |
412 case 'R': case 'r': | |
413 file_util_rename(image_get_path(imd), NULL, imd->widget); | |
414 break; | |
415 case 'D': case 'd': | |
416 file_util_delete(image_get_path(imd), NULL, imd->widget); | |
417 break; | |
418 case 'P': case 'p': | |
419 info_window_new(image_get_path(imd), NULL); | |
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); |
9 | 435 start_editor_from_file(n, image_get_path(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 { |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
457 const gchar *path; |
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); |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
461 path = image_get_path(imd); |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
462 print_window_new(path, |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
463 (path) ? g_list_append(NULL, g_strdup(path)) : NULL, |
50dc5a14d37b
Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
464 path_list_copy(vw->list), vw->window); |
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: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
560 if (enable_delete_key) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
561 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
562 file_util_delete(image_get_path(imd), NULL, imd->widget); |
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 } | |
638 else if ( (state & GDK_SHIFT_MASK) != (mousewheel_scrolls)) | |
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; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
751 const gchar *path; |
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; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
756 path = image_get_path(view_window_active_image(vw)); |
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 { |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
759 gchar *temp; |
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; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
762 if (strcmp(path, temp) == 0) |
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 { | |
783 vw->ss = slideshow_start_from_path_list(view_window_active_image(vw), | |
784 path_list_copy(vw->list), | |
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 |
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
813 path_list_free(vw->list); |
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 | |
9 | 832 static ViewWindow *real_view_window_new(const gchar *path, 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 |
839 if (!path && !list && (!cd || !info)) return NULL; | |
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 | |
847 vw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
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_window_set_title (GTK_WINDOW(vw->window), "GQview"); | |
855 gtk_window_set_wmclass(GTK_WINDOW(vw->window), "view", "GQview"); | |
856 gtk_container_set_border_width(GTK_CONTAINER(vw->window), 0); | |
857 | |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
89
diff
changeset
|
858 window_set_icon(vw->window, PIXBUF_INLINE_ICON_VIEW, NULL); |
9 | 859 |
860 vw->imd = image_new(FALSE); | |
861 | |
862 if (black_window_background) image_background_set_black(vw->imd, TRUE); | |
863 | |
864 image_attach_window(vw->imd, vw->window, NULL, "GQview", TRUE); | |
865 | |
866 image_auto_refresh(vw->imd, 0); | |
867 image_top_window_set_sync(vw->imd, TRUE); | |
868 | |
869 gtk_container_add(GTK_CONTAINER(vw->window), vw->imd->widget); | |
870 gtk_widget_show(vw->imd->widget); | |
871 | |
872 view_window_dnd_init(vw); | |
1 | 873 |
9 | 874 view_image_set_buttons(vw, vw->imd); |
1 | 875 |
89
b3149a34d0dd
Sat Oct 28 14:41:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
876 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
|
877 G_CALLBACK(view_window_destroy_cb), vw); |
9 | 878 g_signal_connect(G_OBJECT(vw->window), "delete_event", |
879 G_CALLBACK(view_window_delete_cb), vw); | |
880 g_signal_connect(G_OBJECT(vw->window), "key_press_event", | |
881 G_CALLBACK(view_window_key_press_cb), vw); | |
882 if (cd && info) | |
883 { | |
884 image_change_from_collection(vw->imd, cd, info, image_zoom_get_default(NULL, zoom_mode)); | |
885 if (enable_read_ahead) | |
886 { | |
887 CollectInfo * r_info = collection_next_by_info(cd, info); | |
888 if (!r_info) r_info = collection_prev_by_info(cd, info); | |
889 if (r_info) image_prebuffer_set(vw->imd, r_info->path); | |
890 } | |
891 } | |
892 else if (list) | |
893 { | |
894 view_window_set_list(vw, list); | |
895 vw->list_pointer = vw->list; | |
896 image_change_path(vw->imd, (gchar *)vw->list->data, image_zoom_get_default(NULL, zoom_mode)); | |
1 | 897 |
9 | 898 if (enable_read_ahead) |
899 { | |
900 GList *work = vw->list->next; | |
901 if (work) image_prebuffer_set(vw->imd, (gchar *)work->data); | |
902 } | |
903 } | |
904 else | |
905 { | |
906 image_change_path(vw->imd, path, image_zoom_get_default(NULL, zoom_mode)); | |
907 } | |
1 | 908 |
9 | 909 if (image_zoom_get(vw->imd) == 0.0) |
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_image_size(PIXBUF_RENDERER(vw->imd->pr), &w, &h); |
9 | 912 } |
913 else | |
914 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
915 pixbuf_renderer_get_scaled_size(PIXBUF_RENDERER(vw->imd->pr), &w, &h); |
9 | 916 } |
1 | 917 if (limit_window_size) |
918 { | |
919 gint mw = gdk_screen_width() * max_window_size / 100; | |
920 gint mh = gdk_screen_height() * max_window_size / 100; | |
921 | |
922 if (w > mw) w = mw; | |
923 if (h > mh) h = mh; | |
924 } | |
925 | |
9 | 926 gtk_window_set_default_size(GTK_WINDOW(vw->window), w, h); |
1 | 927 req_size.x = req_size.y = 0; |
928 req_size.width = w; | |
929 req_size.height = h; | |
9 | 930 gtk_widget_size_allocate(GTK_WIDGET(vw->window), &req_size); |
931 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
932 gtk_widget_set_size_request(vw->imd->pr, w, h); |
9 | 933 |
934 gtk_widget_show(vw->window); | |
935 | |
936 view_window_list = g_list_append(view_window_list, vw); | |
937 | |
938 return vw; | |
939 } | |
940 | |
941 static void view_window_collection_unref_cb(GtkWidget *widget, gpointer data) | |
942 { | |
943 CollectionData *cd = data; | |
944 | |
945 collection_unref(cd); | |
946 } | |
947 | |
948 void view_window_new(const gchar *path) | |
949 { | |
950 if (file_extension_match(path, ".gqv")) | |
951 { | |
952 ViewWindow *vw; | |
953 CollectionData *cd; | |
954 CollectInfo *info; | |
955 | |
956 cd = collection_new(path); | |
957 if (collection_load(cd, path, FALSE)) | |
958 { | |
959 info = collection_get_first(cd); | |
960 } | |
961 else | |
962 { | |
963 collection_unref(cd); | |
964 cd = NULL; | |
965 info = NULL; | |
966 } | |
967 vw = real_view_window_new(NULL, NULL, cd, info); | |
968 if (vw && cd) | |
969 { | |
970 g_signal_connect(G_OBJECT(vw->window), "destroy", | |
971 G_CALLBACK(view_window_collection_unref_cb), cd); | |
972 } | |
973 } | |
974 else if (isdir(path)) | |
975 { | |
976 GList *list = NULL; | |
1 | 977 |
9 | 978 if (path_list(path, &list, NULL)) |
979 { | |
980 list = path_list_sort(list); | |
981 list = path_list_filter(list, FALSE); | |
982 } | |
983 real_view_window_new(NULL, list, NULL, NULL); | |
984 path_list_free(list); | |
985 } | |
986 else | |
987 { | |
988 real_view_window_new(path, NULL, NULL, NULL); | |
989 } | |
990 } | |
991 | |
992 void view_window_new_from_list(GList *list) | |
993 { | |
994 real_view_window_new(NULL, list, NULL, NULL); | |
995 } | |
996 | |
997 void view_window_new_from_collection(CollectionData *cd, CollectInfo *info) | |
998 { | |
999 real_view_window_new(NULL, NULL, cd, info); | |
1000 } | |
1001 | |
1002 /* | |
1003 *----------------------------------------------------------------------------- | |
1004 * public | |
1005 *----------------------------------------------------------------------------- | |
1006 */ | |
1007 | |
1008 void view_window_colors_update(void) | |
1009 { | |
1010 GList *work; | |
1 | 1011 |
9 | 1012 work = view_window_list; |
1013 while (work) | |
1014 { | |
1015 ViewWindow *vw = work->data; | |
1016 work = work->next; | |
1017 | |
1018 image_background_set_black(vw->imd, black_window_background); | |
1019 } | |
1020 } | |
1021 | |
1022 gint view_window_find_image(ImageWindow *imd, gint *index, gint *total) | |
1023 { | |
1024 GList *work; | |
1025 | |
1026 work = view_window_list; | |
1027 while (work) | |
1028 { | |
1029 ViewWindow *vw = work->data; | |
1030 work = work->next; | |
1031 | |
1032 if (vw->imd == imd || | |
1033 (vw->fs && vw->fs->imd == imd)) | |
1034 { | |
1035 if (vw->ss) | |
1036 { | |
1037 gint n; | |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1038 gint t; |
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1039 |
9 | 1040 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
|
1041 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
|
1042 if (n == 0) n = t; |
9 | 1043 if (index) *index = n - 1; |
118
ac0f7f942c4d
Wed Nov 29 22:53:03 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1044 if (total) *total = t; |
9 | 1045 } |
1046 else | |
1047 { | |
1048 if (index) *index = g_list_position(vw->list, vw->list_pointer); | |
1049 if (total) *total = g_list_length(vw->list); | |
1050 } | |
1051 return TRUE; | |
1052 } | |
1053 } | |
1054 | |
1055 return FALSE; | |
1 | 1056 } |
1057 | |
1058 /* | |
1059 *----------------------------------------------------------------------------- | |
1060 * view window menu routines and callbacks | |
1061 *----------------------------------------------------------------------------- | |
1062 */ | |
1063 | |
9 | 1064 static void view_new_window_cb(GtkWidget *widget, gpointer data) |
1 | 1065 { |
9 | 1066 ViewWindow *vw = data; |
1067 CollectionData *cd; | |
1068 CollectInfo *info; | |
1069 | |
1070 cd = image_get_collection(vw->imd, &info); | |
1071 | |
1072 if (cd && info) | |
1073 { | |
1074 view_window_new_from_collection(cd, info); | |
1075 } | |
1076 else | |
1077 { | |
1078 view_window_new(image_get_path(vw->imd)); | |
1079 } | |
1 | 1080 } |
1081 | |
9 | 1082 static void view_edit_cb(GtkWidget *widget, gpointer data) |
1 | 1083 { |
9 | 1084 ViewWindow *vw; |
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1085 ImageWindow *imd; |
9 | 1086 gint n; |
1087 | |
1088 vw = submenu_item_get_data(widget); | |
1089 n = GPOINTER_TO_INT(data); | |
1090 if (!vw) return; | |
1091 | |
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1092 if (!editor_window_flag_set(n)) |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1093 { |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1094 view_fullscreen_toggle(vw, TRUE); |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1095 } |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1096 |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1097 imd = view_window_active_image(vw); |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1098 start_editor_from_file(n, image_get_path(imd)); |
1 | 1099 } |
1100 | |
9 | 1101 static void view_alter_cb(GtkWidget *widget, gpointer data) |
1102 { | |
1103 ViewWindow *vw; | |
1104 AlterType type; | |
1105 | |
1106 vw = submenu_item_get_data(widget); | |
1107 type = GPOINTER_TO_INT(data); | |
1108 | |
1109 if (!vw) return; | |
1110 image_alter(vw->imd, type); | |
1111 } | |
1112 | |
1113 static void view_info_cb(GtkWidget *widget, gpointer data) | |
3 | 1114 { |
9 | 1115 ViewWindow *vw = data; |
1116 ImageWindow *imd; | |
1117 | |
1118 imd = view_window_active_image(vw); | |
1119 info_window_new(image_get_path(imd), NULL); | |
1120 } | |
1121 | |
1122 static void view_wallpaper_cb(GtkWidget *widget, gpointer data) | |
1123 { | |
1124 ViewWindow *vw = data; | |
1125 ImageWindow *imd; | |
1126 | |
1127 imd = view_window_active_image(vw); | |
1128 image_to_root_window(imd, (image_zoom_get(imd) == 0.0)); | |
3 | 1129 } |
1130 | |
1 | 1131 static void view_zoom_in_cb(GtkWidget *widget, gpointer data) |
1132 { | |
9 | 1133 ViewWindow *vw = data; |
1134 | |
1135 image_zoom_adjust(view_window_active_image(vw), get_zoom_increment()); | |
1 | 1136 } |
1137 | |
1138 static void view_zoom_out_cb(GtkWidget *widget, gpointer data) | |
1139 { | |
9 | 1140 ViewWindow *vw = data; |
1141 | |
1142 image_zoom_adjust(view_window_active_image(vw), -get_zoom_increment()); | |
1 | 1143 } |
1144 | |
1145 static void view_zoom_1_1_cb(GtkWidget *widget, gpointer data) | |
1146 { | |
9 | 1147 ViewWindow *vw = data; |
1148 | |
1149 image_zoom_set(view_window_active_image(vw), 1.0); | |
1 | 1150 } |
1151 | |
1152 static void view_zoom_fit_cb(GtkWidget *widget, gpointer data) | |
1153 { | |
9 | 1154 ViewWindow *vw = data; |
1155 | |
1156 image_zoom_set(view_window_active_image(vw), 0.0); | |
1 | 1157 } |
1158 | |
1159 static void view_copy_cb(GtkWidget *widget, gpointer data) | |
1160 { | |
9 | 1161 ViewWindow *vw = data; |
1162 ImageWindow *imd; | |
1163 | |
1164 imd = view_window_active_image(vw); | |
1165 file_util_copy(image_get_path(imd), NULL, NULL, imd->widget); | |
1 | 1166 } |
1167 | |
1168 static void view_move_cb(GtkWidget *widget, gpointer data) | |
1169 { | |
9 | 1170 ViewWindow *vw = data; |
1171 ImageWindow *imd; | |
1172 | |
1173 imd = view_window_active_image(vw); | |
1174 file_util_move(image_get_path(imd), NULL, NULL, imd->widget); | |
1 | 1175 } |
1176 | |
1177 static void view_rename_cb(GtkWidget *widget, gpointer data) | |
1178 { | |
9 | 1179 ViewWindow *vw = data; |
1180 ImageWindow *imd; | |
1181 | |
1182 imd = view_window_active_image(vw); | |
1183 file_util_rename(image_get_path(imd), NULL, imd->widget); | |
1 | 1184 } |
1185 | |
1186 static void view_delete_cb(GtkWidget *widget, gpointer data) | |
1187 { | |
9 | 1188 ViewWindow *vw = data; |
1189 ImageWindow *imd; | |
1190 | |
1191 imd = view_window_active_image(vw); | |
1192 file_util_delete(image_get_path(imd), NULL, imd->widget); | |
1193 } | |
1194 | |
1195 static void view_fullscreen_cb(GtkWidget *widget, gpointer data) | |
1196 { | |
1197 ViewWindow *vw = data; | |
1198 | |
1199 view_fullscreen_toggle(vw, FALSE); | |
1200 } | |
1201 | |
1202 static void view_slideshow_start_cb(GtkWidget *widget, gpointer data) | |
1203 { | |
1204 ViewWindow *vw = data; | |
1205 | |
1206 view_slideshow_start(vw); | |
1207 } | |
1208 | |
1209 static void view_slideshow_stop_cb(GtkWidget *widget, gpointer data) | |
1210 { | |
1211 ViewWindow *vw = data; | |
1212 | |
1213 view_slideshow_stop(vw); | |
1214 } | |
1215 | |
1216 static void view_slideshow_pause_cb(GtkWidget *widget, gpointer data) | |
1217 { | |
1218 ViewWindow *vw = data; | |
1219 | |
1220 slideshow_pause_toggle(vw->ss); | |
1 | 1221 } |
1222 | |
1223 static void view_close_cb(GtkWidget *widget, gpointer data) | |
1224 { | |
9 | 1225 ViewWindow *vw = data; |
1226 | |
1227 view_window_close(vw); | |
1228 } | |
1229 | |
1230 static GtkWidget *view_popup_menu(ViewWindow *vw) | |
1231 { | |
1232 GtkWidget *menu; | |
1233 GtkWidget *item; | |
1234 | |
1235 menu = popup_menu_short_lived(); | |
1236 | |
1237 menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN, G_CALLBACK(view_zoom_in_cb), vw); | |
1238 menu_item_add_stock(menu, _("Zoom _out"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(view_zoom_out_cb), vw); | |
1239 menu_item_add_stock(menu, _("Zoom _1:1"), GTK_STOCK_ZOOM_100, G_CALLBACK(view_zoom_1_1_cb), vw); | |
1240 menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(view_zoom_fit_cb), vw); | |
1241 menu_item_add_divider(menu); | |
1242 | |
1243 item = submenu_add_edit(menu, NULL, G_CALLBACK(view_edit_cb), vw); | |
1244 menu_item_add_divider(item); | |
1245 menu_item_add(item, _("Set as _wallpaper"), G_CALLBACK(view_wallpaper_cb), vw); | |
1246 | |
1247 submenu_add_alter(menu, G_CALLBACK(view_alter_cb), vw); | |
1248 | |
1249 menu_item_add_stock(menu, _("_Properties"), GTK_STOCK_PROPERTIES, G_CALLBACK(view_info_cb), vw); | |
1250 | |
1251 menu_item_add_stock(menu, _("View in _new window"), GTK_STOCK_NEW, G_CALLBACK(view_new_window_cb), vw); | |
1252 | |
1253 menu_item_add_divider(menu); | |
1254 menu_item_add_stock(menu, _("_Copy..."), GTK_STOCK_COPY, G_CALLBACK(view_copy_cb), vw); | |
1255 menu_item_add(menu, _("_Move..."), G_CALLBACK(view_move_cb), vw); | |
1256 menu_item_add(menu, _("_Rename..."), G_CALLBACK(view_rename_cb), vw); | |
1257 menu_item_add_stock(menu, _("_Delete..."), GTK_STOCK_DELETE, G_CALLBACK(view_delete_cb), vw); | |
1258 | |
1259 menu_item_add_divider(menu); | |
1260 | |
1261 if (vw->ss) | |
1262 { | |
1263 menu_item_add(menu, _("_Stop slideshow"), G_CALLBACK(view_slideshow_stop_cb), vw); | |
1264 if (slideshow_paused(vw->ss)) | |
1265 { | |
1266 item = menu_item_add(menu, _("Continue slides_how"), | |
1267 G_CALLBACK(view_slideshow_pause_cb), vw); | |
1268 } | |
1269 else | |
1270 { | |
1271 item = menu_item_add(menu, _("Pause slides_how"), | |
1272 G_CALLBACK(view_slideshow_pause_cb), vw); | |
1273 } | |
1274 } | |
1275 else | |
1276 { | |
1277 item = menu_item_add(menu, _("_Start slideshow"), G_CALLBACK(view_slideshow_start_cb), vw); | |
1278 gtk_widget_set_sensitive(item, (vw->list != NULL) || view_window_contains_collection(vw)); | |
1279 item = menu_item_add(menu, _("Pause slides_how"), G_CALLBACK(view_slideshow_pause_cb), vw); | |
1280 gtk_widget_set_sensitive(item, FALSE); | |
1281 } | |
1282 | |
1283 if (vw->fs) | |
1284 { | |
1285 menu_item_add(menu, _("Exit _full screen"), G_CALLBACK(view_fullscreen_cb), vw); | |
1286 } | |
1287 else | |
1288 { | |
1289 menu_item_add(menu, _("_Full screen"), G_CALLBACK(view_fullscreen_cb), vw); | |
1290 } | |
1291 | |
1292 menu_item_add_divider(menu); | |
1293 menu_item_add_stock(menu, _("C_lose window"), GTK_STOCK_CLOSE, G_CALLBACK(view_close_cb), vw); | |
1294 | |
1295 return menu; | |
1296 } | |
1297 | |
1298 /* | |
1299 *------------------------------------------------------------------- | |
1300 * dnd confirm dir | |
1301 *------------------------------------------------------------------- | |
1302 */ | |
1303 | |
1304 typedef struct { | |
1305 ViewWindow *vw; | |
1306 GList *list; | |
1307 } CViewConfirmD; | |
1308 | |
1309 static void view_dir_list_cancel(GtkWidget *widget, gpointer data) | |
1310 { | |
1311 /* do nothing */ | |
1312 } | |
1313 | |
1314 static void view_dir_list_do(ViewWindow *vw, GList *list, gint skip, gint recurse) | |
1315 { | |
1316 GList *work; | |
1317 | |
1318 view_window_set_list(vw, NULL); | |
1319 | |
1320 work = list; | |
1321 while (work) | |
1322 { | |
1323 gchar *path = work->data; | |
1324 work = work->next; | |
1325 | |
1326 if (isdir(path)) | |
1327 { | |
1328 if (!skip) | |
1329 { | |
1330 GList *list = NULL; | |
1331 | |
1332 if (recurse) | |
1333 { | |
1334 list = path_list_recursive(path); | |
1335 } | |
1336 else | |
1337 { | |
1338 path_list(path, &list, NULL); | |
1339 list = path_list_sort(list); | |
1340 list = path_list_filter(list, FALSE); | |
1341 } | |
1342 if (list) vw->list = g_list_concat(vw->list, list); | |
1343 } | |
1344 } | |
1345 else | |
1346 { | |
1347 /* FIXME: no filtering here */ | |
1348 vw->list = g_list_append(vw->list, g_strdup(path)); | |
1349 } | |
1350 } | |
1351 | |
1352 if (vw->list) | |
1353 { | |
1354 gchar *path; | |
1355 | |
1356 vw->list_pointer = vw->list; | |
1357 path = vw->list->data; | |
1358 image_change_path(vw->imd, path, image_zoom_get_default(vw->imd, zoom_mode)); | |
1359 | |
1360 work = vw->list->next; | |
1361 if (enable_read_ahead && work) | |
1362 { | |
1363 path = work->data; | |
1364 image_prebuffer_set(vw->imd, path); | |
1365 } | |
1366 } | |
1367 else | |
1368 { | |
1369 image_change_path(vw->imd, NULL, image_zoom_get_default(vw->imd, zoom_mode)); | |
1370 } | |
1371 } | |
1372 | |
1373 static void view_dir_list_add(GtkWidget *widget, gpointer data) | |
1374 { | |
1375 CViewConfirmD *d = data; | |
1376 view_dir_list_do(d->vw, d->list, FALSE, FALSE); | |
1377 } | |
1378 | |
1379 static void view_dir_list_recurse(GtkWidget *widget, gpointer data) | |
1380 { | |
1381 CViewConfirmD *d = data; | |
1382 view_dir_list_do(d->vw, d->list, FALSE, TRUE); | |
1383 } | |
1384 | |
1385 static void view_dir_list_skip(GtkWidget *widget, gpointer data) | |
1386 { | |
1387 CViewConfirmD *d = data; | |
1388 view_dir_list_do(d->vw, d->list, TRUE, FALSE); | |
1389 } | |
1390 | |
1391 static void view_dir_list_destroy(GtkWidget *widget, gpointer data) | |
1392 { | |
1393 CViewConfirmD *d = data; | |
1394 path_list_free(d->list); | |
1395 g_free(d); | |
1396 } | |
1397 | |
1398 static GtkWidget *view_confirm_dir_list(ViewWindow *vw, GList *list) | |
1399 { | |
1400 GtkWidget *menu; | |
1401 CViewConfirmD *d; | |
1402 | |
1403 d = g_new(CViewConfirmD, 1); | |
1404 d->vw = vw; | |
1405 d->list = list; | |
1406 | |
1407 menu = popup_menu_short_lived(); | |
1408 g_signal_connect(G_OBJECT(menu), "destroy", | |
1409 G_CALLBACK(view_dir_list_destroy), d); | |
1410 | |
1411 menu_item_add_stock(menu, _("Dropped list includes folders."), GTK_STOCK_DND_MULTIPLE, NULL, NULL); | |
1412 menu_item_add_divider(menu); | |
1413 menu_item_add_stock(menu, _("_Add contents"), GTK_STOCK_OK, G_CALLBACK(view_dir_list_add), d); | |
1414 menu_item_add_stock(menu, _("Add contents _recursive"), GTK_STOCK_ADD, G_CALLBACK(view_dir_list_recurse), d); | |
1415 menu_item_add_stock(menu, _("_Skip folders"), GTK_STOCK_REMOVE, G_CALLBACK(view_dir_list_skip), d); | |
1416 menu_item_add_divider(menu); | |
1417 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, G_CALLBACK(view_dir_list_cancel), d); | |
1418 | |
1419 return menu; | |
1 | 1420 } |
1421 | |
9 | 1422 /* |
1423 *----------------------------------------------------------------------------- | |
1424 * image drag and drop routines | |
1425 *----------------------------------------------------------------------------- | |
1426 */ | |
1427 | |
1428 static void view_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, | |
1429 gint x, gint y, | |
1430 GtkSelectionData *selection_data, guint info, | |
1431 guint time, gpointer data) | |
1 | 1432 { |
9 | 1433 ViewWindow *vw = data; |
1434 ImageWindow *imd; | |
1435 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1436 if (gtk_drag_get_source_widget(context) == vw->imd->pr) return; |
9 | 1437 |
1438 imd = vw->imd; | |
1439 | |
1440 if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER) | |
1441 { | |
1442 CollectionData *source; | |
1443 GList *list; | |
1444 GList *info_list; | |
1445 | |
1446 if (info == TARGET_URI_LIST) | |
1447 { | |
1448 GList *work; | |
1449 | |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
60
diff
changeset
|
1450 list = uri_list_from_text((gchar *)selection_data->data, TRUE); |
9 | 1451 |
1452 work = list; | |
1453 while (work) | |
1454 { | |
1455 if (isdir((gchar *)work->data)) | |
1456 { | |
1457 GtkWidget *menu; | |
1458 menu = view_confirm_dir_list(vw, list); | |
1459 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, time); | |
1460 return; | |
1461 } | |
1462 work = work->next; | |
1463 } | |
1464 | |
1465 list = path_list_filter(list, FALSE); | |
1466 | |
1467 source = NULL; | |
1468 info_list = NULL; | |
1469 } | |
1470 else | |
1471 { | |
1472 source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); | |
1473 } | |
1474 | |
1475 if (list) | |
1476 { | |
1477 gchar *path; | |
1478 | |
1479 path = list->data; | |
1480 if (isfile(path)) | |
1481 { | |
1482 view_slideshow_stop(vw); | |
1483 view_window_set_list(vw, NULL); | |
1 | 1484 |
9 | 1485 if (source && info_list) |
1486 { | |
1487 image_change_from_collection(imd, source, info_list->data, image_zoom_get_default(imd, zoom_mode)); | |
1488 } | |
1489 else | |
1490 { | |
1491 if (list->next) | |
1492 { | |
1493 vw->list = list; | |
1494 list = NULL; | |
1495 | |
1496 vw->list_pointer = vw->list; | |
1497 } | |
1498 image_change_path(imd, path, image_zoom_get_default(imd, zoom_mode)); | |
1499 } | |
1500 } | |
1501 } | |
1502 path_list_free(list); | |
1503 g_list_free(info_list); | |
1504 } | |
1505 } | |
1506 | |
1507 static void view_window_set_dnd_data(GtkWidget *widget, GdkDragContext *context, | |
1508 GtkSelectionData *selection_data, guint info, | |
1509 guint time, gpointer data) | |
1510 { | |
1511 ViewWindow *vw = data; | |
1512 const gchar *path; | |
1513 | |
1514 path = image_get_path(vw->imd); | |
1 | 1515 |
9 | 1516 if (path) |
1517 { | |
1518 gchar *text = NULL; | |
1519 gint len; | |
1520 gint plain_text; | |
1521 GList *list; | |
1 | 1522 |
9 | 1523 switch (info) |
1524 { | |
1525 case TARGET_URI_LIST: | |
1526 plain_text = FALSE; | |
1527 break; | |
1528 case TARGET_TEXT_PLAIN: | |
1529 default: | |
1530 plain_text = TRUE; | |
1531 break; | |
1532 } | |
1533 list = g_list_append(NULL, (gchar *)path); | |
1534 text = uri_text_from_list(list, &len, plain_text); | |
1535 g_list_free(list); | |
1536 if (text) | |
1537 { | |
1538 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
|
1539 8, (guchar *)text, len); |
9 | 1540 g_free(text); |
1541 } | |
1542 } | |
1543 else | |
1544 { | |
1545 gtk_selection_data_set (selection_data, selection_data->target, | |
1546 8, NULL, 0); | |
1547 } | |
1 | 1548 } |
1549 | |
9 | 1550 static void view_window_dnd_init(ViewWindow *vw) |
1551 { | |
1552 ImageWindow *imd; | |
1 | 1553 |
9 | 1554 imd = vw->imd; |
1555 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1556 gtk_drag_source_set(imd->pr, GDK_BUTTON2_MASK, |
9 | 1557 dnd_file_drag_types, dnd_file_drag_types_count, |
1558 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
|
1559 g_signal_connect(G_OBJECT(imd->pr), "drag_data_get", |
9 | 1560 G_CALLBACK(view_window_set_dnd_data), vw); |
1561 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1562 gtk_drag_dest_set(imd->pr, |
9 | 1563 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, |
1564 dnd_file_drop_types, dnd_file_drop_types_count, | |
1565 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
|
1566 g_signal_connect(G_OBJECT(imd->pr), "drag_data_received", |
9 | 1567 G_CALLBACK(view_window_get_dnd_data), vw); |
1568 } | |
1569 | |
1570 /* | |
1571 *----------------------------------------------------------------------------- | |
1572 * maintenance (for rename, move, remove) | |
1573 *----------------------------------------------------------------------------- | |
1574 */ | |
1575 | |
1576 static void view_real_removed(ViewWindow *vw, const gchar *path, GList *ignore_list) | |
1577 { | |
1578 ImageWindow *imd; | |
1579 const gchar *image_path; | |
1580 | |
1581 imd = view_window_active_image(vw); | |
1582 image_path = image_get_path(imd); | |
1583 | |
1584 if (image_path && strcmp(image_path, path) == 0) | |
1585 { | |
1586 if (vw->list) | |
1587 { | |
1588 view_list_step(vw, TRUE); | |
1589 if (image_get_path(imd) == image_path) | |
1590 { | |
1591 view_list_step(vw, FALSE); | |
1592 } | |
1593 } | |
1594 else if (view_window_contains_collection(vw)) | |
1595 { | |
1596 view_collection_step(vw, TRUE); | |
1597 if (image_get_path(imd) == image_path) | |
1598 { | |
1599 view_collection_step(vw, FALSE); | |
1600 } | |
1601 } | |
1602 if (image_get_path(imd) == image_path) | |
1603 { | |
1604 image_change_path(imd, NULL, image_zoom_get_default(imd, zoom_mode)); | |
1605 } | |
1606 } | |
1607 | |
1608 if (vw->list) | |
1609 { | |
1610 GList *work; | |
1611 GList *old; | |
1612 | |
1613 old = vw->list_pointer; | |
1614 | |
1615 work = vw->list; | |
1616 while (work) | |
1617 { | |
1618 gchar *chk_path; | |
1619 GList *chk_link; | |
1620 | |
1621 chk_path = work->data; | |
1622 chk_link = work; | |
1623 work = work->next; | |
1624 | |
1625 if (strcmp(chk_path, path) == 0) | |
1626 { | |
1627 if (vw->list_pointer == chk_link) | |
1628 { | |
1629 vw->list_pointer = (chk_link->next) ? chk_link->next : chk_link->prev; | |
1630 } | |
1631 vw->list = g_list_remove(vw->list, chk_path); | |
1632 g_free(chk_path); | |
1633 } | |
1634 } | |
1635 | |
1636 /* handles stepping correctly when same image is in the list more than once */ | |
1637 if (old && old != vw->list_pointer) | |
1638 { | |
1639 gchar *path; | |
1640 | |
1641 if (vw->list_pointer) | |
1642 { | |
1643 path = vw->list_pointer->data; | |
1644 } | |
1645 else | |
1646 { | |
1647 path = NULL; | |
1648 } | |
1649 | |
1650 image_change_path(imd, path, image_zoom_get_default(imd, zoom_mode)); | |
1651 } | |
1652 } | |
1653 | |
117
0c2e1f0a001b
Wed Nov 29 14:28:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
94
diff
changeset
|
1654 image_osd_update(imd); |
9 | 1655 } |
1656 | |
1657 static void view_real_moved(ViewWindow *vw, const gchar *source, const gchar *dest) | |
1658 { | |
1659 ImageWindow *imd; | |
1660 const gchar *image_path; | |
1661 | |
1662 imd = view_window_active_image(vw); | |
1663 image_path = image_get_path(imd); | |
1664 | |
1665 if (image_path && strcmp(image_path, source) == 0) | |
1666 { | |
1667 image_set_path(imd, dest); | |
1668 } | |
1669 | |
1670 if (vw->list) | |
1671 { | |
1672 GList *work; | |
1673 work = vw->list; | |
1674 while (work) | |
1675 { | |
1676 gchar *chk_path; | |
1677 | |
1678 chk_path = work->data; | |
1679 | |
1680 if (strcmp(chk_path, source) == 0) | |
1681 { | |
1682 work->data = g_strdup(dest); | |
1683 g_free(chk_path); | |
1684 } | |
1685 | |
1686 work = work->next; | |
1687 } | |
1688 } | |
1689 } | |
1690 | |
1691 void view_window_maint_removed(const gchar *path, GList *ignore_list) | |
1692 { | |
1693 GList *work = view_window_list; | |
1694 while (work) | |
1695 { | |
1696 ViewWindow *vw = work->data; | |
1697 work = work->next; | |
1698 | |
1699 view_real_removed(vw, path, ignore_list); | |
1700 } | |
1701 } | |
1702 | |
1703 void view_window_maint_moved(const gchar *source, const gchar *dest) | |
1704 { | |
1705 GList *work = view_window_list; | |
1706 while (work) | |
1707 { | |
1708 ViewWindow *vw = work->data; | |
1709 work = work->next; | |
1710 | |
1711 view_real_moved(vw, source, dest); | |
1712 } | |
1713 } | |
1714 |