Mercurial > geeqie.yaz
annotate src/layout_image.c @ 1037:86148ec8a299
fixed various problems with preserving viewport on image change,
options->image.scroll_reset_method should work again (it needs to be
added to the preferences dialog)
author | nadvornik |
---|---|
date | Thu, 04 Sep 2008 21:19:09 +0000 |
parents | 9962b24b6b43 |
children | 5fc64d6252e7 |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
3 * (C) 2006 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
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! | |
11 */ | |
12 | |
281 | 13 #include "main.h" |
9 | 14 #include "layout_image.h" |
15 | |
16 #include "collect.h" | |
17 #include "dnd.h" | |
18 #include "editors.h" | |
586 | 19 #include "filedata.h" |
9 | 20 #include "fullscreen.h" |
21 #include "image.h" | |
22 #include "image-overlay.h" | |
23 #include "img-view.h" | |
24 #include "info.h" | |
25 #include "layout.h" | |
26 #include "layout_util.h" | |
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" |
9 | 29 #include "pixbuf_util.h" |
30 #include "slideshow.h" | |
31 #include "ui_fileops.h" | |
32 #include "ui_menu.h" | |
904
1698baa37871
Move uri_*() functions to separate files: uri_utils.[ch]
zas_
parents:
888
diff
changeset
|
33 #include "uri_utils.h" |
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
995
diff
changeset
|
34 #include "utilops.h" |
9 | 35 |
36 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
37 | |
38 | |
39 static GtkWidget *layout_image_pop_menu(LayoutWindow *lw); | |
40 static void layout_image_set_buttons(LayoutWindow *lw); | |
41 | |
42 /* | |
43 *---------------------------------------------------------------------------- | |
44 * full screen overlay | |
45 *---------------------------------------------------------------------------- | |
46 */ | |
47 | |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
48 void layout_image_overlay_toggle(LayoutWindow *lw) |
9 | 49 { |
481
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
479
diff
changeset
|
50 if (!lw) return; |
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
479
diff
changeset
|
51 image_osd_toggle(lw->image); |
9 | 52 } |
53 | |
54 /* | |
55 *---------------------------------------------------------------------------- | |
56 * full screen | |
57 *---------------------------------------------------------------------------- | |
58 */ | |
160 | 59 |
9 | 60 static void layout_image_full_screen_stop_func(FullScreenData *fs, gpointer data) |
61 { | |
62 LayoutWindow *lw = data; | |
63 | |
64 /* restore image window */ | |
65 lw->image = fs->normal_imd; | |
66 | |
67 if (lw->slideshow) | |
68 { | |
69 lw->slideshow->imd = lw->image; | |
70 } | |
71 | |
72 lw->full_screen = NULL; | |
73 } | |
74 | |
75 void layout_image_full_screen_start(LayoutWindow *lw) | |
76 { | |
77 if (!layout_valid(&lw)) return; | |
78 | |
79 if (lw->full_screen) return; | |
80 | |
81 lw->full_screen = fullscreen_start(lw->window, lw->image, | |
82 layout_image_full_screen_stop_func, lw); | |
83 | |
84 /* set to new image window */ | |
85 lw->image = lw->full_screen->imd; | |
86 | |
87 if (lw->slideshow) | |
88 { | |
89 lw->slideshow->imd = lw->image; | |
90 } | |
91 | |
92 layout_image_set_buttons(lw); | |
93 | |
94 g_signal_connect(G_OBJECT(lw->full_screen->window), "key_press_event", | |
160 | 95 G_CALLBACK(layout_key_press_cb), lw); |
9 | 96 |
160 | 97 layout_actions_add_window(lw, lw->full_screen->window); |
9 | 98 #if 0 |
99 gtk_widget_set_sensitive(lw->window, FALSE); | |
100 if (lw->tools) gtk_widget_set_sensitive(lw->tools, FALSE); | |
101 #endif | |
102 | |
621 | 103 if (image_osd_get(lw->full_screen->normal_imd) & OSD_SHOW_INFO) |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
104 { |
621 | 105 image_osd_set(lw->image, image_osd_get(lw->full_screen->normal_imd)); |
614 | 106 image_osd_set(lw->full_screen->normal_imd, OSD_SHOW_NOTHING); |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
107 } |
9 | 108 } |
109 | |
110 void layout_image_full_screen_stop(LayoutWindow *lw) | |
111 { | |
112 if (!layout_valid(&lw)) return; | |
113 if (!lw->full_screen) return; | |
114 | |
621 | 115 if (image_osd_get(lw->full_screen->normal_imd) & OSD_SHOW_INFO) |
116 image_osd_set(lw->full_screen->normal_imd, image_osd_get(lw->image)); | |
117 | |
9 | 118 fullscreen_stop(lw->full_screen); |
119 | |
120 #if 0 | |
121 gtk_widget_set_sensitive(lw->window, TRUE); | |
122 if (lw->tools) gtk_widget_set_sensitive(lw->tools, TRUE); | |
123 #endif | |
124 } | |
125 | |
126 void layout_image_full_screen_toggle(LayoutWindow *lw) | |
127 { | |
128 if (!layout_valid(&lw)) return; | |
129 if (lw->full_screen) | |
130 { | |
131 layout_image_full_screen_stop(lw); | |
132 } | |
133 else | |
134 { | |
135 layout_image_full_screen_start(lw); | |
136 } | |
137 } | |
138 | |
139 gint layout_image_full_screen_active(LayoutWindow *lw) | |
140 { | |
141 if (!layout_valid(&lw)) return FALSE; | |
142 | |
143 return (lw->full_screen != NULL); | |
144 } | |
145 | |
146 /* | |
147 *---------------------------------------------------------------------------- | |
148 * slideshow | |
149 *---------------------------------------------------------------------------- | |
150 */ | |
151 | |
152 static void layout_image_slideshow_next(LayoutWindow *lw) | |
153 { | |
154 if (lw->slideshow) slideshow_next(lw->slideshow); | |
155 } | |
156 | |
157 static void layout_image_slideshow_prev(LayoutWindow *lw) | |
158 { | |
159 if (lw->slideshow) slideshow_prev(lw->slideshow); | |
160 } | |
161 | |
162 static void layout_image_slideshow_stop_func(SlideShowData *ss, gpointer data) | |
163 { | |
164 LayoutWindow *lw = data; | |
165 | |
166 lw->slideshow = NULL; | |
167 layout_status_update_info(lw, NULL); | |
168 } | |
169 | |
170 void layout_image_slideshow_start(LayoutWindow *lw) | |
171 { | |
172 CollectionData *cd; | |
173 CollectInfo *info; | |
174 | |
175 if (!layout_valid(&lw)) return; | |
176 if (lw->slideshow) return; | |
177 | |
178 cd = image_get_collection(lw->image, &info); | |
179 | |
180 if (cd && info) | |
181 { | |
182 lw->slideshow = slideshow_start_from_collection(lw->image, cd, | |
183 layout_image_slideshow_stop_func, lw, info); | |
184 } | |
185 else | |
186 { | |
187 lw->slideshow = slideshow_start(lw->image, lw, | |
783 | 188 layout_list_get_index(lw, layout_image_get_fd(lw)), |
9 | 189 layout_image_slideshow_stop_func, lw); |
190 } | |
191 | |
192 layout_status_update_info(lw, NULL); | |
193 } | |
194 | |
195 /* note that slideshow will take ownership of the list, do not free it */ | |
196 void layout_image_slideshow_start_from_list(LayoutWindow *lw, GList *list) | |
197 { | |
198 if (!layout_valid(&lw)) return; | |
199 | |
200 if (lw->slideshow || !list) | |
201 { | |
138 | 202 filelist_free(list); |
9 | 203 return; |
204 } | |
205 | |
138 | 206 lw->slideshow = slideshow_start_from_filelist(lw->image, list, |
9 | 207 layout_image_slideshow_stop_func, lw); |
208 | |
209 layout_status_update_info(lw, NULL); | |
210 } | |
211 | |
212 void layout_image_slideshow_stop(LayoutWindow *lw) | |
213 { | |
214 if (!layout_valid(&lw)) return; | |
215 | |
216 if (!lw->slideshow) return; | |
217 | |
218 slideshow_free(lw->slideshow); | |
219 /* the stop_func sets lw->slideshow to NULL for us */ | |
220 } | |
221 | |
222 void layout_image_slideshow_toggle(LayoutWindow *lw) | |
223 { | |
224 if (!layout_valid(&lw)) return; | |
225 | |
226 if (lw->slideshow) | |
227 { | |
228 layout_image_slideshow_stop(lw); | |
229 } | |
230 else | |
231 { | |
232 layout_image_slideshow_start(lw); | |
233 } | |
234 } | |
235 | |
236 gint layout_image_slideshow_active(LayoutWindow *lw) | |
237 { | |
238 if (!layout_valid(&lw)) return FALSE; | |
239 | |
240 return (lw->slideshow != NULL); | |
241 } | |
242 | |
243 gint layout_image_slideshow_pause_toggle(LayoutWindow *lw) | |
244 { | |
245 gint ret; | |
246 | |
247 if (!layout_valid(&lw)) return FALSE; | |
248 | |
249 ret = slideshow_pause_toggle(lw->slideshow); | |
250 | |
251 layout_status_update_info(lw, NULL); | |
252 | |
253 return ret; | |
254 } | |
255 | |
256 gint layout_image_slideshow_paused(LayoutWindow *lw) | |
257 { | |
258 if (!layout_valid(&lw)) return FALSE; | |
259 | |
260 return (slideshow_paused(lw->slideshow)); | |
261 } | |
262 | |
263 static gint layout_image_slideshow_continue_check(LayoutWindow *lw) | |
264 { | |
265 if (!lw->slideshow) return FALSE; | |
266 | |
267 if (!slideshow_should_continue(lw->slideshow)) | |
268 { | |
269 layout_image_slideshow_stop(lw); | |
270 return FALSE; | |
271 } | |
272 | |
273 return TRUE; | |
274 } | |
275 | |
276 /* | |
277 *---------------------------------------------------------------------------- | |
278 * pop-up menus | |
279 *---------------------------------------------------------------------------- | |
280 */ | |
281 | |
282 static void li_pop_menu_zoom_in_cb(GtkWidget *widget, gpointer data) | |
283 { | |
284 LayoutWindow *lw = data; | |
285 | |
130 | 286 layout_image_zoom_adjust(lw, get_zoom_increment()); |
9 | 287 } |
288 | |
289 static void li_pop_menu_zoom_out_cb(GtkWidget *widget, gpointer data) | |
290 { | |
291 LayoutWindow *lw = data; | |
130 | 292 layout_image_zoom_adjust(lw, -get_zoom_increment()); |
9 | 293 } |
294 | |
295 static void li_pop_menu_zoom_1_1_cb(GtkWidget *widget, gpointer data) | |
296 { | |
297 LayoutWindow *lw = data; | |
298 | |
130 | 299 layout_image_zoom_set(lw, 1.0); |
9 | 300 } |
301 | |
302 static void li_pop_menu_zoom_fit_cb(GtkWidget *widget, gpointer data) | |
303 { | |
304 LayoutWindow *lw = data; | |
305 | |
130 | 306 layout_image_zoom_set(lw, 0.0); |
9 | 307 } |
308 | |
309 static void li_pop_menu_edit_cb(GtkWidget *widget, gpointer data) | |
310 { | |
311 LayoutWindow *lw; | |
312 gint n; | |
313 | |
314 lw = submenu_item_get_data(widget); | |
315 n = GPOINTER_TO_INT(data); | |
316 | |
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
317 if (!editor_window_flag_set(n)) |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
318 { |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
319 layout_image_full_screen_stop(lw); |
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
320 } |
753 | 321 file_util_start_editor_from_file(n, layout_image_get_fd(lw), lw->window); |
9 | 322 } |
323 | |
324 static void li_pop_menu_wallpaper_cb(GtkWidget *widget, gpointer data) | |
325 { | |
326 LayoutWindow *lw = data; | |
327 | |
328 layout_image_to_root(lw); | |
329 } | |
330 | |
331 static void li_pop_menu_alter_cb(GtkWidget *widget, gpointer data) | |
332 { | |
333 LayoutWindow *lw = data; | |
334 AlterType type; | |
335 | |
336 lw = submenu_item_get_data(widget); | |
337 type = (AlterType)GPOINTER_TO_INT(data); | |
338 | |
339 image_alter(lw->image, type); | |
340 } | |
341 | |
342 static void li_pop_menu_info_cb(GtkWidget *widget, gpointer data) | |
343 { | |
344 LayoutWindow *lw = data; | |
345 | |
479
5212d4fed37f
Ensure Properties dialog is displayed above fullscreen window.
zas_
parents:
475
diff
changeset
|
346 info_window_new(layout_image_get_fd(lw), NULL, lw->full_screen ? lw->full_screen->window : NULL); |
9 | 347 } |
348 | |
349 static void li_pop_menu_new_cb(GtkWidget *widget, gpointer data) | |
350 { | |
351 LayoutWindow *lw = data; | |
352 | |
138 | 353 view_window_new(layout_image_get_fd(lw)); |
9 | 354 } |
355 | |
356 static GtkWidget *li_pop_menu_click_parent(GtkWidget *widget, LayoutWindow *lw) | |
357 { | |
358 GtkWidget *menu; | |
359 GtkWidget *parent; | |
360 | |
361 menu = gtk_widget_get_toplevel(widget); | |
362 if (!menu) return NULL; | |
363 | |
364 parent = g_object_get_data(G_OBJECT(menu), "click_parent"); | |
365 | |
366 if (!parent && lw->full_screen) | |
367 { | |
368 parent = lw->full_screen->imd->widget; | |
369 } | |
370 | |
371 return parent; | |
372 } | |
373 | |
374 static void li_pop_menu_copy_cb(GtkWidget *widget, gpointer data) | |
375 { | |
376 LayoutWindow *lw = data; | |
377 | |
138 | 378 file_util_copy(layout_image_get_fd(lw), NULL, NULL, |
9 | 379 li_pop_menu_click_parent(widget, lw)); |
380 } | |
381 | |
497 | 382 static void li_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data) |
383 { | |
384 LayoutWindow *lw = data; | |
385 | |
386 file_util_copy_path_to_clipboard(layout_image_get_fd(lw)); | |
387 } | |
388 | |
9 | 389 static void li_pop_menu_move_cb(GtkWidget *widget, gpointer data) |
390 { | |
391 LayoutWindow *lw = data; | |
392 | |
138 | 393 file_util_move(layout_image_get_fd(lw), NULL, NULL, |
9 | 394 li_pop_menu_click_parent(widget, lw)); |
395 } | |
396 | |
397 static void li_pop_menu_rename_cb(GtkWidget *widget, gpointer data) | |
398 { | |
399 LayoutWindow *lw = data; | |
400 | |
138 | 401 file_util_rename(layout_image_get_fd(lw), NULL, |
9 | 402 li_pop_menu_click_parent(widget, lw)); |
403 } | |
404 | |
405 static void li_pop_menu_delete_cb(GtkWidget *widget, gpointer data) | |
406 { | |
407 LayoutWindow *lw = data; | |
408 | |
138 | 409 file_util_delete(layout_image_get_fd(lw), NULL, |
9 | 410 li_pop_menu_click_parent(widget, lw)); |
411 } | |
412 | |
413 static void li_pop_menu_slide_start_cb(GtkWidget *widget, gpointer data) | |
414 { | |
415 LayoutWindow *lw = data; | |
416 | |
417 layout_image_slideshow_start(lw); | |
418 } | |
419 | |
420 static void li_pop_menu_slide_stop_cb(GtkWidget *widget, gpointer data) | |
421 { | |
422 LayoutWindow *lw = data; | |
423 | |
424 layout_image_slideshow_stop(lw); | |
425 } | |
426 | |
427 static void li_pop_menu_slide_pause_cb(GtkWidget *widget, gpointer data) | |
428 { | |
429 LayoutWindow *lw = data; | |
430 | |
431 layout_image_slideshow_pause_toggle(lw); | |
432 } | |
433 | |
434 static void li_pop_menu_full_screen_cb(GtkWidget *widget, gpointer data) | |
435 { | |
436 LayoutWindow *lw = data; | |
437 | |
438 layout_image_full_screen_toggle(lw); | |
439 } | |
440 | |
441 static void li_pop_menu_hide_cb(GtkWidget *widget, gpointer data) | |
442 { | |
443 LayoutWindow *lw = data; | |
444 | |
445 layout_tools_hide_toggle(lw); | |
446 } | |
447 | |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
448 static void li_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:
339
diff
changeset
|
449 { |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
450 LayoutWindow *lw = data; |
783 | 451 FileData *fd; |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
452 |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
453 if (!layout_valid(&lw)) return; |
442 | 454 |
783 | 455 fd = layout_image_get_fd(lw); |
456 if (fd) layout_set_fd(lw, fd); | |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
457 } |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
458 |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
459 static gint li_check_if_current_path(LayoutWindow *lw, const gchar *path) |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
460 { |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
461 gchar *dirname; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
462 gint ret; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
463 |
783 | 464 if (!path || !layout_valid(&lw) || !lw->dir_fd) return FALSE; |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
465 |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
466 dirname = g_path_get_dirname(path); |
783 | 467 ret = (strcmp(lw->dir_fd->path, dirname) == 0); |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
468 g_free(dirname); |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
469 return ret; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
470 } |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
471 |
9 | 472 static GtkWidget *layout_image_pop_menu(LayoutWindow *lw) |
473 { | |
474 GtkWidget *menu; | |
475 GtkWidget *item; | |
476 GtkWidget *submenu; | |
477 const gchar *path; | |
478 gint fullscreen; | |
479 | |
480 path = layout_image_get_path(lw); | |
481 fullscreen = layout_image_full_screen_active(lw); | |
482 | |
483 menu = popup_menu_short_lived(); | |
484 | |
485 menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN, G_CALLBACK(li_pop_menu_zoom_in_cb), lw); | |
486 menu_item_add_stock(menu, _("Zoom _out"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(li_pop_menu_zoom_out_cb), lw); | |
487 menu_item_add_stock(menu, _("Zoom _1:1"), GTK_STOCK_ZOOM_100, G_CALLBACK(li_pop_menu_zoom_1_1_cb), lw); | |
488 menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(li_pop_menu_zoom_fit_cb), lw); | |
489 menu_item_add_divider(menu); | |
490 | |
491 submenu = submenu_add_edit(menu, &item, G_CALLBACK(li_pop_menu_edit_cb), lw); | |
492 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
493 menu_item_add_divider(submenu); | |
494 menu_item_add(submenu, _("Set as _wallpaper"), G_CALLBACK(li_pop_menu_wallpaper_cb), lw); | |
495 | |
496 item = submenu_add_alter(menu, G_CALLBACK(li_pop_menu_alter_cb), lw); | |
497 | |
498 item = menu_item_add_stock(menu, _("_Properties"), GTK_STOCK_PROPERTIES, G_CALLBACK(li_pop_menu_info_cb), lw); | |
499 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
500 | |
501 item = menu_item_add_stock(menu, _("View in _new window"), GTK_STOCK_NEW, G_CALLBACK(li_pop_menu_new_cb), lw); | |
502 if (!path || fullscreen) gtk_widget_set_sensitive(item, FALSE); | |
442 | 503 |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
504 item = menu_item_add(menu, _("_Go to directory view"), G_CALLBACK(li_set_layout_path_cb), lw); |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
505 if (!path || li_check_if_current_path(lw, path)) gtk_widget_set_sensitive(item, FALSE); |
9 | 506 |
507 menu_item_add_divider(menu); | |
508 | |
509 item = menu_item_add_stock(menu, _("_Copy..."), GTK_STOCK_COPY, G_CALLBACK(li_pop_menu_copy_cb), lw); | |
510 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
511 item = menu_item_add(menu, _("_Move..."), G_CALLBACK(li_pop_menu_move_cb), lw); | |
512 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
513 item = menu_item_add(menu, _("_Rename..."), G_CALLBACK(li_pop_menu_rename_cb), lw); | |
514 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
515 item = menu_item_add_stock(menu, _("_Delete..."), GTK_STOCK_DELETE, G_CALLBACK(li_pop_menu_delete_cb), lw); | |
516 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
497 | 517 |
518 if (options->show_copy_path) | |
519 { | |
520 item = menu_item_add(menu, _("_Copy path"), G_CALLBACK(li_pop_menu_copy_path_cb), lw); | |
521 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
522 } | |
9 | 523 |
524 menu_item_add_divider(menu); | |
525 | |
526 if (layout_image_slideshow_active(lw)) | |
527 { | |
528 menu_item_add(menu, _("_Stop slideshow"), G_CALLBACK(li_pop_menu_slide_stop_cb), lw); | |
529 if (layout_image_slideshow_paused(lw)) | |
530 { | |
531 item = menu_item_add(menu, _("Continue slides_how"), | |
532 G_CALLBACK(li_pop_menu_slide_pause_cb), lw); | |
533 } | |
534 else | |
535 { | |
536 item = menu_item_add(menu, _("Pause slides_how"), | |
537 G_CALLBACK(li_pop_menu_slide_pause_cb), lw); | |
538 } | |
539 } | |
540 else | |
442 | 541 { |
9 | 542 menu_item_add(menu, _("_Start slideshow"), G_CALLBACK(li_pop_menu_slide_start_cb), lw); |
543 item = menu_item_add(menu, _("Pause slides_how"), G_CALLBACK(li_pop_menu_slide_pause_cb), lw); | |
544 gtk_widget_set_sensitive(item, FALSE); | |
545 } | |
546 | |
547 if (!fullscreen) | |
548 { | |
549 menu_item_add(menu, _("_Full screen"), G_CALLBACK(li_pop_menu_full_screen_cb), lw); | |
550 } | |
551 else | |
552 { | |
553 menu_item_add(menu, _("Exit _full screen"), G_CALLBACK(li_pop_menu_full_screen_cb), lw); | |
554 } | |
555 | |
556 menu_item_add_divider(menu); | |
557 | |
558 item = menu_item_add_check(menu, _("Hide file _list"), lw->tools_hidden, | |
559 G_CALLBACK(li_pop_menu_hide_cb), lw); | |
560 if (fullscreen) gtk_widget_set_sensitive(item, FALSE); | |
561 | |
562 return menu; | |
563 } | |
564 | |
565 static void layout_image_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
566 { | |
567 LayoutWindow *lw = data; | |
568 | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
569 gdk_window_get_origin(lw->image->pr->window, x, y); |
9 | 570 popup_menu_position_clamp(menu, x, y, 0); |
571 } | |
572 | |
573 void layout_image_menu_popup(LayoutWindow *lw) | |
574 { | |
575 GtkWidget *menu; | |
576 | |
577 menu = layout_image_pop_menu(lw); | |
578 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, layout_image_menu_pos_cb, lw, 0, GDK_CURRENT_TIME); | |
579 } | |
580 | |
581 /* | |
582 *---------------------------------------------------------------------------- | |
583 * dnd | |
584 *---------------------------------------------------------------------------- | |
585 */ | |
586 | |
587 static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *context, | |
588 gint x, gint y, | |
589 GtkSelectionData *selection_data, guint info, | |
590 guint time, gpointer data) | |
591 { | |
592 LayoutWindow *lw = data; | |
127 | 593 gint i; |
442 | 594 |
595 | |
520 | 596 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
127 | 597 { |
598 if (lw->split_images[i] && lw->split_images[i]->pr == widget) | |
599 break; | |
600 } | |
601 if (i < MAX_SPLIT_IMAGES) | |
602 { | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
603 DEBUG_1("dnd image activate %d", i); |
127 | 604 layout_image_activate(lw, i); |
605 } | |
606 | |
9 | 607 |
608 if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER) | |
609 { | |
610 CollectionData *source; | |
611 GList *list; | |
612 GList *info_list; | |
613 | |
614 if (info == TARGET_URI_LIST) | |
615 { | |
138 | 616 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); |
9 | 617 source = NULL; |
618 info_list = NULL; | |
619 } | |
620 else | |
621 { | |
622 source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); | |
623 } | |
624 | |
625 if (list) | |
626 { | |
138 | 627 FileData *fd = list->data; |
9 | 628 |
138 | 629 if (isfile(fd->path)) |
9 | 630 { |
631 gchar *base; | |
632 gint row; | |
783 | 633 FileData *dir_fd; |
9 | 634 |
138 | 635 base = remove_level_from_path(fd->path); |
783 | 636 dir_fd = file_data_new_simple(base); |
637 if (dir_fd != lw->dir_fd) | |
9 | 638 { |
783 | 639 layout_set_fd(lw, dir_fd); |
9 | 640 } |
783 | 641 file_data_unref(dir_fd); |
9 | 642 g_free(base); |
643 | |
783 | 644 row = layout_list_get_index(lw, fd); |
9 | 645 if (source && info_list) |
646 { | |
647 layout_image_set_collection(lw, source, info_list->data); | |
648 } | |
649 else if (row == -1) | |
650 { | |
138 | 651 layout_image_set_fd(lw, fd); |
9 | 652 } |
653 else | |
654 { | |
655 layout_image_set_index(lw, row); | |
656 } | |
657 } | |
138 | 658 else if (isdir(fd->path)) |
9 | 659 { |
783 | 660 layout_set_fd(lw, fd); |
138 | 661 layout_image_set_fd(lw, NULL); |
9 | 662 } |
663 } | |
664 | |
138 | 665 filelist_free(list); |
9 | 666 g_list_free(info_list); |
667 } | |
668 } | |
669 | |
670 static void layout_image_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
671 GtkSelectionData *selection_data, guint info, | |
672 guint time, gpointer data) | |
673 { | |
674 LayoutWindow *lw = data; | |
138 | 675 FileData *fd; |
127 | 676 gint i; |
442 | 677 |
678 | |
520 | 679 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
127 | 680 { |
681 if (lw->split_images[i] && lw->split_images[i]->pr == widget) | |
682 break; | |
683 } | |
684 if (i < MAX_SPLIT_IMAGES) | |
685 { | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
686 DEBUG_1("dnd get from %d", i); |
138 | 687 fd = image_get_fd(lw->split_images[i]); |
127 | 688 } |
689 else | |
138 | 690 fd = layout_image_get_fd(lw); |
9 | 691 |
138 | 692 if (fd) |
9 | 693 { |
694 gchar *text = NULL; | |
695 gint len; | |
696 gint plain_text; | |
697 GList *list; | |
698 | |
699 switch (info) | |
700 { | |
701 case TARGET_URI_LIST: | |
702 plain_text = FALSE; | |
703 break; | |
704 case TARGET_TEXT_PLAIN: | |
705 default: | |
706 plain_text = TRUE; | |
707 break; | |
708 } | |
138 | 709 list = g_list_append(NULL, fd); |
710 text = uri_text_from_filelist(list, &len, plain_text); | |
9 | 711 g_list_free(list); |
712 if (text) | |
713 { | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
714 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:
507
diff
changeset
|
715 8, (guchar *)text, len); |
9 | 716 g_free(text); |
717 } | |
718 } | |
719 else | |
720 { | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
721 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:
507
diff
changeset
|
722 8, NULL, 0); |
9 | 723 } |
724 } | |
725 | |
726 static void layout_image_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
727 { | |
728 LayoutWindow *lw = data; | |
729 if (context->action == GDK_ACTION_MOVE) | |
730 { | |
783 | 731 FileData *fd; |
9 | 732 gint row; |
733 | |
783 | 734 fd = layout_image_get_fd(lw); |
735 row = layout_list_get_index(lw, fd); | |
9 | 736 if (row < 0) return; |
737 | |
783 | 738 if (!isfile(fd->path)) |
9 | 739 { |
736 | 740 if ((guint) row < layout_list_count(lw, NULL) - 1) |
9 | 741 { |
742 layout_image_next(lw); | |
743 } | |
744 else | |
745 { | |
746 layout_image_prev(lw); | |
747 } | |
748 } | |
749 layout_refresh(lw); | |
750 } | |
751 } | |
752 | |
127 | 753 static void layout_image_dnd_init(LayoutWindow *lw, gint i) |
9 | 754 { |
127 | 755 ImageWindow *imd = lw->split_images[i]; |
756 | |
757 gtk_drag_source_set(imd->pr, GDK_BUTTON2_MASK, | |
9 | 758 dnd_file_drag_types, dnd_file_drag_types_count, |
759 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
127 | 760 g_signal_connect(G_OBJECT(imd->pr), "drag_data_get", |
9 | 761 G_CALLBACK(layout_image_dnd_get), lw); |
127 | 762 g_signal_connect(G_OBJECT(imd->pr), "drag_end", |
9 | 763 G_CALLBACK(layout_image_dnd_end), lw); |
764 | |
127 | 765 gtk_drag_dest_set(imd->pr, |
9 | 766 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, |
767 dnd_file_drop_types, dnd_file_drop_types_count, | |
442 | 768 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); |
127 | 769 g_signal_connect(G_OBJECT(imd->pr), "drag_data_received", |
9 | 770 G_CALLBACK(layout_image_dnd_receive), lw); |
771 } | |
772 | |
773 | |
774 /* | |
775 *---------------------------------------------------------------------------- | |
776 * misc | |
777 *---------------------------------------------------------------------------- | |
778 */ | |
779 | |
780 void layout_image_to_root(LayoutWindow *lw) | |
781 { | |
782 image_to_root_window(lw->image, (image_zoom_get(lw->image) == 0)); | |
783 } | |
784 | |
785 /* | |
786 *---------------------------------------------------------------------------- | |
787 * manipulation + accessors | |
788 *---------------------------------------------------------------------------- | |
789 */ | |
790 | |
791 void layout_image_scroll(LayoutWindow *lw, gint x, gint y) | |
792 { | |
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
793 gdouble dx, dy; |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
794 gint width, height, i; |
9 | 795 if (!layout_valid(&lw)) return; |
796 | |
797 image_scroll(lw->image, x, y); | |
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
798 |
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
799 if (!lw->connect_scroll) return; |
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
800 |
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
801 image_get_image_size(lw->image, &width, &height); |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
802 dx = (gdouble) x / width; |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
803 dy = (gdouble) y / height; |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
804 |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
805 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
806 { |
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
807 if (lw->split_images[i] && lw->split_images[i] != lw->image) |
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
808 { |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
809 gdouble sx, sy; |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
810 image_get_scroll_center(lw->split_images[i], &sx, &sy); |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
811 sx += dx; |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
812 sy += dy; |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
813 image_set_scroll_center(lw->split_images[i], sx, sy); |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
814 } |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
815 } |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
816 |
9 | 817 } |
818 | |
819 void layout_image_zoom_adjust(LayoutWindow *lw, gdouble increment) | |
820 { | |
130 | 821 gint i; |
9 | 822 if (!layout_valid(&lw)) return; |
823 | |
824 image_zoom_adjust(lw->image, increment); | |
130 | 825 |
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
826 if (!lw->connect_zoom) return; |
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
827 |
520 | 828 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
130 | 829 { |
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
830 if (lw->split_images[i] && lw->split_images[i] != lw->image) |
130 | 831 image_zoom_adjust(lw->split_images[i], increment); ; |
832 } | |
9 | 833 } |
834 | |
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
835 void layout_image_zoom_adjust_at_point(LayoutWindow *lw, gdouble increment, gint x, gint y) |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
836 { |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
837 gint i; |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
838 if (!layout_valid(&lw)) return; |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
839 |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
840 image_zoom_adjust_at_point(lw->image, increment, x, y); |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
841 |
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
842 if (!lw->connect_zoom) return; |
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
843 |
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
844 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
845 { |
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
846 if (lw->split_images[i] && lw->split_images[i] != lw->image) |
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
847 image_zoom_adjust_at_point(lw->split_images[i], increment, x, y); |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
848 } |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
849 } |
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
850 |
9 | 851 void layout_image_zoom_set(LayoutWindow *lw, gdouble zoom) |
852 { | |
130 | 853 gint i; |
9 | 854 if (!layout_valid(&lw)) return; |
855 | |
856 image_zoom_set(lw->image, zoom); | |
130 | 857 |
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
858 if (!lw->connect_zoom) return; |
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
859 |
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
860 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
130 | 861 { |
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
862 if (lw->split_images[i] && lw->split_images[i] != lw->image) |
130 | 863 image_zoom_set(lw->split_images[i], zoom); |
864 } | |
9 | 865 } |
866 | |
867 void layout_image_zoom_set_fill_geometry(LayoutWindow *lw, gint vertical) | |
868 { | |
869 if (!layout_valid(&lw)) return; | |
870 | |
871 image_zoom_set_fill_geometry(lw->image, vertical); | |
872 } | |
873 | |
874 void layout_image_alter(LayoutWindow *lw, AlterType type) | |
875 { | |
876 if (!layout_valid(&lw)) return; | |
877 | |
878 image_alter(lw->image, type); | |
879 } | |
880 | |
881 const gchar *layout_image_get_path(LayoutWindow *lw) | |
882 { | |
883 if (!layout_valid(&lw)) return NULL; | |
884 | |
885 return image_get_path(lw->image); | |
886 } | |
887 | |
888 const gchar *layout_image_get_name(LayoutWindow *lw) | |
889 { | |
890 if (!layout_valid(&lw)) return NULL; | |
891 | |
892 return image_get_name(lw->image); | |
893 } | |
894 | |
138 | 895 FileData *layout_image_get_fd(LayoutWindow *lw) |
896 { | |
897 if (!layout_valid(&lw)) return NULL; | |
898 | |
899 return image_get_fd(lw->image); | |
900 } | |
901 | |
9 | 902 CollectionData *layout_image_get_collection(LayoutWindow *lw, CollectInfo **info) |
903 { | |
904 if (!layout_valid(&lw)) return NULL; | |
905 | |
906 return image_get_collection(lw->image, info); | |
907 } | |
908 | |
909 gint layout_image_get_index(LayoutWindow *lw) | |
910 { | |
783 | 911 return layout_list_get_index(lw, image_get_fd(lw->image)); |
9 | 912 } |
913 | |
914 /* | |
915 *---------------------------------------------------------------------------- | |
916 * image changers | |
917 *---------------------------------------------------------------------------- | |
918 */ | |
919 | |
138 | 920 void layout_image_set_fd(LayoutWindow *lw, FileData *fd) |
9 | 921 { |
922 if (!layout_valid(&lw)) return; | |
923 | |
885
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
879
diff
changeset
|
924 image_change_fd(lw->image, fd, image_zoom_get_default(lw->image)); |
9 | 925 |
138 | 926 layout_list_sync_fd(lw, fd); |
9 | 927 layout_image_slideshow_continue_check(lw); |
928 layout_bars_new_image(lw); | |
929 } | |
930 | |
138 | 931 void layout_image_set_with_ahead(LayoutWindow *lw, FileData *fd, FileData *read_ahead_fd) |
9 | 932 { |
933 if (!layout_valid(&lw)) return; | |
934 | |
144 | 935 /* |
936 This should be handled at the caller: in vflist_select_image | |
937 if (path) | |
9 | 938 { |
939 const gchar *old_path; | |
940 | |
941 old_path = layout_image_get_path(lw); | |
942 if (old_path && strcmp(path, old_path) == 0) return; | |
943 } | |
127 | 944 */ |
138 | 945 layout_image_set_fd(lw, fd); |
334 | 946 if (options->image.enable_read_ahead) image_prebuffer_set(lw->image, read_ahead_fd); |
9 | 947 } |
948 | |
949 void layout_image_set_index(LayoutWindow *lw, gint index) | |
950 { | |
138 | 951 FileData *fd; |
952 FileData *read_ahead_fd; | |
9 | 953 gint old; |
954 | |
955 if (!layout_valid(&lw)) return; | |
956 | |
783 | 957 old = layout_list_get_index(lw, layout_image_get_fd(lw)); |
138 | 958 fd = layout_list_get_fd(lw, index); |
9 | 959 |
960 if (old > index) | |
961 { | |
138 | 962 read_ahead_fd = layout_list_get_fd(lw, index - 1); |
9 | 963 } |
964 else | |
965 { | |
138 | 966 read_ahead_fd = layout_list_get_fd(lw, index + 1); |
9 | 967 } |
968 | |
995 | 969 if (layout_selection_count(lw, 0) > 1) |
220 | 970 { |
995 | 971 GList *x = layout_selection_list_by_index(lw); |
972 GList *y; | |
973 GList *last; | |
220 | 974 |
995 | 975 for (last = y = x; y; y = y->next) |
976 last = y; | |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
977 for (y = x; y && (GPOINTER_TO_INT(y->data)) != index; y = y->next) |
220 | 978 ; |
979 | |
980 if (y) | |
981 { | |
982 gint newindex; | |
983 | |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
984 if ((index > old && (index != GPOINTER_TO_INT(last->data) || old != GPOINTER_TO_INT(x->data))) |
995 | 985 || (old == GPOINTER_TO_INT(last->data) && index == GPOINTER_TO_INT(x->data))) |
442 | 986 { |
220 | 987 if (y->next) |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
988 newindex = GPOINTER_TO_INT(y->next->data); |
220 | 989 else |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
990 newindex = GPOINTER_TO_INT(x->data); |
220 | 991 } |
992 else | |
993 { | |
994 if (y->prev) | |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
995 newindex = GPOINTER_TO_INT(y->prev->data); |
220 | 996 else |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
997 newindex = GPOINTER_TO_INT(last->data); |
995 | 998 } |
220 | 999 |
1000 read_ahead_fd = layout_list_get_fd(lw, newindex); | |
1001 } | |
442 | 1002 |
220 | 1003 while (x) |
1004 x = g_list_remove(x, x->data); | |
1005 } | |
1006 | |
138 | 1007 layout_image_set_with_ahead(lw, fd, read_ahead_fd); |
9 | 1008 } |
1009 | |
1010 static void layout_image_set_collection_real(LayoutWindow *lw, CollectionData *cd, CollectInfo *info, gint forward) | |
1011 { | |
1012 if (!layout_valid(&lw)) return; | |
1013 | |
885
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
879
diff
changeset
|
1014 image_change_from_collection(lw->image, cd, info, image_zoom_get_default(lw->image)); |
334 | 1015 if (options->image.enable_read_ahead) |
9 | 1016 { |
1017 CollectInfo *r_info; | |
1018 if (forward) | |
1019 { | |
1020 r_info = collection_next_by_info(cd, info); | |
1021 if (!r_info) r_info = collection_prev_by_info(cd, info); | |
1022 } | |
1023 else | |
1024 { | |
1025 r_info = collection_prev_by_info(cd, info); | |
1026 if (!r_info) r_info = collection_next_by_info(cd, info); | |
1027 } | |
138 | 1028 if (r_info) image_prebuffer_set(lw->image, r_info->fd); |
9 | 1029 } |
1030 | |
1031 layout_image_slideshow_continue_check(lw); | |
1032 layout_bars_new_image(lw); | |
1033 } | |
1034 | |
1035 void layout_image_set_collection(LayoutWindow *lw, CollectionData *cd, CollectInfo *info) | |
1036 { | |
1037 layout_image_set_collection_real(lw, cd, info, TRUE); | |
138 | 1038 layout_list_sync_fd(lw, layout_image_get_fd(lw)); |
9 | 1039 } |
1040 | |
1041 void layout_image_refresh(LayoutWindow *lw) | |
1042 { | |
1043 if (!layout_valid(&lw)) return; | |
1044 | |
1045 image_reload(lw->image); | |
1046 } | |
1047 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1048 void layout_image_color_profile_set(LayoutWindow *lw, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1049 gint input_type, gint screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1050 gint use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1051 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1052 if (!layout_valid(&lw)) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1053 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1054 image_color_profile_set(lw->image, input_type, screen_type, use_image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1055 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1056 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1057 gint layout_image_color_profile_get(LayoutWindow *lw, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1058 gint *input_type, gint *screen_type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1059 gint *use_image) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1060 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1061 if (!layout_valid(&lw)) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1062 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1063 return image_color_profile_get(lw->image, input_type, screen_type, use_image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1064 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1065 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1066 void layout_image_color_profile_set_use(LayoutWindow *lw, gint enable) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1067 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1068 if (!layout_valid(&lw)) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1069 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1070 image_color_profile_set_use(lw->image, enable); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1071 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1072 if (lw->info_color) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1073 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1074 #ifndef HAVE_LCMS |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1075 enable = FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1076 #endif |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1077 gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, enable); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1078 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1079 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1080 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1081 gint layout_image_color_profile_get_use(LayoutWindow *lw) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1082 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1083 if (!layout_valid(&lw)) return FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1084 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1085 return image_color_profile_get_use(lw->image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1086 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1087 |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1088 gint layout_image_color_profile_get_from_image(LayoutWindow *lw) |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1089 { |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1090 if (!layout_valid(&lw)) return FALSE; |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1091 |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1092 return image_color_profile_get_from_image(lw->image); |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1093 } |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1094 |
9 | 1095 /* |
1096 *---------------------------------------------------------------------------- | |
1097 * list walkers | |
1098 *---------------------------------------------------------------------------- | |
1099 */ | |
1100 | |
1101 void layout_image_next(LayoutWindow *lw) | |
1102 { | |
1103 gint current; | |
1104 CollectionData *cd; | |
1105 CollectInfo *info; | |
1106 | |
1107 if (!layout_valid(&lw)) return; | |
1108 | |
1109 if (layout_image_slideshow_active(lw)) | |
1110 { | |
1111 layout_image_slideshow_next(lw); | |
1112 return; | |
1113 } | |
1114 | |
220 | 1115 if (layout_selection_count(lw, 0) > 1) |
1116 { | |
1117 GList *x = layout_selection_list_by_index(lw); | |
783 | 1118 gint old = layout_list_get_index(lw, layout_image_get_fd(lw)); |
220 | 1119 GList *y; |
1120 | |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1121 for (y = x; y && (GPOINTER_TO_INT(y->data)) != old; y = y->next) |
220 | 1122 ; |
1123 if (y) | |
1124 { | |
442 | 1125 if (y->next) |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1126 layout_image_set_index(lw, GPOINTER_TO_INT(y->next->data)); |
442 | 1127 else |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1128 layout_image_set_index(lw, GPOINTER_TO_INT(x->data)); |
220 | 1129 } |
1130 while (x) | |
1131 x = g_list_remove(x, x->data); | |
1132 if (y) /* not dereferenced */ | |
1133 return; | |
1134 } | |
1135 | |
9 | 1136 cd = image_get_collection(lw->image, &info); |
1137 | |
1138 if (cd && info) | |
1139 { | |
1140 info = collection_next_by_info(cd, info); | |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1141 if (info) |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1142 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1143 layout_image_set_collection_real(lw, cd, info, TRUE); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1144 } |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1145 else |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1146 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1147 image_osd_icon(lw->image, IMAGE_OSD_LAST, -1); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1148 } |
9 | 1149 return; |
1150 } | |
1151 | |
1152 current = layout_image_get_index(lw); | |
1153 | |
1154 if (current >= 0) | |
1155 { | |
736 | 1156 if ((guint) current < layout_list_count(lw, NULL) - 1) |
9 | 1157 { |
1158 layout_image_set_index(lw, current + 1); | |
1159 } | |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1160 else |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1161 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1162 image_osd_icon(lw->image, IMAGE_OSD_LAST, -1); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1163 } |
9 | 1164 } |
1165 else | |
1166 { | |
1167 layout_image_set_index(lw, 0); | |
1168 } | |
1169 } | |
1170 | |
1171 void layout_image_prev(LayoutWindow *lw) | |
1172 { | |
1173 gint current; | |
1174 CollectionData *cd; | |
1175 CollectInfo *info; | |
1176 | |
1177 if (!layout_valid(&lw)) return; | |
1178 | |
1179 if (layout_image_slideshow_active(lw)) | |
1180 { | |
1181 layout_image_slideshow_prev(lw); | |
1182 return; | |
1183 } | |
1184 | |
220 | 1185 if (layout_selection_count(lw, 0) > 1) |
1186 { | |
1187 GList *x = layout_selection_list_by_index(lw); | |
783 | 1188 gint old = layout_list_get_index(lw, layout_image_get_fd(lw)); |
220 | 1189 GList *y; |
1190 GList *last; | |
1191 | |
1192 for (last = y = x; y; y = y->next) | |
1193 last = y; | |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1194 for (y = x; y && (GPOINTER_TO_INT(y->data)) != old; y = y->next) |
220 | 1195 ; |
1196 if (y) | |
1197 { | |
442 | 1198 if (y->prev) |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1199 layout_image_set_index(lw, GPOINTER_TO_INT(y->prev->data)); |
220 | 1200 else |
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1201 layout_image_set_index(lw, GPOINTER_TO_INT(last->data)); |
220 | 1202 } |
1203 while (x) | |
1204 x = g_list_remove(x, x->data); | |
1205 if (y) /* not dereferenced */ | |
1206 return; | |
1207 } | |
1208 | |
9 | 1209 cd = image_get_collection(lw->image, &info); |
1210 | |
1211 if (cd && info) | |
1212 { | |
1213 info = collection_prev_by_info(cd, info); | |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1214 if (info) |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1215 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1216 layout_image_set_collection_real(lw, cd, info, FALSE); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1217 } |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1218 else |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1219 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1220 image_osd_icon(lw->image, IMAGE_OSD_FIRST, -1); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1221 } |
9 | 1222 return; |
1223 } | |
1224 | |
1225 current = layout_image_get_index(lw); | |
1226 | |
1227 if (current >= 0) | |
1228 { | |
1229 if (current > 0) | |
1230 { | |
1231 layout_image_set_index(lw, current - 1); | |
1232 } | |
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1233 else |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1234 { |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1235 image_osd_icon(lw->image, IMAGE_OSD_FIRST, -1); |
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1236 } |
9 | 1237 } |
1238 else | |
1239 { | |
1240 layout_image_set_index(lw, layout_list_count(lw, NULL) - 1); | |
1241 } | |
1242 } | |
1243 | |
1244 void layout_image_first(LayoutWindow *lw) | |
1245 { | |
1246 gint current; | |
1247 CollectionData *cd; | |
1248 CollectInfo *info; | |
1249 | |
1250 if (!layout_valid(&lw)) return; | |
1251 | |
1252 cd = image_get_collection(lw->image, &info); | |
1253 | |
1254 if (cd && info) | |
1255 { | |
1256 CollectInfo *new; | |
1257 new = collection_get_first(cd); | |
1258 if (new != info) layout_image_set_collection_real(lw, cd, new, TRUE); | |
1259 return; | |
1260 } | |
1261 | |
1262 current = layout_image_get_index(lw); | |
1263 if (current != 0 && layout_list_count(lw, NULL) > 0) | |
1264 { | |
1265 layout_image_set_index(lw, 0); | |
1266 } | |
1267 } | |
1268 | |
1269 void layout_image_last(LayoutWindow *lw) | |
1270 { | |
1271 gint current; | |
1272 gint count; | |
1273 CollectionData *cd; | |
1274 CollectInfo *info; | |
1275 | |
1276 if (!layout_valid(&lw)) return; | |
1277 | |
1278 cd = image_get_collection(lw->image, &info); | |
1279 | |
1280 if (cd && info) | |
1281 { | |
1282 CollectInfo *new; | |
1283 new = collection_get_last(cd); | |
1284 if (new != info) layout_image_set_collection_real(lw, cd, new, FALSE); | |
1285 return; | |
1286 } | |
1287 | |
1288 current = layout_image_get_index(lw); | |
1289 count = layout_list_count(lw, NULL); | |
1290 if (current != count - 1 && count > 0) | |
1291 { | |
1292 layout_image_set_index(lw, count - 1); | |
1293 } | |
1294 } | |
1295 | |
1296 /* | |
1297 *---------------------------------------------------------------------------- | |
1298 * mouse callbacks | |
1299 *---------------------------------------------------------------------------- | |
1300 */ | |
1301 | |
127 | 1302 static gint image_idx(LayoutWindow *lw, ImageWindow *imd) |
1303 { | |
1304 gint i; | |
442 | 1305 |
520 | 1306 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
127 | 1307 { |
1308 if (lw->split_images[i] == imd) | |
1309 break; | |
1310 } | |
1311 if (i < MAX_SPLIT_IMAGES) | |
1312 { | |
1313 return i; | |
1314 } | |
1315 return -1; | |
1316 } | |
1317 | |
1318 | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1319 static void layout_image_button_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) |
9 | 1320 { |
1321 LayoutWindow *lw = data; | |
1322 GtkWidget *menu; | |
1323 | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1324 switch (event->button) |
9 | 1325 { |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1326 case MOUSE_BUTTON_LEFT: |
9 | 1327 layout_image_next(lw); |
1328 break; | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1329 case MOUSE_BUTTON_MIDDLE: |
9 | 1330 layout_image_prev(lw); |
1331 break; | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1332 case MOUSE_BUTTON_RIGHT: |
9 | 1333 menu = layout_image_pop_menu(lw); |
1334 if (imd == lw->image) | |
1335 { | |
1336 g_object_set_data(G_OBJECT(menu), "click_parent", imd->widget); | |
1337 } | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1338 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); |
9 | 1339 break; |
1340 default: | |
1341 break; | |
1342 } | |
1343 } | |
1344 | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1345 static void layout_image_scroll_cb(ImageWindow *imd, GdkEventScroll *event, gpointer data) |
9 | 1346 { |
1347 LayoutWindow *lw = data; | |
1348 | |
127 | 1349 gint i = image_idx(lw, imd); |
442 | 1350 |
127 | 1351 if (i != -1) |
1352 { | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
1353 DEBUG_1("image activate scroll %d", i); |
127 | 1354 layout_image_activate(lw, i); |
1355 } | |
1356 | |
1357 | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1358 if (event->state & GDK_CONTROL_MASK) |
9 | 1359 { |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1360 switch (event->direction) |
9 | 1361 { |
1362 case GDK_SCROLL_UP: | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1363 layout_image_zoom_adjust_at_point(lw, get_zoom_increment(), event->x, event->y); |
9 | 1364 break; |
1365 case GDK_SCROLL_DOWN: | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1366 layout_image_zoom_adjust_at_point(lw, -get_zoom_increment(), event->x, event->y); |
9 | 1367 break; |
1368 default: | |
1369 break; | |
1370 } | |
1371 } | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1372 else if ( (event->state & GDK_SHIFT_MASK) != (guint) (options->mousewheel_scrolls)) |
9 | 1373 { |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1374 switch (event->direction) |
9 | 1375 { |
1376 case GDK_SCROLL_UP: | |
1377 image_scroll(imd, 0, -MOUSEWHEEL_SCROLL_SIZE); | |
1378 break; | |
1379 case GDK_SCROLL_DOWN: | |
1380 image_scroll(imd, 0, MOUSEWHEEL_SCROLL_SIZE); | |
1381 break; | |
1382 case GDK_SCROLL_LEFT: | |
1383 image_scroll(imd, -MOUSEWHEEL_SCROLL_SIZE, 0); | |
1384 break; | |
1385 case GDK_SCROLL_RIGHT: | |
1386 image_scroll(imd, MOUSEWHEEL_SCROLL_SIZE, 0); | |
1387 break; | |
1388 default: | |
1389 break; | |
1390 } | |
1391 } | |
1392 else | |
1393 { | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1394 switch (event->direction) |
9 | 1395 { |
1396 case GDK_SCROLL_UP: | |
1397 layout_image_prev(lw); | |
1398 break; | |
1399 case GDK_SCROLL_DOWN: | |
1400 layout_image_next(lw); | |
1401 break; | |
1402 default: | |
1403 break; | |
1404 } | |
1405 } | |
1406 } | |
1407 | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1408 static void layout_image_drag_cb(ImageWindow *imd, GdkEventButton *event, gdouble dx, gdouble dy, gpointer data) |
127 | 1409 { |
1410 gint i; | |
1411 LayoutWindow *lw = data; | |
1412 | |
869
371a1c3d4504
layout_image_drag_cb(): optimize when connected scrolling is unset.
zas_
parents:
868
diff
changeset
|
1413 if (!lw->connect_scroll) return; |
371a1c3d4504
layout_image_drag_cb(): optimize when connected scrolling is unset.
zas_
parents:
868
diff
changeset
|
1414 |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1415 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
127 | 1416 { |
869
371a1c3d4504
layout_image_drag_cb(): optimize when connected scrolling is unset.
zas_
parents:
868
diff
changeset
|
1417 if (lw->split_images[i] && lw->split_images[i] != imd) |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1418 { |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1419 gdouble sx, sy; |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1420 |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1421 if (event->state & GDK_CONTROL_MASK) |
129 | 1422 { |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1423 image_get_scroll_center(imd, &sx, &sy); |
129 | 1424 } |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1425 else |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1426 { |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1427 image_get_scroll_center(lw->split_images[i], &sx, &sy); |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1428 sx += dx; |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1429 sy += dy; |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1430 } |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1431 image_set_scroll_center(lw->split_images[i], sx, sy); |
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1432 } |
127 | 1433 } |
1434 } | |
1435 | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1436 static void layout_image_button_inactive_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) |
127 | 1437 { |
1438 LayoutWindow *lw = data; | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1439 GtkWidget *menu; |
127 | 1440 gint i = image_idx(lw, imd); |
442 | 1441 |
127 | 1442 if (i != -1) |
1443 { | |
1444 layout_image_activate(lw, i); | |
1445 } | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1446 |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1447 switch (event->button) |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1448 { |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1449 case MOUSE_BUTTON_RIGHT: |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1450 menu = layout_image_pop_menu(lw); |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1451 if (imd == lw->image) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1452 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1453 g_object_set_data(G_OBJECT(menu), "click_parent", imd->widget); |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1454 } |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1455 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1456 break; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1457 default: |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1458 break; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1459 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1460 |
127 | 1461 } |
1462 | |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1463 static void layout_image_drag_inactive_cb(ImageWindow *imd, GdkEventButton *event, gdouble dx, gdouble dy, gpointer data) |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1464 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1465 LayoutWindow *lw = data; |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1466 gint i = image_idx(lw, imd); |
442 | 1467 |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1468 if (i != -1) |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1469 { |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1470 layout_image_activate(lw, i); |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1471 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1472 |
129 | 1473 /* continue as with active image */ |
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1474 layout_image_drag_cb(imd, event, dx, dy, data); |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1475 } |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1476 |
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1477 |
9 | 1478 static void layout_image_set_buttons(LayoutWindow *lw) |
1479 { | |
1480 image_set_button_func(lw->image, layout_image_button_cb, lw); | |
1481 image_set_scroll_func(lw->image, layout_image_scroll_cb, lw); | |
1482 } | |
1483 | |
127 | 1484 static void layout_image_set_buttons_inactive(LayoutWindow *lw, gint i) |
1485 { | |
1486 image_set_button_func(lw->split_images[i], layout_image_button_inactive_cb, lw); | |
1487 image_set_scroll_func(lw->split_images[i], layout_image_scroll_cb, lw); | |
1488 } | |
1489 | |
9 | 1490 /* |
1491 *---------------------------------------------------------------------------- | |
1492 * setup | |
1493 *---------------------------------------------------------------------------- | |
1494 */ | |
1495 | |
1496 static void layout_image_update_cb(ImageWindow *imd, gpointer data) | |
1497 { | |
1498 LayoutWindow *lw = data; | |
1499 layout_status_update_image(lw); | |
1500 } | |
1501 | |
127 | 1502 GtkWidget *layout_image_new(LayoutWindow *lw, gint i) |
9 | 1503 { |
837
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1504 if (!lw->split_image_sizegroup) lw->split_image_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); |
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1505 |
442 | 1506 if (!lw->split_images[i]) |
9 | 1507 { |
127 | 1508 lw->split_images[i] = image_new(TRUE); |
1509 | |
1510 gtk_widget_ref(lw->split_images[i]->widget); | |
9 | 1511 |
339
de1c2cd06fce
Rename user_specified_window_background and window_background_color
zas_
parents:
334
diff
changeset
|
1512 image_background_set_color(lw->split_images[i], options->image.use_custom_border_color ? &options->image.border_color : NULL); |
9 | 1513 |
888 | 1514 image_auto_refresh_enable(lw->split_images[i], TRUE); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1515 |
127 | 1516 layout_image_dnd_init(lw, i); |
207 | 1517 image_color_profile_set(lw->split_images[i], |
327 | 1518 options->color_profile.input_type, |
1519 options->color_profile.screen_type, | |
1520 options->color_profile.use_image); | |
1521 image_color_profile_set_use(lw->split_images[i], options->color_profile.enabled); | |
837
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1522 |
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1523 gtk_size_group_add_widget(lw->split_image_sizegroup, lw->split_images[i]->widget); |
9 | 1524 } |
1525 | |
127 | 1526 return lw->split_images[i]->widget; |
1527 } | |
1528 | |
1529 void layout_image_deactivate(LayoutWindow *lw, gint i) | |
1530 { | |
1531 | |
1532 if (!lw->split_images[i]) return; | |
1533 image_set_update_func(lw->split_images[i], NULL, NULL); | |
1534 layout_image_set_buttons_inactive(lw, i); | |
129 | 1535 image_set_drag_func(lw->split_images[i], layout_image_drag_inactive_cb, lw); |
127 | 1536 |
1537 image_attach_window(lw->split_images[i], NULL, NULL, NULL, FALSE); | |
1538 image_select(lw->split_images[i], FALSE); | |
1539 } | |
1540 | |
1541 | |
1542 void layout_image_activate(LayoutWindow *lw, gint i) | |
1543 { | |
138 | 1544 FileData *fd; |
442 | 1545 |
127 | 1546 if (!lw->split_images[i]) return; |
1547 | |
1548 /* deactivate currently active */ | |
1549 if (lw->active_split_image != i) | |
1550 layout_image_deactivate(lw, lw->active_split_image); | |
1551 | |
1552 lw->image = lw->split_images[i]; | |
1553 lw->active_split_image = i; | |
442 | 1554 |
127 | 1555 image_set_update_func(lw->image, layout_image_update_cb, lw); |
1556 layout_image_set_buttons(lw); | |
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1557 image_set_drag_func(lw->image, layout_image_drag_cb, lw); |
127 | 1558 |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
1559 image_attach_window(lw->image, lw->window, NULL, GQ_APPNAME, FALSE); |
127 | 1560 |
152 | 1561 /* do not hilight selected image in SPLIT_NONE */ |
1562 /* maybe the image should be selected always and hilight should be controled by | |
1563 another image option */ | |
1564 if (lw->split_mode != SPLIT_NONE) | |
1565 image_select(lw->split_images[i], TRUE); | |
1566 else | |
1567 image_select(lw->split_images[i], FALSE); | |
127 | 1568 |
138 | 1569 fd = image_get_fd(lw->image); |
127 | 1570 |
442 | 1571 if (fd) |
127 | 1572 { |
1573 // layout_list_sync_path(lw, path); | |
783 | 1574 layout_set_fd(lw, fd); |
127 | 1575 } |
1576 } | |
1577 | |
1578 | |
1579 GtkWidget *layout_image_setup_split_none(LayoutWindow *lw) | |
1580 { | |
1581 gint i; | |
442 | 1582 |
152 | 1583 lw->split_mode = SPLIT_NONE; |
1584 | |
127 | 1585 if (!lw->split_images[0]) |
1586 { | |
1587 layout_image_new(lw, 0); | |
175 | 1588 image_set_frame(lw->split_images[0], (!lw->tools_float && !lw->tools_hidden)); |
1589 image_set_selectable(lw->split_images[0], 0); | |
127 | 1590 layout_image_activate(lw, 0); |
1591 } | |
175 | 1592 else |
1593 { | |
1594 image_set_frame(lw->split_images[0], (!lw->tools_float && !lw->tools_hidden)); | |
1595 image_set_selectable(lw->split_images[0], 0); | |
1596 } | |
442 | 1597 |
520 | 1598 for (i = 1; i < MAX_SPLIT_IMAGES; i++) |
127 | 1599 { |
1600 if (lw->split_images[i]) | |
1601 { | |
1602 gtk_widget_unref(lw->split_images[i]->widget); | |
1603 lw->split_images[i] = NULL; | |
1604 } | |
1605 } | |
152 | 1606 |
175 | 1607 |
152 | 1608 layout_image_activate(lw, 0); |
442 | 1609 |
127 | 1610 lw->split_image_widget = lw->split_images[0]->widget; |
442 | 1611 |
127 | 1612 return lw->split_image_widget; |
9 | 1613 } |
1614 | |
127 | 1615 GtkWidget *layout_image_setup_split_hv(LayoutWindow *lw, gboolean horizontal) |
1616 { | |
1617 GtkWidget *paned; | |
1618 gint i; | |
837
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1619 |
152 | 1620 lw->split_mode = horizontal ? SPLIT_HOR : SPLIT_VERT; |
442 | 1621 |
127 | 1622 if (!lw->split_images[0]) |
1623 { | |
1624 layout_image_new(lw, 0); | |
1625 } | |
175 | 1626 image_set_frame(lw->split_images[0], 1); |
1627 image_set_selectable(lw->split_images[0], 1); | |
127 | 1628 |
1629 if (!lw->split_images[1]) | |
1630 { | |
1631 layout_image_new(lw, 1); | |
175 | 1632 image_set_frame(lw->split_images[1], 1); |
1633 image_set_selectable(lw->split_images[1], 1); | |
127 | 1634 if (lw->image) |
153
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1635 { |
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1636 gdouble sx, sy; |
442 | 1637 image_change_fd(lw->split_images[1], |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1638 image_get_fd(lw->image), image_zoom_get(lw->image)); |
153
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1639 image_get_scroll_center(lw->image, &sx, &sy); |
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1640 image_set_scroll_center(lw->split_images[1], sx, sy); |
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1641 } |
127 | 1642 layout_image_deactivate(lw, 1); |
152 | 1643 layout_image_activate(lw, 0); |
127 | 1644 } |
175 | 1645 else |
1646 { | |
1647 image_set_frame(lw->split_images[1], 1); | |
1648 image_set_selectable(lw->split_images[1], 1); | |
1649 } | |
127 | 1650 |
442 | 1651 |
520 | 1652 for (i = 2; i < MAX_SPLIT_IMAGES; i++) |
127 | 1653 { |
1654 if (lw->split_images[i]) | |
1655 { | |
1656 gtk_widget_unref(lw->split_images[i]->widget); | |
1657 lw->split_images[i] = NULL; | |
1658 } | |
1659 } | |
1660 | |
442 | 1661 if (!lw->image || lw->active_split_image < 0 || lw->active_split_image > 1) |
127 | 1662 { |
1663 layout_image_activate(lw, 0); | |
1664 } | |
1665 | |
156
dd6dc0a55d3d
better integration of split image functions into menu
nadvornik
parents:
153
diff
changeset
|
1666 /* horizontal split means vpaned and vice versa */ |
127 | 1667 if (horizontal) |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1668 paned = gtk_vpaned_new(); |
156
dd6dc0a55d3d
better integration of split image functions into menu
nadvornik
parents:
153
diff
changeset
|
1669 else |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1670 paned = gtk_hpaned_new(); |
127 | 1671 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1672 gtk_paned_pack1(GTK_PANED(paned), lw->split_images[0]->widget, TRUE, TRUE); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1673 gtk_paned_pack2(GTK_PANED(paned), lw->split_images[1]->widget, TRUE, TRUE); |
442 | 1674 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1675 gtk_widget_show(lw->split_images[0]->widget); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1676 gtk_widget_show(lw->split_images[1]->widget); |
442 | 1677 |
127 | 1678 lw->split_image_widget = paned; |
442 | 1679 |
127 | 1680 return lw->split_image_widget; |
1681 | |
1682 } | |
1683 | |
1684 GtkWidget *layout_image_setup_split_quad(LayoutWindow *lw) | |
1685 { | |
1686 GtkWidget *hpaned; | |
1687 GtkWidget *vpaned1; | |
1688 GtkWidget *vpaned2; | |
1689 gint i; | |
442 | 1690 |
152 | 1691 lw->split_mode = SPLIT_QUAD; |
1692 | |
127 | 1693 if (!lw->split_images[0]) |
1694 { | |
1695 layout_image_new(lw, 0); | |
152 | 1696 } |
1697 | |
175 | 1698 image_set_frame(lw->split_images[0], 1); |
1699 image_set_selectable(lw->split_images[0], 1); | |
1700 | |
152 | 1701 if (!lw->split_images[1]) |
1702 { | |
127 | 1703 layout_image_activate(lw, 0); |
1704 } | |
1705 | |
520 | 1706 for (i = 1; i < 4; i++) |
127 | 1707 if (!lw->split_images[i]) |
1708 { | |
1709 layout_image_new(lw, i); | |
175 | 1710 image_set_frame(lw->split_images[i], 1); |
1711 image_set_selectable(lw->split_images[i], 1); | |
127 | 1712 if (lw->image) |
153
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1713 { |
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1714 gdouble sx, sy; |
442 | 1715 image_change_fd(lw->split_images[i], |
153
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1716 image_get_fd(lw->image), image_zoom_get(lw->image)); |
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1717 image_get_scroll_center(lw->image, &sx, &sy); |
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1718 image_set_scroll_center(lw->split_images[i], sx, sy); |
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1719 } |
127 | 1720 layout_image_deactivate(lw, i); |
1721 } | |
175 | 1722 else |
1723 { | |
1724 image_set_frame(lw->split_images[i], 1); | |
1725 image_set_selectable(lw->split_images[i], 1); | |
1726 } | |
127 | 1727 |
520 | 1728 for (i = 4; i < MAX_SPLIT_IMAGES; i++) |
127 | 1729 { |
1730 if (lw->split_images[i]) | |
1731 { | |
1732 gtk_widget_unref(lw->split_images[i]->widget); | |
1733 lw->split_images[i] = NULL; | |
1734 } | |
1735 } | |
1736 | |
174 | 1737 |
442 | 1738 if (!lw->image || lw->active_split_image < 0 || lw->active_split_image > 3) |
127 | 1739 { |
1740 layout_image_activate(lw, 0); | |
1741 } | |
1742 | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1743 hpaned = gtk_hpaned_new(); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1744 vpaned1 = gtk_vpaned_new(); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1745 vpaned2 = gtk_vpaned_new(); |
127 | 1746 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1747 gtk_paned_pack1(GTK_PANED(vpaned1), lw->split_images[0]->widget, TRUE, TRUE); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1748 gtk_paned_pack2(GTK_PANED(vpaned1), lw->split_images[2]->widget, TRUE, TRUE); |
127 | 1749 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1750 gtk_paned_pack1(GTK_PANED(vpaned2), lw->split_images[1]->widget, TRUE, TRUE); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1751 gtk_paned_pack2(GTK_PANED(vpaned2), lw->split_images[3]->widget, TRUE, TRUE); |
127 | 1752 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1753 gtk_paned_pack1(GTK_PANED(hpaned), vpaned1, TRUE, TRUE); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1754 gtk_paned_pack2(GTK_PANED(hpaned), vpaned2, TRUE, TRUE); |
127 | 1755 |
442 | 1756 |
520 | 1757 for (i = 0; i < 4; i++) |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1758 gtk_widget_show(lw->split_images[i]->widget); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1759 |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1760 gtk_widget_show(vpaned1); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1761 gtk_widget_show(vpaned2); |
442 | 1762 |
127 | 1763 |
1764 lw->split_image_widget = hpaned; | |
442 | 1765 |
127 | 1766 return lw->split_image_widget; |
1767 | |
1768 } | |
1769 | |
1770 GtkWidget *layout_image_setup_split(LayoutWindow *lw, ImageSplitMode mode) | |
1771 { | |
1772 switch (mode) | |
1773 { | |
442 | 1774 case SPLIT_HOR: |
127 | 1775 return layout_image_setup_split_hv(lw, TRUE); |
1776 case SPLIT_VERT: | |
1777 return layout_image_setup_split_hv(lw, FALSE); | |
1778 case SPLIT_QUAD: | |
1779 return layout_image_setup_split_quad(lw); | |
1780 case SPLIT_NONE: | |
1781 default: | |
1782 return layout_image_setup_split_none(lw); | |
1783 } | |
1784 } | |
1785 | |
1786 | |
9 | 1787 /* |
1788 *----------------------------------------------------------------------------- | |
1789 * maintenance (for rename, move, remove) | |
1790 *----------------------------------------------------------------------------- | |
1791 */ | |
1792 | |
796 | 1793 static void layout_image_maint_renamed(LayoutWindow *lw, FileData *fd) |
9 | 1794 { |
138 | 1795 FileData *img_fd; |
9 | 1796 |
138 | 1797 img_fd = layout_image_get_fd(lw); |
1798 if (img_fd == fd) | |
9 | 1799 { |
138 | 1800 image_set_fd(lw->image, fd); |
9 | 1801 layout_bars_maint_renamed(lw); |
1802 } | |
1803 } | |
1804 | |
796 | 1805 static void layout_image_maint_removed(LayoutWindow *lw, FileData *fd) |
9 | 1806 { |
138 | 1807 FileData *img_fd; |
9 | 1808 |
138 | 1809 img_fd = layout_image_get_fd(lw); |
1810 if (img_fd == fd) | |
9 | 1811 { |
1812 CollectionData *cd; | |
1813 CollectInfo *info; | |
1814 | |
1815 cd = image_get_collection(lw->image, &info); | |
1816 if (cd && info) | |
1817 { | |
1818 CollectInfo *new; | |
1819 | |
1820 new = collection_next_by_info(cd, info); | |
1821 if (!new) new = collection_prev_by_info(cd, info); | |
1822 | |
1823 if (new) | |
1824 { | |
1825 layout_image_set_collection(lw, cd, new); | |
1826 return; | |
1827 } | |
1828 } | |
1829 | |
138 | 1830 layout_image_set_fd(lw, NULL); |
9 | 1831 } |
1832 } | |
1833 | |
796 | 1834 |
1835 void layout_image_notify_cb(FileData *fd, NotifyType type, gpointer data) | |
9 | 1836 { |
796 | 1837 LayoutWindow *lw = data; |
1838 | |
803 | 1839 if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; |
796 | 1840 |
1841 switch(fd->change->type) | |
1842 { | |
1843 case FILEDATA_CHANGE_MOVE: | |
1844 case FILEDATA_CHANGE_RENAME: | |
1845 layout_image_maint_renamed(lw, fd); | |
1846 break; | |
1847 case FILEDATA_CHANGE_DELETE: | |
1848 layout_image_maint_removed(lw, fd); | |
1849 break; | |
1850 case FILEDATA_CHANGE_COPY: | |
1851 case FILEDATA_CHANGE_UNSPECIFIED: | |
1852 break; | |
1853 } | |
1854 | |
9 | 1855 } |