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