4 * Copyright (C) 2008 - 2010 The Geeqie Team
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!
15 #include "layout_util.h"
17 #include "advanced_exif.h"
20 #include "cache_maint.h"
22 #include "collect-dlg.h"
24 #include "color-man.h"
28 #include "history_list.h"
29 #include "image-overlay.h"
30 #include "histogram.h"
32 #include "layout_image.h"
33 #include "logwindow.h"
36 #include "pixbuf_util.h"
37 #include "preferences.h"
40 #include "ui_fileops.h"
43 #include "ui_tabcomp.h"
49 #include "desktop_file.h"
51 #include <gdk/gdkkeysyms.h> /* for keyboard values */
54 #define MENU_EDIT_ACTION_OFFSET 16
56 static gboolean layout_bar_enabled(LayoutWindow *lw);
57 static gboolean layout_bar_sort_enabled(LayoutWindow *lw);
58 static void layout_util_sync_views(LayoutWindow *lw);
61 *-----------------------------------------------------------------------------
63 *-----------------------------------------------------------------------------
66 static guint tree_key_overrides[] = {
67 GDK_Page_Up, GDK_KP_Page_Up,
68 GDK_Page_Down, GDK_KP_Page_Down,
69 GDK_Home, GDK_KP_Home,
73 static gboolean layout_key_match(guint keyval)
77 for (i = 0; i < sizeof(tree_key_overrides) / sizeof(guint); i++)
79 if (keyval == tree_key_overrides[i]) return TRUE;
85 gboolean layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
87 LayoutWindow *lw = data;
88 gboolean stop_signal = FALSE;
92 #if GTK_CHECK_VERSION(2,20,0)
93 if (lw->path_entry && gtk_widget_has_focus(lw->path_entry))
95 if (lw->path_entry && GTK_WIDGET_HAS_FOCUS(lw->path_entry))
98 if (event->keyval == GDK_Escape && lw->dir_fd)
100 gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path);
103 /* the gtkaccelgroup of the window is stealing presses before they get to the entry (and more),
104 * so when the some widgets have focus, give them priority (HACK)
106 if (gtk_widget_event(lw->path_entry, (GdkEvent *)event))
111 #if GTK_CHECK_VERSION(2,20,0)
112 if (lw->vd && lw->options.dir_view_type == DIRVIEW_TREE && gtk_widget_has_focus(lw->vd->view) &&
114 if (lw->vd && lw->options.dir_view_type == DIRVIEW_TREE && GTK_WIDGET_HAS_FOCUS(lw->vd->view) &&
116 !layout_key_match(event->keyval) &&
117 gtk_widget_event(lw->vd->view, (GdkEvent *)event))
122 bar_event(lw->bar, (GdkEvent *)event))
128 if (event->type == GDK_KEY_PRESS && lw->full_screen &&
129 gtk_accel_groups_activate(G_OBJECT(lw->window), event->keyval, event->state))
134 #if GTK_CHECK_VERSION(2,20,0)
135 (gtk_widget_has_focus(lw->image->widget) || (lw->tools && widget == lw->window) || lw->full_screen) )
137 (GTK_WIDGET_HAS_FOCUS(lw->image->widget) || (lw->tools && widget == lw->window) || lw->full_screen) )
141 switch (event->keyval)
143 case GDK_Left: case GDK_KP_Left:
146 case GDK_Right: case GDK_KP_Right:
149 case GDK_Up: case GDK_KP_Up:
152 case GDK_Down: case GDK_KP_Down:
161 !(event->state & GDK_CONTROL_MASK))
164 switch (event->keyval)
167 layout_image_menu_popup(lw);
178 keyboard_scroll_calc(&x, &y, event);
179 layout_image_scroll(lw, x, y, (event->state & GDK_SHIFT_MASK));
185 void layout_keyboard_init(LayoutWindow *lw, GtkWidget *window)
187 g_signal_connect(G_OBJECT(window), "key_press_event",
188 G_CALLBACK(layout_key_press_cb), lw);
192 *-----------------------------------------------------------------------------
194 *-----------------------------------------------------------------------------
198 static GtkWidget *layout_window(LayoutWindow *lw)
200 return lw->full_screen ? lw->full_screen->window : lw->window;
203 static void layout_exit_fullscreen(LayoutWindow *lw)
205 if (!lw->full_screen) return;
206 layout_image_full_screen_stop(lw);
209 static void layout_menu_new_window_cb(GtkAction *action, gpointer data)
211 LayoutWindow *lw = data;
214 gboolean tmp = options->save_window_positions;
215 options->save_window_positions = FALSE; /* let the windowmanager decide for the first time */
217 layout_exit_fullscreen(lw);
219 layout_sync_options_with_current_state(lw);
220 lop = lw->options; /* we can copy it directly, no strings are modified */
222 lop.id = NULL; /* get a new id */
223 nw = layout_new(NULL, &lop);
224 layout_sort_set(nw, options->file_sort.method, options->file_sort.ascending);
225 layout_set_fd(nw, lw->dir_fd);
226 options->save_window_positions = tmp;
229 static void layout_menu_new_cb(GtkAction *action, gpointer data)
231 LayoutWindow *lw = data;
233 layout_exit_fullscreen(lw);
234 collection_window_new(NULL);
237 static void layout_menu_open_cb(GtkAction *action, gpointer data)
239 LayoutWindow *lw = data;
241 layout_exit_fullscreen(lw);
242 collection_dialog_load(NULL);
245 static void layout_menu_search_cb(GtkAction *action, gpointer data)
247 LayoutWindow *lw = data;
249 layout_exit_fullscreen(lw);
250 search_new(lw->dir_fd, layout_image_get_fd(lw));
253 static void layout_menu_dupes_cb(GtkAction *action, gpointer data)
255 LayoutWindow *lw = data;
257 layout_exit_fullscreen(lw);
258 dupe_window_new(DUPE_MATCH_NAME);
261 static void layout_menu_pan_cb(GtkAction *action, gpointer data)
263 LayoutWindow *lw = data;
265 layout_exit_fullscreen(lw);
266 pan_window_new(lw->dir_fd);
269 static void layout_menu_print_cb(GtkAction *action, gpointer data)
271 LayoutWindow *lw = data;
273 print_window_new(layout_image_get_fd(lw), layout_selection_list(lw), layout_list(lw), layout_window(lw));
276 static void layout_menu_dir_cb(GtkAction *action, gpointer data)
278 LayoutWindow *lw = data;
280 if (lw->vd) vd_new_folder(lw->vd, lw->dir_fd);
283 static void layout_menu_copy_cb(GtkAction *action, gpointer data)
285 LayoutWindow *lw = data;
287 file_util_copy(NULL, layout_selection_list(lw), NULL, layout_window(lw));
290 static void layout_menu_copy_path_cb(GtkAction *action, gpointer data)
292 LayoutWindow *lw = data;
294 file_util_copy_path_list_to_clipboard(layout_selection_list(lw));
297 static void layout_menu_move_cb(GtkAction *action, gpointer data)
299 LayoutWindow *lw = data;
301 file_util_move(NULL, layout_selection_list(lw), NULL, layout_window(lw));
304 static void layout_menu_rename_cb(GtkAction *action, gpointer data)
306 LayoutWindow *lw = data;
308 file_util_rename(NULL, layout_selection_list(lw), layout_window(lw));
311 static void layout_menu_delete_cb(GtkAction *action, gpointer data)
313 LayoutWindow *lw = data;
315 file_util_delete(NULL, layout_selection_list(lw), layout_window(lw));
318 static void layout_menu_disable_grouping_cb(GtkAction *action, gpointer data)
320 LayoutWindow *lw = data;
322 file_data_disable_grouping_list(layout_selection_list(lw), TRUE);
325 static void layout_menu_enable_grouping_cb(GtkAction *action, gpointer data)
327 LayoutWindow *lw = data;
329 file_data_disable_grouping_list(layout_selection_list(lw), FALSE);
332 static void layout_menu_close_cb(GtkAction *action, gpointer data)
334 LayoutWindow *lw = data;
336 layout_exit_fullscreen(lw);
340 static void layout_menu_exit_cb(GtkAction *action, gpointer data)
345 static void layout_menu_alter_90_cb(GtkAction *action, gpointer data)
347 LayoutWindow *lw = data;
349 layout_image_alter_orientation(lw, ALTER_ROTATE_90);
352 static void layout_menu_alter_90cc_cb(GtkAction *action, gpointer data)
354 LayoutWindow *lw = data;
356 layout_image_alter_orientation(lw, ALTER_ROTATE_90_CC);
359 static void layout_menu_alter_180_cb(GtkAction *action, gpointer data)
361 LayoutWindow *lw = data;
363 layout_image_alter_orientation(lw, ALTER_ROTATE_180);
366 static void layout_menu_alter_mirror_cb(GtkAction *action, gpointer data)
368 LayoutWindow *lw = data;
370 layout_image_alter_orientation(lw, ALTER_MIRROR);
373 static void layout_menu_alter_flip_cb(GtkAction *action, gpointer data)
375 LayoutWindow *lw = data;
377 layout_image_alter_orientation(lw, ALTER_FLIP);
380 static void layout_menu_alter_desaturate_cb(GtkToggleAction *action, gpointer data)
382 LayoutWindow *lw = data;
384 layout_image_set_desaturate(lw, gtk_toggle_action_get_active(action));
387 static void layout_menu_alter_none_cb(GtkAction *action, gpointer data)
389 LayoutWindow *lw = data;
391 layout_image_alter_orientation(lw, ALTER_NONE);
394 static void layout_menu_config_cb(GtkAction *action, gpointer data)
396 LayoutWindow *lw = data;
398 layout_exit_fullscreen(lw);
399 show_config_window();
402 static void layout_menu_editors_cb(GtkAction *action, gpointer data)
404 LayoutWindow *lw = data;
406 layout_exit_fullscreen(lw);
407 show_editor_list_window();
410 static void layout_menu_layout_config_cb(GtkAction *action, gpointer data)
412 LayoutWindow *lw = data;
414 layout_exit_fullscreen(lw);
415 layout_show_config_window(lw);
418 static void layout_menu_remove_thumb_cb(GtkAction *action, gpointer data)
420 LayoutWindow *lw = data;
422 layout_exit_fullscreen(lw);
423 cache_manager_show();
426 static void layout_menu_wallpaper_cb(GtkAction *action, gpointer data)
428 LayoutWindow *lw = data;
430 layout_image_to_root(lw);
433 /* single window zoom */
434 static void layout_menu_zoom_in_cb(GtkAction *action, gpointer data)
436 LayoutWindow *lw = data;
438 layout_image_zoom_adjust(lw, get_zoom_increment(), FALSE);
441 static void layout_menu_zoom_out_cb(GtkAction *action, gpointer data)
443 LayoutWindow *lw = data;
445 layout_image_zoom_adjust(lw, -get_zoom_increment(), FALSE);
448 static void layout_menu_zoom_1_1_cb(GtkAction *action, gpointer data)
450 LayoutWindow *lw = data;
452 layout_image_zoom_set(lw, 1.0, FALSE);
455 static void layout_menu_zoom_fit_cb(GtkAction *action, gpointer data)
457 LayoutWindow *lw = data;
459 layout_image_zoom_set(lw, 0.0, FALSE);
462 static void layout_menu_zoom_fit_hor_cb(GtkAction *action, gpointer data)
464 LayoutWindow *lw = data;
466 layout_image_zoom_set_fill_geometry(lw, FALSE, FALSE);
469 static void layout_menu_zoom_fit_vert_cb(GtkAction *action, gpointer data)
471 LayoutWindow *lw = data;
473 layout_image_zoom_set_fill_geometry(lw, TRUE, FALSE);
476 static void layout_menu_zoom_2_1_cb(GtkAction *action, gpointer data)
478 LayoutWindow *lw = data;
480 layout_image_zoom_set(lw, 2.0, FALSE);
483 static void layout_menu_zoom_3_1_cb(GtkAction *action, gpointer data)
485 LayoutWindow *lw = data;
487 layout_image_zoom_set(lw, 3.0, FALSE);
489 static void layout_menu_zoom_4_1_cb(GtkAction *action, gpointer data)
491 LayoutWindow *lw = data;
493 layout_image_zoom_set(lw, 4.0, FALSE);
496 static void layout_menu_zoom_1_2_cb(GtkAction *action, gpointer data)
498 LayoutWindow *lw = data;
500 layout_image_zoom_set(lw, -2.0, FALSE);
503 static void layout_menu_zoom_1_3_cb(GtkAction *action, gpointer data)
505 LayoutWindow *lw = data;
507 layout_image_zoom_set(lw, -3.0, FALSE);
510 static void layout_menu_zoom_1_4_cb(GtkAction *action, gpointer data)
512 LayoutWindow *lw = data;
514 layout_image_zoom_set(lw, -4.0, FALSE);
518 static void layout_menu_connect_zoom_in_cb(GtkAction *action, gpointer data)
520 LayoutWindow *lw = data;
522 layout_image_zoom_adjust(lw, get_zoom_increment(), TRUE);
525 static void layout_menu_connect_zoom_out_cb(GtkAction *action, gpointer data)
527 LayoutWindow *lw = data;
529 layout_image_zoom_adjust(lw, -get_zoom_increment(), TRUE);
532 static void layout_menu_connect_zoom_1_1_cb(GtkAction *action, gpointer data)
534 LayoutWindow *lw = data;
536 layout_image_zoom_set(lw, 1.0, TRUE);
539 static void layout_menu_connect_zoom_fit_cb(GtkAction *action, gpointer data)
541 LayoutWindow *lw = data;
543 layout_image_zoom_set(lw, 0.0, TRUE);
546 static void layout_menu_connect_zoom_fit_hor_cb(GtkAction *action, gpointer data)
548 LayoutWindow *lw = data;
550 layout_image_zoom_set_fill_geometry(lw, FALSE, TRUE);
553 static void layout_menu_connect_zoom_fit_vert_cb(GtkAction *action, gpointer data)
555 LayoutWindow *lw = data;
557 layout_image_zoom_set_fill_geometry(lw, TRUE, TRUE);
560 static void layout_menu_connect_zoom_2_1_cb(GtkAction *action, gpointer data)
562 LayoutWindow *lw = data;
564 layout_image_zoom_set(lw, 2.0, TRUE);
567 static void layout_menu_connect_zoom_3_1_cb(GtkAction *action, gpointer data)
569 LayoutWindow *lw = data;
571 layout_image_zoom_set(lw, 3.0, TRUE);
573 static void layout_menu_connect_zoom_4_1_cb(GtkAction *action, gpointer data)
575 LayoutWindow *lw = data;
577 layout_image_zoom_set(lw, 4.0, TRUE);
580 static void layout_menu_connect_zoom_1_2_cb(GtkAction *action, gpointer data)
582 LayoutWindow *lw = data;
584 layout_image_zoom_set(lw, -2.0, TRUE);
587 static void layout_menu_connect_zoom_1_3_cb(GtkAction *action, gpointer data)
589 LayoutWindow *lw = data;
591 layout_image_zoom_set(lw, -3.0, TRUE);
594 static void layout_menu_connect_zoom_1_4_cb(GtkAction *action, gpointer data)
596 LayoutWindow *lw = data;
598 layout_image_zoom_set(lw, -4.0, TRUE);
602 static void layout_menu_split_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
604 LayoutWindow *lw = data;
607 layout_exit_fullscreen(lw);
608 mode = gtk_radio_action_get_current_value(action);
609 layout_split_change(lw, mode);
613 static void layout_menu_thumb_cb(GtkToggleAction *action, gpointer data)
615 LayoutWindow *lw = data;
617 layout_thumb_set(lw, gtk_toggle_action_get_active(action));
621 static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
623 LayoutWindow *lw = data;
625 layout_exit_fullscreen(lw);
626 layout_views_set(lw, lw->options.dir_view_type, (FileViewType) gtk_radio_action_get_current_value(action));
629 static void layout_menu_view_dir_as_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
631 LayoutWindow *lw = data;
633 layout_exit_fullscreen(lw);
634 layout_views_set(lw, (DirViewType) gtk_radio_action_get_current_value(action), lw->options.file_view_type);
637 static void layout_menu_view_in_new_window_cb(GtkAction *action, gpointer data)
639 LayoutWindow *lw = data;
641 layout_exit_fullscreen(lw);
642 view_window_new(layout_image_get_fd(lw));
645 static void layout_menu_fullscreen_cb(GtkAction *action, gpointer data)
647 LayoutWindow *lw = data;
649 layout_image_full_screen_toggle(lw);
652 static void layout_menu_escape_cb(GtkAction *action, gpointer data)
654 LayoutWindow *lw = data;
656 layout_exit_fullscreen(lw);
658 /* FIXME:interrupting thumbs no longer allowed */
664 static void layout_menu_overlay_toggle_cb(GtkAction *action, gpointer data)
666 LayoutWindow *lw = data;
668 image_osd_toggle(lw->image);
669 layout_util_sync_views(lw);
673 static void layout_menu_overlay_cb(GtkToggleAction *action, gpointer data)
675 LayoutWindow *lw = data;
677 if (gtk_toggle_action_get_active(action))
679 OsdShowFlags flags = image_osd_get(lw->image);
681 if ((flags | OSD_SHOW_INFO | OSD_SHOW_STATUS) != flags)
682 image_osd_set(lw->image, flags | OSD_SHOW_INFO | OSD_SHOW_STATUS);
686 GtkToggleAction *histogram_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(lw->action_group, "ImageHistogram"));
688 image_osd_set(lw->image, OSD_SHOW_NOTHING);
689 gtk_toggle_action_set_active(histogram_action, FALSE); /* this calls layout_menu_histogram_cb */
693 static void layout_menu_histogram_cb(GtkToggleAction *action, gpointer data)
695 LayoutWindow *lw = data;
697 if (gtk_toggle_action_get_active(action))
699 image_osd_set(lw->image, OSD_SHOW_INFO | OSD_SHOW_STATUS | OSD_SHOW_HISTOGRAM);
700 layout_util_sync_views(lw); /* show the overlay state, default channel and mode in the menu */
704 OsdShowFlags flags = image_osd_get(lw->image);
705 if (flags & OSD_SHOW_HISTOGRAM)
706 image_osd_set(lw->image, flags & ~OSD_SHOW_HISTOGRAM);
710 static void layout_menu_histogram_toggle_channel_cb(GtkAction *action, gpointer data)
712 LayoutWindow *lw = data;
714 image_osd_histogram_toggle_channel(lw->image);
715 layout_util_sync_views(lw);
718 static void layout_menu_histogram_toggle_mode_cb(GtkAction *action, gpointer data)
720 LayoutWindow *lw = data;
722 image_osd_histogram_toggle_mode(lw->image);
723 layout_util_sync_views(lw);
726 static void layout_menu_histogram_channel_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
728 LayoutWindow *lw = data;
729 gint channel = gtk_radio_action_get_current_value(action);
730 GtkToggleAction *histogram_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(lw->action_group, "ImageHistogram"));
732 if (channel < 0 || channel >= HCHAN_COUNT) return;
734 gtk_toggle_action_set_active(histogram_action, TRUE); /* this calls layout_menu_histogram_cb */
735 image_osd_histogram_set_channel(lw->image, channel);
738 static void layout_menu_histogram_mode_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
740 LayoutWindow *lw = data;
741 gint mode = gtk_radio_action_get_current_value(action);
742 GtkToggleAction *histogram_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(lw->action_group, "ImageHistogram"));
744 if (mode < 0 || mode > 1) return;
746 gtk_toggle_action_set_active(histogram_action, TRUE); /* this calls layout_menu_histogram_cb */
747 image_osd_histogram_set_mode(lw->image, mode);
750 static void layout_menu_refresh_cb(GtkAction *action, gpointer data)
752 LayoutWindow *lw = data;
757 static void layout_menu_bar_exif_cb(GtkAction *action, gpointer data)
759 LayoutWindow *lw = data;
761 layout_exit_fullscreen(lw);
762 layout_exif_window_new(lw);
765 static void layout_menu_float_cb(GtkToggleAction *action, gpointer data)
767 LayoutWindow *lw = data;
769 if (lw->options.tools_float == gtk_toggle_action_get_active(action)) return;
771 layout_exit_fullscreen(lw);
772 layout_tools_float_toggle(lw);
775 static void layout_menu_hide_cb(GtkAction *action, gpointer data)
777 LayoutWindow *lw = data;
779 layout_exit_fullscreen(lw);
780 layout_tools_hide_toggle(lw);
783 static void layout_menu_toolbar_cb(GtkToggleAction *action, gpointer data)
785 LayoutWindow *lw = data;
787 if (lw->options.toolbar_hidden == gtk_toggle_action_get_active(action)) return;
789 layout_exit_fullscreen(lw);
790 layout_toolbar_toggle(lw);
793 static void layout_menu_info_pixel_cb(GtkToggleAction *action, gpointer data)
795 LayoutWindow *lw = data;
797 if (lw->options.show_info_pixel == gtk_toggle_action_get_active(action)) return;
799 layout_exit_fullscreen(lw);
800 layout_info_pixel_set(lw, !lw->options.show_info_pixel);
803 /* NOTE: these callbacks are called also from layout_util_sync_views */
804 static void layout_menu_bar_cb(GtkToggleAction *action, gpointer data)
806 LayoutWindow *lw = data;
808 if (layout_bar_enabled(lw) == gtk_toggle_action_get_active(action)) return;
810 layout_exit_fullscreen(lw);
811 layout_bar_toggle(lw);
814 static void layout_menu_bar_sort_cb(GtkToggleAction *action, gpointer data)
816 LayoutWindow *lw = data;
818 if (layout_bar_sort_enabled(lw) == gtk_toggle_action_get_active(action)) return;
820 layout_exit_fullscreen(lw);
821 layout_bar_sort_toggle(lw);
824 static void layout_menu_slideshow_cb(GtkToggleAction *action, gpointer data)
826 LayoutWindow *lw = data;
828 if (layout_image_slideshow_active(lw) == gtk_toggle_action_get_active(action)) return;
829 layout_image_slideshow_toggle(lw);
832 static void layout_menu_slideshow_pause_cb(GtkAction *action, gpointer data)
834 LayoutWindow *lw = data;
836 layout_image_slideshow_pause_toggle(lw);
839 static void layout_menu_stereo_swap_cb(GtkAction *action, gpointer data)
841 LayoutWindow *lw = data;
843 layout_image_stereo_swap(lw);
846 static void layout_menu_stereo_mode_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
848 LayoutWindow *lw = data;
849 gint mode = gtk_radio_action_get_current_value(action);
850 layout_image_stereo_set(lw, (layout_image_stereo_get(lw) & ~(PR_STEREO_ANAGLYPH | PR_STEREO_HORIZ | PR_STEREO_VERT)) | mode);
856 static void layout_menu_help_cb(GtkAction *action, gpointer data)
858 LayoutWindow *lw = data;
860 layout_exit_fullscreen(lw);
861 help_window_show("html_contents");
864 static void layout_menu_help_keys_cb(GtkAction *action, gpointer data)
866 LayoutWindow *lw = data;
868 layout_exit_fullscreen(lw);
869 help_window_show("documentation");
872 static void layout_menu_notes_cb(GtkAction *action, gpointer data)
874 LayoutWindow *lw = data;
876 layout_exit_fullscreen(lw);
877 help_window_show("release_notes");
880 static void layout_menu_about_cb(GtkAction *action, gpointer data)
882 LayoutWindow *lw = data;
884 layout_exit_fullscreen(lw);
888 static void layout_menu_log_window_cb(GtkAction *action, gpointer data)
890 LayoutWindow *lw = data;
892 layout_exit_fullscreen(lw);
898 *-----------------------------------------------------------------------------
900 *-----------------------------------------------------------------------------
903 static void layout_menu_select_all_cb(GtkAction *action, gpointer data)
905 LayoutWindow *lw = data;
907 layout_select_all(lw);
910 static void layout_menu_unselect_all_cb(GtkAction *action, gpointer data)
912 LayoutWindow *lw = data;
914 layout_select_none(lw);
917 static void layout_menu_invert_selection_cb(GtkAction *action, gpointer data)
919 LayoutWindow *lw = data;
921 layout_select_invert(lw);
924 static void layout_menu_marks_cb(GtkToggleAction *action, gpointer data)
926 LayoutWindow *lw = data;
928 layout_marks_set(lw, gtk_toggle_action_get_active(action));
932 static void layout_menu_set_mark_sel_cb(GtkAction *action, gpointer data)
934 LayoutWindow *lw = data;
935 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
936 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
938 layout_selection_to_mark(lw, mark, STM_MODE_SET);
941 static void layout_menu_res_mark_sel_cb(GtkAction *action, gpointer data)
943 LayoutWindow *lw = data;
944 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
945 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
947 layout_selection_to_mark(lw, mark, STM_MODE_RESET);
950 static void layout_menu_toggle_mark_sel_cb(GtkAction *action, gpointer data)
952 LayoutWindow *lw = data;
953 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
954 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
956 layout_selection_to_mark(lw, mark, STM_MODE_TOGGLE);
959 static void layout_menu_sel_mark_cb(GtkAction *action, gpointer data)
961 LayoutWindow *lw = data;
962 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
963 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
965 layout_mark_to_selection(lw, mark, MTS_MODE_SET);
968 static void layout_menu_sel_mark_or_cb(GtkAction *action, gpointer data)
970 LayoutWindow *lw = data;
971 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
972 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
974 layout_mark_to_selection(lw, mark, MTS_MODE_OR);
977 static void layout_menu_sel_mark_and_cb(GtkAction *action, gpointer data)
979 LayoutWindow *lw = data;
980 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
981 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
983 layout_mark_to_selection(lw, mark, MTS_MODE_AND);
986 static void layout_menu_sel_mark_minus_cb(GtkAction *action, gpointer data)
988 LayoutWindow *lw = data;
989 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
990 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
992 layout_mark_to_selection(lw, mark, MTS_MODE_MINUS);
995 static void layout_menu_mark_filter_toggle_cb(GtkAction *action, gpointer data)
997 LayoutWindow *lw = data;
998 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "mark_num"));
999 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
1001 layout_marks_set(lw, TRUE);
1002 layout_mark_filter_toggle(lw, mark);
1007 *-----------------------------------------------------------------------------
1009 *-----------------------------------------------------------------------------
1012 static void layout_menu_image_first_cb(GtkAction *action, gpointer data)
1014 LayoutWindow *lw = data;
1015 layout_image_first(lw);
1018 static void layout_menu_image_prev_cb(GtkAction *action, gpointer data)
1020 LayoutWindow *lw = data;
1021 layout_image_prev(lw);
1024 static void layout_menu_image_next_cb(GtkAction *action, gpointer data)
1026 LayoutWindow *lw = data;
1027 layout_image_next(lw);
1030 static void layout_menu_image_last_cb(GtkAction *action, gpointer data)
1032 LayoutWindow *lw = data;
1033 layout_image_last(lw);
1036 static void layout_menu_back_cb(GtkAction *action, gpointer data)
1038 LayoutWindow *lw = data;
1041 GList *list = history_list_get_by_key("path_list");
1047 /* Previous path from history */
1048 path = (gchar *)list->data;
1057 /* Open previous path */
1058 dir_fd = file_data_new_simple(path);
1059 layout_set_fd(lw, dir_fd);
1060 file_data_unref(dir_fd);
1063 static void layout_menu_home_cb(GtkAction *action, gpointer data)
1065 LayoutWindow *lw = data;
1068 if (lw->options.home_path && *lw->options.home_path)
1069 path = lw->options.home_path;
1075 FileData *dir_fd = file_data_new_simple(path);
1076 layout_set_fd(lw, dir_fd);
1077 file_data_unref(dir_fd);
1083 *-----------------------------------------------------------------------------
1085 *-----------------------------------------------------------------------------
1088 static void layout_menu_edit_cb(GtkAction *action, gpointer data)
1090 LayoutWindow *lw = data;
1091 const gchar *key = gtk_action_get_name(action);
1093 if (!editor_window_flag_set(key))
1094 layout_exit_fullscreen(lw);
1096 file_util_start_editor_from_filelist(key, layout_selection_list(lw), layout_get_path(lw), lw->window);
1100 static void layout_menu_metadata_write_cb(GtkAction *action, gpointer data)
1102 metadata_write_queue_confirm(TRUE, NULL, NULL);
1107 *-----------------------------------------------------------------------------
1108 * color profile button (and menu)
1109 *-----------------------------------------------------------------------------
1112 static void layout_color_menu_enable_cb(GtkToggleAction *action, gpointer data)
1115 LayoutWindow *lw = data;
1117 if (layout_image_color_profile_get_use(lw) == gtk_toggle_action_get_active(action)) return;
1119 layout_image_color_profile_set_use(lw, gtk_toggle_action_get_active(action));
1120 layout_util_sync_color(lw);
1121 layout_image_refresh(lw);
1125 static void layout_color_menu_use_image_cb(GtkToggleAction *action, gpointer data)
1128 LayoutWindow *lw = data;
1132 if (!layout_image_color_profile_get(lw, &input, &use_image)) return;
1133 if (use_image == gtk_toggle_action_get_active(action)) return;
1134 layout_image_color_profile_set(lw, input, gtk_toggle_action_get_active(action));
1135 layout_util_sync_color(lw);
1136 layout_image_refresh(lw);
1140 static void layout_color_menu_input_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
1143 LayoutWindow *lw = data;
1148 type = gtk_radio_action_get_current_value(action);
1149 if (type < 0 || type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) return;
1151 if (!layout_image_color_profile_get(lw, &input, &use_image)) return;
1152 if (type == input) return;
1154 layout_image_color_profile_set(lw, type, use_image);
1155 layout_image_refresh(lw);
1161 *-----------------------------------------------------------------------------
1163 *-----------------------------------------------------------------------------
1166 static void layout_menu_recent_cb(GtkWidget *widget, gpointer data)
1171 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "recent_index"));
1173 path = g_list_nth_data(history_list_get_by_key("recent"), n);
1177 /* make a copy of it */
1178 path = g_strdup(path);
1179 collection_window_new(path);
1183 static void layout_menu_recent_update(LayoutWindow *lw)
1191 if (!lw->ui_manager) return;
1193 list = history_list_get_by_key("recent");
1196 menu = gtk_menu_new();
1200 const gchar *filename = filename_from_path((gchar *)list->data);
1202 gboolean free_name = FALSE;
1204 if (file_extension_match(filename, GQ_COLLECTION_EXT))
1206 name = remove_extension_from_path(filename);
1211 name = (gchar *) filename;
1214 item = menu_item_add_simple(menu, name, G_CALLBACK(layout_menu_recent_cb), lw);
1215 if (free_name) g_free(name);
1216 g_object_set_data(G_OBJECT(item), "recent_index", GINT_TO_POINTER(n));
1223 menu_item_add(menu, _("Empty"), NULL, NULL);
1226 recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/FileMenu/OpenRecent");
1227 gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu);
1228 gtk_widget_set_sensitive(recent, (n != 0));
1231 void layout_recent_update_all(void)
1235 work = layout_window_list;
1238 LayoutWindow *lw = work->data;
1241 layout_menu_recent_update(lw);
1245 void layout_recent_add_path(const gchar *path)
1249 history_list_add_to_key("recent", path, options->open_recent_list_maxsize);
1251 layout_recent_update_all();
1255 *-----------------------------------------------------------------------------
1257 *-----------------------------------------------------------------------------
1260 #define CB G_CALLBACK
1262 static GtkActionEntry menu_entries[] = {
1263 { "FileMenu", NULL, N_("_File"), NULL, NULL, NULL },
1264 { "GoMenu", NULL, N_("_Go"), NULL, NULL, NULL },
1265 { "EditMenu", NULL, N_("_Edit"), NULL, NULL, NULL },
1266 { "SelectMenu", NULL, N_("_Select"), NULL, NULL, NULL },
1267 { "OrientationMenu", NULL, N_("_Orientation"), NULL, NULL, NULL },
1268 { "ExternalMenu", NULL, N_("E_xternal Editors"), NULL, NULL, NULL },
1269 { "PreferencesMenu", NULL, N_("P_references"), NULL, NULL, NULL },
1270 { "ViewMenu", NULL, N_("_View"), NULL, NULL, NULL },
1271 { "FileDirMenu", NULL, N_("_Files and Folders"), NULL, NULL, NULL },
1272 { "ZoomMenu", NULL, N_("_Zoom"), NULL, NULL, NULL },
1273 { "ColorMenu", NULL, N_("_Color Management"), NULL, NULL, NULL },
1274 { "ConnectZoomMenu", NULL, N_("_Connected Zoom"), NULL, NULL, NULL },
1275 { "SplitMenu", NULL, N_("Spli_t"), NULL, NULL, NULL },
1276 { "StereoMenu", NULL, N_("Stere_o"), NULL, NULL, NULL },
1277 { "OverlayMenu", NULL, N_("Image _Overlay"), NULL, NULL, NULL },
1278 { "HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL },
1280 { "FirstImage", GTK_STOCK_GOTO_TOP, N_("_First Image"), "Home", N_("First Image"), CB(layout_menu_image_first_cb) },
1281 { "PrevImage", GTK_STOCK_GO_UP, N_("_Previous Image"), "BackSpace", N_("Previous Image"), CB(layout_menu_image_prev_cb) },
1282 { "PrevImageAlt1", GTK_STOCK_GO_UP, N_("_Previous Image"), "Page_Up", N_("Previous Image"), CB(layout_menu_image_prev_cb) },
1283 { "PrevImageAlt2", GTK_STOCK_GO_UP, N_("_Previous Image"), "KP_Page_Up", N_("Previous Image"), CB(layout_menu_image_prev_cb) },
1284 { "NextImage", GTK_STOCK_GO_DOWN, N_("_Next Image"), "space", N_("Next Image"), CB(layout_menu_image_next_cb) },
1285 { "NextImageAlt1", GTK_STOCK_GO_DOWN, N_("_Next Image"), "Page_Down", N_("Next Image"), CB(layout_menu_image_next_cb) },
1286 { "NextImageAlt2", GTK_STOCK_GO_DOWN, N_("_Next Image"), "KP_Page_Down", N_("Next Image"), CB(layout_menu_image_next_cb) },
1287 { "LastImage", GTK_STOCK_GOTO_BOTTOM, N_("_Last Image"), "End", N_("Last Image"), CB(layout_menu_image_last_cb) },
1288 { "Back", GTK_STOCK_GO_BACK, N_("_Back"), NULL, N_("Back"), CB(layout_menu_back_cb) },
1289 { "Home", GTK_STOCK_HOME, N_("_Home"), NULL, N_("Home"), CB(layout_menu_home_cb) },
1291 { "NewWindow", GTK_STOCK_NEW, N_("New _window"), "<control>N", N_("New window"), CB(layout_menu_new_window_cb) },
1292 { "NewCollection", GTK_STOCK_INDEX, N_("_New collection"), "C", N_("New collection"), CB(layout_menu_new_cb) },
1293 { "OpenCollection", GTK_STOCK_OPEN, N_("_Open collection..."), "O", N_("Open collection..."), CB(layout_menu_open_cb) },
1294 { "OpenRecent", NULL, N_("Open recen_t"), NULL, N_("Open recent"), NULL },
1295 { "Search", GTK_STOCK_FIND, N_("_Search..."), "F3", N_("Search..."), CB(layout_menu_search_cb) },
1296 { "FindDupes", GTK_STOCK_FIND, N_("_Find duplicates..."), "D", N_("Find duplicates..."), CB(layout_menu_dupes_cb) },
1297 { "PanView", NULL, N_("Pa_n view"), "<control>J", N_("Pan view"), CB(layout_menu_pan_cb) },
1298 { "Print", GTK_STOCK_PRINT, N_("_Print..."), "<shift>P", N_("Print..."), CB(layout_menu_print_cb) },
1299 { "NewFolder", GTK_STOCK_DIRECTORY, N_("N_ew folder..."), "<control>F", N_("New folder..."), CB(layout_menu_dir_cb) },
1300 { "Copy", GTK_STOCK_COPY, N_("_Copy..."), "<control>C", N_("Copy..."), CB(layout_menu_copy_cb) },
1301 { "Move", NULL, N_("_Move..."), "<control>M", N_("Move..."), CB(layout_menu_move_cb) },
1302 { "Rename", NULL, N_("_Rename..."), "<control>R", N_("Rename..."), CB(layout_menu_rename_cb) },
1303 { "Delete", GTK_STOCK_DELETE, N_("_Delete..."), "<control>D", N_("Delete..."), CB(layout_menu_delete_cb) },
1304 { "DeleteAlt1", GTK_STOCK_DELETE, N_("_Delete..."), "Delete", N_("Delete..."), CB(layout_menu_delete_cb) },
1305 { "DeleteAlt2", GTK_STOCK_DELETE, N_("_Delete..."), "KP_Delete", N_("Delete..."), CB(layout_menu_delete_cb) },
1306 { "EnableGrouping", NULL, N_("Enable file _grouping"), NULL, N_("Enable file grouping"), CB(layout_menu_enable_grouping_cb) },
1307 { "DisableGrouping", NULL, N_("Disable file groupi_ng"), NULL, N_("Disable file grouping"), CB(layout_menu_disable_grouping_cb) },
1308 { "CopyPath", NULL, N_("_Copy path to clipboard"), NULL, N_("Copy path to clipboard"), CB(layout_menu_copy_path_cb) },
1309 { "CloseWindow", GTK_STOCK_CLOSE, N_("C_lose window"), "<control>W", N_("Close window"), CB(layout_menu_close_cb) },
1310 { "Quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", N_("Quit"), CB(layout_menu_exit_cb) },
1311 { "RotateCW", NULL, N_("_Rotate clockwise"), "bracketright", N_("Rotate clockwise"), CB(layout_menu_alter_90_cb) },
1312 { "RotateCCW", NULL, N_("Rotate _counterclockwise"), "bracketleft", N_("Rotate counterclockwise"), CB(layout_menu_alter_90cc_cb) },
1313 { "Rotate180", NULL, N_("Rotate 1_80"), "<shift>R", N_("Rotate 180"), CB(layout_menu_alter_180_cb) },
1314 { "Mirror", NULL, N_("_Mirror"), "<shift>M", N_("Mirror"), CB(layout_menu_alter_mirror_cb) },
1315 { "Flip", NULL, N_("_Flip"), "<shift>F", N_("Flip"), CB(layout_menu_alter_flip_cb) },
1316 { "AlterNone", NULL, N_("_Original state"), "<shift>O", N_("Original state"), CB(layout_menu_alter_none_cb) },
1317 { "SelectAll", NULL, N_("Select _all"), "<control>A", N_("Select all"), CB(layout_menu_select_all_cb) },
1318 { "SelectNone", NULL, N_("Select _none"), "<control><shift>A", N_("Select none"), CB(layout_menu_unselect_all_cb) },
1319 { "SelectInvert", NULL, N_("_Invert Selection"), "<control><shift>I", N_("Invert Selection"), CB(layout_menu_invert_selection_cb) },
1320 { "Preferences", GTK_STOCK_PREFERENCES, N_("P_references..."), "<control>O", N_("Preferences..."), CB(layout_menu_config_cb) },
1321 { "Editors", GTK_STOCK_PREFERENCES, N_("Configure _Editors..."), NULL, N_("Configure Editors..."), CB(layout_menu_editors_cb) },
1322 { "LayoutConfig", GTK_STOCK_PREFERENCES, N_("_Configure this window..."), NULL, N_("Configure this window..."), CB(layout_menu_layout_config_cb) },
1323 { "Maintenance", NULL, N_("_Thumbnail maintenance..."), NULL, N_("Thumbnail maintenance..."), CB(layout_menu_remove_thumb_cb) },
1324 { "Wallpaper", NULL, N_("Set as _wallpaper"), NULL, N_("Set as wallpaper"), CB(layout_menu_wallpaper_cb) },
1325 { "SaveMetadata", GTK_STOCK_SAVE, N_("_Save metadata"), "<control>S", N_("Save metadata"), CB(layout_menu_metadata_write_cb) },
1326 { "ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "equal", N_("Zoom in"), CB(layout_menu_zoom_in_cb) },
1327 { "ZoomInAlt1", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "KP_Add", N_("Zoom in"), CB(layout_menu_zoom_in_cb) },
1328 { "ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "minus", N_("Zoom out"), CB(layout_menu_zoom_out_cb) },
1329 { "ZoomOutAlt1", GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "KP_Subtract", N_("Zoom out"), CB(layout_menu_zoom_out_cb) },
1330 { "Zoom100", GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "Z", N_("Zoom 1:1"), CB(layout_menu_zoom_1_1_cb) },
1331 { "Zoom100Alt1", GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "KP_Divide", N_("Zoom 1:1"), CB(layout_menu_zoom_1_1_cb) },
1332 { "ZoomFit", GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "X", N_("Zoom to fit"), CB(layout_menu_zoom_fit_cb) },
1333 { "ZoomFitAlt1", GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "KP_Multiply", N_("Zoom to fit"), CB(layout_menu_zoom_fit_cb) },
1334 { "ZoomFillHor", NULL, N_("Fit _Horizontally"), "H", N_("Fit Horizontally"), CB(layout_menu_zoom_fit_hor_cb) },
1335 { "ZoomFillVert", NULL, N_("Fit _Vertically"), "W", N_("Fit Vertically"), CB(layout_menu_zoom_fit_vert_cb) },
1336 { "Zoom200", NULL, N_("Zoom _2:1"), NULL, N_("Zoom 2:1"), CB(layout_menu_zoom_2_1_cb) },
1337 { "Zoom300", NULL, N_("Zoom _3:1"), NULL, N_("Zoom 3:1"), CB(layout_menu_zoom_3_1_cb) },
1338 { "Zoom400", NULL, N_("Zoom _4:1"), NULL, N_("Zoom 4:1"), CB(layout_menu_zoom_4_1_cb) },
1339 { "Zoom50", NULL, N_("Zoom 1:2"), NULL, N_("Zoom 1:2"), CB(layout_menu_zoom_1_2_cb) },
1340 { "Zoom33", NULL, N_("Zoom 1:3"), NULL, N_("Zoom 1:3"), CB(layout_menu_zoom_1_3_cb) },
1341 { "Zoom25", NULL, N_("Zoom 1:4"), NULL, N_("Zoom 1:4"), CB(layout_menu_zoom_1_4_cb) },
1342 { "ConnectZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "plus", N_("Connected Zoom in"), CB(layout_menu_connect_zoom_in_cb) },
1343 { "ConnectZoomInAlt1",GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "<shift>KP_Add", N_("Connected Zoom in"), CB(layout_menu_connect_zoom_in_cb) },
1344 { "ConnectZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "underscore", N_("Connected Zoom out"), CB(layout_menu_connect_zoom_out_cb) },
1345 { "ConnectZoomOutAlt1",GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "<shift>KP_Subtract", N_("Connected Zoom out"), CB(layout_menu_connect_zoom_out_cb) },
1346 { "ConnectZoom100", GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "<shift>Z", N_("Connected Zoom 1:1"), CB(layout_menu_connect_zoom_1_1_cb) },
1347 { "ConnectZoom100Alt1",GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "<shift>KP_Divide", N_("Connected Zoom 1:1"), CB(layout_menu_connect_zoom_1_1_cb) },
1348 { "ConnectZoomFit", GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "<shift>X", N_("Connected Zoom to fit"), CB(layout_menu_connect_zoom_fit_cb) },
1349 { "ConnectZoomFitAlt1",GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "<shift>KP_Multiply", N_("Connected Zoom to fit"), CB(layout_menu_connect_zoom_fit_cb) },
1350 { "ConnectZoomFillHor",NULL, N_("Fit _Horizontally"), "<shift>H", N_("Connected Fit Horizontally"), CB(layout_menu_connect_zoom_fit_hor_cb) },
1351 { "ConnectZoomFillVert",NULL, N_("Fit _Vertically"), "<shift>W", N_("Connected Fit Vertically"), CB(layout_menu_connect_zoom_fit_vert_cb) },
1352 { "ConnectZoom200", NULL, N_("Zoom _2:1"), NULL, N_("Connected Zoom 2:1"), CB(layout_menu_connect_zoom_2_1_cb) },
1353 { "ConnectZoom300", NULL, N_("Zoom _3:1"), NULL, N_("Connected Zoom 3:1"), CB(layout_menu_connect_zoom_3_1_cb) },
1354 { "ConnectZoom400", NULL, N_("Zoom _4:1"), NULL, N_("Connected Zoom 4:1"), CB(layout_menu_connect_zoom_4_1_cb) },
1355 { "ConnectZoom50", NULL, N_("Zoom 1:2"), NULL, N_("Connected Zoom 1:2"), CB(layout_menu_connect_zoom_1_2_cb) },
1356 { "ConnectZoom33", NULL, N_("Zoom 1:3"), NULL, N_("Connected Zoom 1:3"), CB(layout_menu_connect_zoom_1_3_cb) },
1357 { "ConnectZoom25", NULL, N_("Zoom 1:4"), NULL, N_("Connected Zoom 1:4"), CB(layout_menu_connect_zoom_1_4_cb) },
1358 { "ViewInNewWindow", NULL, N_("_View in new window"), "<control>V", N_("View in new window"), CB(layout_menu_view_in_new_window_cb) },
1359 { "FullScreen", GTK_STOCK_FULLSCREEN, N_("F_ull screen"), "F", N_("Full screen"), CB(layout_menu_fullscreen_cb) },
1360 { "FullScreenAlt1", GTK_STOCK_FULLSCREEN, N_("F_ull screen"), "V", N_("Full screen"), CB(layout_menu_fullscreen_cb) },
1361 { "FullScreenAlt2", GTK_STOCK_FULLSCREEN, N_("F_ull screen"), "F11", N_("Full screen"), CB(layout_menu_fullscreen_cb) },
1362 { "Escape", GTK_STOCK_LEAVE_FULLSCREEN,N_("_Leave full screen"), "Escape", N_("Leave full screen"), CB(layout_menu_escape_cb) },
1363 { "EscapeAlt1", GTK_STOCK_LEAVE_FULLSCREEN,N_("_Leave full screen"), "Q", N_("Leave full screen"), CB(layout_menu_escape_cb) },
1364 { "ImageOverlayCycle",NULL, N_("_Cycle through overlay modes"), "I", N_("Cycle through Overlay modes"), CB(layout_menu_overlay_toggle_cb) },
1365 { "HistogramChanCycle",NULL, N_("Cycle through histogram ch_annels"),"K", N_("Cycle through histogram channels"), CB(layout_menu_histogram_toggle_channel_cb) },
1366 { "HistogramModeCycle",NULL, N_("Cycle through histogram mo_des"), "J", N_("Cycle through histogram modes"), CB(layout_menu_histogram_toggle_mode_cb) },
1367 { "HideTools", NULL, N_("_Hide file list"), "<control>H", N_("Hide file list"), CB(layout_menu_hide_cb) },
1368 { "SlideShowPause", GTK_STOCK_MEDIA_PAUSE, N_("_Pause slideshow"), "P", N_("Pause slideshow"), CB(layout_menu_slideshow_pause_cb) },
1369 { "Refresh", GTK_STOCK_REFRESH, N_("_Refresh"), "R", N_("Refresh"), CB(layout_menu_refresh_cb) },
1370 { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", N_("Contents"), CB(layout_menu_help_cb) },
1371 { "HelpShortcuts", NULL, N_("_Keyboard shortcuts"), NULL, N_("Keyboard shortcuts"), CB(layout_menu_help_keys_cb) },
1372 { "HelpNotes", NULL, N_("_Release notes"), NULL, N_("Release notes"), CB(layout_menu_notes_cb) },
1373 { "About", GTK_STOCK_ABOUT, N_("_About"), NULL, N_("About"), CB(layout_menu_about_cb) },
1374 { "LogWindow", NULL, N_("_Log Window"), NULL, N_("Log Window"), CB(layout_menu_log_window_cb) },
1375 { "ExifWin", NULL, N_("_Exif window"), "<control>E", N_("Exif window"), CB(layout_menu_bar_exif_cb) },
1379 static GtkToggleActionEntry menu_toggle_entries[] = {
1380 { "Thumbnails", PIXBUF_INLINE_ICON_THUMB,N_("Show _Thumbnails"), "T", N_("Show Thumbnails"), CB(layout_menu_thumb_cb), FALSE },
1381 { "ShowMarks", NULL, N_("Show _Marks"), "M", N_("Show Marks"), CB(layout_menu_marks_cb), FALSE },
1382 { "ShowInfoPixel", GTK_STOCK_COLOR_PICKER, N_("Pi_xel Info"), NULL, N_("Show Pixel Info"), CB(layout_menu_info_pixel_cb), FALSE },
1383 { "FloatTools", PIXBUF_INLINE_ICON_FLOAT,N_("_Float file list"), "L", N_("Float file list"), CB(layout_menu_float_cb), FALSE },
1384 { "HideToolbar", NULL, N_("Hide tool_bar"), NULL, N_("Hide toolbar"), CB(layout_menu_toolbar_cb), FALSE },
1385 { "SBar", NULL, N_("_Info sidebar"), "<control>K", N_("Info sidebar"), CB(layout_menu_bar_cb), FALSE },
1386 { "SBarSort", NULL, N_("Sort _manager"), "<shift>S", N_("Sort manager"), CB(layout_menu_bar_sort_cb), FALSE },
1387 { "SlideShow", GTK_STOCK_MEDIA_PLAY, N_("Toggle _slideshow"), "S", N_("Toggle slideshow"), CB(layout_menu_slideshow_cb), FALSE },
1388 { "UseColorProfiles", GTK_STOCK_SELECT_COLOR, N_("Use _color profiles"), NULL, N_("Use color profiles"), CB(layout_color_menu_enable_cb), FALSE},
1389 { "UseImageProfile", NULL, N_("Use profile from _image"), NULL, N_("Use profile from image"), CB(layout_color_menu_use_image_cb), FALSE},
1390 { "Grayscale", NULL, N_("Toggle _grayscale"), "<shift>G", N_("Toggle grayscale"), CB(layout_menu_alter_desaturate_cb), FALSE},
1391 { "ImageOverlay", NULL, N_("Image _Overlay"), NULL, N_("Image Overlay"), CB(layout_menu_overlay_cb), FALSE },
1392 { "ImageHistogram", NULL, N_("_Show Histogram"), NULL, N_("Show Histogram"), CB(layout_menu_histogram_cb), FALSE },
1393 { "StereoSwap", NULL, N_("Swap stereo images"), NULL, N_("Swap stereo images"), CB(layout_menu_stereo_swap_cb), FALSE },
1396 static GtkRadioActionEntry menu_radio_entries[] = {
1397 { "ViewList", NULL, N_("Image _List"), "<control>L", N_("View Images as List"), FILEVIEW_LIST },
1398 { "ViewIcons", NULL, N_("I_cons"), "<control>I", N_("View Images as Icons"), FILEVIEW_ICON }
1401 static GtkRadioActionEntry menu_view_dir_radio_entries[] = {
1402 { "FolderList", NULL, N_("Folder Li_st"), "<meta>L", N_("View Folders as List"), DIRVIEW_LIST },
1403 { "FolderTree", NULL, N_("Folder T_ree"), "<control>T", N_("View Folders as Tree"), DIRVIEW_TREE },
1406 static GtkRadioActionEntry menu_split_radio_entries[] = {
1407 { "SplitHorizontal", NULL, N_("_Horizontal"), "E", N_("Split Horizontal"), SPLIT_HOR },
1408 { "SplitVertical", NULL, N_("_Vertical"), "U", N_("Split Vertical"), SPLIT_VERT },
1409 { "SplitQuad", NULL, N_("_Quad"), NULL, N_("Split Quad"), SPLIT_QUAD },
1410 { "SplitSingle", NULL, N_("_Single"), "Y", N_("Split Single"), SPLIT_NONE }
1413 static GtkRadioActionEntry menu_color_radio_entries[] = {
1414 { "ColorProfile0", NULL, N_("Input _0: sRGB"), NULL, N_("Input 0: sRGB"), COLOR_PROFILE_SRGB },
1415 { "ColorProfile1", NULL, N_("Input _1: AdobeRGB compatible"), NULL, N_("Input 1: AdobeRGB compatible"), COLOR_PROFILE_ADOBERGB },
1416 { "ColorProfile2", NULL, N_("Input _2"), NULL, N_("Input 2"), COLOR_PROFILE_FILE },
1417 { "ColorProfile3", NULL, N_("Input _3"), NULL, N_("Input 3"), COLOR_PROFILE_FILE + 1 },
1418 { "ColorProfile4", NULL, N_("Input _4"), NULL, N_("Input 4"), COLOR_PROFILE_FILE + 2 },
1419 { "ColorProfile5", NULL, N_("Input _5"), NULL, N_("Input 5"), COLOR_PROFILE_FILE + 3 }
1422 static GtkRadioActionEntry menu_histogram_channel[] = {
1423 { "HistogramChanR", NULL, N_("Histogram on _Red"), NULL, N_("Histogram on Red"), HCHAN_R },
1424 { "HistogramChanG", NULL, N_("Histogram on _Green"), NULL, N_("Histogram on Green"), HCHAN_G },
1425 { "HistogramChanB", NULL, N_("Histogram on _Blue"), NULL, N_("Histogram on Blue"), HCHAN_B },
1426 { "HistogramChanRGB", NULL, N_("_Histogram on RGB"), NULL, N_("Histogram on RGB"), HCHAN_RGB },
1427 { "HistogramChanV", NULL, N_("Histogram on _Value"), NULL, N_("Histogram on Value"), HCHAN_MAX }
1430 static GtkRadioActionEntry menu_histogram_mode[] = {
1431 { "HistogramModeLin", NULL, N_("Li_near Histogram"), NULL, N_("Linear Histogram"), 0 },
1432 { "HistogramModeLog", NULL, N_("_Log Histogram"), NULL, N_("Log Histogram"), 1 },
1435 static GtkRadioActionEntry menu_stereo_mode_entries[] = {
1436 { "StereoNone", NULL, N_("_None"), NULL, N_("Stereo Off"), PR_STEREO_NONE },
1437 { "StereoAnaglyph", NULL, N_("_Anaglyph"), NULL, N_("Stereo Anaglyph"), PR_STEREO_ANAGLYPH },
1438 { "StereoHoriz", NULL, N_("_Side by Side"), NULL, N_("Stereo Side by Side"), PR_STEREO_HORIZ },
1439 { "StereoVert", NULL, N_("Above-_Below"), NULL, N_("Stereo Above-Below"), PR_STEREO_VERT }
1445 static const gchar *menu_ui_description =
1447 " <menubar name='MainMenu'>"
1448 " <menu action='FileMenu'>"
1449 " <menuitem action='NewWindow'/>"
1450 " <menuitem action='NewCollection'/>"
1451 " <menuitem action='OpenCollection'/>"
1452 " <menuitem action='OpenRecent'/>"
1453 " <placeholder name='OpenSection'/>"
1455 " <menuitem action='Search'/>"
1456 " <menuitem action='FindDupes'/>"
1457 " <placeholder name='SearchSection'/>"
1459 " <menuitem action='Print'/>"
1460 " <placeholder name='PrintSection'/>"
1462 " <menuitem action='NewFolder'/>"
1463 " <menuitem action='Copy'/>"
1464 " <menuitem action='Move'/>"
1465 " <menuitem action='Rename'/>"
1466 " <menuitem action='Delete'/>"
1467 " <placeholder name='FileOpsSection'/>"
1469 " <placeholder name='QuitSection'/>"
1470 " <menuitem action='CloseWindow'/>"
1471 " <menuitem action='Quit'/>"
1474 " <menu action='GoMenu'>"
1475 " <menuitem action='FirstImage'/>"
1476 " <menuitem action='PrevImage'/>"
1477 " <menuitem action='NextImage'/>"
1478 " <menuitem action='LastImage'/>"
1480 " <menuitem action='Back'/>"
1481 " <menuitem action='Home'/>"
1484 " <menu action='SelectMenu'>"
1485 " <menuitem action='SelectAll'/>"
1486 " <menuitem action='SelectNone'/>"
1487 " <menuitem action='SelectInvert'/>"
1488 " <placeholder name='SelectSection'/>"
1490 " <menuitem action='CopyPath'/>"
1491 " <placeholder name='ClipboardSection'/>"
1493 " <menuitem action='ShowMarks'/>"
1494 " <placeholder name='MarksSection'/>"
1497 " <menu action='EditMenu'>"
1498 " <menu action='ExternalMenu'>"
1500 " <placeholder name='EditSection'/>"
1502 " <menu action='OrientationMenu'>"
1503 " <menuitem action='RotateCW'/>"
1504 " <menuitem action='RotateCCW'/>"
1505 " <menuitem action='Rotate180'/>"
1506 " <menuitem action='Mirror'/>"
1507 " <menuitem action='Flip'/>"
1508 " <menuitem action='AlterNone'/>"
1510 " <menuitem action='SaveMetadata'/>"
1511 " <placeholder name='PropertiesSection'/>"
1513 " <menu action='PreferencesMenu'>"
1514 " <menuitem action='Preferences'/>"
1515 " <menuitem action='Editors'/>"
1516 " <menuitem action='LayoutConfig'/>"
1517 " <menuitem action='Maintenance'/>"
1519 " <placeholder name='PreferencesSection'/>"
1521 " <menuitem action='Wallpaper'/>"
1524 " <menu action='ViewMenu'>"
1525 " <menuitem action='ViewInNewWindow'/>"
1526 " <menuitem action='PanView'/>"
1527 " <menuitem action='ExifWin'/>"
1528 " <placeholder name='WindowSection'/>"
1530 " <menu action='FileDirMenu'>"
1531 " <menuitem action='FolderList'/>"
1532 " <menuitem action='FolderTree'/>"
1533 " <placeholder name='FolderSection'/>"
1535 " <menuitem action='ViewList'/>"
1536 " <menuitem action='ViewIcons'/>"
1537 " <menuitem action='Thumbnails'/>"
1538 " <placeholder name='ListSection'/>"
1540 " <menuitem action='FloatTools'/>"
1541 " <menuitem action='HideTools'/>"
1542 " <menuitem action='HideToolbar'/>"
1544 " <placeholder name='DirSection'/>"
1546 " <menu action='ZoomMenu'>"
1547 " <menu action='ConnectZoomMenu'>"
1548 " <menuitem action='ConnectZoomIn'/>"
1549 " <menuitem action='ConnectZoomOut'/>"
1550 " <menuitem action='ConnectZoomFit'/>"
1551 " <menuitem action='ConnectZoomFillHor'/>"
1552 " <menuitem action='ConnectZoomFillVert'/>"
1553 " <menuitem action='ConnectZoom100'/>"
1554 " <menuitem action='ConnectZoom200'/>"
1555 " <menuitem action='ConnectZoom300'/>"
1556 " <menuitem action='ConnectZoom400'/>"
1557 " <menuitem action='ConnectZoom50'/>"
1558 " <menuitem action='ConnectZoom33'/>"
1559 " <menuitem action='ConnectZoom25'/>"
1561 " <menuitem action='ZoomIn'/>"
1562 " <menuitem action='ZoomOut'/>"
1563 " <menuitem action='ZoomFit'/>"
1564 " <menuitem action='ZoomFillHor'/>"
1565 " <menuitem action='ZoomFillVert'/>"
1566 " <menuitem action='Zoom100'/>"
1567 " <menuitem action='Zoom200'/>"
1568 " <menuitem action='Zoom300'/>"
1569 " <menuitem action='Zoom400'/>"
1570 " <menuitem action='Zoom50'/>"
1571 " <menuitem action='Zoom33'/>"
1572 " <menuitem action='Zoom25'/>"
1574 " <menu action='SplitMenu'>"
1575 " <menuitem action='SplitHorizontal'/>"
1576 " <menuitem action='SplitVertical'/>"
1577 " <menuitem action='SplitQuad'/>"
1578 " <menuitem action='SplitSingle'/>"
1580 " <menu action='StereoMenu'>"
1581 " <menuitem action='StereoSwap'/>"
1583 " <menuitem action='StereoNone'/>"
1584 " <menuitem action='StereoAnaglyph'/>"
1585 " <menuitem action='StereoHoriz'/>"
1586 " <menuitem action='StereoVert'/>"
1588 " <menu action='ColorMenu'>"
1589 " <menuitem action='UseColorProfiles'/>"
1590 " <menuitem action='UseImageProfile'/>"
1591 " <menuitem action='ColorProfile0'/>"
1592 " <menuitem action='ColorProfile1'/>"
1593 " <menuitem action='ColorProfile2'/>"
1594 " <menuitem action='ColorProfile3'/>"
1595 " <menuitem action='ColorProfile4'/>"
1596 " <menuitem action='ColorProfile5'/>"
1598 " <menuitem action='Grayscale'/>"
1600 " <menu action='OverlayMenu'>"
1601 " <menuitem action='ImageOverlay'/>"
1602 " <menuitem action='ImageHistogram'/>"
1603 " <menuitem action='ImageOverlayCycle'/>"
1605 " <menuitem action='HistogramChanR'/>"
1606 " <menuitem action='HistogramChanG'/>"
1607 " <menuitem action='HistogramChanB'/>"
1608 " <menuitem action='HistogramChanRGB'/>"
1609 " <menuitem action='HistogramChanV'/>"
1610 " <menuitem action='HistogramChanCycle'/>"
1612 " <menuitem action='HistogramModeLin'/>"
1613 " <menuitem action='HistogramModeLog'/>"
1614 " <menuitem action='HistogramModeCycle'/>"
1616 " <menuitem action='FullScreen'/>"
1617 " <placeholder name='ViewSection'/>"
1619 " <menuitem action='SBar'/>"
1620 " <menuitem action='SBarSort'/>"
1621 " <menuitem action='ShowInfoPixel'/>"
1622 " <placeholder name='ToolsSection'/>"
1624 " <menuitem action='SlideShow'/>"
1625 " <menuitem action='SlideShowPause'/>"
1626 " <menuitem action='Refresh'/>"
1627 " <placeholder name='SlideShowSection'/>"
1630 " <menu action='HelpMenu'>"
1632 " <menuitem action='HelpContents'/>"
1633 " <menuitem action='HelpShortcuts'/>"
1634 " <menuitem action='HelpNotes'/>"
1635 " <placeholder name='HelpSection'/>"
1637 " <menuitem action='About'/>"
1639 " <menuitem action='LogWindow'/>"
1643 " <toolbar name='ToolBar'>"
1645 " <toolbar name='StatusBar'>"
1647 "<accelerator action='PrevImageAlt1'/>"
1648 "<accelerator action='PrevImageAlt2'/>"
1649 "<accelerator action='NextImageAlt1'/>"
1650 "<accelerator action='NextImageAlt2'/>"
1651 "<accelerator action='DeleteAlt1'/>"
1652 "<accelerator action='DeleteAlt2'/>"
1653 "<accelerator action='FullScreenAlt1'/>"
1654 "<accelerator action='FullScreenAlt2'/>"
1655 "<accelerator action='Escape'/>"
1656 "<accelerator action='EscapeAlt1'/>"
1658 "<accelerator action='ZoomInAlt1'/>"
1659 "<accelerator action='ZoomOutAlt1'/>"
1660 "<accelerator action='Zoom100Alt1'/>"
1661 "<accelerator action='ZoomFitAlt1'/>"
1663 "<accelerator action='ConnectZoomInAlt1'/>"
1664 "<accelerator action='ConnectZoomOutAlt1'/>"
1665 "<accelerator action='ConnectZoom100Alt1'/>"
1666 "<accelerator action='ConnectZoomFitAlt1'/>"
1669 static gchar *menu_translate(const gchar *path, gpointer data)
1671 return (gchar *)(_(path));
1674 static void layout_actions_setup_mark(LayoutWindow *lw, gint mark, gchar *name_tmpl,
1675 gchar *label_tmpl, gchar *accel_tmpl, gchar *tooltip_tmpl, GCallback cb)
1681 GtkActionEntry entry = { name, NULL, label, accel, tooltip, cb };
1684 g_snprintf(name, sizeof(name), name_tmpl, mark);
1685 g_snprintf(label, sizeof(label), label_tmpl, mark);
1688 g_snprintf(accel, sizeof(accel), accel_tmpl, mark % 10);
1690 entry.accelerator = NULL;
1693 g_snprintf(tooltip, sizeof(tooltip), tooltip_tmpl, mark);
1695 entry.tooltip = NULL;
1697 gtk_action_group_add_actions(lw->action_group, &entry, 1, lw);
1698 action = gtk_action_group_get_action(lw->action_group, name);
1699 g_object_set_data(G_OBJECT(action), "mark_num", GINT_TO_POINTER(mark));
1702 static void layout_actions_setup_marks(LayoutWindow *lw)
1706 GString *desc = g_string_new(
1708 " <menubar name='MainMenu'>"
1709 " <menu action='SelectMenu'>");
1711 for (mark = 1; mark <= FILEDATA_MARKS_SIZE; mark++)
1713 layout_actions_setup_mark(lw, mark, "Mark%d", _("Mark _%d"), NULL, NULL, NULL);
1714 layout_actions_setup_mark(lw, mark, "SetMark%d", _("_Set mark %d"), NULL, _("Set mark %d"), G_CALLBACK(layout_menu_set_mark_sel_cb));
1715 layout_actions_setup_mark(lw, mark, "ResetMark%d", _("_Reset mark %d"), NULL, _("Reset mark %d"), G_CALLBACK(layout_menu_res_mark_sel_cb));
1716 layout_actions_setup_mark(lw, mark, "ToggleMark%d", _("_Toggle mark %d"), "%d", _("Toggle mark %d"), G_CALLBACK(layout_menu_toggle_mark_sel_cb));
1717 layout_actions_setup_mark(lw, mark, "ToggleMark%dAlt1", _("_Toggle mark %d"), "KP_%d", _("Toggle mark %d"), G_CALLBACK(layout_menu_toggle_mark_sel_cb));
1718 layout_actions_setup_mark(lw, mark, "SelectMark%d", _("Se_lect mark %d"), "<control>%d", _("Select mark %d"), G_CALLBACK(layout_menu_sel_mark_cb));
1719 layout_actions_setup_mark(lw, mark, "SelectMark%dAlt1", _("_Select mark %d"), "<control>KP_%d", _("Select mark %d"), G_CALLBACK(layout_menu_sel_mark_cb));
1720 layout_actions_setup_mark(lw, mark, "AddMark%d", _("_Add mark %d"), NULL, _("Add mark %d"), G_CALLBACK(layout_menu_sel_mark_or_cb));
1721 layout_actions_setup_mark(lw, mark, "IntMark%d", _("_Intersection with mark %d"), NULL, _("Intersection with mark %d"), G_CALLBACK(layout_menu_sel_mark_and_cb));
1722 layout_actions_setup_mark(lw, mark, "UnselMark%d", _("_Unselect mark %d"), NULL, _("Unselect mark %d"), G_CALLBACK(layout_menu_sel_mark_minus_cb));
1723 layout_actions_setup_mark(lw, mark, "FilterMark%d", _("_Filter mark %d"), NULL, _("Filter mark %d"), G_CALLBACK(layout_menu_mark_filter_toggle_cb));
1725 g_string_append_printf(desc,
1726 " <menu action='Mark%d'>"
1727 " <menuitem action='ToggleMark%d'/>"
1728 " <menuitem action='SetMark%d'/>"
1729 " <menuitem action='ResetMark%d'/>"
1731 " <menuitem action='SelectMark%d'/>"
1732 " <menuitem action='AddMark%d'/>"
1733 " <menuitem action='IntMark%d'/>"
1734 " <menuitem action='UnselMark%d'/>"
1736 " <menuitem action='FilterMark%d'/>"
1738 mark, mark, mark, mark, mark, mark, mark, mark, mark);
1741 g_string_append(desc,
1744 for (mark = 1; mark <= FILEDATA_MARKS_SIZE; mark++)
1746 g_string_append_printf(desc,
1747 "<accelerator action='ToggleMark%dAlt1'/>"
1748 "<accelerator action='SelectMark%dAlt1'/>",
1751 g_string_append(desc, "</ui>" );
1754 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, desc->str, -1, &error))
1756 g_message("building menus failed: %s", error->message);
1757 g_error_free(error);
1760 g_string_free(desc, TRUE);
1763 static GList *layout_actions_editor_menu_path(EditorDescription *editor)
1765 gchar **split = g_strsplit(editor->menu_path, "/", 0);
1769 if (split[0] == NULL)
1777 ret = g_list_prepend(ret, g_strdup(split[i]));
1783 ret = g_list_prepend(ret, g_strdup(editor->key));
1785 return g_list_reverse(ret);
1788 static void layout_actions_editor_add(GString *desc, GList *path, GList *old_path)
1790 gint to_open, to_close, i;
1791 while (path && old_path && strcmp((gchar *)path->data, (gchar *)old_path->data) == 0)
1794 old_path = old_path->next;
1796 to_open = g_list_length(path) - 1;
1797 to_close = g_list_length(old_path) - 1;
1801 old_path = g_list_last(old_path);
1802 old_path = old_path->prev;
1805 for (i = 0; i < to_close; i++)
1807 gchar *name = old_path->data;
1808 if (g_str_has_suffix(name, "Section"))
1810 g_string_append(desc, " </placeholder>");
1812 else if (g_str_has_suffix(name, "Menu"))
1814 g_string_append(desc, " </menu>");
1818 g_warning("invalid menu path item %s", name);
1820 old_path = old_path->prev;
1823 for (i = 0; i < to_open; i++)
1825 gchar *name = path->data;
1826 if (g_str_has_suffix(name, "Section"))
1828 g_string_append_printf(desc, " <placeholder name='%s'>", name);
1830 else if (g_str_has_suffix(name, "Menu"))
1832 g_string_append_printf(desc, " <menu action='%s'>", name);
1836 g_warning("invalid menu path item %s", name);
1842 g_string_append_printf(desc, " <menuitem action='%s'/>", (gchar *)path->data);
1845 static void layout_actions_setup_editors(LayoutWindow *lw)
1848 GList *editors_list;
1853 if (lw->ui_editors_id)
1855 gtk_ui_manager_remove_ui(lw->ui_manager, lw->ui_editors_id);
1858 if (lw->action_group_editors)
1860 gtk_ui_manager_remove_action_group(lw->ui_manager, lw->action_group_editors);
1861 g_object_unref(lw->action_group_editors);
1863 lw->action_group_editors = gtk_action_group_new("MenuActionsExternal");
1864 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group_editors, 1);
1866 /* lw->action_group_editors contains translated entries, no translate func is required */
1867 desc = g_string_new(
1869 " <menubar name='MainMenu'>");
1871 editors_list = editor_list_get();
1874 work = editors_list;
1878 EditorDescription *editor = work->data;
1879 GtkActionEntry entry = { editor->key,
1883 editor->comment ? editor->comment : editor->name,
1884 G_CALLBACK(layout_menu_edit_cb) };
1888 entry.stock_id = editor->key;
1890 gtk_action_group_add_actions(lw->action_group_editors, &entry, 1, lw);
1892 path = layout_actions_editor_menu_path(editor);
1893 layout_actions_editor_add(desc, path, old_path);
1895 string_list_free(old_path);
1900 layout_actions_editor_add(desc, NULL, old_path);
1901 string_list_free(old_path);
1903 g_string_append(desc, " </menubar>"
1908 lw->ui_editors_id = gtk_ui_manager_add_ui_from_string(lw->ui_manager, desc->str, -1, &error);
1909 if (!lw->ui_editors_id)
1911 g_message("building menus failed: %s", error->message);
1912 g_error_free(error);
1915 g_string_free(desc, TRUE);
1916 g_list_free(editors_list);
1919 void layout_actions_setup(LayoutWindow *lw)
1924 DEBUG_1("%s layout_actions_setup: start", get_exec_time());
1925 if (lw->ui_manager) return;
1927 lw->action_group = gtk_action_group_new("MenuActions");
1928 gtk_action_group_set_translate_func(lw->action_group, menu_translate, NULL, NULL);
1930 gtk_action_group_add_actions(lw->action_group,
1931 menu_entries, G_N_ELEMENTS(menu_entries), lw);
1932 gtk_action_group_add_toggle_actions(lw->action_group,
1933 menu_toggle_entries, G_N_ELEMENTS(menu_toggle_entries), lw);
1934 gtk_action_group_add_radio_actions(lw->action_group,
1935 menu_radio_entries, G_N_ELEMENTS(menu_radio_entries),
1936 0, G_CALLBACK(layout_menu_list_cb), lw);
1937 gtk_action_group_add_radio_actions(lw->action_group,
1938 menu_split_radio_entries, G_N_ELEMENTS(menu_split_radio_entries),
1939 0, G_CALLBACK(layout_menu_split_cb), lw);
1940 gtk_action_group_add_radio_actions(lw->action_group,
1941 menu_view_dir_radio_entries, VIEW_DIR_TYPES_COUNT,
1942 0, G_CALLBACK(layout_menu_view_dir_as_cb), lw);
1943 gtk_action_group_add_radio_actions(lw->action_group,
1944 menu_color_radio_entries, COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS,
1945 0, G_CALLBACK(layout_color_menu_input_cb), lw);
1946 gtk_action_group_add_radio_actions(lw->action_group,
1947 menu_histogram_channel, G_N_ELEMENTS(menu_histogram_channel),
1948 0, G_CALLBACK(layout_menu_histogram_channel_cb), lw);
1949 gtk_action_group_add_radio_actions(lw->action_group,
1950 menu_histogram_mode, G_N_ELEMENTS(menu_histogram_mode),
1951 0, G_CALLBACK(layout_menu_histogram_mode_cb), lw);
1952 gtk_action_group_add_radio_actions(lw->action_group,
1953 menu_stereo_mode_entries, G_N_ELEMENTS(menu_stereo_mode_entries),
1954 0, G_CALLBACK(layout_menu_stereo_mode_cb), lw);
1957 lw->ui_manager = gtk_ui_manager_new();
1958 gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE);
1959 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0);
1961 DEBUG_1("%s layout_actions_setup: add menu", get_exec_time());
1963 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, menu_ui_description, -1, &error))
1965 g_message("building menus failed: %s", error->message);
1966 g_error_free(error);
1970 DEBUG_1("%s layout_actions_setup: add toolbar", get_exec_time());
1971 for (i = 0; i < TOOLBAR_COUNT; i++)
1973 layout_toolbar_clear(lw, i);
1974 layout_toolbar_add_default(lw, i);
1978 DEBUG_1("%s layout_actions_setup: marks", get_exec_time());
1979 layout_actions_setup_marks(lw);
1981 DEBUG_1("%s layout_actions_setup: editors", get_exec_time());
1982 layout_actions_setup_editors(lw);
1984 DEBUG_1("%s layout_actions_setup: status_update_write", get_exec_time());
1985 layout_util_status_update_write(lw);
1987 DEBUG_1("%s layout_actions_setup: actions_add_window", get_exec_time());
1988 layout_actions_add_window(lw, lw->window);
1989 DEBUG_1("%s layout_actions_setup: end", get_exec_time());
1992 static gint layout_editors_reload_idle_id = -1;
1993 static GList *layout_editors_desktop_files = NULL;
1995 static gboolean layout_editors_reload_idle_cb(gpointer data)
1997 if (!layout_editors_desktop_files)
1999 DEBUG_1("%s layout_editors_reload_idle_cb: get_desktop_files", get_exec_time());
2000 layout_editors_desktop_files = editor_get_desktop_files();
2004 editor_read_desktop_file(layout_editors_desktop_files->data);
2005 g_free(layout_editors_desktop_files->data);
2006 layout_editors_desktop_files = g_list_delete_link(layout_editors_desktop_files, layout_editors_desktop_files);
2009 if (!layout_editors_desktop_files)
2012 DEBUG_1("%s layout_editors_reload_idle_cb: setup_editors", get_exec_time());
2013 editor_table_finish();
2015 work = layout_window_list;
2018 LayoutWindow *lw = work->data;
2020 layout_actions_setup_editors(lw);
2023 DEBUG_1("%s layout_editors_reload_idle_cb: setup_editors done", get_exec_time());
2025 layout_editors_reload_idle_id = -1;
2031 void layout_editors_reload_start(void)
2035 DEBUG_1("%s layout_editors_reload_start", get_exec_time());
2037 if (layout_editors_reload_idle_id != -1)
2039 g_source_remove(layout_editors_reload_idle_id);
2040 string_list_free(layout_editors_desktop_files);
2043 work = layout_window_list;
2045 editor_table_clear();
2046 layout_editors_reload_idle_id = g_idle_add(layout_editors_reload_idle_cb, NULL);
2049 void layout_editors_reload_finish(void)
2051 if (layout_editors_reload_idle_id != -1)
2053 DEBUG_1("%s layout_editors_reload_finish", get_exec_time());
2054 g_source_remove(layout_editors_reload_idle_id);
2055 while (layout_editors_reload_idle_id != -1)
2057 layout_editors_reload_idle_cb(NULL);
2062 void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window)
2064 GtkAccelGroup *group;
2066 if (!lw->ui_manager) return;
2068 group = gtk_ui_manager_get_accel_group(lw->ui_manager);
2069 gtk_window_add_accel_group(GTK_WINDOW(window), group);
2072 GtkWidget *layout_actions_menu_bar(LayoutWindow *lw)
2074 if (lw->menu_bar) return lw->menu_bar;
2075 lw->menu_bar = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu");
2076 g_object_ref(lw->menu_bar);
2077 return lw->menu_bar;
2080 GtkWidget *layout_actions_toolbar(LayoutWindow *lw, ToolbarType type)
2082 if (lw->toolbar[type]) return lw->toolbar[type];
2086 lw->toolbar[type] = gtk_ui_manager_get_widget(lw->ui_manager, "/ToolBar");
2087 gtk_toolbar_set_icon_size(GTK_TOOLBAR(lw->toolbar[type]), GTK_ICON_SIZE_SMALL_TOOLBAR);
2088 gtk_toolbar_set_style(GTK_TOOLBAR(lw->toolbar[type]), GTK_TOOLBAR_ICONS);
2090 case TOOLBAR_STATUS:
2091 lw->toolbar[type] = gtk_ui_manager_get_widget(lw->ui_manager, "/StatusBar");
2092 gtk_toolbar_set_icon_size(GTK_TOOLBAR(lw->toolbar[type]), GTK_ICON_SIZE_MENU);
2093 gtk_toolbar_set_style(GTK_TOOLBAR(lw->toolbar[type]), GTK_TOOLBAR_ICONS);
2094 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(lw->toolbar[type]), FALSE);
2099 g_object_ref(lw->toolbar[type]);
2100 return lw->toolbar[type];
2103 void layout_toolbar_clear(LayoutWindow *lw, ToolbarType type)
2105 if (lw->toolbar_merge_id[type])
2107 gtk_ui_manager_remove_ui(lw->ui_manager, lw->toolbar_merge_id[type]);
2108 gtk_ui_manager_ensure_update(lw->ui_manager);
2110 string_list_free(lw->toolbar_actions[type]);
2111 lw->toolbar_actions[type] = NULL;
2113 lw->toolbar_merge_id[type] = gtk_ui_manager_new_merge_id(lw->ui_manager);
2117 void layout_toolbar_add(LayoutWindow *lw, ToolbarType type, const gchar *action)
2119 const gchar *path = NULL;
2120 if (!action || !lw->ui_manager) return;
2122 if (g_list_find_custom(lw->toolbar_actions[type], action, (GCompareFunc)strcmp)) return;
2129 case TOOLBAR_STATUS:
2130 path = "/StatusBar";
2137 if (g_str_has_suffix(action, ".desktop"))
2139 /* this may be called before the external editors are read
2140 create a dummy action for now */
2142 if (!lw->action_group_editors)
2144 lw->action_group_editors = gtk_action_group_new("MenuActionsExternal");
2145 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group_editors, 1);
2147 if (!gtk_action_group_get_action(lw->action_group_editors, action))
2149 GtkActionEntry entry = { action,
2150 GTK_STOCK_MISSING_IMAGE,
2155 DEBUG_1("Creating temporary action %s", action);
2156 gtk_action_group_add_actions(lw->action_group_editors, &entry, 1, lw);
2159 gtk_ui_manager_add_ui(lw->ui_manager, lw->toolbar_merge_id[type], path, action, action, GTK_UI_MANAGER_TOOLITEM, FALSE);
2160 lw->toolbar_actions[type] = g_list_append(lw->toolbar_actions[type], g_strdup(action));
2164 void layout_toolbar_add_default(LayoutWindow *lw, ToolbarType type)
2169 layout_toolbar_add(lw, type, "Thumbnails");
2170 layout_toolbar_add(lw, type, "Back");
2171 layout_toolbar_add(lw, type, "Home");
2172 layout_toolbar_add(lw, type, "Refresh");
2173 layout_toolbar_add(lw, type, "ZoomIn");
2174 layout_toolbar_add(lw, type, "ZoomOut");
2175 layout_toolbar_add(lw, type, "ZoomFit");
2176 layout_toolbar_add(lw, type, "Zoom100");
2177 layout_toolbar_add(lw, type, "Preferences");
2178 layout_toolbar_add(lw, type, "FloatTools");
2180 case TOOLBAR_STATUS:
2181 layout_toolbar_add(lw, type, "ShowInfoPixel");
2182 layout_toolbar_add(lw, type, "UseColorProfiles");
2183 layout_toolbar_add(lw, type, "SaveMetadata");
2190 void layout_toolbar_write_config(LayoutWindow *lw, ToolbarType type, GString *outstr, gint indent)
2192 const gchar *name = NULL;
2193 GList *work = lw->toolbar_actions[type];
2200 case TOOLBAR_STATUS:
2207 WRITE_NL(); WRITE_STRING("<%s>", name);
2209 WRITE_NL(); WRITE_STRING("<clear/>");
2212 gchar *action = work->data;
2214 WRITE_NL(); WRITE_STRING("<toolitem ");
2215 write_char_option(outstr, indent + 1, "action", action);
2219 WRITE_NL(); WRITE_STRING("</%s>", name);
2222 void layout_toolbar_add_from_config(LayoutWindow *lw, ToolbarType type, const gchar **attribute_names, const gchar **attribute_values)
2224 gchar *action = NULL;
2226 while (*attribute_names)
2228 const gchar *option = *attribute_names++;
2229 const gchar *value = *attribute_values++;
2231 if (READ_CHAR_FULL("action", action)) continue;
2233 log_printf("unknown attribute %s = %s\n", option, value);
2236 layout_toolbar_add(lw, type, action);
2241 *-----------------------------------------------------------------------------
2243 *-----------------------------------------------------------------------------
2246 void layout_util_status_update_write(LayoutWindow *lw)
2249 gint n = metadata_queue_length();
2250 action = gtk_action_group_get_action(lw->action_group, "SaveMetadata");
2251 gtk_action_set_sensitive(action, n > 0);
2254 gchar *buf = g_strdup_printf(_("Number of files with unsaved metadata: %d"), n);
2255 g_object_set(G_OBJECT(action), "tooltip", buf, NULL);
2260 g_object_set(G_OBJECT(action), "tooltip", _("No unsaved metadata"), NULL);
2264 void layout_util_status_update_write_all(void)
2268 work = layout_window_list;
2271 LayoutWindow *lw = work->data;
2274 layout_util_status_update_write(lw);
2278 static gchar *layout_color_name_parse(const gchar *name)
2280 if (!name || !*name) return g_strdup(_("Empty"));
2281 return g_strdelimit(g_strdup(name), "_", '-');
2284 void layout_util_sync_color(LayoutWindow *lw)
2289 gboolean use_image = FALSE;
2291 gchar action_name[15];
2292 gchar *image_profile;
2293 gchar *screen_profile;
2296 if (!lw->action_group) return;
2297 if (!layout_image_color_profile_get(lw, &input, &use_image)) return;
2299 use_color = layout_image_color_profile_get_use(lw);
2301 action = gtk_action_group_get_action(lw->action_group, "UseColorProfiles");
2303 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_color);
2304 if (layout_image_color_profile_get_status(lw, &image_profile, &screen_profile))
2307 buf = g_strdup_printf(_("Image profile: %s\nScreen profile: %s"), image_profile, screen_profile);
2308 g_object_set(G_OBJECT(action), "tooltip", buf, NULL);
2309 g_free(image_profile);
2310 g_free(screen_profile);
2315 g_object_set(G_OBJECT(action), "tooltip", _("Click to enable color management"), NULL);
2318 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE);
2319 gtk_action_set_sensitive(action, FALSE);
2320 g_object_set(G_OBJECT(action), "tooltip", _("Color profiles not supported"), NULL);
2323 action = gtk_action_group_get_action(lw->action_group, "UseImageProfile");
2324 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_image);
2325 gtk_action_set_sensitive(action, use_color);
2327 for (i = 0; i < COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS; i++)
2329 sprintf(action_name, "ColorProfile%d", i);
2330 action = gtk_action_group_get_action(lw->action_group, action_name);
2332 if (i >= COLOR_PROFILE_FILE)
2334 const gchar *name = options->color_profile.input_name[i - COLOR_PROFILE_FILE];
2335 const gchar *file = options->color_profile.input_file[i - COLOR_PROFILE_FILE];
2339 if (!name || !name[0]) name = filename_from_path(file);
2341 end = layout_color_name_parse(name);
2342 buf = g_strdup_printf(_("Input _%d: %s"), i, end);
2345 g_object_set(G_OBJECT(action), "label", buf, NULL);
2348 gtk_action_set_visible(action, file && file[0]);
2351 gtk_action_set_sensitive(action, !use_image);
2352 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), (i == input));
2355 action = gtk_action_group_get_action(lw->action_group, "Grayscale");
2356 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_get_desaturate(lw));
2359 static void layout_util_sync_views(LayoutWindow *lw)
2362 OsdShowFlags osd_flags = image_osd_get(lw->image);
2364 if (!lw->action_group) return;
2366 action = gtk_action_group_get_action(lw->action_group, "FolderTree");
2367 radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->options.dir_view_type);
2369 action = gtk_action_group_get_action(lw->action_group, "SplitSingle");
2370 radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->split_mode);
2372 action = gtk_action_group_get_action(lw->action_group, "ViewIcons");
2373 radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->options.file_view_type);
2375 action = gtk_action_group_get_action(lw->action_group, "FloatTools");
2376 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.tools_float);
2378 action = gtk_action_group_get_action(lw->action_group, "SBar");
2379 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_bar_enabled(lw));
2381 action = gtk_action_group_get_action(lw->action_group, "SBarSort");
2382 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_bar_sort_enabled(lw));
2384 action = gtk_action_group_get_action(lw->action_group, "HideToolbar");
2385 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.toolbar_hidden);
2387 action = gtk_action_group_get_action(lw->action_group, "ShowInfoPixel");
2388 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.show_info_pixel);
2390 action = gtk_action_group_get_action(lw->action_group, "ShowMarks");
2391 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.show_marks);
2393 action = gtk_action_group_get_action(lw->action_group, "SlideShow");
2394 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_slideshow_active(lw));
2396 action = gtk_action_group_get_action(lw->action_group, "ImageOverlay");
2397 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), osd_flags != OSD_SHOW_NOTHING);
2399 action = gtk_action_group_get_action(lw->action_group, "ImageHistogram");
2400 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), osd_flags & OSD_SHOW_HISTOGRAM);
2402 if (osd_flags & OSD_SHOW_HISTOGRAM)
2404 action = gtk_action_group_get_action(lw->action_group, "HistogramChanR");
2405 radio_action_set_current_value(GTK_RADIO_ACTION(action), image_osd_histogram_get_channel(lw->image));
2407 action = gtk_action_group_get_action(lw->action_group, "HistogramModeLin");
2408 radio_action_set_current_value(GTK_RADIO_ACTION(action), image_osd_histogram_get_mode(lw->image));
2411 action = gtk_action_group_get_action(lw->action_group, "ConnectZoomMenu");
2412 gtk_action_set_sensitive(action, lw->split_mode != SPLIT_NONE);
2414 layout_util_sync_color(lw);
2417 void layout_util_sync_thumb(LayoutWindow *lw)
2421 if (!lw->action_group) return;
2423 action = gtk_action_group_get_action(lw->action_group, "Thumbnails");
2424 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.show_thumbnails);
2425 g_object_set(action, "sensitive", (lw->options.file_view_type == FILEVIEW_LIST), NULL);
2428 void layout_util_sync(LayoutWindow *lw)
2430 layout_util_sync_views(lw);
2431 layout_util_sync_thumb(lw);
2432 layout_menu_recent_update(lw);
2433 // layout_menu_edit_update(lw);
2438 *-----------------------------------------------------------------------------
2440 *-----------------------------------------------------------------------------
2443 static gboolean layout_bar_enabled(LayoutWindow *lw)
2445 #if GTK_CHECK_VERSION(2,20,0)
2446 return lw->bar && gtk_widget_get_visible(lw->bar);
2448 return lw->bar && GTK_WIDGET_VISIBLE(lw->bar);
2452 static void layout_bar_destroyed(GtkWidget *widget, gpointer data)
2454 LayoutWindow *lw = data;
2458 do not call layout_util_sync_views(lw) here
2459 this is called either when whole layout is destroyed - no need for update
2460 or when the bar is replaced - sync is called by upper function at the end of whole operation
2465 static void layout_bar_set_default(LayoutWindow *lw)
2469 if (!lw->utility_box) return;
2473 layout_bar_set(lw, bar);
2475 bar_populate_default(bar);
2478 static void layout_bar_close(LayoutWindow *lw)
2488 void layout_bar_set(LayoutWindow *lw, GtkWidget *bar)
2490 if (!lw->utility_box) return;
2492 layout_bar_close(lw); /* if any */
2497 g_signal_connect(G_OBJECT(lw->bar), "destroy",
2498 G_CALLBACK(layout_bar_destroyed), lw);
2501 // gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar, FALSE, FALSE, 0);
2502 gtk_paned_pack2(GTK_PANED(lw->utility_paned), lw->bar, FALSE, TRUE);
2504 bar_set_fd(lw->bar, layout_image_get_fd(lw));
2508 void layout_bar_toggle(LayoutWindow *lw)
2510 if (layout_bar_enabled(lw))
2512 gtk_widget_hide(lw->bar);
2518 layout_bar_set_default(lw);
2520 gtk_widget_show(lw->bar);
2521 bar_set_fd(lw->bar, layout_image_get_fd(lw));
2523 layout_util_sync_views(lw);
2526 static void layout_bar_new_image(LayoutWindow *lw)
2528 if (!layout_bar_enabled(lw)) return;
2530 bar_set_fd(lw->bar, layout_image_get_fd(lw));
2533 static void layout_bar_new_selection(LayoutWindow *lw, gint count)
2535 if (!layout_bar_enabled(lw)) return;
2537 bar_notify_selection(lw->bar, count);
2540 static gboolean layout_bar_sort_enabled(LayoutWindow *lw)
2542 #if GTK_CHECK_VERSION(2,20,0)
2543 return lw->bar_sort && gtk_widget_get_visible(lw->bar_sort);
2545 return lw->bar_sort && GTK_WIDGET_VISIBLE(lw->bar_sort);
2550 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data)
2552 LayoutWindow *lw = data;
2554 lw->bar_sort = NULL;
2557 do not call layout_util_sync_views(lw) here
2558 this is called either when whole layout is destroyed - no need for update
2559 or when the bar is replaced - sync is called by upper function at the end of whole operation
2564 static void layout_bar_sort_set_default(LayoutWindow *lw)
2568 if (!lw->utility_box) return;
2570 bar = bar_sort_new_default(lw);
2572 layout_bar_sort_set(lw, bar);
2575 static void layout_bar_sort_close(LayoutWindow *lw)
2579 bar_sort_close(lw->bar_sort);
2580 lw->bar_sort = NULL;
2584 void layout_bar_sort_set(LayoutWindow *lw, GtkWidget *bar)
2586 if (!lw->utility_box) return;
2588 layout_bar_sort_close(lw); /* if any */
2593 g_signal_connect(G_OBJECT(lw->bar_sort), "destroy",
2594 G_CALLBACK(layout_bar_sort_destroyed), lw);
2596 gtk_box_pack_end(GTK_BOX(lw->utility_box), lw->bar_sort, FALSE, FALSE, 0);
2599 void layout_bar_sort_toggle(LayoutWindow *lw)
2601 if (layout_bar_sort_enabled(lw))
2603 gtk_widget_hide(lw->bar_sort);
2609 layout_bar_sort_set_default(lw);
2611 gtk_widget_show(lw->bar_sort);
2613 layout_util_sync_views(lw);
2616 void layout_bars_new_image(LayoutWindow *lw)
2618 layout_bar_new_image(lw);
2620 if (lw->exif_window) advanced_exif_set_fd(lw->exif_window, layout_image_get_fd(lw));
2622 /* this should be called here to handle the metadata edited in bars */
2623 if (options->metadata.confirm_on_image_change)
2624 metadata_write_queue_confirm(FALSE, NULL, NULL);
2627 void layout_bars_new_selection(LayoutWindow *lw, gint count)
2629 layout_bar_new_selection(lw, count);
2632 GtkWidget *layout_bars_prepare(LayoutWindow *lw, GtkWidget *image)
2634 if (lw->utility_box) return lw->utility_box;
2635 lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP);
2636 lw->utility_paned = gtk_hpaned_new();
2637 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->utility_paned, TRUE, TRUE, 0);
2639 gtk_paned_pack1(GTK_PANED(lw->utility_paned), image, TRUE, FALSE);
2640 gtk_widget_show(lw->utility_paned);
2642 gtk_widget_show(image);
2644 g_object_ref(lw->utility_box);
2645 return lw->utility_box;
2648 void layout_bars_close(LayoutWindow *lw)
2650 layout_bar_sort_close(lw);
2651 layout_bar_close(lw);
2654 static void layout_exif_window_destroy(GtkWidget *widget, gpointer data)
2656 LayoutWindow *lw = data;
2657 lw->exif_window = NULL;
2660 void layout_exif_window_new(LayoutWindow *lw)
2662 if (lw->exif_window) return;
2664 lw->exif_window = advanced_exif_new();
2665 if (!lw->exif_window) return;
2666 g_signal_connect(G_OBJECT(lw->exif_window), "destroy",
2667 G_CALLBACK(layout_exif_window_destroy), lw);
2668 advanced_exif_set_fd(lw->exif_window, layout_image_get_fd(lw));
2671 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */