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