gqview.h -> main.h
[geeqie.git] / src / layout_util.c
1 /*
2  * Geeqie
3  * (C) 2004 John Ellis
4  *
5  * Author: John Ellis
6  *
7  * This software is released under the GNU General Public License (GNU GPL).
8  * Please read the included file COPYING for more information.
9  * This software comes with no warranty of any kind, use at your own risk!
10  */
11
12
13 #include "main.h"
14 #include "layout_util.h"
15
16 #include "bar_info.h"
17 #include "bar_exif.h"
18 #include "bar_sort.h"
19 #include "cache_maint.h"
20 #include "collect.h"
21 #include "collect-dlg.h"
22 #include "dupe.h"
23 #include "editors.h"
24 #include "filelist.h"
25 #include "img-view.h"
26 #include "info.h"
27 #include "layout_image.h"
28 #include "pan-view.h"
29 #include "pixbuf_util.h"
30 #include "preferences.h"
31 #include "print.h"
32 #include "search.h"
33 #include "utilops.h"
34 #include "ui_bookmark.h"
35 #include "ui_fileops.h"
36 #include "ui_menu.h"
37 #include "ui_misc.h"
38 #include "ui_tabcomp.h"
39
40 #include <gdk/gdkkeysyms.h> /* for keyboard values */
41
42
43 #define MENU_EDIT_ACTION_OFFSET 16
44
45
46 /*
47  *-----------------------------------------------------------------------------
48  * keyboard handler
49  *-----------------------------------------------------------------------------
50  */
51
52 static guint tree_key_overrides[] = {
53         GDK_Page_Up,    GDK_KP_Page_Up,
54         GDK_Page_Down,  GDK_KP_Page_Down,
55         GDK_Home,       GDK_KP_Home,
56         GDK_End,        GDK_KP_End
57 };
58
59 static gint layout_key_match(guint keyval)
60 {
61         gint i;
62
63         for (i = 0; i < sizeof(tree_key_overrides) / sizeof(guint); i++)
64                 {
65                 if (keyval == tree_key_overrides[i]) return TRUE;
66                 }
67
68         return FALSE;
69 }
70
71 gint layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
72 {
73         LayoutWindow *lw = data;
74         gint stop_signal = FALSE;
75         gint x = 0;
76         gint y = 0;
77
78         if (lw->path_entry && GTK_WIDGET_HAS_FOCUS(lw->path_entry))
79                 {
80                 if (event->keyval == GDK_Escape && lw->path)
81                         {
82                         gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path);
83                         }
84
85                 /* the gtkaccelgroup of the window is stealing presses before they get to the entry (and more),
86                  * so when the some widgets have focus, give them priority (HACK)
87                  */
88                 if (gtk_widget_event(lw->path_entry, (GdkEvent *)event))
89                         {
90                         return TRUE;
91                         }
92                 }
93         if (lw->vdt && GTK_WIDGET_HAS_FOCUS(lw->vdt->treeview) &&
94             !layout_key_match(event->keyval) &&
95             gtk_widget_event(lw->vdt->treeview, (GdkEvent *)event))
96                 {
97                 return TRUE;
98                 }
99         if (lw->bar_info &&
100             bar_info_event(lw->bar_info, (GdkEvent *)event))
101                 {
102                 return TRUE;
103                 }
104
105 /*
106         if (event->type == GDK_KEY_PRESS && lw->full_screen &&
107             gtk_accel_groups_activate(G_OBJECT(lw->window), event->keyval, event->state))
108                 return TRUE;
109 */
110
111         if (lw->image &&
112             (GTK_WIDGET_HAS_FOCUS(lw->image->widget) || (lw->tools && widget == lw->window) || lw->full_screen) )
113                 {
114                 stop_signal = TRUE;
115                 switch (event->keyval)
116                         {
117                         case GDK_Left: case GDK_KP_Left:
118                                 x -= 1;
119                                 break;
120                         case GDK_Right: case GDK_KP_Right:
121                                 x += 1;
122                                 break;
123                         case GDK_Up: case GDK_KP_Up:
124                                 y -= 1;
125                                 break;
126                         case GDK_Down: case GDK_KP_Down:
127                                 y += 1;
128                                 break;
129                         default:
130                                 stop_signal = FALSE;
131                                 break;
132                         }
133
134                 if (!stop_signal &&
135                     !(event->state & GDK_CONTROL_MASK))
136                         {
137                         stop_signal = TRUE;
138                         switch (event->keyval)
139                                 {
140                                 case GDK_Menu:
141                                         layout_image_menu_popup(lw);
142                                         break;
143                                 default:
144                                         stop_signal = FALSE;
145                                         break;
146                                 }
147                         }
148                 }
149
150         if (x != 0 || y!= 0)
151                 {
152                 if (event->state & GDK_SHIFT_MASK)
153                         {
154                         x *= 3;
155                         y *= 3;
156                         }
157
158                 keyboard_scroll_calc(&x, &y, event);
159                 layout_image_scroll(lw, x, y);
160                 }
161
162         if (stop_signal) return stop_signal;
163
164         if (event->state & GDK_CONTROL_MASK)
165                 {
166                 stop_signal = FALSE;
167                 }
168         else
169                 {
170                 stop_signal = TRUE;
171                 switch (event->keyval)
172                         {
173                         case '+': case GDK_KP_Add:
174                                 layout_image_zoom_adjust(lw, get_zoom_increment());
175                                 break;
176                         case GDK_KP_Subtract:
177                                 layout_image_zoom_adjust(lw, -get_zoom_increment());
178                                 break;
179                         case GDK_KP_Multiply:
180                                 layout_image_zoom_set(lw, 0.0);
181                                 break;
182                         case GDK_KP_Divide:
183                                 layout_image_zoom_set(lw, 1.0);
184                                 break;
185                         case GDK_Page_Up: case GDK_KP_Page_Up:
186                                 layout_image_prev(lw);
187                                 break;
188                         case GDK_Page_Down: case GDK_KP_Page_Down:
189                                 layout_image_next(lw);
190                                 break;
191                         case GDK_Delete: case GDK_KP_Delete:
192                                 if (enable_delete_key)
193                                         {
194                                         file_util_delete(NULL, layout_selection_list(lw), widget);
195                                         }
196                                 break;
197                         case GDK_Escape:
198                                 /* FIXME:interrupting thumbs no longer allowed */
199 #if 0
200                                 interrupt_thumbs();
201 #endif
202                                 break;
203                         case 'P': case 'p':
204                                 if (!event->state & GDK_SHIFT_MASK)
205                                         {
206                                         layout_image_slideshow_pause_toggle(lw);
207                                         }
208                                 else
209                                         {
210                                         stop_signal = FALSE;
211                                         }
212                                 break;
213                         case 'V': case 'v':
214                         case GDK_F11:
215                                 layout_image_full_screen_toggle(lw);
216                                 break;
217                         default:
218                                 stop_signal = FALSE;
219                                 break;
220                         }
221                 }
222
223 #if 0
224         if (stop_signal) g_signal_stop_emission_by_name(G_OBJECT(widget), "key_press_event");
225 #endif
226
227         return stop_signal;
228 }
229
230 void layout_keyboard_init(LayoutWindow *lw, GtkWidget *window)
231 {
232         g_signal_connect(G_OBJECT(window), "key_press_event",
233                          G_CALLBACK(layout_key_press_cb), lw);
234 }
235
236 /*
237  *-----------------------------------------------------------------------------
238  * menu callbacks
239  *-----------------------------------------------------------------------------
240  */
241  
242  
243 static GtkWidget *layout_window(LayoutWindow *lw)
244 {
245         return lw->full_screen ? lw->full_screen->window : lw->window;
246 }
247
248 static void layout_menu_new_window_cb(GtkAction *action, gpointer data)
249 {
250         LayoutWindow *lw = data;
251         LayoutWindow *nw;
252
253         if (lw->full_screen)
254                 layout_image_full_screen_stop(lw);
255
256         nw = layout_new(NULL, FALSE, FALSE);
257         layout_sort_set(nw, file_sort_method, file_sort_ascending);
258         layout_set_path(nw, layout_get_path(lw));
259 }
260
261 static void layout_menu_new_cb(GtkAction *action, gpointer data)
262 {
263         LayoutWindow *lw = data;
264         if (lw->full_screen)
265                 layout_image_full_screen_stop(lw);
266         collection_window_new(NULL);
267 }
268
269 static void layout_menu_open_cb(GtkAction *action, gpointer data)
270 {
271         LayoutWindow *lw = data;
272         if (lw->full_screen)
273                 layout_image_full_screen_stop(lw);
274         collection_dialog_load(NULL);
275 }
276
277 static void layout_menu_search_cb(GtkAction *action, gpointer data)
278 {
279         LayoutWindow *lw = data;
280         if (lw->full_screen)
281                 layout_image_full_screen_stop(lw);
282
283         search_new(lw->path, layout_image_get_path(lw));
284 }
285
286 static void layout_menu_dupes_cb(GtkAction *action, gpointer data)
287 {
288         LayoutWindow *lw = data;
289         if (lw->full_screen)
290                 layout_image_full_screen_stop(lw);
291
292         dupe_window_new(DUPE_MATCH_NAME);
293 }
294
295 static void layout_menu_pan_cb(GtkAction *action, gpointer data)
296 {
297         LayoutWindow *lw = data;
298         if (lw->full_screen)
299                 layout_image_full_screen_stop(lw);
300
301         pan_window_new(layout_get_path(lw));
302 }
303
304 static void layout_menu_print_cb(GtkAction *action, gpointer data)
305 {
306         LayoutWindow *lw = data;
307
308         print_window_new(layout_image_get_fd(lw), layout_selection_list(lw), layout_list(lw), layout_window(lw));
309 }
310
311 static void layout_menu_dir_cb(GtkAction *action, gpointer data)
312 {
313         LayoutWindow *lw = data;
314
315         file_util_create_dir(lw->path, layout_window(lw));
316 }
317
318 static void layout_menu_copy_cb(GtkAction *action, gpointer data)
319 {
320         LayoutWindow *lw = data;
321
322         file_util_copy(NULL, layout_selection_list(lw), NULL, layout_window(lw));
323 }
324
325 static void layout_menu_move_cb(GtkAction *action, gpointer data)
326 {
327         LayoutWindow *lw = data;
328
329         file_util_move(NULL, layout_selection_list(lw), NULL, layout_window(lw));
330 }
331
332 static void layout_menu_rename_cb(GtkAction *action, gpointer data)
333 {
334         LayoutWindow *lw = data;
335
336         file_util_rename(NULL, layout_selection_list(lw), layout_window(lw));
337 }
338
339 static void layout_menu_delete_cb(GtkAction *action, gpointer data)
340 {
341         LayoutWindow *lw = data;
342
343         file_util_delete(NULL, layout_selection_list(lw), layout_window(lw));
344 }
345
346 static void layout_menu_close_cb(GtkAction *action, gpointer data)
347 {
348         LayoutWindow *lw = data;
349         if (lw->full_screen)
350                 layout_image_full_screen_stop(lw);
351
352         layout_close(lw);
353 }
354
355 static void layout_menu_exit_cb(GtkAction *action, gpointer data)
356 {
357         exit_program();
358 }
359
360 static void layout_menu_alter_90_cb(GtkAction *action, gpointer data)
361 {
362         LayoutWindow *lw = data;
363
364         layout_image_alter(lw, ALTER_ROTATE_90);
365 }
366
367 static void layout_menu_alter_90cc_cb(GtkAction *action, gpointer data)
368 {
369         LayoutWindow *lw = data;
370
371         layout_image_alter(lw, ALTER_ROTATE_90_CC);
372 }
373
374 static void layout_menu_alter_180_cb(GtkAction *action, gpointer data)
375 {
376         LayoutWindow *lw = data;
377
378         layout_image_alter(lw, ALTER_ROTATE_180);
379 }
380
381 static void layout_menu_alter_mirror_cb(GtkAction *action, gpointer data)
382 {
383         LayoutWindow *lw = data;
384
385         layout_image_alter(lw, ALTER_MIRROR);
386 }
387
388 static void layout_menu_alter_flip_cb(GtkAction *action, gpointer data)
389 {
390         LayoutWindow *lw = data;
391
392         layout_image_alter(lw, ALTER_FLIP);
393 }
394
395 static void layout_menu_alter_desaturate_cb(GtkAction *action, gpointer data)
396 {
397         LayoutWindow *lw = data;
398
399         layout_image_alter(lw, ALTER_DESATURATE);
400 }
401
402 static void layout_menu_info_cb(GtkAction *action, gpointer data)
403 {
404         LayoutWindow *lw = data;
405         GList *list;
406         FileData *fd = NULL;
407
408         list = layout_selection_list(lw);
409         if (!list) fd = layout_image_get_fd(lw);
410
411         info_window_new(fd, list);
412 }
413
414
415 static void layout_menu_config_cb(GtkAction *action, gpointer data)
416 {
417         LayoutWindow *lw = data;
418         if (lw->full_screen)
419                 layout_image_full_screen_stop(lw);
420
421         show_config_window();
422 }
423
424 static void layout_menu_remove_thumb_cb(GtkAction *action, gpointer data)
425 {
426         LayoutWindow *lw = data;
427         if (lw->full_screen)
428                 layout_image_full_screen_stop(lw);
429
430         cache_manager_show();
431 }
432
433 static void layout_menu_wallpaper_cb(GtkAction *action, gpointer data)
434 {
435         LayoutWindow *lw = data;
436
437         layout_image_to_root(lw);
438 }
439
440 static void layout_menu_zoom_in_cb(GtkAction *action, gpointer data)
441 {
442         LayoutWindow *lw = data;
443
444         layout_image_zoom_adjust(lw, get_zoom_increment());
445 }
446
447 static void layout_menu_zoom_out_cb(GtkAction *action, gpointer data)
448 {
449         LayoutWindow *lw = data;
450
451         layout_image_zoom_adjust(lw, -get_zoom_increment());
452 }
453
454 static void layout_menu_zoom_1_1_cb(GtkAction *action, gpointer data)
455 {
456         LayoutWindow *lw = data;
457
458         layout_image_zoom_set(lw, 1.0);
459 }
460
461 static void layout_menu_zoom_fit_cb(GtkAction *action, gpointer data)
462 {
463         LayoutWindow *lw = data;
464
465         layout_image_zoom_set(lw, 0.0);
466 }
467
468 static void layout_menu_zoom_fit_hor_cb(GtkAction *action, gpointer data)
469 {
470         LayoutWindow *lw = data;
471
472         layout_image_zoom_set_fill_geometry(lw, TRUE);
473 }
474
475 static void layout_menu_zoom_fit_vert_cb(GtkAction *action, gpointer data)
476 {
477         LayoutWindow *lw = data;
478
479         layout_image_zoom_set_fill_geometry(lw, FALSE);
480 }
481
482 static void layout_menu_zoom_2_1_cb(GtkAction *action, gpointer data)
483 {
484         LayoutWindow *lw = data;
485
486         layout_image_zoom_set(lw, 2.0);
487 }
488
489 static void layout_menu_zoom_3_1_cb(GtkAction *action, gpointer data)
490 {
491         LayoutWindow *lw = data;
492
493         layout_image_zoom_set(lw, 3.0);
494 }
495 static void layout_menu_zoom_4_1_cb(GtkAction *action, gpointer data)
496 {
497         LayoutWindow *lw = data;
498
499         layout_image_zoom_set(lw, 4.0);
500 }
501
502 static void layout_menu_zoom_1_2_cb(GtkAction *action, gpointer data)
503 {
504         LayoutWindow *lw = data;
505
506         layout_image_zoom_set(lw, -2.0);
507 }
508
509 static void layout_menu_zoom_1_3_cb(GtkAction *action, gpointer data)
510 {
511         LayoutWindow *lw = data;
512
513         layout_image_zoom_set(lw, -3.0);
514 }
515
516 static void layout_menu_zoom_1_4_cb(GtkAction *action, gpointer data)
517 {
518         LayoutWindow *lw = data;
519
520         layout_image_zoom_set(lw, -4.0);
521 }
522
523
524 static void layout_menu_split_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
525 {
526         LayoutWindow *lw = data;
527         if (lw->full_screen)
528                 layout_image_full_screen_stop(lw);
529
530         ImageSplitMode mode = gtk_radio_action_get_current_value(action);
531         
532         if (mode == lw->split_mode) mode = 0; /* toggle back */
533
534         layout_split_change(lw, mode);
535 }
536
537 static void layout_menu_connect_scroll_cb(GtkToggleAction *action, gpointer data)
538 {
539         LayoutWindow *lw = data;
540         lw->connect_scroll = gtk_toggle_action_get_active(action);
541 }
542
543 static void layout_menu_connect_zoom_cb(GtkToggleAction *action, gpointer data)
544 {
545         LayoutWindow *lw = data;
546         lw->connect_zoom = gtk_toggle_action_get_active(action);
547 }
548
549
550 static void layout_menu_thumb_cb(GtkToggleAction *action, gpointer data)
551 {
552         LayoutWindow *lw = data;
553
554         layout_thumb_set(lw, gtk_toggle_action_get_active(action));
555 }
556
557
558 static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
559 {
560         LayoutWindow *lw = data;
561         if (lw->full_screen)
562                 layout_image_full_screen_stop(lw);
563
564         layout_views_set(lw, lw->tree_view, (gtk_radio_action_get_current_value(action) == 1));
565 }
566
567 static void layout_menu_tree_cb(GtkToggleAction *action, gpointer data)
568 {
569         LayoutWindow *lw = data;
570         if (lw->full_screen)
571                 layout_image_full_screen_stop(lw);
572
573         layout_views_set(lw, gtk_toggle_action_get_active(action), lw->icon_view);
574 }
575
576 static void layout_menu_view_in_new_window_cb(GtkAction *action, gpointer data)
577 {
578         LayoutWindow *lw = data;
579
580         if (lw->full_screen)
581                 layout_image_full_screen_stop(lw);
582         view_window_new(layout_image_get_fd(lw));
583 }
584
585 static void layout_menu_fullscreen_cb(GtkAction *action, gpointer data)
586 {
587         LayoutWindow *lw = data;
588
589         layout_image_full_screen_toggle(lw);
590 }
591
592 static void layout_menu_overlay_cb(GtkAction *action, gpointer data)
593 {
594         LayoutWindow *lw = data;
595
596         if (image_osd_get(lw->image, NULL, NULL))
597                 {
598                 if (image_osd_histogram_onoff_status(lw->image))
599                         {
600                         image_osd_histogram_onoff_toggle(lw->image, 0);
601                         layout_image_overlay_update(lw);
602                         }
603                 else
604                         layout_image_overlay_toggle(lw);
605                 }
606         else
607                 {
608                 layout_image_overlay_toggle(lw);
609                 image_osd_histogram_onoff_toggle(lw->image, 1);
610                 layout_image_overlay_update(lw);
611                 }
612 }
613
614 static void layout_menu_histogram_chan_cb(GtkAction *action, gpointer data)
615 {
616         LayoutWindow *lw = data;
617
618         image_osd_histogram_chan_toggle(lw->image);
619         layout_image_overlay_update(lw);
620 }
621
622 static void layout_menu_histogram_log_cb(GtkAction *action, gpointer data)
623 {
624         LayoutWindow *lw = data;
625
626         image_osd_histogram_log_toggle(lw->image);
627         layout_image_overlay_update(lw);
628 }
629
630 static void layout_menu_refresh_cb(GtkAction *action, gpointer data)
631 {
632         LayoutWindow *lw = data;
633
634         layout_refresh(lw);
635 }
636
637 static void layout_menu_float_cb(GtkToggleAction *action, gpointer data)
638 {
639         LayoutWindow *lw = data;
640         if (lw->full_screen)
641                 layout_image_full_screen_stop(lw);
642
643         if (lw->tools_float != gtk_toggle_action_get_active(action))
644                 {
645                 layout_tools_float_toggle(lw);
646                 }
647 }
648
649 static void layout_menu_hide_cb(GtkAction *action, gpointer data)
650 {
651         LayoutWindow *lw = data;
652         if (lw->full_screen)
653                 layout_image_full_screen_stop(lw);
654
655         layout_tools_hide_toggle(lw);
656 }
657
658 static void layout_menu_toolbar_cb(GtkToggleAction *action, gpointer data)
659 {
660         LayoutWindow *lw = data;
661         if (lw->full_screen)
662                 layout_image_full_screen_stop(lw);
663
664         if (lw->toolbar_hidden != gtk_toggle_action_get_active(action))
665                 {
666                 layout_toolbar_toggle(lw);
667                 }
668 }
669
670 static void layout_menu_bar_info_cb(GtkToggleAction *action, gpointer data)
671 {
672         LayoutWindow *lw = data;
673         if (lw->full_screen)
674                 layout_image_full_screen_stop(lw);
675
676         if (lw->bar_info_enabled != gtk_toggle_action_get_active(action))
677                 {
678                 layout_bar_info_toggle(lw);
679                 }
680 }
681
682 static void layout_menu_bar_exif_cb(GtkToggleAction *action, gpointer data)
683 {
684         LayoutWindow *lw = data;
685         if (lw->full_screen)
686                 layout_image_full_screen_stop(lw);
687
688         if (lw->bar_exif_enabled != gtk_toggle_action_get_active(action))
689                 {
690                 layout_bar_exif_toggle(lw);
691                 }
692 }
693
694 static void layout_menu_bar_sort_cb(GtkToggleAction *action, gpointer data)
695 {
696         LayoutWindow *lw = data;
697         if (lw->full_screen)
698                 layout_image_full_screen_stop(lw);
699
700         if (lw->bar_sort_enabled != gtk_toggle_action_get_active(action))
701                 {
702                 layout_bar_sort_toggle(lw);
703                 }
704 }
705
706 static void layout_menu_slideshow_cb(GtkAction *action, gpointer data)
707 {
708         LayoutWindow *lw = data;
709
710         layout_image_slideshow_toggle(lw);
711 }
712
713 static void layout_menu_help_cb(GtkAction *action, gpointer data)
714 {
715         LayoutWindow *lw = data;
716         if (lw->full_screen)
717                 layout_image_full_screen_stop(lw);
718         help_window_show("html_contents");
719 }
720
721 static void layout_menu_help_keys_cb(GtkAction *action, gpointer data)
722 {
723         LayoutWindow *lw = data;
724         if (lw->full_screen)
725                 layout_image_full_screen_stop(lw);
726         help_window_show("documentation");
727 }
728
729 static void layout_menu_notes_cb(GtkAction *action, gpointer data)
730 {
731         LayoutWindow *lw = data;
732         if (lw->full_screen)
733                 layout_image_full_screen_stop(lw);
734         help_window_show("release_notes");
735 }
736
737 static void layout_menu_about_cb(GtkAction *action, gpointer data)
738 {
739         LayoutWindow *lw = data;
740         if (lw->full_screen)
741                 layout_image_full_screen_stop(lw);
742         show_about_window();
743 }
744
745
746 /*
747  *-----------------------------------------------------------------------------
748  * select menu
749  *-----------------------------------------------------------------------------
750  */ 
751
752 static void layout_menu_select_all_cb(GtkAction *action, gpointer data)
753 {
754         LayoutWindow *lw = data;
755
756         layout_select_all(lw);
757 }
758
759 static void layout_menu_unselect_all_cb(GtkAction *action, gpointer data)
760 {
761         LayoutWindow *lw = data;
762
763         layout_select_none(lw);
764 }
765
766 static void layout_menu_marks_cb(GtkToggleAction *action, gpointer data)
767 {
768         LayoutWindow *lw = data;
769
770         layout_marks_set(lw, gtk_toggle_action_get_active(action));
771 }
772
773
774 static void layout_menu_set_mark_sel_cb(GtkAction *action, gpointer data)
775 {
776         LayoutWindow *lw = data;
777         gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
778         g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
779         mark--;
780         
781         layout_selection_to_mark(lw, mark, STM_MODE_SET);
782 }
783
784 static void layout_menu_res_mark_sel_cb(GtkAction *action, gpointer data)
785 {
786         LayoutWindow *lw = data;
787         gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
788         g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
789         mark--;
790         
791         layout_selection_to_mark(lw, mark, STM_MODE_RESET);
792 }
793
794 static void layout_menu_toggle_mark_sel_cb(GtkAction *action, gpointer data)
795 {
796         LayoutWindow *lw = data;
797         gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
798         g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
799         mark--;
800         
801         layout_selection_to_mark(lw, mark, STM_MODE_TOGGLE);
802 }
803
804 static void layout_menu_sel_mark_cb(GtkAction *action, gpointer data)
805 {
806         LayoutWindow *lw = data;
807         gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
808         g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
809         mark--;
810         
811         layout_mark_to_selection(lw, mark, MTS_MODE_SET);
812 }
813
814 static void layout_menu_sel_mark_or_cb(GtkAction *action, gpointer data)
815 {
816         LayoutWindow *lw = data;
817         gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
818         g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
819         mark--;
820         
821         layout_mark_to_selection(lw, mark, MTS_MODE_OR);
822 }
823
824 static void layout_menu_sel_mark_and_cb(GtkAction *action, gpointer data)
825 {
826         LayoutWindow *lw = data;
827         gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
828         g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
829         mark--;
830         
831         layout_mark_to_selection(lw, mark, MTS_MODE_AND);
832 }
833
834 static void layout_menu_sel_mark_minus_cb(GtkAction *action, gpointer data)
835 {
836         LayoutWindow *lw = data;
837         gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
838         g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
839         mark--;
840         
841         layout_mark_to_selection(lw, mark, MTS_MODE_MINUS);
842 }
843
844
845 /*
846  *-----------------------------------------------------------------------------
847  * go menu
848  *-----------------------------------------------------------------------------
849  */ 
850
851 static void layout_menu_image_first_cb(GtkAction *action, gpointer data)
852 {
853         LayoutWindow *lw = data;
854         layout_image_first(lw);
855 }
856
857 static void layout_menu_image_prev_cb(GtkAction *action, gpointer data)
858 {
859         LayoutWindow *lw = data;
860         layout_image_prev(lw);
861 }
862
863 static void layout_menu_image_next_cb(GtkAction *action, gpointer data)
864 {
865         LayoutWindow *lw = data;
866         layout_image_next(lw);
867 }
868
869 static void layout_menu_image_last_cb(GtkAction *action, gpointer data)
870 {
871         LayoutWindow *lw = data;
872         layout_image_last(lw);
873 }
874
875
876 /*
877  *-----------------------------------------------------------------------------
878  * edit menu
879  *-----------------------------------------------------------------------------
880  */ 
881
882 static void layout_menu_edit_cb(GtkAction *action, gpointer data)
883 {
884         LayoutWindow *lw = data;
885         GList *list;
886         gint n;
887
888         n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "edit_index"));
889
890
891         if (lw->full_screen && !editor_window_flag_set(n))
892                 {
893                 layout_image_full_screen_stop(lw);
894                 }
895         list = layout_selection_list(lw);
896         start_editor_from_filelist(n, list);
897         filelist_free(list);
898 }
899
900 static void layout_menu_edit_update(LayoutWindow *lw)
901 {
902         gint i;
903
904         /* main edit menu */
905
906         if (!lw->action_group) return;
907
908         for (i = 0; i < 10; i++)
909                 {
910                 gchar *key;
911                 GtkAction *action;
912
913                 key = g_strdup_printf("Editor%d", i);
914
915                 action = gtk_action_group_get_action(lw->action_group, key);
916                 g_object_set_data(G_OBJECT(action), "edit_index", GINT_TO_POINTER(i));
917
918                 if (editor_command[i] && strlen(editor_command[i]) > 0)
919                         {
920                         gchar *text;
921
922                         if (editor_name[i] && strlen(editor_name[i]) > 0)
923                                 {
924                                 text = g_strdup_printf(_("in %s..."), editor_name[i]);
925                                 }
926                         else
927                                 {
928                                 text = g_strdup(_("in (unknown)..."));
929                                 }
930                         g_object_set(action, "label", text,
931                                              "sensitive", TRUE, NULL);
932                         g_free(text);
933                         }
934                 else
935                         {
936                         g_object_set(action, "label", _("empty"),
937                                              "sensitive", FALSE, NULL);
938                         }
939
940                 g_free(key);
941                 }
942 }
943
944 void layout_edit_update_all(void)
945 {
946         GList *work;
947
948         work = layout_window_list;
949         while (work)
950                 {
951                 LayoutWindow *lw = work->data;
952                 work = work->next;
953
954                 layout_menu_edit_update(lw);
955                 }
956 }
957
958 /*
959  *-----------------------------------------------------------------------------
960  * recent menu
961  *-----------------------------------------------------------------------------
962  */
963
964 static void layout_menu_recent_cb(GtkWidget *widget, gpointer data)
965 {
966         gint n;
967         gchar *path;
968
969         n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "recent_index"));
970
971         path = g_list_nth_data(history_list_get_by_key("recent"), n);
972
973         if (!path) return;
974
975         /* make a copy of it */
976         path = g_strdup(path);
977         collection_window_new(path);
978         g_free(path);
979 }
980
981 static void layout_menu_recent_update(LayoutWindow *lw)
982 {
983         GtkWidget *menu;
984         GtkWidget *recent;
985         GtkWidget *item;
986         GList *list;
987         gint n;
988
989         if (!lw->ui_manager) return;
990
991         list = history_list_get_by_key("recent");
992         n = 0;
993
994         menu = gtk_menu_new();
995
996         while (list)
997                 {
998                 item = menu_item_add_simple(menu, filename_from_path((gchar *)list->data),
999                                             G_CALLBACK(layout_menu_recent_cb), lw);
1000                 g_object_set_data(G_OBJECT(item), "recent_index", GINT_TO_POINTER(n));
1001                 list = list->next;
1002                 n++;
1003                 }
1004
1005         if (n == 0)
1006                 {
1007                 menu_item_add(menu, _("Empty"), NULL, NULL);
1008                 }
1009
1010         recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/FileMenu/OpenRecent");
1011         gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu);
1012         gtk_widget_set_sensitive(recent, (n != 0));
1013 }
1014
1015 void layout_recent_update_all(void)
1016 {
1017         GList *work;
1018
1019         work = layout_window_list;
1020         while (work)
1021                 {
1022                 LayoutWindow *lw = work->data;
1023                 work = work->next;
1024
1025                 layout_menu_recent_update(lw);
1026                 }
1027 }
1028
1029 void layout_recent_add_path(const gchar *path)
1030 {
1031         if (!path) return;
1032
1033         history_list_add_to_key("recent", path, recent_list_max);
1034
1035         layout_recent_update_all();
1036 }
1037
1038 /*
1039  *-----------------------------------------------------------------------------
1040  * menu
1041  *-----------------------------------------------------------------------------
1042  */ 
1043
1044 #define CB G_CALLBACK
1045
1046 static GtkActionEntry menu_entries[] = {
1047   { "FileMenu",         NULL,           N_("_File") },
1048   { "GoMenu",           NULL,           N_("_Go") },
1049   { "EditMenu",         NULL,           N_("_Edit") },
1050   { "SelectMenu",       NULL,           N_("_Select") },
1051   { "AdjustMenu",       NULL,           N_("_Adjust") },
1052   { "ViewMenu",         NULL,           N_("_View") },
1053   { "ZoomMenu",         NULL,           N_("_Zoom") },
1054   { "SplitMenu",        NULL,           N_("_Split") },
1055   { "HelpMenu",         NULL,           N_("_Help") },
1056
1057   { "FirstImage",       GTK_STOCK_GOTO_TOP,     N_("_First Image"),     "Home",         NULL,   CB(layout_menu_image_first_cb) },
1058   { "PrevImage",        GTK_STOCK_GO_UP,        N_("_Previous Image"),  "BackSpace",    NULL,   CB(layout_menu_image_prev_cb) },
1059   { "NextImage",        GTK_STOCK_GO_DOWN,      N_("_Next Image"),      "space",        NULL,   CB(layout_menu_image_next_cb) },
1060   { "LastImage",        GTK_STOCK_GOTO_BOTTOM,  N_("_Last Image"),      "End",          NULL,   CB(layout_menu_image_last_cb) },
1061
1062
1063   { "NewWindow",        GTK_STOCK_NEW,  N_("New _window"),      NULL,           NULL,   CB(layout_menu_new_window_cb) },
1064   { "NewCollection",    GTK_STOCK_INDEX,N_("_New collection"),  "C",            NULL,   CB(layout_menu_new_cb) },
1065   { "OpenCollection",   GTK_STOCK_OPEN, N_("_Open collection..."),"O",          NULL,   CB(layout_menu_open_cb) },
1066   { "OpenRecent",       NULL,           N_("Open _recent") },
1067   { "Search",           GTK_STOCK_FIND, N_("_Search..."),       "F3",           NULL,   CB(layout_menu_search_cb) },
1068   { "FindDupes",        GTK_STOCK_FIND, N_("_Find duplicates..."),"D",          NULL,   CB(layout_menu_dupes_cb) },
1069   { "PanView",          NULL,           N_("Pan _view"),        "<control>J",   NULL,   CB(layout_menu_pan_cb) },
1070   { "Print",            GTK_STOCK_PRINT,N_("_Print..."),        "<shift>P",     NULL,   CB(layout_menu_print_cb) },
1071   { "NewFolder",        NULL,           N_("N_ew folder..."),   "<control>F",   NULL,   CB(layout_menu_dir_cb) },
1072   { "Copy",             NULL,           N_("_Copy..."),         "<control>C",   NULL,   CB(layout_menu_copy_cb) },
1073   { "Move",             NULL,           N_("_Move..."),         "<control>M",   NULL,   CB(layout_menu_move_cb) },
1074   { "Rename",           NULL,           N_("_Rename..."),       "<control>R",   NULL,   CB(layout_menu_rename_cb) },
1075   { "Delete",   GTK_STOCK_DELETE,       N_("_Delete..."),       "<control>D",   NULL,   CB(layout_menu_delete_cb) },
1076   { "CloseWindow",      GTK_STOCK_CLOSE,N_("C_lose window"),    "<control>W",   NULL,   CB(layout_menu_close_cb) },
1077   { "Quit",             GTK_STOCK_QUIT, N_("_Quit"),            "<control>Q",   NULL,   CB(layout_menu_exit_cb) },
1078
1079   { "Editor0",          NULL,           "editor0",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1080   { "Editor1",          NULL,           "editor1",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1081   { "Editor2",          NULL,           "editor2",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1082   { "Editor3",          NULL,           "editor3",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1083   { "Editor4",          NULL,           "editor4",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1084   { "Editor5",          NULL,           "editor5",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1085   { "Editor6",          NULL,           "editor6",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1086   { "Editor7",          NULL,           "editor7",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1087   { "Editor8",          NULL,           "editor8",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1088   { "Editor9",          NULL,           "editor9",              NULL,           NULL,   CB(layout_menu_edit_cb) },
1089   { "RotateCW",         NULL,   N_("_Rotate clockwise"),        "bracketright", NULL,   CB(layout_menu_alter_90_cb) },
1090   { "RotateCCW",        NULL,   N_("Rotate _counterclockwise"), "bracketleft",  NULL,   CB(layout_menu_alter_90cc_cb) },
1091   { "Rotate180",        NULL,           N_("Rotate 1_80"),      "<shift>R",     NULL,   CB(layout_menu_alter_180_cb) },
1092   { "Mirror",           NULL,           N_("_Mirror"),          "<shift>M",     NULL,   CB(layout_menu_alter_mirror_cb) },
1093   { "Flip",             NULL,           N_("_Flip"),            "<shift>F",     NULL,   CB(layout_menu_alter_flip_cb) },
1094   { "Grayscale",        NULL,           N_("_Grayscale"),       "<shift>G",     NULL,   CB(layout_menu_alter_desaturate_cb) },
1095   { "Properties",GTK_STOCK_PROPERTIES,  N_("_Properties"),      "<control>P",   NULL,   CB(layout_menu_info_cb) },
1096   { "SelectAll",        NULL,           N_("Select _all"),      "<control>A",   NULL,   CB(layout_menu_select_all_cb) },
1097   { "SelectNone",       NULL,           N_("Select _none"), "<control><shift>A",NULL,   CB(layout_menu_unselect_all_cb) },
1098   { "Preferences",GTK_STOCK_PREFERENCES,N_("P_references..."),  "<control>O",   NULL,   CB(layout_menu_config_cb) },
1099   { "Maintenance",      NULL,           N_("_Thumbnail maintenance..."),NULL,   NULL,   CB(layout_menu_remove_thumb_cb) },
1100   { "Wallpaper",        NULL,           N_("Set as _wallpaper"),NULL,           NULL,   CB(layout_menu_wallpaper_cb) },
1101
1102   { "ZoomIn",   GTK_STOCK_ZOOM_IN,      N_("Zoom _in"),         "equal",        NULL,   CB(layout_menu_zoom_in_cb) },
1103   { "ZoomOut",  GTK_STOCK_ZOOM_OUT,     N_("Zoom _out"),        "minus",        NULL,   CB(layout_menu_zoom_out_cb) },
1104   { "Zoom100",  GTK_STOCK_ZOOM_100,     N_("Zoom _1:1"),        "Z",            NULL,   CB(layout_menu_zoom_1_1_cb) },
1105   { "ZoomFit",  GTK_STOCK_ZOOM_FIT,     N_("_Zoom to fit"),     "X",            NULL,   CB(layout_menu_zoom_fit_cb) },
1106   { "ZoomFillHor",      NULL,           N_("Fit _Horizontally"),"H",            NULL,   CB(layout_menu_zoom_fit_hor_cb) },
1107   { "ZoomFillVert",     NULL,           N_("Fit _Vorizontally"),"W",            NULL,   CB(layout_menu_zoom_fit_vert_cb) },
1108   { "Zoom200",          NULL,           N_("Zoom _2:1"),        NULL,           NULL,   CB(layout_menu_zoom_2_1_cb) },
1109   { "Zoom300",          NULL,           N_("Zoom _3:1"),        NULL,           NULL,   CB(layout_menu_zoom_3_1_cb) },
1110   { "Zoom400",          NULL,           N_("Zoom _4:1"),        NULL,           NULL,   CB(layout_menu_zoom_4_1_cb) },
1111   { "Zoom50",           NULL,           N_("Zoom 1:2"),         NULL,           NULL,   CB(layout_menu_zoom_1_2_cb) },
1112   { "Zoom33",           NULL,           N_("Zoom 1:3"),         NULL,           NULL,   CB(layout_menu_zoom_1_3_cb) },
1113   { "Zoom25",           NULL,           N_("Zoom 1:4"),         NULL,           NULL,   CB(layout_menu_zoom_1_4_cb) },
1114
1115
1116   { "ViewInNewWindow",  NULL,           N_("_View in new window"),      "<control>V",           NULL,   CB(layout_menu_view_in_new_window_cb) },
1117
1118   { "FullScreen",       NULL,           N_("F_ull screen"),     "F",            NULL,   CB(layout_menu_fullscreen_cb) },
1119   { "ImageOverlay",     NULL,           N_("_Image Overlay"),   "I",            NULL,   CB(layout_menu_overlay_cb) },
1120   { "HistogramChan",    NULL,   N_("Histogram _channels"),      "K",            NULL,   CB(layout_menu_histogram_chan_cb) },
1121   { "HistogramLog",     NULL,   N_("Histogram _log mode"),      "J",            NULL,   CB(layout_menu_histogram_log_cb) },
1122   { "HideTools",        NULL,           N_("_Hide file list"),  "<control>H",   NULL,   CB(layout_menu_hide_cb) },
1123   { "SlideShow",        NULL,           N_("Toggle _slideshow"),"S",            NULL,   CB(layout_menu_slideshow_cb) },
1124   { "Refresh",  GTK_STOCK_REFRESH,      N_("_Refresh"),         "R",            NULL,   CB(layout_menu_refresh_cb) },
1125
1126   { "HelpContents",     GTK_STOCK_HELP, N_("_Contents"),        "F1",           NULL,   CB(layout_menu_help_cb) },
1127   { "HelpShortcuts",    NULL,           N_("_Keyboard shortcuts"),NULL,         NULL,   CB(layout_menu_help_keys_cb) },
1128   { "HelpNotes",        NULL,           N_("_Release notes"),   NULL,           NULL,   CB(layout_menu_notes_cb) },
1129   { "About",            NULL,           N_("_About"),           NULL,           NULL,   CB(layout_menu_about_cb) }
1130 };
1131
1132 static GtkToggleActionEntry menu_toggle_entries[] = {
1133   { "Thumbnails",       NULL,           N_("_Thumbnails"),      "T",            NULL,   CB(layout_menu_thumb_cb) },
1134   { "ShowMarks",        NULL,           N_("Show _Marks"),      "M",            NULL,   CB(layout_menu_marks_cb) },  
1135   { "FolderTree",       NULL,           N_("Tr_ee"),            "<control>T",   NULL,   CB(layout_menu_tree_cb) },
1136   { "FloatTools",       NULL,           N_("_Float file list"), "L",            NULL,   CB(layout_menu_float_cb) },
1137   { "HideToolbar",      NULL,           N_("Hide tool_bar"),    NULL,           NULL,   CB(layout_menu_toolbar_cb) },
1138   { "SBarKeywords",     NULL,           N_("_Keywords"),        "<control>K",   NULL,   CB(layout_menu_bar_info_cb) },
1139   { "SBarExif",         NULL,           N_("E_xif data"),       "<control>E",   NULL,   CB(layout_menu_bar_exif_cb) },
1140   { "SBarSort",         NULL,           N_("Sort _manager"),    "<control>S",   NULL,   CB(layout_menu_bar_sort_cb) },
1141   { "ConnectScroll",    NULL,           N_("Connected scroll"), "<control>U",   NULL,   CB(layout_menu_connect_scroll_cb) },
1142   { "ConnectZoom",      NULL,           N_("Connected zoom"),   "<control>Y",   NULL,   CB(layout_menu_connect_zoom_cb) }
1143 };
1144
1145 static GtkRadioActionEntry menu_radio_entries[] = {
1146   { "ViewList",         NULL,           N_("_List"),            "<control>L",   NULL,   0 },
1147   { "ViewIcons",        NULL,           N_("I_cons"),           "<control>I",   NULL,   1 }
1148 };
1149
1150 static GtkRadioActionEntry menu_split_radio_entries[] = {
1151   { "SplitHorizontal",  NULL,           N_("Horizontal"),       "E",            NULL,   SPLIT_HOR },
1152   { "SplitVertical",    NULL,           N_("Vertical"),         "U",            NULL,   SPLIT_VERT },
1153   { "SplitQuad",        NULL,           N_("Quad"),             "Q",            NULL,   SPLIT_QUAD },
1154   { "SplitSingle",      NULL,           N_("Single"),           "Y",            NULL,   SPLIT_NONE }
1155 };
1156
1157 #undef CB
1158
1159 static const char *menu_ui_description =
1160 "<ui>"
1161 "  <menubar name='MainMenu'>"
1162 "    <menu action='FileMenu'>"
1163 "      <menuitem action='NewWindow'/>"
1164 "      <menuitem action='NewCollection'/>"
1165 "      <menuitem action='OpenCollection'/>"
1166 "      <menuitem action='OpenRecent'/>"
1167 "      <separator/>"
1168 "      <menuitem action='Search'/>"
1169 "      <menuitem action='FindDupes'/>"
1170 "      <menuitem action='PanView'/>"
1171 "      <separator/>"
1172 "      <menuitem action='Print'/>"
1173 "      <menuitem action='NewFolder'/>"
1174 "      <separator/>"
1175 "      <menuitem action='Copy'/>"
1176 "      <menuitem action='Move'/>"
1177 "      <menuitem action='Rename'/>"
1178 "      <menuitem action='Delete'/>"
1179 "      <separator/>"
1180 "      <menuitem action='CloseWindow'/>"
1181 "      <menuitem action='Quit'/>"
1182 "    </menu>"
1183 "    <menu action='GoMenu'>"
1184 "      <menuitem action='FirstImage'/>"
1185 "      <menuitem action='PrevImage'/>"
1186 "      <menuitem action='NextImage'/>"
1187 "      <menuitem action='LastImage'/>"
1188 "    </menu>"
1189 "    <menu action='SelectMenu'>"
1190 "      <menuitem action='SelectAll'/>"
1191 "      <menuitem action='SelectNone'/>"
1192 "      <separator/>"
1193 "      <menuitem action='ShowMarks'/>"
1194 "      <separator/>"
1195 "    </menu>"
1196 "    <menu action='EditMenu'>"
1197 "      <menuitem action='Editor0'/>"
1198 "      <menuitem action='Editor1'/>"
1199 "      <menuitem action='Editor2'/>"
1200 "      <menuitem action='Editor3'/>"
1201 "      <menuitem action='Editor4'/>"
1202 "      <menuitem action='Editor5'/>"
1203 "      <menuitem action='Editor6'/>"
1204 "      <menuitem action='Editor7'/>"
1205 "      <menuitem action='Editor8'/>"
1206 "      <menuitem action='Editor9'/>"
1207 "      <separator/>"
1208 "      <menu action='AdjustMenu'>"
1209 "        <menuitem action='RotateCW'/>"
1210 "        <menuitem action='RotateCCW'/>"
1211 "        <menuitem action='Rotate180'/>"
1212 "        <menuitem action='Mirror'/>"
1213 "        <menuitem action='Flip'/>"
1214 "        <menuitem action='Grayscale'/>"
1215 "      </menu>"
1216 "      <menuitem action='Properties'/>"
1217 "      <separator/>"
1218 "      <menuitem action='Preferences'/>"
1219 "      <menuitem action='Maintenance'/>"
1220 "      <separator/>"
1221 "      <menuitem action='Wallpaper'/>"
1222 "    </menu>"
1223 "    <menu action='ViewMenu'>"
1224 "      <menuitem action='ViewInNewWindow'/>"
1225 "      <separator/>"
1226 "      <menu action='ZoomMenu'>"
1227 "        <menuitem action='ZoomIn'/>"
1228 "        <menuitem action='ZoomOut'/>"
1229 "        <menuitem action='ZoomFit'/>"
1230 "        <menuitem action='ZoomFillHor'/>"
1231 "        <menuitem action='ZoomFillVert'/>"
1232 "        <menuitem action='Zoom100'/>"
1233 "        <menuitem action='Zoom200'/>"
1234 "        <menuitem action='Zoom300'/>"
1235 "        <menuitem action='Zoom400'/>"
1236 "        <menuitem action='Zoom50'/>"
1237 "        <menuitem action='Zoom33'/>"
1238 "        <menuitem action='Zoom25'/>"
1239 "      </menu>"
1240 "      <separator/>"
1241 "      <menu action='SplitMenu'>"
1242 "        <menuitem action='SplitHorizontal'/>"
1243 "        <menuitem action='SplitVertical'/>"
1244 "        <menuitem action='SplitQuad'/>"
1245 "        <menuitem action='SplitSingle'/>"
1246 "      </menu>"
1247 "      <menuitem action='ConnectScroll'/>"
1248 "      <menuitem action='ConnectZoom'/>"
1249 "      <separator/>"
1250 "      <menuitem action='Thumbnails'/>"
1251 "      <menuitem action='ViewList'/>"
1252 "      <menuitem action='ViewIcons'/>"
1253 "      <separator/>"
1254 "      <menuitem action='FolderTree'/>"
1255 "      <menuitem action='ImageOverlay'/>"
1256 "      <menuitem action='HistogramChan'/>"
1257 "      <menuitem action='HistogramLog'/>"
1258 "      <menuitem action='FullScreen'/>"
1259 "      <separator/>"
1260 "      <menuitem action='FloatTools'/>"
1261 "      <menuitem action='HideTools'/>"
1262 "      <menuitem action='HideToolbar'/>"
1263 "      <separator/>"
1264 "      <menuitem action='SBarKeywords'/>"
1265 "      <menuitem action='SBarExif'/>"
1266 "      <menuitem action='SBarSort'/>"
1267 "      <separator/>"
1268 "      <menuitem action='SlideShow'/>"
1269 "      <menuitem action='Refresh'/>"
1270 "    </menu>"
1271 "    <menu action='HelpMenu'>"
1272 "      <separator/>"
1273 "      <menuitem action='HelpContents'/>"
1274 "      <menuitem action='HelpShortcuts'/>"
1275 "      <menuitem action='HelpNotes'/>"
1276 "      <separator/>"
1277 "      <menuitem action='About'/>"
1278 "    </menu>"
1279 "  </menubar>"
1280 "</ui>";
1281
1282
1283 static gchar *menu_translate(const gchar *path, gpointer data)
1284 {
1285         return _(path);
1286 }
1287
1288 static void layout_actions_setup_mark(LayoutWindow *lw, gint mark, char *name_tmpl, char *label_tmpl, char *accel_tmpl,  GCallback cb)
1289 {
1290         char name[50];
1291         char label[100];
1292         char accel[50];
1293         GtkActionEntry entry = { name, NULL, label, accel, NULL, cb };
1294         GtkAction *action;
1295
1296         g_snprintf(name, sizeof(name), name_tmpl, mark);
1297         g_snprintf(label, sizeof(label), label_tmpl, mark);
1298         if (accel_tmpl)
1299                 g_snprintf(accel, sizeof(accel), accel_tmpl, mark % 10);
1300         else
1301                 accel[0] = 0;
1302         gtk_action_group_add_actions(lw->action_group, &entry, 1, lw);
1303         action = gtk_action_group_get_action(lw->action_group, name);
1304         g_object_set_data(G_OBJECT(action), "mark_num", GINT_TO_POINTER(mark));
1305 }
1306
1307 static void layout_actions_setup_marks(LayoutWindow *lw)
1308 {
1309         int mark;
1310         GError *error;
1311         GString *desc = g_string_new(
1312                                 "<ui>"
1313                                 "  <menubar name='MainMenu'>"
1314                                 "    <menu action='SelectMenu'>");
1315         
1316         for (mark = 1; mark <= FILEDATA_MARKS_SIZE; mark++)
1317                 {
1318                 layout_actions_setup_mark(lw, mark, "Mark%d",           _("Mark _%d"), NULL, NULL);
1319                 layout_actions_setup_mark(lw, mark, "SetMark%d",        _("_Set mark %d"),                      NULL, G_CALLBACK(layout_menu_set_mark_sel_cb));
1320                 layout_actions_setup_mark(lw, mark, "ResetMark%d",      _("_Reset mark %d"),                    NULL, G_CALLBACK(layout_menu_res_mark_sel_cb));
1321                 layout_actions_setup_mark(lw, mark, "ToggleMark%d",     _("_Toggle mark %d"),                   "%d", G_CALLBACK(layout_menu_toggle_mark_sel_cb));
1322                 layout_actions_setup_mark(lw, mark, "SelectMark%d",     _("_Select mark %d"),                   "<control>%d", G_CALLBACK(layout_menu_sel_mark_cb));
1323                 layout_actions_setup_mark(lw, mark, "AddMark%d",        _("_Add mark %d"),                      NULL, G_CALLBACK(layout_menu_sel_mark_or_cb));
1324                 layout_actions_setup_mark(lw, mark, "IntMark%d",        _("_Intersection with mark %d"),        NULL, G_CALLBACK(layout_menu_sel_mark_and_cb));
1325                 layout_actions_setup_mark(lw, mark, "UnselMark%d",      _("_Unselect mark %d"),                 NULL, G_CALLBACK(layout_menu_sel_mark_minus_cb));
1326
1327                 g_string_append_printf(desc,
1328                                 "      <menu action='Mark%d'>"
1329                                 "        <menuitem action='ToggleMark%d'/>"
1330                                 "        <menuitem action='SetMark%d'/>"
1331                                 "        <menuitem action='ResetMark%d'/>"
1332                                 "        <separator/>"
1333                                 "        <menuitem action='SelectMark%d'/>"
1334                                 "        <menuitem action='AddMark%d'/>"
1335                                 "        <menuitem action='IntMark%d'/>"
1336                                 "        <menuitem action='UnselMark%d'/>"
1337                                 "      </menu>",
1338                                 mark, mark, mark, mark, mark, mark, mark, mark);
1339                 }
1340
1341         g_string_append(desc,
1342                                 "    </menu>"
1343                                 "  </menubar>"
1344                                 "</ui>" );
1345
1346         error = NULL;
1347         if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, desc->str, -1, &error))
1348                 {
1349                 g_message ("building menus failed: %s", error->message);
1350                 g_error_free (error);
1351                 exit (EXIT_FAILURE);
1352                 }
1353         g_string_free(desc, TRUE);
1354 }
1355
1356 void layout_actions_setup(LayoutWindow *lw)
1357 {
1358         GError *error;
1359
1360         if (lw->ui_manager) return;
1361
1362         lw->action_group = gtk_action_group_new ("MenuActions");
1363         gtk_action_group_set_translate_func(lw->action_group, menu_translate, NULL, NULL);
1364
1365         gtk_action_group_add_actions(lw->action_group,
1366                                      menu_entries, G_N_ELEMENTS(menu_entries), lw);
1367         gtk_action_group_add_toggle_actions(lw->action_group,
1368                                             menu_toggle_entries, G_N_ELEMENTS(menu_toggle_entries), lw);
1369         gtk_action_group_add_radio_actions(lw->action_group,
1370                                            menu_radio_entries, G_N_ELEMENTS(menu_radio_entries),
1371                                            0, G_CALLBACK(layout_menu_list_cb), lw);
1372         gtk_action_group_add_radio_actions(lw->action_group,
1373                                            menu_split_radio_entries, G_N_ELEMENTS(menu_split_radio_entries),
1374                                            0, G_CALLBACK(layout_menu_split_cb), lw);
1375
1376         lw->ui_manager = gtk_ui_manager_new();
1377         gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE);
1378         gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0);
1379
1380         error = NULL;
1381         if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, menu_ui_description, -1, &error))
1382                 {
1383                 g_message ("building menus failed: %s", error->message);
1384                 g_error_free (error);
1385                 exit (EXIT_FAILURE);
1386                 }
1387
1388         layout_actions_setup_marks(lw);
1389 }
1390
1391 void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window)
1392 {
1393         GtkAccelGroup *group;
1394
1395         if (!lw->ui_manager) return;
1396
1397         group = gtk_ui_manager_get_accel_group(lw->ui_manager);
1398         gtk_window_add_accel_group(GTK_WINDOW(window), group);
1399 }
1400
1401 GtkWidget *layout_actions_menu_bar(LayoutWindow *lw)
1402 {
1403         return gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu");
1404 }
1405
1406
1407 /*
1408  *-----------------------------------------------------------------------------
1409  * toolbar
1410  *-----------------------------------------------------------------------------
1411  */ 
1412
1413 static void layout_button_thumb_cb(GtkWidget *widget, gpointer data)
1414 {
1415         LayoutWindow *lw = data;
1416
1417         layout_thumb_set(lw, gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget)));
1418 }
1419
1420 static void layout_button_home_cb(GtkWidget *widget, gpointer data)
1421 {
1422         LayoutWindow *lw = data;
1423         const gchar *path = homedir();
1424
1425         if (path) layout_set_path(lw, path);
1426 }
1427
1428 static void layout_button_refresh_cb(GtkWidget *widget, gpointer data)
1429 {
1430         LayoutWindow *lw = data;
1431
1432         layout_refresh(lw);
1433 }
1434
1435 static void layout_button_zoom_in_cb(GtkWidget *widget, gpointer data)
1436 {
1437         LayoutWindow *lw = data;
1438
1439         layout_image_zoom_adjust(lw, get_zoom_increment());
1440 }
1441
1442 static void layout_button_zoom_out_cb(GtkWidget *widget, gpointer data)
1443 {
1444         LayoutWindow *lw = data;
1445
1446         layout_image_zoom_adjust(lw, -get_zoom_increment());
1447 }
1448
1449 static void layout_button_zoom_fit_cb(GtkWidget *widget, gpointer data)
1450 {
1451         LayoutWindow *lw = data;
1452
1453         layout_image_zoom_set(lw, 0.0);
1454 }
1455
1456 static void layout_button_zoom_1_1_cb(GtkWidget *widget, gpointer data)
1457 {
1458         LayoutWindow *lw = data;
1459
1460         layout_image_zoom_set(lw, 1.0);
1461 }
1462
1463 static void layout_button_config_cb(GtkWidget *widget, gpointer data)
1464 {
1465         show_config_window();
1466 }
1467
1468 static void layout_button_float_cb(GtkWidget *widget, gpointer data)
1469 {
1470         LayoutWindow *lw = data;
1471
1472         layout_tools_float_toggle(lw);
1473 }
1474
1475 static void layout_button_custom_icon(GtkWidget *button, const gchar *key)
1476 {
1477         GtkWidget *icon;
1478         GdkPixbuf *pixbuf;
1479
1480         pixbuf = pixbuf_inline(key);
1481         if (!pixbuf) return;
1482
1483         icon = gtk_image_new_from_pixbuf(pixbuf);
1484         g_object_unref(pixbuf);
1485
1486         pref_toolbar_button_set_icon(button, icon, NULL);
1487         gtk_widget_show(icon);
1488 }
1489
1490 GtkWidget *layout_button_bar(LayoutWindow *lw)
1491 {
1492         GtkWidget *box;
1493         GtkWidget *button;
1494
1495         box =  pref_toolbar_new(NULL, GTK_TOOLBAR_ICONS);
1496
1497         button = pref_toolbar_button(box, NULL, _("_Thumbnails"), TRUE,
1498                                      _("Show thumbnails"), G_CALLBACK(layout_button_thumb_cb), lw);
1499         layout_button_custom_icon(button, PIXBUF_INLINE_ICON_THUMB);
1500         lw->thumb_button = button;
1501
1502         pref_toolbar_button(box, GTK_STOCK_HOME, NULL, FALSE,
1503                             _("Change to home folder"), G_CALLBACK(layout_button_home_cb), lw);
1504         pref_toolbar_button(box, GTK_STOCK_REFRESH, NULL, FALSE,
1505                             _("Refresh file list"), G_CALLBACK(layout_button_refresh_cb), lw);
1506         pref_toolbar_button(box, GTK_STOCK_ZOOM_IN, NULL, FALSE,
1507                             _("Zoom in"), G_CALLBACK(layout_button_zoom_in_cb), lw);
1508         pref_toolbar_button(box, GTK_STOCK_ZOOM_OUT, NULL, FALSE,
1509                             _("Zoom out"), G_CALLBACK(layout_button_zoom_out_cb), lw);
1510         pref_toolbar_button(box, GTK_STOCK_ZOOM_FIT, NULL, FALSE,
1511                             _("Fit image to window"), G_CALLBACK(layout_button_zoom_fit_cb), lw);
1512         pref_toolbar_button(box, GTK_STOCK_ZOOM_100, NULL, FALSE,
1513                             _("Set zoom 1:1"), G_CALLBACK(layout_button_zoom_1_1_cb), lw);
1514         pref_toolbar_button(box, GTK_STOCK_PREFERENCES, NULL, FALSE,
1515                             _("Configure options"), G_CALLBACK(layout_button_config_cb), lw);
1516         button = pref_toolbar_button(box, NULL, _("_Float"), FALSE,
1517                                      _("Float Controls"), G_CALLBACK(layout_button_float_cb), lw);
1518         layout_button_custom_icon(button, PIXBUF_INLINE_ICON_FLOAT);
1519
1520         return box;
1521 }
1522
1523 /*
1524  *-----------------------------------------------------------------------------
1525  * misc
1526  *-----------------------------------------------------------------------------
1527  */
1528
1529 static void layout_util_sync_views(LayoutWindow *lw)
1530 {
1531         GtkAction *action;
1532
1533         if (!lw->action_group) return;
1534
1535         action = gtk_action_group_get_action(lw->action_group, "FolderTree");
1536         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tree_view);
1537
1538         action = gtk_action_group_get_action(lw->action_group, "ViewIcons");
1539         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->icon_view);
1540
1541         action = gtk_action_group_get_action(lw->action_group, "FloatTools");
1542         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tools_float);
1543
1544         action = gtk_action_group_get_action(lw->action_group, "SBarKeywords");
1545         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_info_enabled);
1546
1547         action = gtk_action_group_get_action(lw->action_group, "SBarExif");
1548         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_exif_enabled);
1549
1550         action = gtk_action_group_get_action(lw->action_group, "SBarSort");
1551         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_sort_enabled);
1552
1553         action = gtk_action_group_get_action(lw->action_group, "HideToolbar");
1554         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->toolbar_hidden);
1555 }
1556
1557 void layout_util_sync_thumb(LayoutWindow *lw)
1558 {
1559         GtkAction *action;
1560
1561         if (!lw->action_group) return;
1562
1563         action = gtk_action_group_get_action(lw->action_group, "Thumbnails");
1564         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->thumbs_enabled);
1565         g_object_set(action, "sensitive", !lw->icon_view, NULL);
1566
1567         gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(lw->thumb_button), lw->thumbs_enabled);
1568         gtk_widget_set_sensitive(lw->thumb_button, !lw->icon_view);
1569 }
1570
1571 void layout_util_sync(LayoutWindow *lw)
1572 {
1573         layout_util_sync_views(lw);
1574         layout_util_sync_thumb(lw);
1575         layout_menu_recent_update(lw);
1576         layout_menu_edit_update(lw);
1577 }
1578
1579 /*
1580  *-----------------------------------------------------------------------------
1581  * icons (since all the toolbar icons are included here, best place as any)
1582  *-----------------------------------------------------------------------------
1583  */
1584
1585 PixmapFolders *folder_icons_new(void)
1586 {
1587         PixmapFolders *pf;
1588
1589         pf = g_new0(PixmapFolders, 1);
1590
1591         pf->close = pixbuf_inline(PIXBUF_INLINE_FOLDER_CLOSED);
1592         pf->open = pixbuf_inline(PIXBUF_INLINE_FOLDER_OPEN);
1593         pf->deny = pixbuf_inline(PIXBUF_INLINE_FOLDER_LOCKED);
1594         pf->parent = pixbuf_inline(PIXBUF_INLINE_FOLDER_UP);
1595
1596         return pf;
1597 }
1598
1599 void folder_icons_free(PixmapFolders *pf)
1600 {
1601         if (!pf) return;
1602
1603         g_object_unref(pf->close);
1604         g_object_unref(pf->open);
1605         g_object_unref(pf->deny);
1606         g_object_unref(pf->parent);
1607
1608         g_free(pf);
1609 }
1610
1611 /*
1612  *-----------------------------------------------------------------------------
1613  * sidebars
1614  *-----------------------------------------------------------------------------
1615  */
1616
1617 #define SIDEBAR_WIDTH 288
1618
1619 static void layout_bar_info_destroyed(GtkWidget *widget, gpointer data)
1620 {
1621         LayoutWindow *lw = data;
1622
1623         lw->bar_info = NULL;
1624
1625         if (lw->utility_box)
1626                 {
1627                 /* destroyed from within itself */
1628                 lw->bar_info_enabled = FALSE;
1629                 layout_util_sync_views(lw);
1630                 }
1631 }
1632
1633 static GList *layout_bar_info_list_cb(gpointer data)
1634 {
1635         LayoutWindow *lw = data;
1636
1637         return layout_selection_list(lw);
1638 }
1639
1640 static void layout_bar_info_new(LayoutWindow *lw)
1641 {
1642         if (!lw->utility_box) return;
1643                                                                                                                     
1644         lw->bar_info = bar_info_new(layout_image_get_fd(lw), FALSE, lw->utility_box);
1645         bar_info_set_selection_func(lw->bar_info, layout_bar_info_list_cb, lw);
1646         bar_info_selection(lw->bar_info, layout_selection_count(lw, NULL) - 1);
1647         bar_info_size_request(lw->bar_info, SIDEBAR_WIDTH * 3 / 4);
1648         g_signal_connect(G_OBJECT(lw->bar_info), "destroy",
1649                          G_CALLBACK(layout_bar_info_destroyed), lw);
1650         lw->bar_info_enabled = TRUE;
1651
1652         gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar_info, FALSE, FALSE, 0);
1653         gtk_widget_show(lw->bar_info);
1654 }
1655                                                                                                                     
1656 static void layout_bar_info_close(LayoutWindow *lw)
1657 {
1658         if (lw->bar_info)
1659                 {
1660                 bar_info_close(lw->bar_info);
1661                 lw->bar_info = NULL;
1662                 }
1663         lw->bar_info_enabled = FALSE;
1664 }
1665
1666 void layout_bar_info_toggle(LayoutWindow *lw)
1667 {
1668         if (lw->bar_info_enabled)
1669                 {
1670                 layout_bar_info_close(lw);
1671                 }
1672         else
1673                 {
1674                 layout_bar_info_new(lw);
1675                 }
1676 }
1677
1678 static void layout_bar_info_new_image(LayoutWindow *lw)
1679 {
1680         if (!lw->bar_info || !lw->bar_info_enabled) return;
1681
1682         bar_info_set(lw->bar_info, layout_image_get_fd(lw));
1683 }
1684
1685 static void layout_bar_info_new_selection(LayoutWindow *lw, gint count)
1686 {
1687         if (!lw->bar_info || !lw->bar_info_enabled) return;
1688
1689         bar_info_selection(lw->bar_info, count - 1);
1690 }
1691
1692 static void layout_bar_info_maint_renamed(LayoutWindow *lw)
1693 {
1694         if (!lw->bar_info || !lw->bar_info_enabled) return;
1695
1696         bar_info_maint_renamed(lw->bar_info, layout_image_get_fd(lw));
1697 }
1698
1699 static void layout_bar_exif_destroyed(GtkWidget *widget, gpointer data)
1700 {
1701         LayoutWindow *lw = data;
1702
1703         if (lw->bar_exif)
1704                 {
1705                 lw->bar_exif_advanced = bar_exif_is_advanced(lw->bar_exif);
1706                 }
1707
1708         lw->bar_exif = NULL;
1709         if (lw->utility_box)
1710                 {
1711                 /* destroyed from within itself */
1712                 lw->bar_exif_enabled = FALSE;
1713                 layout_util_sync_views(lw);
1714                 }
1715 }
1716
1717 static void layout_bar_exif_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
1718 {
1719         LayoutWindow *lw = data;
1720
1721         if (lw->bar_exif)
1722                 {
1723                 lw->bar_exif_size = allocation->width;
1724                 }
1725 }
1726
1727 static void layout_bar_exif_new(LayoutWindow *lw)
1728 {
1729         if (!lw->utility_box) return;
1730
1731         lw->bar_exif = bar_exif_new(TRUE, layout_image_get_fd(lw),
1732                                     lw->bar_exif_advanced, lw->utility_box);
1733         g_signal_connect(G_OBJECT(lw->bar_exif), "destroy",
1734                          G_CALLBACK(layout_bar_exif_destroyed), lw);
1735         g_signal_connect(G_OBJECT(lw->bar_exif), "size_allocate",
1736                          G_CALLBACK(layout_bar_exif_sized), lw);
1737         lw->bar_exif_enabled = TRUE;
1738
1739         if (lw->bar_exif_size < 1) lw->bar_exif_size = SIDEBAR_WIDTH;
1740         gtk_widget_set_size_request(lw->bar_exif, lw->bar_exif_size, -1);
1741         gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar_exif, FALSE, FALSE, 0);
1742         if (lw->bar_info) gtk_box_reorder_child(GTK_BOX(lw->utility_box), lw->bar_exif, 1);
1743         gtk_widget_show(lw->bar_exif);
1744 }
1745
1746 static void layout_bar_exif_close(LayoutWindow *lw)
1747 {
1748         if (lw->bar_exif)
1749                 {
1750                 bar_exif_close(lw->bar_exif);
1751                 lw->bar_exif = NULL;
1752                 }
1753         lw->bar_exif_enabled = FALSE;
1754 }
1755
1756 void layout_bar_exif_toggle(LayoutWindow *lw)
1757 {
1758         if (lw->bar_exif_enabled)
1759                 {
1760                 layout_bar_exif_close(lw);
1761                 }
1762         else
1763                 {
1764                 layout_bar_exif_new(lw);
1765                 }
1766 }
1767
1768 static void layout_bar_exif_new_image(LayoutWindow *lw)
1769 {
1770         if (!lw->bar_exif || !lw->bar_exif_enabled) return;
1771
1772         bar_exif_set(lw->bar_exif, layout_image_get_fd(lw));
1773 }
1774
1775 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data)
1776 {
1777         LayoutWindow *lw = data;
1778
1779         lw->bar_sort = NULL;
1780
1781         if (lw->utility_box)
1782                 {
1783                 /* destroyed from within itself */
1784                 lw->bar_sort_enabled = FALSE;
1785
1786                 layout_util_sync_views(lw);
1787                 }
1788 }
1789
1790 static void layout_bar_sort_new(LayoutWindow *lw)
1791 {
1792         if (!lw->utility_box) return;
1793
1794         lw->bar_sort = bar_sort_new(lw);
1795         g_signal_connect(G_OBJECT(lw->bar_sort), "destroy",
1796                          G_CALLBACK(layout_bar_sort_destroyed), lw);
1797         lw->bar_sort_enabled = TRUE;
1798
1799         gtk_box_pack_end(GTK_BOX(lw->utility_box), lw->bar_sort, FALSE, FALSE, 0);
1800         gtk_widget_show(lw->bar_sort);
1801 }
1802
1803 static void layout_bar_sort_close(LayoutWindow *lw)
1804 {
1805         if (lw->bar_sort)
1806                 {
1807                 bar_sort_close(lw->bar_sort);
1808                 lw->bar_sort = NULL;
1809                 }
1810         lw->bar_sort_enabled = FALSE;
1811 }
1812
1813 void layout_bar_sort_toggle(LayoutWindow *lw)
1814 {
1815         if (lw->bar_sort_enabled)
1816                 {
1817                 layout_bar_sort_close(lw);
1818                 }
1819         else
1820                 {
1821                 layout_bar_sort_new(lw);
1822                 }
1823 }
1824
1825 void layout_bars_new_image(LayoutWindow *lw)
1826 {
1827         layout_bar_info_new_image(lw);
1828         layout_bar_exif_new_image(lw);
1829 }
1830
1831 void layout_bars_new_selection(LayoutWindow *lw, gint count)
1832 {
1833         layout_bar_info_new_selection(lw, count);
1834 }
1835
1836 GtkWidget *layout_bars_prepare(LayoutWindow *lw, GtkWidget *image)
1837 {
1838         lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP);
1839         gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0);
1840         gtk_widget_show(image);
1841
1842         if (lw->bar_sort_enabled)
1843                 {
1844                 layout_bar_sort_new(lw);
1845                 }
1846
1847         if (lw->bar_info_enabled)
1848                 {
1849                 layout_bar_info_new(lw);
1850                 }
1851
1852         if (lw->bar_exif_enabled)
1853                 {
1854                 layout_bar_exif_new(lw);
1855                 }
1856
1857         return lw->utility_box;
1858 }
1859
1860 void layout_bars_close(LayoutWindow *lw)
1861 {
1862         layout_bar_sort_close(lw);
1863         layout_bar_exif_close(lw);
1864         layout_bar_info_close(lw);
1865 }
1866
1867 void layout_bars_maint_renamed(LayoutWindow *lw)
1868 {
1869         layout_bar_info_maint_renamed(lw);
1870 }
1871