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