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