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