Mercurial > geeqie
annotate src/img-view.c @ 86:cade6a52a165
Mon Oct 23 05:34:29 2006 John Ellis <johne@verizon.net>
* img-view.c, layout_image.c, layout_util.c, pan-view.c: Make F11 also
toggle fullscreen.
author | gqview |
---|---|
date | Mon, 23 Oct 2006 09:40:37 +0000 |
parents | ba3c39002a24 |
children | b3149a34d0dd |
rev | line source |
---|---|
1 | 1 /* |
9 | 2 * GQview |
3 * (C) 2004 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" |
9 | 27 #include "slideshow.h" |
28 #include "utilops.h" | |
29 #include "ui_bookmark.h" | |
30 #include "ui_fileops.h" | |
31 #include "ui_menu.h" | |
32 | |
1 | 33 #include <gdk/gdkkeysyms.h> /* for keyboard values */ |
34 | |
9 | 35 #include "icons/view.xpm" |
36 | |
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; |
9 | 456 default: |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
457 stop_signal = FALSE; |
9 | 458 break; |
459 } | |
1 | 460 } |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
461 else |
1 | 462 { |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
463 stop_signal = TRUE; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
464 switch (event->keyval) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
465 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
466 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
|
467 case GDK_BackSpace: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
468 case 'B': case 'b': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
469 view_step_prev(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
470 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
471 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
|
472 case GDK_space: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
473 case 'N': case 'n': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
474 view_step_next(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
475 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
476 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
|
477 view_step_to_end(vw, FALSE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
478 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
479 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
|
480 view_step_to_end(vw, TRUE); |
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 '+': case '=': case GDK_KP_Add: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
483 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
|
484 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
485 case '-': case GDK_KP_Subtract: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
486 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
|
487 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
488 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
|
489 image_zoom_set(imd, 0.0); |
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 '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
|
492 image_zoom_set(imd, 1.0); |
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 '2': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
495 image_zoom_set(imd, 2.0); |
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 '3': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
498 image_zoom_set(imd, 3.0); |
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 '4': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
501 image_zoom_set(imd, 4.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 '7': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
504 image_zoom_set(imd, -4.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 '8': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
507 image_zoom_set(imd, -3.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 '9': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
510 image_zoom_set(imd, -2.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 'W': case 'w': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
513 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
|
514 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
515 case 'H': case 'h': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
516 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
|
517 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
518 case 'R': case 'r': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
519 image_reload(imd); |
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 'S': case 's': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
522 if (vw->ss) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
523 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
524 view_slideshow_stop(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
525 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
526 else |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
527 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
528 view_slideshow_start(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
529 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
530 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
531 case 'P': case 'p': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
532 slideshow_pause_toggle(vw->ss); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
533 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
534 case 'F': case 'f': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
535 case 'V': case 'v': |
86
cade6a52a165
Mon Oct 23 05:34:29 2006 John Ellis <johne@verizon.net>
gqview
parents:
84
diff
changeset
|
536 case GDK_F11: |
84
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
537 view_fullscreen_toggle(vw, FALSE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
538 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
539 case 'I': case 'i': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
540 view_overlay_toggle(vw); |
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 ']': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
543 image_alter(imd, ALTER_ROTATE_90); |
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 '[': |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
546 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
|
547 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
548 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
|
549 if (enable_delete_key) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
550 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
551 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
|
552 } |
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 GDK_Escape: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
555 if (vw->fs) |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
556 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
557 view_fullscreen_toggle(vw, TRUE); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
558 } |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
559 else |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
560 { |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
561 gtk_widget_destroy(vw->window); |
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 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
564 case GDK_Menu: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
565 case GDK_F10: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
566 menu = view_popup_menu(vw); |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
567 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
|
568 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
|
569 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
570 default: |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
571 stop_signal = FALSE; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
572 break; |
ba3c39002a24
Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
573 } |
1 | 574 } |
575 | |
576 return stop_signal; | |
577 } | |
578 | |
579 /* | |
580 *----------------------------------------------------------------------------- | |
581 * view window main routines | |
582 *----------------------------------------------------------------------------- | |
583 */ | |
584 | |
9 | 585 static void button_cb(ImageWindow *imd, gint button, guint32 time, |
586 gdouble x, gdouble y, guint state, gpointer data) | |
587 { | |
588 ViewWindow *vw = data; | |
589 GtkWidget *menu; | |
590 | |
591 switch (button) | |
592 { | |
593 case 1: | |
594 view_step_next(vw); | |
595 break; | |
596 case 2: | |
597 view_step_prev(vw); | |
598 break; | |
599 case 3: | |
600 menu = view_popup_menu(vw); | |
601 gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, time); | |
602 break; | |
603 default: | |
604 break; | |
605 } | |
606 } | |
607 | |
608 static void scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 time, | |
609 gdouble x, gdouble y, guint state, gpointer data) | |
1 | 610 { |
9 | 611 ViewWindow *vw = data; |
612 | |
613 if (state & GDK_CONTROL_MASK) | |
614 { | |
615 switch (direction) | |
616 { | |
617 case GDK_SCROLL_UP: | |
618 image_zoom_adjust_at_point(imd, get_zoom_increment(), x, y); | |
619 break; | |
620 case GDK_SCROLL_DOWN: | |
621 image_zoom_adjust_at_point(imd, -get_zoom_increment(), x, y); | |
622 break; | |
623 default: | |
624 break; | |
625 } | |
626 } | |
627 else if ( (state & GDK_SHIFT_MASK) != (mousewheel_scrolls)) | |
628 { | |
629 switch (direction) | |
630 { | |
631 case GDK_SCROLL_UP: | |
632 image_scroll(imd, 0, -MOUSEWHEEL_SCROLL_SIZE); | |
633 break; | |
634 case GDK_SCROLL_DOWN: | |
635 image_scroll(imd, 0, MOUSEWHEEL_SCROLL_SIZE); | |
636 break; | |
637 case GDK_SCROLL_LEFT: | |
638 image_scroll(imd, -MOUSEWHEEL_SCROLL_SIZE, 0); | |
639 break; | |
640 case GDK_SCROLL_RIGHT: | |
641 image_scroll(imd, MOUSEWHEEL_SCROLL_SIZE, 0); | |
642 break; | |
643 default: | |
644 break; | |
645 } | |
646 } | |
647 else | |
648 { | |
649 switch (direction) | |
650 { | |
651 case GDK_SCROLL_UP: | |
652 view_step_prev(vw); | |
653 break; | |
654 case GDK_SCROLL_DOWN: | |
655 view_step_next(vw); | |
656 break; | |
657 default: | |
658 break; | |
659 } | |
660 } | |
661 } | |
662 | |
663 static void view_image_set_buttons(ViewWindow *vw, ImageWindow *imd) | |
664 { | |
665 image_set_button_func(imd, button_cb, vw); | |
666 image_set_scroll_func(imd, scroll_cb, vw); | |
667 } | |
668 | |
669 static void view_fullscreen_stop_func(FullScreenData *fs, gpointer data) | |
670 { | |
671 ViewWindow *vw = data; | |
672 | |
673 vw->fs = NULL; | |
674 | |
675 if (vw->ss) vw->ss->imd = vw->imd; | |
1 | 676 } |
677 | |
9 | 678 static void view_fullscreen_toggle(ViewWindow *vw, gint force_off) |
4 | 679 { |
9 | 680 if (force_off && !vw->fs) return; |
681 | |
682 if (vw->fs) | |
683 { | |
684 fullscreen_stop(vw->fs); | |
685 | |
686 if (vw->overlay_id != -1) vw->overlay_id = image_overlay_info_enable(vw->imd); | |
687 } | |
688 else | |
689 { | |
690 vw->fs = fullscreen_start(vw->window, vw->imd, view_fullscreen_stop_func, vw); | |
691 | |
692 view_image_set_buttons(vw, vw->fs->imd); | |
693 g_signal_connect(G_OBJECT(vw->fs->window), "key_press_event", | |
694 G_CALLBACK(view_window_key_press_cb), vw); | |
695 | |
696 if (vw->ss) vw->ss->imd = vw->fs->imd; | |
697 | |
698 if (vw->overlay_id != -1) | |
699 { | |
700 image_overlay_info_disable(vw->imd, vw->overlay_id); | |
701 vw->overlay_id = image_overlay_info_enable(vw->fs->imd); | |
702 } | |
703 } | |
704 } | |
705 | |
706 static void view_overlay_toggle(ViewWindow *vw) | |
707 { | |
708 ImageWindow *imd; | |
709 | |
710 imd = view_window_active_image(vw); | |
711 | |
712 if (vw->overlay_id == -1) | |
713 { | |
714 vw->overlay_id = image_overlay_info_enable(imd); | |
715 } | |
716 else | |
717 { | |
718 image_overlay_info_disable(imd, vw->overlay_id); | |
719 vw->overlay_id = -1; | |
720 } | |
721 } | |
722 | |
723 static void view_slideshow_next(ViewWindow *vw) | |
724 { | |
725 if (vw->ss) slideshow_next(vw->ss); | |
4 | 726 } |
727 | |
9 | 728 static void view_slideshow_prev(ViewWindow *vw) |
729 { | |
730 if (vw->ss) slideshow_prev(vw->ss); | |
731 } | |
732 | |
733 static void view_slideshow_stop_func(SlideShowData *fs, gpointer data) | |
734 { | |
735 ViewWindow *vw = data; | |
736 | |
737 vw->ss = NULL; | |
738 } | |
739 | |
740 static void view_slideshow_start(ViewWindow *vw) | |
4 | 741 { |
9 | 742 if (!vw->ss) |
743 { | |
744 CollectionData *cd; | |
745 CollectInfo *info; | |
746 | |
747 if (vw->list) | |
748 { | |
749 vw->ss = slideshow_start_from_path_list(view_window_active_image(vw), | |
750 path_list_copy(vw->list), | |
751 view_slideshow_stop_func, vw); | |
752 vw->list_pointer = NULL; | |
753 return; | |
754 } | |
755 | |
756 cd = image_get_collection(view_window_active_image(vw), &info); | |
757 if (cd && info) | |
758 { | |
759 vw->ss = slideshow_start_from_collection(view_window_active_image(vw), cd, | |
760 view_slideshow_stop_func, vw, info); | |
761 } | |
762 } | |
763 } | |
764 | |
765 static void view_slideshow_stop(ViewWindow *vw) | |
766 { | |
767 if (vw->ss) slideshow_free(vw->ss); | |
768 } | |
769 | |
770 static void view_window_close(ViewWindow *vw) | |
771 { | |
772 view_window_list = g_list_remove(view_window_list, vw); | |
773 | |
774 view_slideshow_stop(vw); | |
775 view_fullscreen_toggle(vw, TRUE); | |
776 gtk_widget_destroy(vw->window); | |
777 path_list_free(vw->list); | |
778 g_free(vw); | |
4 | 779 } |
780 | |
1 | 781 static gint view_window_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) |
782 { | |
9 | 783 ViewWindow *vw = data; |
784 | |
785 view_window_close(vw); | |
1 | 786 return TRUE; |
787 } | |
788 | |
9 | 789 static ViewWindow *real_view_window_new(const gchar *path, GList *list, CollectionData *cd, CollectInfo *info) |
1 | 790 { |
9 | 791 ViewWindow *vw; |
1 | 792 GtkAllocation req_size; |
9 | 793 GdkGeometry geometry; |
1 | 794 gint w, h; |
9 | 795 |
796 if (!path && !list && (!cd || !info)) return NULL; | |
797 | |
798 vw = g_new0(ViewWindow, 1); | |
799 vw->fs = NULL; | |
800 vw->ss = NULL; | |
801 vw->list = NULL; | |
802 vw->list_pointer = NULL; | |
803 | |
804 vw->overlay_id = -1; | |
805 | |
806 vw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
807 | |
808 geometry.min_width = 8; | |
809 geometry.min_height = 8; | |
810 gtk_window_set_geometry_hints(GTK_WINDOW(vw->window), NULL, &geometry, GDK_HINT_MIN_SIZE); | |
1 | 811 |
9 | 812 gtk_window_set_resizable(GTK_WINDOW(vw->window), TRUE); |
813 gtk_window_set_title (GTK_WINDOW(vw->window), "GQview"); | |
814 gtk_window_set_wmclass(GTK_WINDOW(vw->window), "view", "GQview"); | |
815 gtk_container_set_border_width(GTK_CONTAINER(vw->window), 0); | |
816 | |
817 window_set_icon(vw->window, (const gchar **)view_xpm, NULL); | |
818 | |
819 vw->imd = image_new(FALSE); | |
820 | |
821 if (black_window_background) image_background_set_black(vw->imd, TRUE); | |
822 | |
823 image_attach_window(vw->imd, vw->window, NULL, "GQview", TRUE); | |
824 | |
825 image_auto_refresh(vw->imd, 0); | |
826 image_top_window_set_sync(vw->imd, TRUE); | |
827 | |
828 gtk_container_add(GTK_CONTAINER(vw->window), vw->imd->widget); | |
829 gtk_widget_show(vw->imd->widget); | |
830 | |
831 view_window_dnd_init(vw); | |
1 | 832 |
9 | 833 view_image_set_buttons(vw, vw->imd); |
1 | 834 |
9 | 835 g_signal_connect(G_OBJECT(vw->window), "delete_event", |
836 G_CALLBACK(view_window_delete_cb), vw); | |
837 g_signal_connect(G_OBJECT(vw->window), "key_press_event", | |
838 G_CALLBACK(view_window_key_press_cb), vw); | |
839 if (cd && info) | |
840 { | |
841 image_change_from_collection(vw->imd, cd, info, image_zoom_get_default(NULL, zoom_mode)); | |
842 if (enable_read_ahead) | |
843 { | |
844 CollectInfo * r_info = collection_next_by_info(cd, info); | |
845 if (!r_info) r_info = collection_prev_by_info(cd, info); | |
846 if (r_info) image_prebuffer_set(vw->imd, r_info->path); | |
847 } | |
848 } | |
849 else if (list) | |
850 { | |
851 view_window_set_list(vw, list); | |
852 vw->list_pointer = vw->list; | |
853 image_change_path(vw->imd, (gchar *)vw->list->data, image_zoom_get_default(NULL, zoom_mode)); | |
1 | 854 |
9 | 855 if (enable_read_ahead) |
856 { | |
857 GList *work = vw->list->next; | |
858 if (work) image_prebuffer_set(vw->imd, (gchar *)work->data); | |
859 } | |
860 } | |
861 else | |
862 { | |
863 image_change_path(vw->imd, path, image_zoom_get_default(NULL, zoom_mode)); | |
864 } | |
1 | 865 |
9 | 866 if (image_zoom_get(vw->imd) == 0.0) |
867 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
868 pixbuf_renderer_get_image_size(PIXBUF_RENDERER(vw->imd->pr), &w, &h); |
9 | 869 } |
870 else | |
871 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
872 pixbuf_renderer_get_scaled_size(PIXBUF_RENDERER(vw->imd->pr), &w, &h); |
9 | 873 } |
1 | 874 if (limit_window_size) |
875 { | |
876 gint mw = gdk_screen_width() * max_window_size / 100; | |
877 gint mh = gdk_screen_height() * max_window_size / 100; | |
878 | |
879 if (w > mw) w = mw; | |
880 if (h > mh) h = mh; | |
881 } | |
882 | |
9 | 883 gtk_window_set_default_size(GTK_WINDOW(vw->window), w, h); |
1 | 884 req_size.x = req_size.y = 0; |
885 req_size.width = w; | |
886 req_size.height = h; | |
9 | 887 gtk_widget_size_allocate(GTK_WIDGET(vw->window), &req_size); |
888 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
889 gtk_widget_set_size_request(vw->imd->pr, w, h); |
9 | 890 |
891 gtk_widget_show(vw->window); | |
892 | |
893 view_window_list = g_list_append(view_window_list, vw); | |
894 | |
895 return vw; | |
896 } | |
897 | |
898 static void view_window_collection_unref_cb(GtkWidget *widget, gpointer data) | |
899 { | |
900 CollectionData *cd = data; | |
901 | |
902 collection_unref(cd); | |
903 } | |
904 | |
905 void view_window_new(const gchar *path) | |
906 { | |
907 if (file_extension_match(path, ".gqv")) | |
908 { | |
909 ViewWindow *vw; | |
910 CollectionData *cd; | |
911 CollectInfo *info; | |
912 | |
913 cd = collection_new(path); | |
914 if (collection_load(cd, path, FALSE)) | |
915 { | |
916 info = collection_get_first(cd); | |
917 } | |
918 else | |
919 { | |
920 collection_unref(cd); | |
921 cd = NULL; | |
922 info = NULL; | |
923 } | |
924 vw = real_view_window_new(NULL, NULL, cd, info); | |
925 if (vw && cd) | |
926 { | |
927 g_signal_connect(G_OBJECT(vw->window), "destroy", | |
928 G_CALLBACK(view_window_collection_unref_cb), cd); | |
929 } | |
930 } | |
931 else if (isdir(path)) | |
932 { | |
933 GList *list = NULL; | |
1 | 934 |
9 | 935 if (path_list(path, &list, NULL)) |
936 { | |
937 list = path_list_sort(list); | |
938 list = path_list_filter(list, FALSE); | |
939 } | |
940 real_view_window_new(NULL, list, NULL, NULL); | |
941 path_list_free(list); | |
942 } | |
943 else | |
944 { | |
945 real_view_window_new(path, NULL, NULL, NULL); | |
946 } | |
947 } | |
948 | |
949 void view_window_new_from_list(GList *list) | |
950 { | |
951 real_view_window_new(NULL, list, NULL, NULL); | |
952 } | |
953 | |
954 void view_window_new_from_collection(CollectionData *cd, CollectInfo *info) | |
955 { | |
956 real_view_window_new(NULL, NULL, cd, info); | |
957 } | |
958 | |
959 /* | |
960 *----------------------------------------------------------------------------- | |
961 * public | |
962 *----------------------------------------------------------------------------- | |
963 */ | |
964 | |
965 void view_window_colors_update(void) | |
966 { | |
967 GList *work; | |
1 | 968 |
9 | 969 work = view_window_list; |
970 while (work) | |
971 { | |
972 ViewWindow *vw = work->data; | |
973 work = work->next; | |
974 | |
975 image_background_set_black(vw->imd, black_window_background); | |
976 } | |
977 } | |
978 | |
979 gint view_window_find_image(ImageWindow *imd, gint *index, gint *total) | |
980 { | |
981 GList *work; | |
982 | |
983 work = view_window_list; | |
984 while (work) | |
985 { | |
986 ViewWindow *vw = work->data; | |
987 work = work->next; | |
988 | |
989 if (vw->imd == imd || | |
990 (vw->fs && vw->fs->imd == imd)) | |
991 { | |
992 if (vw->ss) | |
993 { | |
994 gint n; | |
995 n = g_list_length(vw->ss->list_done); | |
996 if (index) *index = n - 1; | |
997 if (total) *total = n + g_list_length(vw->ss->list); | |
998 } | |
999 else | |
1000 { | |
1001 if (index) *index = g_list_position(vw->list, vw->list_pointer); | |
1002 if (total) *total = g_list_length(vw->list); | |
1003 } | |
1004 return TRUE; | |
1005 } | |
1006 } | |
1007 | |
1008 return FALSE; | |
1 | 1009 } |
1010 | |
1011 /* | |
1012 *----------------------------------------------------------------------------- | |
1013 * view window menu routines and callbacks | |
1014 *----------------------------------------------------------------------------- | |
1015 */ | |
1016 | |
9 | 1017 static void view_new_window_cb(GtkWidget *widget, gpointer data) |
1 | 1018 { |
9 | 1019 ViewWindow *vw = data; |
1020 CollectionData *cd; | |
1021 CollectInfo *info; | |
1022 | |
1023 cd = image_get_collection(vw->imd, &info); | |
1024 | |
1025 if (cd && info) | |
1026 { | |
1027 view_window_new_from_collection(cd, info); | |
1028 } | |
1029 else | |
1030 { | |
1031 view_window_new(image_get_path(vw->imd)); | |
1032 } | |
1 | 1033 } |
1034 | |
9 | 1035 static void view_edit_cb(GtkWidget *widget, gpointer data) |
1 | 1036 { |
9 | 1037 ViewWindow *vw; |
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1038 ImageWindow *imd; |
9 | 1039 gint n; |
1040 | |
1041 vw = submenu_item_get_data(widget); | |
1042 n = GPOINTER_TO_INT(data); | |
1043 if (!vw) return; | |
1044 | |
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1045 if (!editor_window_flag_set(n)) |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1046 { |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1047 view_fullscreen_toggle(vw, TRUE); |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1048 } |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1049 |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1050 imd = view_window_active_image(vw); |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1051 start_editor_from_file(n, image_get_path(imd)); |
1 | 1052 } |
1053 | |
9 | 1054 static void view_alter_cb(GtkWidget *widget, gpointer data) |
1055 { | |
1056 ViewWindow *vw; | |
1057 AlterType type; | |
1058 | |
1059 vw = submenu_item_get_data(widget); | |
1060 type = GPOINTER_TO_INT(data); | |
1061 | |
1062 if (!vw) return; | |
1063 image_alter(vw->imd, type); | |
1064 } | |
1065 | |
1066 static void view_info_cb(GtkWidget *widget, gpointer data) | |
3 | 1067 { |
9 | 1068 ViewWindow *vw = data; |
1069 ImageWindow *imd; | |
1070 | |
1071 imd = view_window_active_image(vw); | |
1072 info_window_new(image_get_path(imd), NULL); | |
1073 } | |
1074 | |
1075 static void view_wallpaper_cb(GtkWidget *widget, gpointer data) | |
1076 { | |
1077 ViewWindow *vw = data; | |
1078 ImageWindow *imd; | |
1079 | |
1080 imd = view_window_active_image(vw); | |
1081 image_to_root_window(imd, (image_zoom_get(imd) == 0.0)); | |
3 | 1082 } |
1083 | |
1 | 1084 static void view_zoom_in_cb(GtkWidget *widget, gpointer data) |
1085 { | |
9 | 1086 ViewWindow *vw = data; |
1087 | |
1088 image_zoom_adjust(view_window_active_image(vw), get_zoom_increment()); | |
1 | 1089 } |
1090 | |
1091 static void view_zoom_out_cb(GtkWidget *widget, gpointer data) | |
1092 { | |
9 | 1093 ViewWindow *vw = data; |
1094 | |
1095 image_zoom_adjust(view_window_active_image(vw), -get_zoom_increment()); | |
1 | 1096 } |
1097 | |
1098 static void view_zoom_1_1_cb(GtkWidget *widget, gpointer data) | |
1099 { | |
9 | 1100 ViewWindow *vw = data; |
1101 | |
1102 image_zoom_set(view_window_active_image(vw), 1.0); | |
1 | 1103 } |
1104 | |
1105 static void view_zoom_fit_cb(GtkWidget *widget, gpointer data) | |
1106 { | |
9 | 1107 ViewWindow *vw = data; |
1108 | |
1109 image_zoom_set(view_window_active_image(vw), 0.0); | |
1 | 1110 } |
1111 | |
1112 static void view_copy_cb(GtkWidget *widget, gpointer data) | |
1113 { | |
9 | 1114 ViewWindow *vw = data; |
1115 ImageWindow *imd; | |
1116 | |
1117 imd = view_window_active_image(vw); | |
1118 file_util_copy(image_get_path(imd), NULL, NULL, imd->widget); | |
1 | 1119 } |
1120 | |
1121 static void view_move_cb(GtkWidget *widget, gpointer data) | |
1122 { | |
9 | 1123 ViewWindow *vw = data; |
1124 ImageWindow *imd; | |
1125 | |
1126 imd = view_window_active_image(vw); | |
1127 file_util_move(image_get_path(imd), NULL, NULL, imd->widget); | |
1 | 1128 } |
1129 | |
1130 static void view_rename_cb(GtkWidget *widget, gpointer data) | |
1131 { | |
9 | 1132 ViewWindow *vw = data; |
1133 ImageWindow *imd; | |
1134 | |
1135 imd = view_window_active_image(vw); | |
1136 file_util_rename(image_get_path(imd), NULL, imd->widget); | |
1 | 1137 } |
1138 | |
1139 static void view_delete_cb(GtkWidget *widget, gpointer data) | |
1140 { | |
9 | 1141 ViewWindow *vw = data; |
1142 ImageWindow *imd; | |
1143 | |
1144 imd = view_window_active_image(vw); | |
1145 file_util_delete(image_get_path(imd), NULL, imd->widget); | |
1146 } | |
1147 | |
1148 static void view_fullscreen_cb(GtkWidget *widget, gpointer data) | |
1149 { | |
1150 ViewWindow *vw = data; | |
1151 | |
1152 view_fullscreen_toggle(vw, FALSE); | |
1153 } | |
1154 | |
1155 static void view_slideshow_start_cb(GtkWidget *widget, gpointer data) | |
1156 { | |
1157 ViewWindow *vw = data; | |
1158 | |
1159 view_slideshow_start(vw); | |
1160 } | |
1161 | |
1162 static void view_slideshow_stop_cb(GtkWidget *widget, gpointer data) | |
1163 { | |
1164 ViewWindow *vw = data; | |
1165 | |
1166 view_slideshow_stop(vw); | |
1167 } | |
1168 | |
1169 static void view_slideshow_pause_cb(GtkWidget *widget, gpointer data) | |
1170 { | |
1171 ViewWindow *vw = data; | |
1172 | |
1173 slideshow_pause_toggle(vw->ss); | |
1 | 1174 } |
1175 | |
1176 static void view_close_cb(GtkWidget *widget, gpointer data) | |
1177 { | |
9 | 1178 ViewWindow *vw = data; |
1179 | |
1180 view_window_close(vw); | |
1181 } | |
1182 | |
1183 static GtkWidget *view_popup_menu(ViewWindow *vw) | |
1184 { | |
1185 GtkWidget *menu; | |
1186 GtkWidget *item; | |
1187 | |
1188 menu = popup_menu_short_lived(); | |
1189 | |
1190 menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN, G_CALLBACK(view_zoom_in_cb), vw); | |
1191 menu_item_add_stock(menu, _("Zoom _out"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(view_zoom_out_cb), vw); | |
1192 menu_item_add_stock(menu, _("Zoom _1:1"), GTK_STOCK_ZOOM_100, G_CALLBACK(view_zoom_1_1_cb), vw); | |
1193 menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(view_zoom_fit_cb), vw); | |
1194 menu_item_add_divider(menu); | |
1195 | |
1196 item = submenu_add_edit(menu, NULL, G_CALLBACK(view_edit_cb), vw); | |
1197 menu_item_add_divider(item); | |
1198 menu_item_add(item, _("Set as _wallpaper"), G_CALLBACK(view_wallpaper_cb), vw); | |
1199 | |
1200 submenu_add_alter(menu, G_CALLBACK(view_alter_cb), vw); | |
1201 | |
1202 menu_item_add_stock(menu, _("_Properties"), GTK_STOCK_PROPERTIES, G_CALLBACK(view_info_cb), vw); | |
1203 | |
1204 menu_item_add_stock(menu, _("View in _new window"), GTK_STOCK_NEW, G_CALLBACK(view_new_window_cb), vw); | |
1205 | |
1206 menu_item_add_divider(menu); | |
1207 menu_item_add_stock(menu, _("_Copy..."), GTK_STOCK_COPY, G_CALLBACK(view_copy_cb), vw); | |
1208 menu_item_add(menu, _("_Move..."), G_CALLBACK(view_move_cb), vw); | |
1209 menu_item_add(menu, _("_Rename..."), G_CALLBACK(view_rename_cb), vw); | |
1210 menu_item_add_stock(menu, _("_Delete..."), GTK_STOCK_DELETE, G_CALLBACK(view_delete_cb), vw); | |
1211 | |
1212 menu_item_add_divider(menu); | |
1213 | |
1214 if (vw->ss) | |
1215 { | |
1216 menu_item_add(menu, _("_Stop slideshow"), G_CALLBACK(view_slideshow_stop_cb), vw); | |
1217 if (slideshow_paused(vw->ss)) | |
1218 { | |
1219 item = menu_item_add(menu, _("Continue slides_how"), | |
1220 G_CALLBACK(view_slideshow_pause_cb), vw); | |
1221 } | |
1222 else | |
1223 { | |
1224 item = menu_item_add(menu, _("Pause slides_how"), | |
1225 G_CALLBACK(view_slideshow_pause_cb), vw); | |
1226 } | |
1227 } | |
1228 else | |
1229 { | |
1230 item = menu_item_add(menu, _("_Start slideshow"), G_CALLBACK(view_slideshow_start_cb), vw); | |
1231 gtk_widget_set_sensitive(item, (vw->list != NULL) || view_window_contains_collection(vw)); | |
1232 item = menu_item_add(menu, _("Pause slides_how"), G_CALLBACK(view_slideshow_pause_cb), vw); | |
1233 gtk_widget_set_sensitive(item, FALSE); | |
1234 } | |
1235 | |
1236 if (vw->fs) | |
1237 { | |
1238 menu_item_add(menu, _("Exit _full screen"), G_CALLBACK(view_fullscreen_cb), vw); | |
1239 } | |
1240 else | |
1241 { | |
1242 menu_item_add(menu, _("_Full screen"), G_CALLBACK(view_fullscreen_cb), vw); | |
1243 } | |
1244 | |
1245 menu_item_add_divider(menu); | |
1246 menu_item_add_stock(menu, _("C_lose window"), GTK_STOCK_CLOSE, G_CALLBACK(view_close_cb), vw); | |
1247 | |
1248 return menu; | |
1249 } | |
1250 | |
1251 /* | |
1252 *------------------------------------------------------------------- | |
1253 * dnd confirm dir | |
1254 *------------------------------------------------------------------- | |
1255 */ | |
1256 | |
1257 typedef struct { | |
1258 ViewWindow *vw; | |
1259 GList *list; | |
1260 } CViewConfirmD; | |
1261 | |
1262 static void view_dir_list_cancel(GtkWidget *widget, gpointer data) | |
1263 { | |
1264 /* do nothing */ | |
1265 } | |
1266 | |
1267 static void view_dir_list_do(ViewWindow *vw, GList *list, gint skip, gint recurse) | |
1268 { | |
1269 GList *work; | |
1270 | |
1271 view_window_set_list(vw, NULL); | |
1272 | |
1273 work = list; | |
1274 while (work) | |
1275 { | |
1276 gchar *path = work->data; | |
1277 work = work->next; | |
1278 | |
1279 if (isdir(path)) | |
1280 { | |
1281 if (!skip) | |
1282 { | |
1283 GList *list = NULL; | |
1284 | |
1285 if (recurse) | |
1286 { | |
1287 list = path_list_recursive(path); | |
1288 } | |
1289 else | |
1290 { | |
1291 path_list(path, &list, NULL); | |
1292 list = path_list_sort(list); | |
1293 list = path_list_filter(list, FALSE); | |
1294 } | |
1295 if (list) vw->list = g_list_concat(vw->list, list); | |
1296 } | |
1297 } | |
1298 else | |
1299 { | |
1300 /* FIXME: no filtering here */ | |
1301 vw->list = g_list_append(vw->list, g_strdup(path)); | |
1302 } | |
1303 } | |
1304 | |
1305 if (vw->list) | |
1306 { | |
1307 gchar *path; | |
1308 | |
1309 vw->list_pointer = vw->list; | |
1310 path = vw->list->data; | |
1311 image_change_path(vw->imd, path, image_zoom_get_default(vw->imd, zoom_mode)); | |
1312 | |
1313 work = vw->list->next; | |
1314 if (enable_read_ahead && work) | |
1315 { | |
1316 path = work->data; | |
1317 image_prebuffer_set(vw->imd, path); | |
1318 } | |
1319 } | |
1320 else | |
1321 { | |
1322 image_change_path(vw->imd, NULL, image_zoom_get_default(vw->imd, zoom_mode)); | |
1323 } | |
1324 } | |
1325 | |
1326 static void view_dir_list_add(GtkWidget *widget, gpointer data) | |
1327 { | |
1328 CViewConfirmD *d = data; | |
1329 view_dir_list_do(d->vw, d->list, FALSE, FALSE); | |
1330 } | |
1331 | |
1332 static void view_dir_list_recurse(GtkWidget *widget, gpointer data) | |
1333 { | |
1334 CViewConfirmD *d = data; | |
1335 view_dir_list_do(d->vw, d->list, FALSE, TRUE); | |
1336 } | |
1337 | |
1338 static void view_dir_list_skip(GtkWidget *widget, gpointer data) | |
1339 { | |
1340 CViewConfirmD *d = data; | |
1341 view_dir_list_do(d->vw, d->list, TRUE, FALSE); | |
1342 } | |
1343 | |
1344 static void view_dir_list_destroy(GtkWidget *widget, gpointer data) | |
1345 { | |
1346 CViewConfirmD *d = data; | |
1347 path_list_free(d->list); | |
1348 g_free(d); | |
1349 } | |
1350 | |
1351 static GtkWidget *view_confirm_dir_list(ViewWindow *vw, GList *list) | |
1352 { | |
1353 GtkWidget *menu; | |
1354 CViewConfirmD *d; | |
1355 | |
1356 d = g_new(CViewConfirmD, 1); | |
1357 d->vw = vw; | |
1358 d->list = list; | |
1359 | |
1360 menu = popup_menu_short_lived(); | |
1361 g_signal_connect(G_OBJECT(menu), "destroy", | |
1362 G_CALLBACK(view_dir_list_destroy), d); | |
1363 | |
1364 menu_item_add_stock(menu, _("Dropped list includes folders."), GTK_STOCK_DND_MULTIPLE, NULL, NULL); | |
1365 menu_item_add_divider(menu); | |
1366 menu_item_add_stock(menu, _("_Add contents"), GTK_STOCK_OK, G_CALLBACK(view_dir_list_add), d); | |
1367 menu_item_add_stock(menu, _("Add contents _recursive"), GTK_STOCK_ADD, G_CALLBACK(view_dir_list_recurse), d); | |
1368 menu_item_add_stock(menu, _("_Skip folders"), GTK_STOCK_REMOVE, G_CALLBACK(view_dir_list_skip), d); | |
1369 menu_item_add_divider(menu); | |
1370 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, G_CALLBACK(view_dir_list_cancel), d); | |
1371 | |
1372 return menu; | |
1 | 1373 } |
1374 | |
9 | 1375 /* |
1376 *----------------------------------------------------------------------------- | |
1377 * image drag and drop routines | |
1378 *----------------------------------------------------------------------------- | |
1379 */ | |
1380 | |
1381 static void view_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, | |
1382 gint x, gint y, | |
1383 GtkSelectionData *selection_data, guint info, | |
1384 guint time, gpointer data) | |
1 | 1385 { |
9 | 1386 ViewWindow *vw = data; |
1387 ImageWindow *imd; | |
1388 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1389 if (gtk_drag_get_source_widget(context) == vw->imd->pr) return; |
9 | 1390 |
1391 imd = vw->imd; | |
1392 | |
1393 if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER) | |
1394 { | |
1395 CollectionData *source; | |
1396 GList *list; | |
1397 GList *info_list; | |
1398 | |
1399 if (info == TARGET_URI_LIST) | |
1400 { | |
1401 GList *work; | |
1402 | |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
60
diff
changeset
|
1403 list = uri_list_from_text((gchar *)selection_data->data, TRUE); |
9 | 1404 |
1405 work = list; | |
1406 while (work) | |
1407 { | |
1408 if (isdir((gchar *)work->data)) | |
1409 { | |
1410 GtkWidget *menu; | |
1411 menu = view_confirm_dir_list(vw, list); | |
1412 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, time); | |
1413 return; | |
1414 } | |
1415 work = work->next; | |
1416 } | |
1417 | |
1418 list = path_list_filter(list, FALSE); | |
1419 | |
1420 source = NULL; | |
1421 info_list = NULL; | |
1422 } | |
1423 else | |
1424 { | |
1425 source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); | |
1426 } | |
1427 | |
1428 if (list) | |
1429 { | |
1430 gchar *path; | |
1431 | |
1432 path = list->data; | |
1433 if (isfile(path)) | |
1434 { | |
1435 view_slideshow_stop(vw); | |
1436 view_window_set_list(vw, NULL); | |
1 | 1437 |
9 | 1438 if (source && info_list) |
1439 { | |
1440 image_change_from_collection(imd, source, info_list->data, image_zoom_get_default(imd, zoom_mode)); | |
1441 } | |
1442 else | |
1443 { | |
1444 if (list->next) | |
1445 { | |
1446 vw->list = list; | |
1447 list = NULL; | |
1448 | |
1449 vw->list_pointer = vw->list; | |
1450 } | |
1451 image_change_path(imd, path, image_zoom_get_default(imd, zoom_mode)); | |
1452 } | |
1453 } | |
1454 } | |
1455 path_list_free(list); | |
1456 g_list_free(info_list); | |
1457 } | |
1458 } | |
1459 | |
1460 static void view_window_set_dnd_data(GtkWidget *widget, GdkDragContext *context, | |
1461 GtkSelectionData *selection_data, guint info, | |
1462 guint time, gpointer data) | |
1463 { | |
1464 ViewWindow *vw = data; | |
1465 const gchar *path; | |
1466 | |
1467 path = image_get_path(vw->imd); | |
1 | 1468 |
9 | 1469 if (path) |
1470 { | |
1471 gchar *text = NULL; | |
1472 gint len; | |
1473 gint plain_text; | |
1474 GList *list; | |
1 | 1475 |
9 | 1476 switch (info) |
1477 { | |
1478 case TARGET_URI_LIST: | |
1479 plain_text = FALSE; | |
1480 break; | |
1481 case TARGET_TEXT_PLAIN: | |
1482 default: | |
1483 plain_text = TRUE; | |
1484 break; | |
1485 } | |
1486 list = g_list_append(NULL, (gchar *)path); | |
1487 text = uri_text_from_list(list, &len, plain_text); | |
1488 g_list_free(list); | |
1489 if (text) | |
1490 { | |
1491 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
|
1492 8, (guchar *)text, len); |
9 | 1493 g_free(text); |
1494 } | |
1495 } | |
1496 else | |
1497 { | |
1498 gtk_selection_data_set (selection_data, selection_data->target, | |
1499 8, NULL, 0); | |
1500 } | |
1 | 1501 } |
1502 | |
9 | 1503 static void view_window_dnd_init(ViewWindow *vw) |
1504 { | |
1505 ImageWindow *imd; | |
1 | 1506 |
9 | 1507 imd = vw->imd; |
1508 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1509 gtk_drag_source_set(imd->pr, GDK_BUTTON2_MASK, |
9 | 1510 dnd_file_drag_types, dnd_file_drag_types_count, |
1511 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
|
1512 g_signal_connect(G_OBJECT(imd->pr), "drag_data_get", |
9 | 1513 G_CALLBACK(view_window_set_dnd_data), vw); |
1514 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
1515 gtk_drag_dest_set(imd->pr, |
9 | 1516 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, |
1517 dnd_file_drop_types, dnd_file_drop_types_count, | |
1518 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
|
1519 g_signal_connect(G_OBJECT(imd->pr), "drag_data_received", |
9 | 1520 G_CALLBACK(view_window_get_dnd_data), vw); |
1521 } | |
1522 | |
1523 /* | |
1524 *----------------------------------------------------------------------------- | |
1525 * maintenance (for rename, move, remove) | |
1526 *----------------------------------------------------------------------------- | |
1527 */ | |
1528 | |
1529 static void view_real_removed(ViewWindow *vw, const gchar *path, GList *ignore_list) | |
1530 { | |
1531 ImageWindow *imd; | |
1532 const gchar *image_path; | |
1533 | |
1534 imd = view_window_active_image(vw); | |
1535 image_path = image_get_path(imd); | |
1536 | |
1537 if (image_path && strcmp(image_path, path) == 0) | |
1538 { | |
1539 if (vw->list) | |
1540 { | |
1541 view_list_step(vw, TRUE); | |
1542 if (image_get_path(imd) == image_path) | |
1543 { | |
1544 view_list_step(vw, FALSE); | |
1545 } | |
1546 } | |
1547 else if (view_window_contains_collection(vw)) | |
1548 { | |
1549 view_collection_step(vw, TRUE); | |
1550 if (image_get_path(imd) == image_path) | |
1551 { | |
1552 view_collection_step(vw, FALSE); | |
1553 } | |
1554 } | |
1555 if (image_get_path(imd) == image_path) | |
1556 { | |
1557 image_change_path(imd, NULL, image_zoom_get_default(imd, zoom_mode)); | |
1558 } | |
1559 } | |
1560 | |
1561 if (vw->list) | |
1562 { | |
1563 GList *work; | |
1564 GList *old; | |
1565 | |
1566 old = vw->list_pointer; | |
1567 | |
1568 work = vw->list; | |
1569 while (work) | |
1570 { | |
1571 gchar *chk_path; | |
1572 GList *chk_link; | |
1573 | |
1574 chk_path = work->data; | |
1575 chk_link = work; | |
1576 work = work->next; | |
1577 | |
1578 if (strcmp(chk_path, path) == 0) | |
1579 { | |
1580 if (vw->list_pointer == chk_link) | |
1581 { | |
1582 vw->list_pointer = (chk_link->next) ? chk_link->next : chk_link->prev; | |
1583 } | |
1584 vw->list = g_list_remove(vw->list, chk_path); | |
1585 g_free(chk_path); | |
1586 } | |
1587 } | |
1588 | |
1589 /* handles stepping correctly when same image is in the list more than once */ | |
1590 if (old && old != vw->list_pointer) | |
1591 { | |
1592 gchar *path; | |
1593 | |
1594 if (vw->list_pointer) | |
1595 { | |
1596 path = vw->list_pointer->data; | |
1597 } | |
1598 else | |
1599 { | |
1600 path = NULL; | |
1601 } | |
1602 | |
1603 image_change_path(imd, path, image_zoom_get_default(imd, zoom_mode)); | |
1604 } | |
1605 } | |
1606 | |
1607 if (vw->overlay_id != -1) image_overlay_update(imd, vw->overlay_id); | |
1608 } | |
1609 | |
1610 static void view_real_moved(ViewWindow *vw, const gchar *source, const gchar *dest) | |
1611 { | |
1612 ImageWindow *imd; | |
1613 const gchar *image_path; | |
1614 | |
1615 imd = view_window_active_image(vw); | |
1616 image_path = image_get_path(imd); | |
1617 | |
1618 if (image_path && strcmp(image_path, source) == 0) | |
1619 { | |
1620 image_set_path(imd, dest); | |
1621 } | |
1622 | |
1623 if (vw->list) | |
1624 { | |
1625 GList *work; | |
1626 work = vw->list; | |
1627 while (work) | |
1628 { | |
1629 gchar *chk_path; | |
1630 | |
1631 chk_path = work->data; | |
1632 | |
1633 if (strcmp(chk_path, source) == 0) | |
1634 { | |
1635 work->data = g_strdup(dest); | |
1636 g_free(chk_path); | |
1637 } | |
1638 | |
1639 work = work->next; | |
1640 } | |
1641 } | |
1642 } | |
1643 | |
1644 void view_window_maint_removed(const gchar *path, GList *ignore_list) | |
1645 { | |
1646 GList *work = view_window_list; | |
1647 while (work) | |
1648 { | |
1649 ViewWindow *vw = work->data; | |
1650 work = work->next; | |
1651 | |
1652 view_real_removed(vw, path, ignore_list); | |
1653 } | |
1654 } | |
1655 | |
1656 void view_window_maint_moved(const gchar *source, const gchar *dest) | |
1657 { | |
1658 GList *work = view_window_list; | |
1659 while (work) | |
1660 { | |
1661 ViewWindow *vw = work->data; | |
1662 work = work->next; | |
1663 | |
1664 view_real_moved(vw, source, dest); | |
1665 } | |
1666 } | |
1667 |