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