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